diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2019-06-19 22:42:51 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2019-06-19 22:42:51 +1200 |
commit | 0dd0b2330cd0e304823151869537d0253a4689b9 (patch) | |
tree | 17aaaf5ff0e008e40aecafc21b0232435da6d3ef | |
parent | Merge branch 'release/v6.32.0' (diff) | |
parent | Bump VERSION (diff) | |
download | dotfiles-0dd0b2330cd0e304823151869537d0253a4689b9.tar.gz dotfiles-0dd0b2330cd0e304823151869537d0253a4689b9.zip |
Merge branch 'release/v6.33.0'v6.33.0
* release/v6.33.0: (23 commits)
Spin off paste_insert.vim into distribution
Use hard tabs for editing Vim :help files
Add a word to a comment
Finishing touches to paste_insert.vim
Remove unneeded expand()
Swap two terms around
Remove leader maps for digits
Back to simpler regex test of &term
Adjust a few comments
Adjust string comparisons
Enable 'smarttab' in Vim
Set filetype-appropriate 'foldlevel'
Set 'shiftwidth' to 4 for C Vim sources
Type proto/*.pro files as C
Correct variable name
Switch to tab indents for writing C
Add abbreviation to TextAnywhere Vim ftplugin
Fix a comment in mail Vim ftplugin
Move 'foldmethod' definitions out to filetypes
...
-rw-r--r-- | .gitmodules | 3 | ||||
-rw-r--r-- | VERSION | 4 | ||||
-rw-r--r-- | vim/after/ftplugin/c.vim | 16 | ||||
-rw-r--r-- | vim/after/ftplugin/perl.vim | 5 | ||||
-rw-r--r-- | vim/after/ftplugin/php.vim | 5 | ||||
-rw-r--r-- | vim/after/ftplugin/sh.vim | 5 | ||||
-rw-r--r-- | vim/after/ftplugin/vim.vim | 5 | ||||
-rw-r--r-- | vim/after/ftplugin/zsh.vim | 5 | ||||
-rw-r--r-- | vim/after/indent/c.vim | 11 | ||||
-rw-r--r-- | vim/after/indent/help.vim | 6 | ||||
-rw-r--r-- | vim/autoload/paste_insert.vim | 12 | ||||
m--------- | vim/bundle/paste_insert | 0 | ||||
-rw-r--r-- | vim/filetype.vim | 1 | ||||
-rw-r--r-- | vim/ftplugin/awk.vim | 5 | ||||
-rw-r--r-- | vim/ftplugin/markdown.vim | 4 | ||||
-rw-r--r-- | vim/ftplugin/sed.vim | 5 | ||||
-rw-r--r-- | vim/ftplugin/textarea.vim | 7 | ||||
-rw-r--r-- | vim/plugin/paste_insert.vim | 8 | ||||
-rw-r--r-- | vim/vimrc | 98 |
19 files changed, 112 insertions, 93 deletions
diff --git a/.gitmodules b/.gitmodules index 5f049838..1a1178e2 100644 --- a/.gitmodules +++ b/.gitmodules @@ -32,6 +32,9 @@ [submodule "vim/bundle/keep_position"] path = vim/bundle/keep_position url = https://sanctum.geek.nz/code/vim-keep-position.git +[submodule "vim/bundle/paste_insert"] + path = vim/bundle/paste_insert + url = https://sanctum.geek.nz/code/vim-paste-insert.git [submodule "vim/bundle/put_blank_lines"] path = vim/bundle/put_blank_lines url = https://sanctum.geek.nz/code/vim-put-blank-lines.git @@ -1,2 +1,2 @@ -tejr dotfiles v6.32.0 -Tue, 18 Jun 2019 23:58:21 +0000 +tejr dotfiles v6.33.0 +Wed, 19 Jun 2019 10:42:51 +0000 diff --git a/vim/after/ftplugin/c.vim b/vim/after/ftplugin/c.vim index b5989410..bc531a61 100644 --- a/vim/after/ftplugin/c.vim +++ b/vim/after/ftplugin/c.vim @@ -1,14 +1,18 @@ -" Set 'commentstring' and 'include' back to their default C-friendly values -setlocal commentstring&vim -setlocal include&vim +" Set 'commentstring', 'define', and 'include' back to their default C-friendly values +setlocal commentstring&vim define&vim include&vim +let b:undo_ftplugin .= '|setlocal commentstring< define< include<' " Include macros in completion setlocal complete+=d +let b:undo_ftplugin .= '|setlocal complete<' + +" Fold based on indent level, and start with all folds closed +setlocal foldmethod=indent +setlocal foldlevel=0 +let b:undo_ftplugin .= '|setlocal foldmethod< foldlevel<' " Include system headers on UNIX if has('unix') setlocal path+=/usr/include + let b:undo_ftplugin .= '|setlocal path<' endif - -" Undo all of the above -let b:undo_ftplugin .= '|setlocal commentstring< complete< include< path<' diff --git a/vim/after/ftplugin/perl.vim b/vim/after/ftplugin/perl.vim index a303fa75..5c9cf8a0 100644 --- a/vim/after/ftplugin/perl.vim +++ b/vim/after/ftplugin/perl.vim @@ -4,6 +4,11 @@ setlocal equalprg=perltidy let b:undo_ftplugin .= '|unlet b:current_compiler' \ . '|setlocal equalprg< errorformat< makeprg<' +" Fold based on indent level, but start with all folds open +setlocal foldmethod=indent +setlocal foldlevel=99 +let b:undo_ftplugin .= '|setlocal foldmethod< foldlevel<' + " Add angle brackets to pairs of matched characters for q<...> setlocal matchpairs+=<:> let b:undo_ftplugin .= '|setlocal matchpairs<' diff --git a/vim/after/ftplugin/php.vim b/vim/after/ftplugin/php.vim index 58d83c49..3b023f9e 100644 --- a/vim/after/ftplugin/php.vim +++ b/vim/after/ftplugin/php.vim @@ -8,6 +8,11 @@ setlocal comments=s1:/*,m:*,ex:*/,://,:# setlocal formatoptions+=or let b:undo_ftplugin .= '|setlocal comments< formatoptions<' +" Fold based on indent level, but start with all folds open +setlocal foldmethod=indent +setlocal foldlevel=99 +let b:undo_ftplugin .= '|setlocal foldmethod< foldlevel<' + " Use pman as 'keywordprg' setlocal keywordprg=pman let b:undo_ftplugin .= '|setlocal keywordprg<' diff --git a/vim/after/ftplugin/sh.vim b/vim/after/ftplugin/sh.vim index 8468b133..39b8d0d6 100644 --- a/vim/after/ftplugin/sh.vim +++ b/vim/after/ftplugin/sh.vim @@ -3,6 +3,11 @@ setlocal comments=:# setlocal formatoptions+=or let b:undo_ftplugin .= '|setlocal comments< formatoptions<' +" Fold based on indent level, but start with all folds open +setlocal foldmethod=indent +setlocal foldlevel=99 +let b:undo_ftplugin .= '|setlocal foldmethod< foldlevel<' + " If subtype is Bash, set 'keywordprg' to han(1df) if exists('b:is_bash') setlocal keywordprg=han diff --git a/vim/after/ftplugin/vim.vim b/vim/after/ftplugin/vim.vim index 30182bba..481af0ec 100644 --- a/vim/after/ftplugin/vim.vim +++ b/vim/after/ftplugin/vim.vim @@ -9,6 +9,11 @@ endif let b:regex_escape_flavor = 'vim' let b:undo_ftplugin .= '|unlet b:regex_escape_flavor' +" Fold based on indent level, but start with all folds open +setlocal foldmethod=indent +setlocal foldlevel=99 +let b:undo_ftplugin .= '|setlocal foldmethod< foldlevel<' + " Use :help as 'keywordprg' if not already set; this is the default since Vim " v8.1.1290 if &keywordprg !=# ':help' diff --git a/vim/after/ftplugin/zsh.vim b/vim/after/ftplugin/zsh.vim index 5aa2600a..880c2c39 100644 --- a/vim/after/ftplugin/zsh.vim +++ b/vim/after/ftplugin/zsh.vim @@ -2,3 +2,8 @@ compiler zsh let b:undo_ftplugin .= '|unlet b:current_compiler' \ . '|setlocal errorformat< makeprg<' + +" Fold based on indent level, but start with all folds open +setlocal foldmethod=indent +setlocal foldlevel=99 +let b:undo_ftplugin .= '|setlocal foldmethod< foldlevel<' diff --git a/vim/after/indent/c.vim b/vim/after/indent/c.vim new file mode 100644 index 00000000..dfc50242 --- /dev/null +++ b/vim/after/indent/c.vim @@ -0,0 +1,11 @@ +" Use hard tabs for C +setlocal noexpandtab shiftwidth=0 tabstop=8 +if &softtabstop != -1 + let &softtabstop = &shiftwidth +endif +let b:undo_indent .= '|setlocal expandtab< shiftwidth< softtabstop< tabstop<' + +" If the path to the file looks like the Vim sources, set 'shiftwidth' to 4 +if expand('%:p') =~# '/vim.*src/' + setlocal shiftwidth=4 +endif diff --git a/vim/after/indent/help.vim b/vim/after/indent/help.vim new file mode 100644 index 00000000..449e3b4a --- /dev/null +++ b/vim/after/indent/help.vim @@ -0,0 +1,6 @@ +" Use hard tabs for Vim help +setlocal noexpandtab shiftwidth=0 tabstop=8 +if &softtabstop != -1 + let &softtabstop = &shiftwidth +endif +let b:undo_indent .= '|setlocal expandtab< shiftwidth< softtabstop< tabstop<' diff --git a/vim/autoload/paste_insert.vim b/vim/autoload/paste_insert.vim deleted file mode 100644 index 675fa5ab..00000000 --- a/vim/autoload/paste_insert.vim +++ /dev/null @@ -1,12 +0,0 @@ -function! paste_insert#() abort - augroup paste_insert - autocmd! - autocmd CursorHold,CursorMoved,User * - \ set nopaste paste? - \|autocmd! paste_insert - autocmd InsertEnter * - \ autocmd paste_insert InsertLeave * - \ doautocmd paste_insert User - augroup END - set paste paste? -endfunction diff --git a/vim/bundle/paste_insert b/vim/bundle/paste_insert new file mode 160000 +Subproject d754e506fdfb10688d721935c01d2615d11b2a1 diff --git a/vim/filetype.vim b/vim/filetype.vim index e65848bb..219ec819 100644 --- a/vim/filetype.vim +++ b/vim/filetype.vim @@ -44,6 +44,7 @@ augroup filetypedetect autocmd BufNewFile,BufRead \ ?*.c \,?*.h + \,*/proto/?*.pro \ setfiletype c " C++ files autocmd BufNewFile,BufRead diff --git a/vim/ftplugin/awk.vim b/vim/ftplugin/awk.vim index 663ba810..dbefa5cd 100644 --- a/vim/ftplugin/awk.vim +++ b/vim/ftplugin/awk.vim @@ -9,6 +9,11 @@ setlocal comments=:# setlocal formatoptions+=or let b:undo_ftplugin = 'setlocal comments< formatoptions<' +" Fold based on indent level, but start with all folds open +setlocal foldmethod=indent +setlocal foldlevel=99 +let b:undo_ftplugin .= '|setlocal foldmethod< foldlevel<' + " Specify ERE flavor for regex_escape.vim let b:regex_escape_flavor = 'ere' let b:undo_ftplugin .= '|unlet b:regex_escape_flavor' diff --git a/vim/ftplugin/markdown.vim b/vim/ftplugin/markdown.vim index d119e599..da2228b3 100644 --- a/vim/ftplugin/markdown.vim +++ b/vim/ftplugin/markdown.vim @@ -39,9 +39,11 @@ function! MarkdownFold() return '=' endfunction +let b:undo_ftplugin .= '|delfunction MarkdownFold' setlocal foldexpr=MarkdownFold() setlocal foldmethod=expr -let b:undo_ftplugin .= '|delfunction MarkdownFold|setlocal foldexpr< foldmethod<' +setlocal foldlevel=99 +let b:undo_ftplugin .= '|setlocal foldexpr< foldmethod< foldlevel<' " Spellcheck documents we're actually editing (not just viewing) if &modifiable && !&readonly diff --git a/vim/ftplugin/sed.vim b/vim/ftplugin/sed.vim index 9627941d..35e705a4 100644 --- a/vim/ftplugin/sed.vim +++ b/vim/ftplugin/sed.vim @@ -8,3 +8,8 @@ let b:did_ftplugin = 1 setlocal comments=:# setlocal formatoptions+=or let b:undo_ftplugin = 'setlocal comments< formatoptions<' + +" Fold based on indent level, but start with all folds open +setlocal foldmethod=indent +setlocal foldlevel=99 +let b:undo_ftplugin .= '|setlocal foldmethod< foldlevel<' diff --git a/vim/ftplugin/textarea.vim b/vim/ftplugin/textarea.vim index 872ae4c6..5cdb2bba 100644 --- a/vim/ftplugin/textarea.vim +++ b/vim/ftplugin/textarea.vim @@ -3,8 +3,11 @@ if exists('no_plugin_maps') || exists('no_textarea_maps') finish endif -" Switch to mail filetype, just because that's very often the contents of text -" areas I edit using TextEditorAnywhere +" Local mapping to switch to mail filetype, just because that's very often the +" contents of text areas I edit using TextEditorAnywhere nnoremap <buffer> <LocalLeader>f \ :<C-U>setlocal filetype=mail<CR> let b:undo_ftplugin = 'nunmap <buffer> <LocalLeader>f' + +" #s expands to the #signature tag used in Cerb +inoreabbrev #s #signature diff --git a/vim/plugin/paste_insert.vim b/vim/plugin/paste_insert.vim deleted file mode 100644 index 2c17f802..00000000 --- a/vim/plugin/paste_insert.vim +++ /dev/null @@ -1,8 +0,0 @@ -if exists('loaded_paste_insert') || &compatible - finish -endif -let loaded_paste_insert = 1 -command! -bar PasteInsert - \ call paste_insert#() -nnoremap <Plug>PasteInsert - \ :<C-U>PasteInsert<CR> @@ -4,12 +4,12 @@ " <https://sanctum.geek.nz/cgit/dotfiles.git> " " This is an attempt at something like a 'literate vimrc', in the tradition of -" Donald Knuth's "literate programming". +" Donald Knuth's "literate programming": " " <http://www.literateprogramming.com/> " -" It's a long file, and comments abound. If this bothers you, you can do -" something like this to strip out all the blank lines and lines with only +" It's a long file, and comments abound. If this bothers you, you can execute +" this command in Vim to strip out all the blank lines and lines with only " comments: " " :g/\m^$\|^\s*"/d @@ -118,7 +118,7 @@ endif " Firstly, MYVIM can't be an empty string. We need a real path. " -if !strlen($MYVIM) +if $MYVIM ==# '' echoerr 'Blank user runtime path' finish endif @@ -149,8 +149,8 @@ endif " " <https://github.com/vim/vim/releases/tag/v7.1.055> " -if stridx($MYVIM, '\') >= 0 - \ && (v:version < 701 || v:version == 701 && !has('patch55')) +if (v:version < 701 || v:version == 701 && !has('patch55')) + \ && stridx($MYVIM, '\') >= 0 echoerr 'Illegal backslash in user runtime path on Vim < v7.1.055' finish endif @@ -252,7 +252,7 @@ endif " provide as a quoted parameter to the function. " function! s:Establish(name) abort - let name = expand(a:name) + let name = a:name let path = 'p' let prot = 0700 if !isdirectory(name) && exists('*mkdir') @@ -499,6 +499,7 @@ set path-=/usr/include set autoindent " Use indent of previous line on new lines set expandtab " Insert spaces when tab key is pressed in insert mode set shiftwidth=4 " Indent command like < and > use four-space indents +set smarttab " Tab at start of line means indent, otherwise means tab " Apply 'softtabstop' option to make a tab key press in insert mode insert the " same number of spaces as defined by the indent depth in 'shiftwidth'. If @@ -584,24 +585,6 @@ set confirm " set noesckeys -" By default, I prefer that figuring out where a region of text to fold away -" should be done by the indent level of its lines, since I tend to be careful -" about my indentation even in languages where it has no semantic meaning. -" -set foldmethod=indent - -" That said, I don't want any of these indent-based folds to start off closed. -" Therefore, we set the depth level at which folds should automatically start -" as closed to a rather high number, per the documentation's recommendations. -" -" I think of a Vim window with a file buffer loaded into it as -" a two-dimensional, planar view of the file, so that moving down one screen -" line means moving down one buffer line, at least when 'wrap' is unset. -" Folds break that mental model, and so I usually enable them explicitly only -" when I'm struggling to grasp some code with very long functions or loops. -" -set foldlevelstart=99 - " Automatic text wrapping options using flags in the 'formatoptions' option " begin here. I rely on the filetype plugins to set the 't' and 'c' flags for " this option to configure whether text or comments should be wrapped, as @@ -821,7 +804,7 @@ set shortmess+=I " plugin doesn't look like it's going to load, whether because plugins have " been disabled, or it's not in any of the plugin directories. " -if !&loadplugins || !strlen(globpath(&runtimepath, 'plugin/matchparen.vim')) +if !&loadplugins || globpath(&runtimepath, 'plugin/matchparen.vim') ==# '' set showmatch matchtime=3 endif @@ -846,7 +829,7 @@ set synmaxcol=500 " windows terminal emulator PuTTY, and the terminal multiplexer tmux, both of " which I use heavily. " -if &term =~# '^\%(putty\|tmux\)' +if &term =~# '^putty\|^tmux' set ttyfast endif @@ -1054,7 +1037,7 @@ endif " almost always stands out too much for my liking. " " You'd think the autocommand pattern here could be used to match the colour -" scheme name, and it can be...after patch v7.4.108, when Christian Brabandt +" scheme name, and it can be ... after patch v7.4.108, when Christian Brabandt " fixed it. Until that version, it matched against the current buffer name, " so we're forced to have an explicit test in the command instead. " @@ -1067,7 +1050,7 @@ autocmd vimrc ColorScheme * " environment variable COLORFGBG or a response in v:termrbgresp that would set " it specifically. " -if !exists('$COLORFGBG') && !strlen(get(v:, 'termrbgresp', '')) +if !exists('$COLORFGBG') && get(v:, 'termrbgresp', '') ==# '' set background=dark endif @@ -1077,7 +1060,7 @@ endif " if &background ==# 'dark' \ && (has('gui_running') || &t_Co >= 256) - \ && strlen(globpath(&runtimepath, 'colors/sahara.vim')) + \ && globpath(&runtimepath, 'colors/sahara.vim') !=# '' colorscheme sahara endif @@ -1170,7 +1153,7 @@ nnoremap <expr> <Space> " If the plugin isn't available, I just abandon CTRL-C to continue its " uselessness. " -if &loadplugins && strlen(globpath(&runtimepath, 'plugin/insert_cancel.vim')) +if &loadplugins && globpath(&runtimepath, 'plugin/insert_cancel.vim') ==# '' imap <C-C> <Plug>(InsertCancel) endif @@ -1326,45 +1309,45 @@ endif " 'cursorline' is always off when in any visual mode, including block mode, " where it actually might have been really handy. +"" Leader,TAB toggles automatic indentation based on the previous line +nnoremap <Leader><Tab> + \ :<C-U>set autoindent! autoindent?<CR> +"" Leader,c toggles highlighted cursor row; doesn't work in visual mode +nnoremap <Leader>c + \ :<C-U>set cursorline! cursorline?<CR> "" Leader,h toggles highlighting search results nnoremap <Leader>h \ :<C-U>set hlsearch! hlsearch?<CR> "" Leader,i toggles showing matches as I enter my pattern nnoremap <Leader>i \ :<C-U>set incsearch! incsearch?<CR> -"" Leader,TAB toggles automatic indentation based on the previous line -nnoremap <Leader><Tab> - \ :<C-U>setlocal autoindent! autoindent?<CR> -"" Leader,c toggles highlighted cursor row; doesn't work in visual mode -nnoremap <Leader>c - \ :<C-U>setlocal cursorline! cursorline?<CR> "" Leader,s toggles spell checking nnoremap <Leader>s - \ :<C-U>setlocal spell! spell?<CR> + \ :<C-U>set spell! spell?<CR> " The next group of option-toggling maps are much the same as the previous " group, except they also include analogous maps for visual mode, defined as " recursive maps into normal mode that conclude with re-selecting the text. -"" Leader,N toggles position display in bottom right -nnoremap <Leader>N - \ :<C-U>set ruler! ruler?<CR> -xmap <Leader>N <Esc><Leader>Ngv "" Leader,C toggles highlighted cursor column; works in visual mode nnoremap <Leader>C - \ :<C-U>setlocal cursorcolumn! cursorcolumn?<CR> + \ :<C-U>set cursorcolumn! cursorcolumn?<CR> xmap <Leader>C <Esc><Leader>Cgv "" Leader,l toggles showing tab, end-of-line, and trailing white space nnoremap <Leader>l - \ :<C-U>setlocal list! list?<CR> + \ :<C-U>set list! list?<CR> xmap <Leader>l <Esc><Leader>lgv "" Leader,n toggles line number display nnoremap <Leader>n - \ :<C-U>setlocal number! number?<CR> + \ :<C-U>set number! number?<CR> xmap <Leader>n <Esc><Leader>ngv +"" Leader,N toggles position display in bottom right +nnoremap <Leader>N + \ :<C-U>set ruler! ruler?<CR> +xmap <Leader>N <Esc><Leader>Ngv "" Leader,w toggles soft wrapping nnoremap <Leader>w - \ :<C-U>setlocal wrap! wrap?<CR> + \ :<C-U>set wrap! wrap?<CR> xmap <Leader>w <Esc><Leader>wgv " This next one just shows option state of the 'formatoptions' affecting how @@ -1372,7 +1355,7 @@ xmap <Leader>w <Esc><Leader>wgv "" Leader,f shows the current 'formatoptions' at a glance nnoremap <Leader>f - \ :<C-U>setlocal formatoptions?<CR> + \ :<C-U>set formatoptions?<CR> " I often have to switch between US English and NZ English. The latter is " almost exactly the same as UK English in most locales, although we use @@ -1382,10 +1365,10 @@ nnoremap <Leader>f "" Leader,u sets US English spelling language nnoremap <Leader>u - \ :<C-U>setlocal spelllang=en_us<CR> + \ :<C-U>set spelllang=en_us<CR> "" Leader,z sets NZ English spelling language nnoremap <Leader>z - \ :<C-U>setlocal spelllang=en_nz<CR> + \ :<C-U>set spelllang=en_nz<CR> " The next mapping is also for toggling an option, but it's more complicated; " it uses a simple plugin of mine called copy_linebreak.vim to manage several @@ -1438,10 +1421,10 @@ nnoremap <Leader>F \ :<C-U>ReloadFileType<CR> "" Leader,t shows current filetype nnoremap <Leader>t - \ :<C-U>setlocal filetype?<CR> + \ :<C-U>set filetype?<CR> "" Leader,T clears filetype nnoremap <Leader>T - \ :<C-U>setlocal filetype=<CR> + \ :<C-U>set filetype=<CR> " These mappings use my put_date.vim plugin for date insertion into the " buffer. @@ -1515,10 +1498,10 @@ nnoremap <Leader><Insert> \ :<C-U>enew<CR> "" Leader,e forces a buffer to be editable, even a :help one nnoremap <Leader>e - \ :<C-U>setlocal modifiable noreadonly<CR> + \ :<C-U>set modifiable noreadonly<CR> "" Leader,E locks a buffer, reversible with <Leader>e nnoremap <Leader>E - \ :<C-U>setlocal nomodifiable readonly<CR> + \ :<C-U>set nomodifiable readonly<CR> "" Leader,j jumps to buffers ("jetpack") nnoremap <Leader>j \ :<C-U>buffers<CR>:buffer<Space> @@ -1625,15 +1608,6 @@ xmap <Leader>r <Plug>(ReplaceOperator) nmap <Leader>* <Plug>(RegexEscape) xmap <Leader>* <Plug>(RegexEscape) -" I don't have anything for which I'm using the numbers just yet, so let's set -" them to apply an explicit 'foldlevel' for now, which is occasionally useful, -" though I suspect I'm more likely to keep using zM, zm, and zr. -" -for s:key in range(0,9) - execute 'nnoremap <Leader>'.s:key.' :<C-U>set foldlevel='.s:key.'<CR>' - execute 'xmap <Leader>'.s:key.' <Esc><Leader>'.s:key.'gv' -endfor - " And last, but definitely not least, I'm required by Vim fanatic law to " include a mapping that reloads my whole configuration. This uses the " command wrapper defined much earlier in the file, so that filetypes also get |