diff options
-rw-r--r-- | .gitmodules | 3 | ||||
-rw-r--r-- | IDEAS.md | 2 | ||||
-rw-r--r-- | Makefile | 6 | ||||
-rw-r--r-- | VERSION | 4 | ||||
-rw-r--r-- | vim/after/ftplugin/html.vim | 16 | ||||
-rw-r--r-- | vim/after/ftplugin/php.vim | 11 | ||||
-rw-r--r-- | vim/after/indent/c.vim | 6 | ||||
-rw-r--r-- | vim/after/indent/gitconfig.vim | 9 | ||||
-rw-r--r-- | vim/autoload/alternate_filetypes.vim | 13 | ||||
-rw-r--r-- | vim/autoload/fortune.vim | 61 | ||||
-rw-r--r-- | vim/autoload/select_old_files.vim | 17 | ||||
m--------- | vim/bundle/select_old_files | 0 | ||||
-rw-r--r-- | vim/filetype.vim | 9 | ||||
-rw-r--r-- | vim/ftplugin/textarea.vim | 11 | ||||
-rw-r--r-- | vim/gvimrc (renamed from vim/gvimrc.vim) | 0 | ||||
-rw-r--r-- | vim/indent/csv.vim | 9 | ||||
-rw-r--r-- | vim/indent/help.vim | 6 | ||||
-rw-r--r-- | vim/plugin/alternate_filetypes.vim | 4 | ||||
-rw-r--r-- | vim/plugin/fortune.vim | 21 | ||||
-rw-r--r-- | vim/plugin/select_old_files.vim | 8 | ||||
-rw-r--r-- | vim/vimrc (renamed from vim/vimrc.vim) | 32 | ||||
-rw-r--r-- | vim/vimrc.stub (renamed from vim/vimrc.stub.vim) | 0 |
22 files changed, 175 insertions, 73 deletions
diff --git a/.gitmodules b/.gitmodules index 1a1178e2..f91504da 100644 --- a/.gitmodules +++ b/.gitmodules @@ -50,6 +50,9 @@ [submodule "vim/bundle/replace_operator"] path = vim/bundle/replace_operator url = https://sanctum.geek.nz/code/vim-replace-operator.git +[submodule "vim/bundle/select_old_files"] + path = vim/bundle/select_old_files + url = https://sanctum.geek.nz/code/vim-select-old-files.git [submodule "vim/bundle/shebang_change_filetype"] path = vim/bundle/shebang_change_filetype url = https://sanctum.geek.nz/code/vim-shebang-change-filetype.git @@ -24,8 +24,6 @@ Ideas * Ideally, the AWK and/or sed scripts in the bin and games directories should be syntax-checked or linted. I could at least add some patient application of appropriate `gawk --lint` calls for each of the .awk scripts. -* Alternate buffer type switching would probably work rather well as a simple - plugin. * Write a ftplugin for Perl to switch between punctuation variable names and English variable names., i.e. \e on `$?` would change to `$CHILD_ERROR`, and vice-versa. @@ -598,8 +598,8 @@ install-vim-compiler: cp -p -- vim/compiler/*.vim $(VIMDIR)/compiler install-vim-config: install-vim-cache - cp -p -- vim/vimrc.stub.vim $(HOME)/.vimrc - cp -p -- vim/vimrc.vim $(VIMRC) + cp -p -- vim/vimrc.stub $(HOME)/.vimrc + cp -p -- vim/vimrc $(VIMRC) install-vim-filetype: cp -p -- vim/filetype.vim vim/scripts.vim $(VIMDIR) @@ -614,7 +614,7 @@ install-vim-gui: install-vim \ install-vim-gui-config install-vim-gui-config: - cp -p -- vim/gvimrc.vim $(GVIMRC) + cp -p -- vim/gvimrc $(GVIMRC) install-vim-indent: mkdir -p -- $(VIMDIR)/indent @@ -1,2 +1,2 @@ -tejr dotfiles v6.36.0 -Thu, 20 Jun 2019 02:58:36 +0000 +tejr dotfiles v6.37.0 +Sat, 22 Jun 2019 06:28:10 +0000 diff --git a/vim/after/ftplugin/html.vim b/vim/after/ftplugin/html.vim index d9c0149c..7866f31b 100644 --- a/vim/after/ftplugin/html.vim +++ b/vim/after/ftplugin/html.vim @@ -1,6 +1,11 @@ -" Spellcheck documents we're actually editing (not just viewing), as long as -" they're actually HTML buffers and not just dotting this in -if &modifiable && !&readonly && &filetype ==# 'html' +" None of this is appropriate for other filetypes that are just sourcing this +" filetype's scripts in, e.g. Markdown, PHP, so cut that off here +if &filetype !=# 'html' + finish +endif + +" Spellcheck documents we're actually editing (not just viewing) +if &modifiable && !&readonly setlocal spell let b:undo_ftplugin .= '|setlocal spell<' endif @@ -36,8 +41,3 @@ endif nnoremap <buffer> <LocalLeader>r \ :<C-U>call html#UrlLink()<CR> let b:undo_ftplugin .= '|nunmap <buffer> <LocalLeader>r' - -" Switch to PHP filetype for templated PHP -nnoremap <buffer> <LocalLeader>f - \ :<C-U>setlocal filetype=php<CR> -let b:undo_ftplugin .= '|nunmap <buffer> <LocalLeader>f' diff --git a/vim/after/ftplugin/php.vim b/vim/after/ftplugin/php.vim index 3b023f9e..c7f77ece 100644 --- a/vim/after/ftplugin/php.vim +++ b/vim/after/ftplugin/php.vim @@ -21,12 +21,7 @@ let b:undo_ftplugin .= '|setlocal keywordprg<' let b:regex_escape_flavor = 'ere' let b:undo_ftplugin .= '|unlet b:regex_escape_flavor' -" Stop here if the user doesn't want ftplugin mappings -if exists('no_plugin_maps') || exists('no_php_maps') - finish +" Set HTML as an alternative filetype +if !exists('b:alternate_filetypes') + let b:alternate_filetypes = [&filetype, 'html'] endif - -" Switch to HTML filetype for templated PHP -nnoremap <buffer> <LocalLeader>f - \ :<C-U>setlocal filetype=html<CR> -let b:undo_ftplugin .= '|nunmap <buffer> <LocalLeader>f' diff --git a/vim/after/indent/c.vim b/vim/after/indent/c.vim index dfc50242..ad01aceb 100644 --- a/vim/after/indent/c.vim +++ b/vim/after/indent/c.vim @@ -1,9 +1,11 @@ " Use hard tabs for C -setlocal noexpandtab shiftwidth=0 tabstop=8 +setlocal noexpandtab +setlocal shiftwidth=0 +let b:undo_indent .= '|setlocal expandtab< shiftwidth<' if &softtabstop != -1 let &softtabstop = &shiftwidth + let b:undo_indent .= '|setlocal softtabstop<' 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/' diff --git a/vim/after/indent/gitconfig.vim b/vim/after/indent/gitconfig.vim index 16a948ab..ff1654e5 100644 --- a/vim/after/indent/gitconfig.vim +++ b/vim/after/indent/gitconfig.vim @@ -1,6 +1,9 @@ " Use tabs for indent in Git config files, rather than fighting with the " frontend tool setlocal noexpandtab -setlocal softtabstop=0 -let &shiftwidth = &tabstop -let b:undo_indent .= '|setlocal expandtab< softtabstop< shiftwidth<' +setlocal shiftwidth=0 +let b:undo_indent .= '|setlocal expandtab< shiftwidth<' +if &softtabstop != -1 + let &softtabstop = &shiftwidth + let b:undo_indent .= '|setlocal softtabstop<' +endif diff --git a/vim/autoload/alternate_filetypes.vim b/vim/autoload/alternate_filetypes.vim new file mode 100644 index 00000000..08ac88dc --- /dev/null +++ b/vim/autoload/alternate_filetypes.vim @@ -0,0 +1,13 @@ +function! alternate_filetypes#() abort + if exists('b:alternate_filetypes') + let filetypes = b:alternate_filetypes + let index = index(filetypes, &filetype) + if index >= 0 + let &filetype = filetypes[ + \ (index + 1) % len(filetypes) + \] + else + unlet b:alternate_filetypes + endif + endif +endfunction diff --git a/vim/autoload/fortune.vim b/vim/autoload/fortune.vim new file mode 100644 index 00000000..339b1aef --- /dev/null +++ b/vim/autoload/fortune.vim @@ -0,0 +1,61 @@ +let s:paths = [ + \ $HOME.'/.fortunes', + \ $HOME.'/.local/share/games/fortunes', + \] + +let s:executables = [ + \ 'fortune', + \ 'timeout', + \] + +function! s:Highlight() abort + highlight Fortune + \ term=NONE + \ cterm=NONE ctermfg=244 ctermbg=NONE + \ gui=NONE guifg=#585858 guibg=NONE +endfunction +augroup fortune + autocmd! + autocmd ColorScheme * + \ call s:Highlight() +augroup END +doautocmd fortune ColorScheme + +function! fortune#() abort + + for executable in s:executables + if !executable(executable) + echoerr 'Missing executable "'.executable.'"' + endif + endfor + + let limit = &columns - 1 + + let command = [ + \ 'timeout', + \ '0.3s', + \ 'fortune', + \ '-s', + \ '-n', + \ limit, + \] + + for path in s:paths + if isdirectory(path) + call add(command, path) + break + endif + endfor + + let fortune = substitute( + \ system(join(command)), + \ '[[:cntrl:][:space:]]\+', + \ ' ', + \ 'g', + \) + + echohl Fortune + echo fortune + echohl None + +endfunction diff --git a/vim/autoload/select_old_files.vim b/vim/autoload/select_old_files.vim deleted file mode 100644 index aceff110..00000000 --- a/vim/autoload/select_old_files.vim +++ /dev/null @@ -1,17 +0,0 @@ -function! select_old_files#(...) abort - if a:0 - if a:1 =~# '^\d\+$' - let limit = a:1 - else - echoerr 'Invalid count' - endif - elseif exists('g:select_old_files_limit') - let limit = g:select_old_files_limit - else - let limit = &lines - 2 - endif - let oldfiles = v:oldfiles - let v:oldfiles = v:oldfiles[:limit - 1] - browse oldfiles - let v:oldfiles = oldfiles -endfunction diff --git a/vim/bundle/select_old_files b/vim/bundle/select_old_files new file mode 160000 +Subproject c9ed42c145e09ea121b8e3ff94061253fe4dbd9 diff --git a/vim/filetype.vim b/vim/filetype.vim index 67c8c333..7852c37e 100644 --- a/vim/filetype.vim +++ b/vim/filetype.vim @@ -135,6 +135,7 @@ augroup filetypedetect autocmd BufNewFile,BufRead \ ~/.vim/doc/?*.txt \,*/vim-*/doc/?*.txt + \,*/vim/*/doc/?*.txt \,*/*.vim/doc/?*.txt \,$VIMRUNTIME/doc/?*.txt \ setfiletype help @@ -398,8 +399,12 @@ augroup filetypedetect autocmd BufNewFile,BufRead \ ?*.vim \,.exrc - \,vimrc,[._]vimrc - \,gvimrc,[._]gvimrc + \,vimrc + \,vimrc.* + \,[._]vimrc + \,gvimrc + \,gvimrc.* + \,[._]gvimrc \ setfiletype vim " .viminfo files autocmd BufNewFile,BufRead diff --git a/vim/ftplugin/textarea.vim b/vim/ftplugin/textarea.vim index 5cdb2bba..4db97b58 100644 --- a/vim/ftplugin/textarea.vim +++ b/vim/ftplugin/textarea.vim @@ -1,13 +1,12 @@ +" Set mail message as an alternative filetype +if !exists('b:alternate_filetypes') + let b:alternate_filetypes = [&filetype, 'mail'] +endif + " Stop here if the user doesn't want ftplugin mappings if exists('no_plugin_maps') || exists('no_textarea_maps') finish endif -" 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/gvimrc.vim b/vim/gvimrc index ccccc20e..ccccc20e 100644 --- a/vim/gvimrc.vim +++ b/vim/gvimrc diff --git a/vim/indent/csv.vim b/vim/indent/csv.vim index 78bddd33..a9aba056 100644 --- a/vim/indent/csv.vim +++ b/vim/indent/csv.vim @@ -10,6 +10,9 @@ let b:undo_indent = 'setlocal autoindent<' " Literal tabs setlocal noexpandtab -setlocal softtabstop=0 -let &shiftwidth = &tabstop -let b:undo_indent = 'setlocal expandtab< softtabstop< shiftwidth<' +setlocal shiftwidth=0 +let b:undo_indent = 'setlocal expandtab< shiftwidth<' +if &softtabstop != -1 + let &l:softtabstop = &l:shiftwidth + let b:undo_indent .= '|setlocal softtabstop<' +endif diff --git a/vim/indent/help.vim b/vim/indent/help.vim index 1edf64fb..c49e1ced 100644 --- a/vim/indent/help.vim +++ b/vim/indent/help.vim @@ -5,8 +5,10 @@ endif let b:did_indent = 1 " Use hard tabs for editing Vim help files -setlocal noexpandtab shiftwidth=0 tabstop=8 +setlocal noexpandtab +setlocal shiftwidth=0 +let b:undo_indent = 'setlocal expandtab< shiftwidth<' if &softtabstop != -1 let &softtabstop = &shiftwidth + let b:undo_indent = 'setlocal softtabstop<' endif -let b:undo_indent = 'setlocal expandtab< shiftwidth< softtabstop< tabstop<' diff --git a/vim/plugin/alternate_filetypes.vim b/vim/plugin/alternate_filetypes.vim new file mode 100644 index 00000000..e024c9b2 --- /dev/null +++ b/vim/plugin/alternate_filetypes.vim @@ -0,0 +1,4 @@ +command -bar AlternateFileType + \ call alternate_filetypes#() | set filetype? +nnoremap <silent> <Plug>(AlternateFileType) + \ :<C-U>AlternateFileType<CR> diff --git a/vim/plugin/fortune.vim b/vim/plugin/fortune.vim new file mode 100644 index 00000000..b1c4955f --- /dev/null +++ b/vim/plugin/fortune.vim @@ -0,0 +1,21 @@ +command! -bar Fortune + \ call fortune#() + +nnoremap <silent> <Plug>(Fortune) + \ :<C-U>Fortune<CR> + +function! s:FortuneVimEnter() abort + if !argc() && line2byte('$') == -1 + try + Fortune + catch + " Do nothing + endtry + endif +endfunction + +augroup fortune + autocmd! + autocmd VimEnter * + \ call s:FortuneVimEnter() +augroup END diff --git a/vim/plugin/select_old_files.vim b/vim/plugin/select_old_files.vim deleted file mode 100644 index 77c7746e..00000000 --- a/vim/plugin/select_old_files.vim +++ /dev/null @@ -1,8 +0,0 @@ -if exists('loaded_select_old_files') || &compatible || !exists(':oldfiles') - finish -endif -let loaded_select_old_files = 1 -command! -bar -nargs=? SelectOldFiles - \ call select_old_files#(<f-args>) -nnoremap <Plug>SelectOldFiles - \ :<C-U>SelectOldFiles<CR> diff --git a/vim/vimrc.vim b/vim/vimrc index 60324470..bfcfdd52 100644 --- a/vim/vimrc.vim +++ b/vim/vimrc @@ -786,6 +786,11 @@ set noruler set sessionoptions-=localoptions " No buffer options or mappings set sessionoptions-=options " No global options or mappings +" Turn 'showcmd' off if a system vimrc has been rude enough to set it; I don't +" like how it can interfere with the display of longer lines. +" +set noshowcmd + " The 'I' flag for the 'shortmess' option prevents the display of the Vim " startup screen with version information, :help hints, and donation " suggestion. After I registered Vim and donated to Uganda per the screen's @@ -1549,9 +1554,10 @@ nnoremap <Leader>+ "" Leader,_ uses last changed or yanked text as an object onoremap <Leader>_ \ :<C-U>execute 'normal! `[v`]'<CR> -"" Leader,% uses entire buffer as an object +"" Leader,% or Leader,5 uses entire buffer as an object onoremap <Leader>% \ :<C-U>execute 'normal! 1GVG'<CR> +omap <Leader>5 <Leader>% " This group defines some useful motions, including navigating by indent " block using a custom plugin: @@ -1596,17 +1602,29 @@ nnoremap <Leader>? "" Leader,. runs the configured make program into the location list nnoremap <Leader>. \ :<C-U>lmake!<CR> -"" Leader,! repeats the last command, adding a bang -nnoremap <Leader>! - \ :<Up><Home><S-Right>!<CR> "" Leader,q formats the current paragraph nnoremap <Leader>q gqap "" Leader,r acts as a replacement operator nmap <Leader>r <Plug>(ReplaceOperator) xmap <Leader>r <Plug>(ReplaceOperator) -"" Leader,* escapes regex metacharacters -nmap <Leader>* <Plug>(RegexEscape) -xmap <Leader>* <Plug>(RegexEscape) +"" Leader,!/1 repeats the last command, adding a bang +nnoremap <Leader>! + \ :<Up><Home><S-Right>!<CR> +nmap <Leader>1 <Leader>! +"" Leader,#/3 gives me my fortune +nmap <Leader># <Plug>(AlternateFileType) +nmap <Leader>3 <Leader># +"" Leader,$/4 gives me my fortune +nmap <Leader>$ <Plug>(Fortune) +nmap <Leader>4 <Leader>$ +"" Leader,&/7 escapes regex metacharacters +nmap <Leader>& <Plug>(RegexEscape) +nmap <Leader>7 <Leader>& +xmap <Leader>& <Plug>(RegexEscape) +xmap <Leader>7 <Leader>& +"" Leader,*/8 is sticky-star: search, highlight, but don't move +nnoremap <silent> <Leader>* *N +nmap <Leader>8 <Leader>* " 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 diff --git a/vim/vimrc.stub.vim b/vim/vimrc.stub index dfadac92..dfadac92 100644 --- a/vim/vimrc.stub.vim +++ b/vim/vimrc.stub |