diff options
-rw-r--r-- | Makefile | 11 | ||||
-rw-r--r-- | README.md | 8 | ||||
-rw-r--r-- | VERSION | 4 | ||||
-rw-r--r-- | git/gitconfig.mi5 | 2 | ||||
-rw-r--r-- | vim/after/ftplugin/gitcommit.vim | 2 | ||||
-rw-r--r-- | vim/after/indent/vim.vim | 17 | ||||
-rw-r--r-- | vim/autoload/shebang.vim | 7 | ||||
-rw-r--r-- | vim/indent/perl.vim | 131 | ||||
-rw-r--r-- | vim/plugin/shebang_update.vim | 20 | ||||
-rw-r--r-- | vim/vimrc | 12 |
10 files changed, 185 insertions, 29 deletions
@@ -432,11 +432,6 @@ install-ncmcpp: install-mpd mkdir -p -- $(HOME)/.ncmpcpp cp -p -- ncmpcpp/config $(HOME)/.ncmpcpp -install-neovim: - make install-vim \ - VIMDIR=$${XDG_CONFIG_HOME:-"$$HOME"/.config}/nvim \ - VIMRC=$${XDF_CONFIG_HOME:="$$HOME"/.config}/init.vim - install-newsboat: mkdir -p -- $(HOME)/.config/newsboat $(HOME)/.local/share/newsboat cp -p -- newsboat/config $(HOME)/.config/newsboat @@ -497,7 +492,6 @@ install-urxvt: urxvt/ext/select find urxvt/ext -type f ! -name '*.pl' \ -exec cp -p -- {} $(HOME)/.urxvt/ext \; -# Change these at invocation to install for NeoVim; see README.md VIMDIR = $(HOME)/.vim VIMRC = $(HOME)/.vimrc @@ -511,6 +505,11 @@ install-vim: install-vim-after \ install-vim-indent \ install-vim-plugin +install-neovim: + make install-vim \ + VIMDIR=$${XDG_CONFIG_HOME:-"$$HOME"/.config}/nvim \ + VIMRC=$${XDF_CONFIG_HOME:="$$HOME"/.config}/init.vim + install-vim-after: install-vim-after-ftplugin \ install-vim-after-indent \ install-vim-after-plugin \ @@ -357,12 +357,8 @@ structures like functions, I like to implement it as a plugin in `~/.vim/doc`. They eventually get either discarded or spun off into their own repositories, -added to this repository as submodules instead, and uploaded to -[vim.org](https://www.vim.org/account/profile.php?user_id=73687). - -In the current version, there are no local plugins; everything's got its own -repository. All plugins and colorschemes are available as submodules in -`~/.vim/bundle`. They are installed into `~/.vim`. +added to this repository as submodules under `vim/bundle` instead, and uploaded +to [vim.org](https://www.vim.org/account/profile.php?user_id=73687). I still use two third-party plugins: Tim Pope's [repeat.vim](https://www.vim.org/scripts/script.php?script_id=2136) and @@ -1,2 +1,2 @@ -tejr dotfiles v1.22.0 -Wed Jul 4 12:05:13 UTC 2018 +tejr dotfiles v1.23.0 +Sat Jul 7 03:31:48 UTC 2018 diff --git a/git/gitconfig.mi5 b/git/gitconfig.mi5 index 3c97a77d..cee0a759 100644 --- a/git/gitconfig.mi5 +++ b/git/gitconfig.mi5 @@ -40,7 +40,7 @@ [merge] ff = false - log = true + log = 500 [pager] diff = cat diff --git a/vim/after/ftplugin/gitcommit.vim b/vim/after/ftplugin/gitcommit.vim index b7538c9c..d903e84e 100644 --- a/vim/after/ftplugin/gitcommit.vim +++ b/vim/after/ftplugin/gitcommit.vim @@ -14,6 +14,6 @@ let b:undo_ftplugin = b:undo_ftplugin " Make angle brackets behave like mail quotes setlocal comments+=n:> -setlocal formatoptions+=cor +setlocal formatoptions+=coqr let b:undo_ftplugin = b:undo_ftplugin \ . '|setlocal comments< formatoptions<' diff --git a/vim/after/indent/vim.vim b/vim/after/indent/vim.vim index 4f2f42f8..73b4e430 100644 --- a/vim/after/indent/vim.vim +++ b/vim/after/indent/vim.vim @@ -1,13 +1,14 @@ " Observe VimL conventions for two-space indents setlocal shiftwidth=2 -if exists('b:undo_indent') - let b:undo_indent = b:undo_indent . '|setlocal shiftwidth<' +if v:version > 703 || v:version == 703 && has('patch693') + setlocal softtabstop=-1 +else + setlocal softtabstop=2 endif -" If we need to set 'softtabstop' too, do it -if &softtabstop == -1 - setlocal softtabstop=2 - if exists('b:undo_indent') - let b:undo_indent = b:undo_indent . '|setlocal softtabstop<' - endif +" Commands to undo the above +if exists('b:undo_indent') + let b:undo_indent = b:undo_indent + \ . '|setlocal shiftwidth<' + \ . '|setlocal softtabstop<' endif diff --git a/vim/autoload/shebang.vim b/vim/autoload/shebang.vim new file mode 100644 index 00000000..f39fcf48 --- /dev/null +++ b/vim/autoload/shebang.vim @@ -0,0 +1,7 @@ +" If the first line was changed in the last insert operation, re-run script +" detection +function! shebang#Update() abort + if line("'[") == 1 + runtime scripts.vim + endif +endfunction diff --git a/vim/indent/perl.vim b/vim/indent/perl.vim new file mode 100644 index 00000000..cd01f30b --- /dev/null +++ b/vim/indent/perl.vim @@ -0,0 +1,131 @@ +" Custom Vim indent file for Perl5; the stock one didn't suit me. + +" Only load this indent file when no other was loaded. +if exists('b:did_indent') || &compatible + finish +endif +let b:did_indent = 1 + +" Indent settings +setlocal indentexpr=GetPerlIndent(v:lnum) +setlocal indentkeys=o,O,0=,0=},0=),0=],0=&&,0=\|\|,0=//,0=?,0=:,<Space> + +" Build patterns for heredoc indenting. Note that we detect indented heredocs +" with tildes like <<~EOF, but we don't treat them any differently. We don't +" strictly match the quotes either, in an effort to keep this fast. +let s:heredoc_word = '\I\i*' +let s:heredoc_open = '<<\~\?' + \ . '\(' + \ . '\\\?' . s:heredoc_word + \ . '\|' + \ . "['`\"]" . s:heredoc_word . "['`\"]" + \ . '\)' + \ . '.*;\s*$' + +" Define indent function +function! GetPerlIndent(lnum) + + " Get previous line, bail if none + let l:pn = prevnonblank(a:lnum - 1) + if !l:pn + return 0 + endif + + " Heredoc and POD flags + let l:heredoc = 0 + let l:pod = 0 + + " Start loop back through up to 512 lines of context + let l:lim = 512 + let l:hpn = a:lnum > l:lim ? a:lnum - l:lim : 0 + while l:hpn < a:lnum + let l:hpl = getline(l:hpn) + + " If we're not in a heredoc and not in a comment ... + if !l:heredoc && l:hpl !~# '^\s*#' + + " POD switching; match any section so that we can handle long PODs + if stridx(l:hpl, '=') == 0 + let l:pod = stridx(l:hpl, '=cut') != 0 + + " Heredoc switch on + else + let l:hpm = matchstr(l:hpl, s:heredoc_open) + if strlen(l:hpm) + let l:heredoc = 1 + let l:hpw = matchstr(l:hpm, s:heredoc_word) + let l:pn = l:hpn + endif + endif + + " If we are in a heredoc and we found the token word, finish it + elseif l:heredoc && l:hpl =~# '^'.l:hpw.'\>' + let l:heredoc = 0 + unlet l:hpw + endif + + " Bump the loop index + let l:hpn = l:hpn + 1 + + endwhile + + " If we ended up in a heredoc, never indent. + if l:heredoc + return 0 + endif + + " If we're in POD, just autoindent; simple and good enough. + if l:pod + return indent(a:lnum - 1) + endif + + " Get data of previous non-blank and non-heredoc line + let l:pl = getline(l:pn) + let l:pi = indent(l:pn) + + " Get value of 'shiftwidth' + let l:sw = &shiftwidth ? &shiftwidth : &tabstop + + " Get current line properties + let l:cl = getline(a:lnum) + + " Base indent with any fractional indent removed + let l:pb = l:pi - l:pi % l:sw + + " Just follow comment indent + if l:pl =~# '^\s*#' + return l:pi + + " Move out with closing brace + elseif l:cl =~# '^\s*[])}]' + return l:pb >= l:sw ? l:pb - l:sw : 0 + + " Move in after opening brace + elseif l:pl =~# '[{([]\s*$' + return l:pb + l:sw + + " Never continue after a semicolon or a double-underscore + elseif l:pl =~# '\;\s*$' + \ || l:pl =~# '__DATA__' + \ || l:pl =~# '__END__' + return l:pb + + " Line continuation hints + elseif l:pl =~# '[^])},]\s*$' + \ || l:cl =~# '^\s*\(and\|or\|xor\)' + \ || l:cl =~# '^\s*\(&&\|||\|//\)' + \ || l:cl =~# '^\s*[?:=]' + return l:pb + l:sw / 2 + + " Default to indent of previous line + else + return l:pb + + endif + +endfunction + +" How to undo all of that +let b:undo_indent = 'setlocal indentexpr<' + \ . '|setlocal indentkeys<' + \ . '|delfunction GetPerlIndent' diff --git a/vim/plugin/shebang_update.vim b/vim/plugin/shebang_update.vim new file mode 100644 index 00000000..1dbcaf67 --- /dev/null +++ b/vim/plugin/shebang_update.vim @@ -0,0 +1,20 @@ +" +" shabeng_update.vim: If the first line of a file was changed, re-run +" scripts.vim to do shebang detection to update the filetype. +" +" Author: Tom Ryder <tom@sanctum.geek.nz> +" License: Same as Vim itself +" +if exists('g:loaded_shebang_update') || &compatible + finish +endif +if v:version < 700 + finish +endif +let g:loaded_shebang_update = 1 + +" Call the update function whenever leaving insert mode +augroup shebang_update + autocmd! + autocmd InsertLeave * call shebang#Update() +augroup END @@ -14,7 +14,7 @@ if has('autocmd') endif " Options dependent on the syntax feature -if has('syntax') && !has('g:syntax_on') +if has('syntax') && !exists('g:syntax_on') " Use syntax highlighting syntax enable @@ -34,7 +34,6 @@ endif " The all-important default indent settings; filetypes to tweak set autoindent " Use indent of previous line on new lines set expandtab " Use spaces instead of tabs -set shiftround " Round indenting to multiples of 'shiftwidth' set shiftwidth=4 " Indent with four spaces " Spaces to insert on Tab key insert @@ -105,9 +104,6 @@ set nomodeline " Treat numbers with a leading zero as decimal, not octal set nrformats-=octal -" Always tell me the number of lines changed by a command -set report=0 - " Abbreviate some more regularly displayed messages set shortmess+=I " Don't show startup splash screen set shortmess+=m " [Modified] -> [+] @@ -239,6 +235,8 @@ nnoremap <Bslash>h :<C-U>set hlsearch! hlsearch?<CR> nnoremap <Bslash>i :<C-U>set incsearch! incsearch?<CR> " \j jumps to buffers (jetpack) nnoremap <Bslash>j :<C-U>buffers<CR>:buffer<Space> +" \k shows my marks +nnoremap <Bslash>k :<C-U>marks<CR> " \l toggles showing tab, end-of-line, and trailing whitespace nnoremap <Bslash>l :<C-U>set list! list?<CR> " \m shows all maps @@ -253,6 +251,8 @@ nmap <Bslash>o <Plug>PasteOpenBelow nmap <Bslash>O <Plug>PasteOpenAbove " \p toggles paste mode nnoremap <Bslash>p :<C-U>set paste! paste?<CR> +" \q formats the current paragraph +nnoremap <Bslash>q gqap " \r reloads .vimrc nnoremap <Bslash>r :<C-U>source $MYVIMRC<CR> " \s toggles spell checking @@ -269,6 +269,8 @@ nnoremap <Bslash>V :<C-U>let b: t: w:<CR> nnoremap <Bslash>w :<C-U>set wrap! wrap?<CR> " \x strips trailing whitespace via a custom plugin nmap <Bslash>x <Plug>StripTrailingWhitespace +" \y shows all registers +nnoremap <Bslash>y :<C-U>registers<CR> " \z sets NZ English spelling (compare \u) nnoremap <Bslash>z :<C-U>setlocal spelllang=en_nz<CR> |