diff options
Diffstat (limited to 'ftplugin')
| -rw-r--r-- | ftplugin/mail_vifm.vim | 66 | ||||
| -rw-r--r-- | ftplugin/vifm-cmdedit.vim | 23 | ||||
| -rw-r--r-- | ftplugin/vifm-edit.vim | 17 | ||||
| -rw-r--r-- | ftplugin/vifm-rename.vim | 62 | ||||
| -rw-r--r-- | ftplugin/vifm.vim | 50 | 
5 files changed, 218 insertions, 0 deletions
| diff --git a/ftplugin/mail_vifm.vim b/ftplugin/mail_vifm.vim new file mode 100644 index 00000000..09cac4c6 --- /dev/null +++ b/ftplugin/mail_vifm.vim @@ -0,0 +1,66 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'vifm') == -1 +   +" Mail file type extension to pick files for attachments via vifm +" Maintainer:  xaizek <xaizek@posteo.net> +" Last Change: January 23, 2016 + +" Insert attachment picked via vifm after 'Subject' header +function! s:AddMailAttacments() +	" TODO: reduce duplication between this file and plugins/vifm.vim +	let l:listf = tempname() + +	if !has('nvim') +		if has('gui_running') +			execute 'silent !' g:vifm_term g:vifm_exec +			                 \ '--choose-files' shellescape(l:listf, 1) +			                 \ g:vifm_exec_args +		else +			execute 'silent !' g:vifm_exec +			                 \ '--choose-files' shellescape(l:listf, 1) +			                 \ g:vifm_exec_args +		endif + +		redraw! + +		call s:HandleRunResults(v:shell_error, l:listf) +	else +		" Work around handicapped neovim... +		let callback = { 'listf': l:listf } +		function! callback.on_exit(id, code) +			buffer # +			silent! bdelete! # +			call s:HandleRunResults(a:code, self.listf) +		endfunction +		enew +		call termopen(g:vifm_exec . ' --choose-files ' . shellescape(l:listf, 1) +		             \. ' ' . g:vifm_exec_args, callback) + +		startinsert +	endif +endfunction + +function! s:HandleRunResults(exitcode, listf) +	if a:exitcode != 0 +		echohl WarningMsg +		echo 'Got non-zero code from vifm: ' . a:exitcode +		echohl None +		call delete(a:listf) +		return +	endif + +	let l:insert_pos = search('^Subject:', 'nw') + +	if filereadable(a:listf) && l:insert_pos != 0 +		for line in readfile(a:listf) +			call append(l:insert_pos, 'Attach: '.line) +			let l:insert_pos += 1 +		endfor +	endif +	call delete(a:listf) +endfunction + +nnoremap <buffer> <silent> <localleader>a :call <sid>AddMailAttacments()<cr> + +" vim: set tabstop=2 softtabstop=2 shiftwidth=2 noexpandtab cinoptions-=(0 : + +endif diff --git a/ftplugin/vifm-cmdedit.vim b/ftplugin/vifm-cmdedit.vim new file mode 100644 index 00000000..1634371e --- /dev/null +++ b/ftplugin/vifm-cmdedit.vim @@ -0,0 +1,23 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'vifm') == -1 +   +" vifm command-line editing buffer filetype plugin +" Maintainer:  xaizek <xaizek@posteo.net> +" Last Change: August 18, 2013 + +if exists("b:did_ftplugin") +	finish +endif + +let b:did_ftplugin = 1 + +" Behave as vifm script file +runtime! ftplugin/vifm.vim + +" Use vifm script highlighting +set syntax=vifm + +call vifm#edit#Init() + +" vim: set tabstop=2 softtabstop=2 shiftwidth=2 noexpandtab cinoptions-=(0 : + +endif diff --git a/ftplugin/vifm-edit.vim b/ftplugin/vifm-edit.vim new file mode 100644 index 00000000..7303e1c6 --- /dev/null +++ b/ftplugin/vifm-edit.vim @@ -0,0 +1,17 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'vifm') == -1 +   +" vifm command-line editing buffer filetype plugin +" Maintainer:  xaizek <xaizek@posteo.net> +" Last Change: August 18, 2013 + +if exists("b:did_ftplugin") +	finish +endif + +let b:did_ftplugin = 1 + +call vifm#edit#Init() + +" vim: set tabstop=2 softtabstop=2 shiftwidth=2 noexpandtab cinoptions-=(0 : + +endif diff --git a/ftplugin/vifm-rename.vim b/ftplugin/vifm-rename.vim new file mode 100644 index 00000000..0cb82351 --- /dev/null +++ b/ftplugin/vifm-rename.vim @@ -0,0 +1,62 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'vifm') == -1 +   +" Filetype plugin for vifm rename buffer +" Maintainer:  xaizek <xaizek@posteo.net> +" Last Change: October 05, 2014 + +if exists("b:did_ftplugin") +	finish +endif + +let b:did_ftplugin = 1 + +" Copy list of original file names +let s:files = getline(1, '$') + +" Closes window/tab/Vim when buffer is left alone in there +function! s:QuitIfOnlyWindow() +	" Boil out if there is more than one window +	if winbufnr(2) != -1 +		return +	endif + +	" Just close tab with this single window or quit Vim with last tab +	if tabpagenr('$') == 1 +		bdelete +		quit +	else +		close +	endif +endfunction + +" Create a vertical split window for original file names and configure it +belowright vsplit __VifmRenameOrig__ +enew +call setline(1, s:files) +setlocal buftype=nofile +setlocal bufhidden=hide +setlocal noswapfile +setlocal nobuflisted +setlocal cursorbind +setlocal scrollbind +setlocal nocursorline + +" Free now useless list of file names +unlet s:files + +" Setup a hook in auxiliary local window to do not leave it alone, when it's +" useless +augroup VifmRenameAutoCmds +	autocmd! * <buffer> +	autocmd BufEnter <buffer> call s:QuitIfOnlyWindow() +augroup END + +" Go back to the original window and ensure it will remain synchronized with +" the auxiliary one +wincmd w +setlocal cursorbind +setlocal scrollbind + +" vim: set tabstop=2 softtabstop=2 shiftwidth=2 noexpandtab cinoptions-=(0 : + +endif diff --git a/ftplugin/vifm.vim b/ftplugin/vifm.vim new file mode 100644 index 00000000..055f0630 --- /dev/null +++ b/ftplugin/vifm.vim @@ -0,0 +1,50 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'vifm') == -1 +   +" vifmrc filetype plugin +" Maintainer:  xaizek <xaizek@posteo.net> +" Last Change: July 08, 2016 +" Based On:    Vim file type file by Bram Moolenaar + +if exists("b:did_ftplugin") +	finish +endif + +let b:did_ftplugin = 1 + +let s:cpo_save = &cpo +set cpo-=C + +let b:undo_ftplugin = "setlocal formatoptions< comments< textwidth< commentstring<" + +" Break comment lines but not other lines +setlocal formatoptions-=t formatoptions+=croql + +" Set comment character +setlocal comments=:\" + +" Format comments to be up to 78 characters long +if &textwidth == 0 +	setlocal textwidth=78 +endif + +" Comments start with a double quote +setlocal commentstring=\"%s + +" Move around comments +nnoremap <silent><buffer> ]" :call search('^\(\s*".*\n\)\@<!\(\s*"\)', "W")<CR> +vnoremap <silent><buffer> ]" :<C-U>exe "normal! gv"<Bar>call search('^\(\s*".*\n\)\@<!\(\s*"\)', "W")<CR> +nnoremap <silent><buffer> [" :call search('\%(^\s*".*\n\)\%(^\s*"\)\@!', "bW")<CR> +vnoremap <silent><buffer> [" :<C-U>exe "normal! gv"<Bar>call search('\%(^\s*".*\n\)\%(^\s*"\)\@!', "bW")<CR> + +" Let the matchit plugin know what items can be matched. +if exists("loaded_matchit") +	let b:match_ignorecase = 0 +	let b:match_words = '\<if\>:\<el\%[seif]\>:\<en\%[dif]\>' +endif + +let &cpo = s:cpo_save +unlet s:cpo_save + +" vim: set tabstop=2 softtabstop=2 shiftwidth=2 noexpandtab cinoptions-=(0 : + +endif | 
