dotfiles

My personal shell configs and stuff
git clone git://git.alex.balgavy.eu/dotfiles.git
Log | Files | Refs | Submodules | README | LICENSE

commit 73a26dc40c540108ec2f3b62c2c015ca2cfc4441
parent 06dc8c9ccd445653c2686c159b97d44cca5b0f41
Author: Alex Balgavy <a.balgavy@gmail.com>
Date:   Wed,  5 Feb 2020 22:02:01 +0100

vim: ins file completion now uses relative to open file

Former-commit-id: a54056737e39c5a5703ab6076f01f7106f44b855
Diffstat:
Avim/autoload/relative_file_complete.vim | 27+++++++++++++++++++++++++++
Avim/plugin/relative_file_complete.vim | 1+
Mvim/vimrc | 1+
3 files changed, 29 insertions(+), 0 deletions(-)

diff --git a/vim/autoload/relative_file_complete.vim b/vim/autoload/relative_file_complete.vim @@ -0,0 +1,27 @@ +" Save cwd, cd to dir enclosing file, then go back to saved dir when complete done +function! relative_file_complete#SaveAndRestoreOnComplete() + " Save the old cwd + let s:olddir = getcwd() + + " Locally switch to the dir enclosing current file + lcd %:p:h + + " Defer changing cwd back until complete is done + augroup relative_file_complete_reset_cwd + au! + au CompleteDone <buffer> call relative_file_complete#Cleanup() + augroup END +endfunction + +" When complete finishes, need to change cwd back and clear autocmd +function! relative_file_complete#Cleanup() + " Go back to the previous dir and remove the saved variable + exe "lcd ".s:olddir + unlet s:olddir + + " Clear the cleanup autocmd and augroup + augroup relative_file_complete_reset_cwd + au! + augroup END + augroup! relative_file_complete_reset_cwd +endfunction diff --git a/vim/plugin/relative_file_complete.vim b/vim/plugin/relative_file_complete.vim @@ -0,0 +1 @@ +command! CompleteRelative :call relative_file_complete#SaveAndRestoreOnComplete() diff --git a/vim/vimrc b/vim/vimrc @@ -839,6 +839,7 @@ nmap <C-P> <Plug>VimcolorSynstack " Correct the last spelling error inoremap <expr> <C-x>s &spell ? "<c-g>u<Esc>[s1z=`]a<c-g>u" : "" +inoremap <C-x><C-f> <c-o>:CompleteRelative<CR><C-x><C-f> " Make-ing (use Dispatch if enabled) nnoremap <leader>m? :set makeprg<CR> nnoremap <expr> <leader>mm g:loaded_dispatch ? ":Make<CR>" : ":silent make<CR>\|:redraw!<CR>\|:cwindow<CR>"