diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2018-07-22 22:46:33 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2018-07-22 22:46:33 +1200 |
commit | 680706a9028163e7af890ec41bd0efd803bcced7 (patch) | |
tree | 1427a57fd53e3646c79a512b9c4a8a43d7054ceb | |
parent | Merge branch 'hotfix/v1.36.1' (diff) | |
parent | Bump VERSION (diff) | |
download | dotfiles-680706a9028163e7af890ec41bd0efd803bcced7.tar.gz dotfiles-680706a9028163e7af890ec41bd0efd803bcced7.zip |
Merge branch 'release/v1.37.0'v1.37.0
* release/v1.37.0:
Bump VERSION
Add Vim mappings for normal {,} in diff buffers
Turn 'hidden' on for a bit
Remove range-stripping from \x mapping
Add some folding settings
Add d (macros) to C and C++ 'complete' setting
More tweaking for Vim tiny compatibility
Don't force locale settings on 'greppreg'
Correct logic on 'encoding' selection
Remove unneeded UNIX test
Try going without 'display' for a little while
Strip some redundant comments
Suppress insert_cancel.vim map if not &loadplugins
Overhaul .vimrc for maximum vim-tiny support
Correct two Vim comments
Define 'grepprg' for GNU grep in .vimrc
-rw-r--r-- | VERSION | 4 | ||||
-rw-r--r-- | vim/after/ftplugin/c.vim | 9 | ||||
-rw-r--r-- | vim/after/ftplugin/cpp.vim | 9 | ||||
-rw-r--r-- | vim/after/ftplugin/diff.vim | 6 | ||||
-rw-r--r-- | vim/vimrc | 190 |
5 files changed, 98 insertions, 120 deletions
@@ -1,2 +1,2 @@ -tejr dotfiles v1.36.1 -Fri Jul 20 10:02:17 UTC 2018 +tejr dotfiles v1.37.0 +Sun Jul 22 10:46:05 UTC 2018 diff --git a/vim/after/ftplugin/c.vim b/vim/after/ftplugin/c.vim index fff9de04..9ac59733 100644 --- a/vim/after/ftplugin/c.vim +++ b/vim/after/ftplugin/c.vim @@ -3,12 +3,15 @@ if &filetype !=# 'c' || v:version < 700 finish endif -" Set comment formats +" Include macros in completion +setlocal complete+=d + +" Set include pattern setlocal include=^\\s*#\\s*include -let b:undo_ftplugin .= '|setlocal include<' " Include headers on UNIX if has('unix') setlocal path+=/usr/include - let b:undo_ftplugin .= '|setlocal path<' endif + +let b:undo_ftplugin .= '|setlocal complete< include< path<' diff --git a/vim/after/ftplugin/cpp.vim b/vim/after/ftplugin/cpp.vim index 38c94330..b5596613 100644 --- a/vim/after/ftplugin/cpp.vim +++ b/vim/after/ftplugin/cpp.vim @@ -3,12 +3,15 @@ if &filetype !=# 'cpp' || v:version < 700 finish endif -" Set comment formats +" Include macros in completion +setlocal complete+=d + +" Set include pattern setlocal include=^\\s*#\\s*include -let b:undo_ftplugin .= '|setlocal include<' " Include headers on UNIX if has('unix') setlocal path+=/usr/include - let b:undo_ftplugin .= '|setlocal path<' endif + +let b:undo_ftplugin .= '|setlocal complete< include< path<' diff --git a/vim/after/ftplugin/diff.vim b/vim/after/ftplugin/diff.vim index 1e2bb2f8..109b5b49 100644 --- a/vim/after/ftplugin/diff.vim +++ b/vim/after/ftplugin/diff.vim @@ -8,6 +8,12 @@ if exists('g:no_plugin_maps') || exists('g:no_diff_maps') finish endif +" Modify curly braces to navigate by diff block +nnoremap <buffer> { ?^@@<CR> +nnoremap <buffer> } /^@@<CR> +let b:undo_ftplugin .= '|nunmap <buffer> {' + \ . '|nunmap <buffer> }' + " Set mappings nmap <buffer> <LocalLeader>p <Plug>(DiffPrune) xmap <buffer> <LocalLeader>p <Plug>(DiffPrune) @@ -1,8 +1,8 @@ " Tom Ryder (tejr)'s vimrc: <https://sanctum.geek.nz/cgit/dotfiles.git> " -" This file is not truly self-contained. It should run without errors on its -" own without the accompanying plugins to which it refers near its end, but -" you'll get errors for some of the leader maps. +" This file is designed to load without unsuppressed errors on Vim 6.0 and up. +" Anything older than that will probably break. There are also some odd bits +" of logic to cope with loading as much config as possible on vim-tiny. " Undo anything the operating system's vimrc may have broken runtime system.vim @@ -37,84 +37,82 @@ endif set autoindent " Use indent of previous line on new lines set expandtab " Use spaces instead of tabs set shiftwidth=4 " Indent with four spaces - -" Spaces to insert on Tab key insert -if v:version > 703 || v:version == 703 && has('patch693') - set softtabstop=-1 " Refer to 'shiftwidth' if supported -else - set softtabstop=4 " Otherwise just four spaces -endif +set softtabstop=4 " Insert four spaces with tab key " Let me backspace over pretty much anything set backspace+=eol " Line breaks set backspace+=indent " Spaces from 'autoindent' set backspace+=start " The start of current insertion -" Do keep backups +" Try to keep backups in one system-appropriate dir set backup +set backupdir^=~/.vim/cache/backup,~/vimfiles/cache/backup -" Try to keep backups in one system-appropriate dir -if has('unix') - set backupdir^=~/.vim/cache/backup -elseif has('win32') || has('win64') - set backupdir^=~/vimfiles/cache/backup -endif +" Add some paths not to back up +set backupskip+=/dev/shm/* +set backupskip+=/var/tmp/* -" Don't back up stuff in /dev/shm or /var/tmp -if has('unix') - set backupskip+=/dev/shm/* - set backupskip+=/var/tmp/* -endif +" Indent wrapped lines +silent! set breakindent + +" Clear default 'comments' value, let the filetype handle it +set comments= " Try to keep swapfiles in one system-appropriate dir -if has('unix') - set directory^=~/.vim/cache/swap// -elseif has('win32') || has('win64') - set directory^=~/vimfiles/cache/swap// -endif +set directory^=~/.vim/cache/swap//,~/vimfiles/cache/swap// -" How to deal with lines wrapping beyond the last screen row -if v:version > 704 || v:version == 704 && has('patch2109') - set display=truncate " Show '@@@' on the last line, if supported -else - set display=lastline " Just let it run off the screen if not +" Use UTF-8 if we can and env LANG didn't tell us not to +if has('multi_byte') && !exists('$LANG') && &encoding ==# 'latin1' + set encoding=utf-8 endif " Don't wait for a key after Escape in insert mode -if exists('+esckeys') " Not in Neovim - set noesckeys -endif +silent! set noesckeys " Delete comment leaders when joining lines, if supported -if v:version > 703 || v:version == 703 && has('patch541') - set formatoptions+=j +silent! set formatoptions+=j + +" If available, use GNU grep niceties for searching +if system('grep --version') =~# '^grep (GNU grep)' + set grepprg=grep\ -HnRs\ --exclude='.git*' endif +" Allow buffers to have changes without being displayed +set hidden + " Keep more command and search history set history=500 +" Highlight completed searches; clear on reload +set hlsearch +if 1 + nohlsearch +endif + " Don't assume I'm editing C; let the filetype set this set include= +" Show search matches as I type my pattern +set incsearch + " Don't join lines with two spaces at the end of sentences set nojoinspaces " Don't show a statusline if there's only one window -if has('nvim') " Neovim changed the default to 2 - set laststatus=1 -endif +set laststatus=1 " Don't redraw the screen during batch execution set lazyredraw +" Break lines at word boundaries +set linebreak + " Define extra 'list' display characters -set listchars+=extends:> " Unwrapped text to screen right -set listchars+=precedes:< " Unwrapped text to screen left -set listchars+=tab:>- " Tab characters, preserve width -set listchars+=trail:_ " Trailing spaces -if v:version >= 700 - set listchars+=nbsp:+ " Non-breaking spaces -endif +set listchars+=extends:> " Unwrapped text to screen right +set listchars+=precedes:< " Unwrapped text to screen left +set listchars+=tab:>- " Tab characters, preserve width +set listchars+=trail:_ " Trailing spaces +silent! set listchars+=nbsp:+ " Non-breaking spaces " Don't allow setting options via buffer content set nomodeline @@ -122,28 +120,32 @@ set nomodeline " Treat numbers with a leading zero as decimal, not octal set nrformats-=octal +" Options for file search with gf/:find +set path-=/usr/include " Let the C/C++ filetypes set that +set path+=** " Search current directory's whole tree + " Don't show startup splash screen (I donated) set shortmess+=I +" Prefix wrapped rows with three dots +set showbreak=... + +" New windows go below or to the right of a split +set splitbelow +set splitright + " Give me a bit longer to complete mappings set timeoutlen=3000 -" Clear default 'comments' value, let the filetype handle it -if has('comments') - set comments= -endif - -" Highlight settings for search -if has('extra_search') - set hlsearch " Highlight completed searches... - nohlsearch " ...but clear it on startup or after re-sourcing - set incsearch " Show matches as I type -endif +" Wildmenu settings; see also plugin/wildignore.vim +set wildmenu " Use wildmenu +set wildmode=list:longest " Tab press completes and lists +silent! set wildignorecase " Case insensitive, if supported -" Options for file search with gf/:find -if has('file_in_path') - set path-=/usr/include " Let the C/C++ filetypes set that - set path+=** " Search current directory's whole tree +" Fold based on indent, but only when I ask +if has('folding') + set foldlevelstart=99 + set foldmethod=indent endif " Don't load GUI menus; set here before GUI starts @@ -151,70 +153,34 @@ if has('gui_running') set guioptions+=M endif -" Line break behaviour settings for 'wrap' -if has('linebreak') - set linebreak " Break lines at word boundaries - set showbreak=... " Prefix wrapped rows with three dots - if exists('+breakindent') - set breakindent " Indent wrapped lines, if supported +" Keep undo files, hopefully in a dedicated directory +if has('persistent_undo') + set undofile + set undodir^=~/.vim/cache/undo// + if has('win32') || has('win64') + set undodir^=~/vimfiles/cache/undo// endif endif " Don't store any options or mappings in sessions -if has('mksession') +if exists('+sessionoptions') set sessionoptions-=localoptions set sessionoptions-=options endif -" If $LANG isn't set and 'encoding' is the default, use UTF-8 -if has('multi_byte') && !exists('$LANG') && &encoding ==# 'latin1' - set encoding=utf-8 -endif - -" Persistent undo settings -if has('persistent_undo') - - " Do keep undo files - set undofile - - " Try to keep them all in one system-appropriate dir - if has('unix') - set undodir^=~/.vim/cache/undo// - elseif has('win32') || has('win64') - set undodir^=~/vimfiles/cache/undo// - endif - -endif - " Let me move beyond buffer text in visual block mode -if has('virtualedit') +if exists('+virtualedit') set virtualedit+=block endif -" Nicer completion for command mode -if has('wildmenu') - set wildmenu " Use wildmenu - set wildmode=list:longest " Tab press completes and lists - if exists('+wildignorecase') - set wildignorecase " Case insensitive, if supported - endif - " 'wildignore' is built in plugin/wildignore.vim -endif - -" New windows go below or to the right of a split -if has('windows') - set splitbelow - if has('vertsplit') - set splitright - endif -endif - " Stack normal/visual/select Ctrl-L to clear search highlight nnoremap <silent> <C-L> :<C-U>nohlsearch<CR><C-L> vnoremap <silent> <C-L> :<C-U>nohlsearch<CR>gv<C-L> " Remap insert Ctrl-C to undo the escaped insert operation -imap <C-C> <Plug>(InsertCancel) +if &loadplugins + imap <C-C> <Plug>(InsertCancel) +endif " Map double Ctrl-K in insert mode to search digraph names imap <C-K><C-K> <Plug>(DigraphSearch) @@ -225,7 +191,7 @@ nnoremap <BS> <C-B> " Remap normal/visual & to preserve substitution flags nnoremap <silent> & :&&<CR> -if v:version >= 700 +if exists(':xnoremap') xnoremap <silent> & :&&<CR> endif @@ -314,8 +280,8 @@ nnoremap <Bslash>V :<C-U>let b: t: w:<CR> " \w toggles wrapping nnoremap <Bslash>w :<C-U>setlocal wrap! wrap?<CR> " \x strips trailing whitespace via a custom plugin -nmap <Bslash>x :<C-U>StripTrailingWhitespace<CR> -if v:version >= 700 +nmap <Bslash>x :StripTrailingWhitespace<CR> +if exists(':xmap') xmap <Bslash>x :StripTrailingWhitespace<CR> endif " \y shows all registers |