From fa3b083016391c7ced5074f498c942ab47034975 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Sun, 29 Oct 2017 01:54:41 -0400 Subject: more vim scoping this fixes, at least, using the Help function directly before opening denite for the first time (since `modifiable` was leaking through) --- vim/ftplugin/gitcommit.vim | 2 +- vim/ftplugin/perl.vim | 2 +- vim/ftplugin/ruby.vim | 11 ++++++----- vim/ftplugin/terraform.vim | 2 +- vim/ftplugin/tex.vim | 24 ++++++++++++------------ vimrc | 15 +++++++++------ 6 files changed, 30 insertions(+), 26 deletions(-) diff --git a/vim/ftplugin/gitcommit.vim b/vim/ftplugin/gitcommit.vim index 11d34aa..758db96 100644 --- a/vim/ftplugin/gitcommit.vim +++ b/vim/ftplugin/gitcommit.vim @@ -1 +1 @@ -set viminfo= +setlocal viminfo= diff --git a/vim/ftplugin/perl.vim b/vim/ftplugin/perl.vim index 6edc9fb..f6383fa 100644 --- a/vim/ftplugin/perl.vim +++ b/vim/ftplugin/perl.vim @@ -13,7 +13,7 @@ function! s:set_excludes() for line in readfile("dist.ini", '', 10) let name = matchstr(line, '\s*name\s*=\s*\zs.*') if name != "" - exe 'set wildignore+=' . name . '-*/*' + exe 'setlocal wildignore+=' . name . '-*/*' break endif endfor diff --git a/vim/ftplugin/ruby.vim b/vim/ftplugin/ruby.vim index e030a3d..035f432 100644 --- a/vim/ftplugin/ruby.vim +++ b/vim/ftplugin/ruby.vim @@ -1,11 +1,11 @@ function! s:rubocop_in_bundler() - let gemfiles = glob("*.gemspec", 1, 1) + let l:gemfiles = glob("*.gemspec", 1, 1) if filereadable("Gemfile") - let gemfiles += ["Gemfile"] + let l:gemfiles += ["Gemfile"] endif - for file in gemfiles - for line in readfile(file) - if line =~ 'gem.*rubocop' + for l:file in l:gemfiles + for l:line in readfile(l:file) + if l:line =~ 'gem.*rubocop' return 1 endif endfor @@ -19,6 +19,7 @@ endif " look up words in ri rather than man for K function! s:ri(word) exe 'silent read! ri -T -f rdoc "' . a:word . '" 2>/dev/null' + setlocal ft= endfunction nnoremap K :call Help(0, [':', '.'], 'ri') vnoremap K :call Help(1, [':', '.'], 'ri') diff --git a/vim/ftplugin/terraform.vim b/vim/ftplugin/terraform.vim index b296111..4e7db16 100644 --- a/vim/ftplugin/terraform.vim +++ b/vim/ftplugin/terraform.vim @@ -1,2 +1,2 @@ setlocal commentstring=#\ %s -let g:terraform_fmt_on_save = 1 +let b:terraform_fmt_on_save = 1 diff --git a/vim/ftplugin/tex.vim b/vim/ftplugin/tex.vim index a283f01..6f9bd52 100644 --- a/vim/ftplugin/tex.vim +++ b/vim/ftplugin/tex.vim @@ -5,28 +5,28 @@ setlocal makeprg=(cd\ /tmp\ &&\ pdflatex\ --halt-on-error\ %:p) " xpdf needs to be manually refreshed when the file changes function! s:xpdf() - let pdf = '/tmp/' . expand(':t:r') . '.pdf' - let processes = split(system('ps xo args'), '\n') - for process in processes - if process =~ 'xpdf -remote localhost' + let l:pdf = '/tmp/' . expand(':t:r') . '.pdf' + let l:processes = split(system('ps xo args'), '\n') + for l:process in l:processes + if l:process =~ 'xpdf -remote localhost' call system('xpdf -remote localhost -reload') return endif endfor - call system('xpdf -remote localhost ' . pdf . ' &') + call system('xpdf -remote localhost ' . l:pdf . ' &') endfunction " evince treats opening the same file twice as meaning 'reload' function! s:evince() - let pdf = '/tmp/' . expand(':t:r') . '.pdf' - system('evince ' . pdf . ' &') + let l:pdf = '/tmp/' . expand(':t:r') . '.pdf' + system('evince ' . l:pdf . ' &') endfunction " don't load the pdf if the make failed function! s:make_errors() - let qf = getqflist() - for line in qf - if line['type'] == 'E' + let l:qf = getqflist() + for l:line in l:qf + if l:line['type'] == 'E' return 1 endif endfor @@ -35,12 +35,12 @@ endfunction let b:automake_enabled = 0 function! s:automake() - let old_shellpipe = &shellpipe + let l:old_shellpipe = &shellpipe let &shellpipe = '>' try silent make! finally - let &shellpipe = old_shellpipe + let &shellpipe = l:old_shellpipe endtry endfunction diff --git a/vimrc b/vimrc index 6f8d7e7..06fbb8b 100644 --- a/vimrc +++ b/vimrc @@ -433,17 +433,20 @@ function! Help(visual, iskeyword, command) let l:word = expand('') endif let &iskeyword = l:iskeyword - exe &helpheight . 'new' - set modifiable + + exe 'noswapfile ' . &helpheight . 'new ' . l:word + setlocal buftype=nofile + setlocal bufhidden=wipe + setlocal nobuflisted + + setlocal modifiable exe 'call ' . a:command . '("' . l:word . '")' normal! ggdd - set buftype=nofile - set nobuflisted - set nomodifiable + setlocal nomodifiable endfunction function! s:man(word) exe 'silent read! man -Pcat ' . a:word - set filetype=man + setlocal filetype=man endfunction nnoremap K :call Help(0, [], 'man') xnoremap K :call Help(1, [], 'man') -- cgit v1.2.3-54-g00ecf