diff options
-rw-r--r-- | VERSION | 4 | ||||
-rw-r--r-- | bash/bash_completion.d/_text_filenames.bash | 3 | ||||
-rw-r--r-- | man/man7/dotfiles.7df | 4 | ||||
-rw-r--r-- | vim/after/ftplugin/html.vim | 5 | ||||
-rw-r--r-- | vim/after/ftplugin/mail.vim | 32 | ||||
-rw-r--r-- | vim/after/ftplugin/markdown.vim | 39 | ||||
-rw-r--r-- | vim/after/ftplugin/sh.vim | 9 | ||||
-rw-r--r-- | vim/after/ftplugin/vim.vim | 6 | ||||
-rw-r--r-- | vim/ftplugin/markdown.vim | 89 | ||||
-rw-r--r-- | vim/vimrc | 37 |
10 files changed, 148 insertions, 80 deletions
@@ -1,2 +1,2 @@ -tejr dotfiles v4.38.0 -Mon May 20 12:44:50 UTC 2019 +tejr dotfiles v4.39.0 +Wed May 22 23:24:50 UTC 2019 diff --git a/bash/bash_completion.d/_text_filenames.bash b/bash/bash_completion.d/_text_filenames.bash index 0f7f6dd8..d379b8f9 100644 --- a/bash/bash_completion.d/_text_filenames.bash +++ b/bash/bash_completion.d/_text_filenames.bash @@ -140,6 +140,9 @@ _text_filenames() { (*.swf) ;; (*.webm) ;; + # Emacs + (\#*\#) ;; + # Vim (*~) ;; (*.swp) ;; diff --git a/man/man7/dotfiles.7df b/man/man7/dotfiles.7df index a74cc82d..fcdb9416 100644 --- a/man/man7/dotfiles.7df +++ b/man/man7/dotfiles.7df @@ -44,9 +44,7 @@ $\ env\ \-i\ HOME="$tmpdir"\ TERM="$TERM"\ "$SHELL"\ \-l .fi .PP The default \f[C]install\f[] target will install these targets and all -their dependencies. -Note that you don't actually have to have any of this except \f[C]sh\f[] -installed. +their dependencies: .IP \[bu] 2 \f[C]install\-bin\f[] .IP \[bu] 2 diff --git a/vim/after/ftplugin/html.vim b/vim/after/ftplugin/html.vim index 8b390528..93845a80 100644 --- a/vim/after/ftplugin/html.vim +++ b/vim/after/ftplugin/html.vim @@ -1,8 +1,3 @@ -" Don't load if the buffer is not actually HTML (e.g. Markdown) -if &filetype !=# 'html' - finish -endif - " Spellcheck documents we're actually editing (not just viewing) if &modifiable && !&readonly setlocal spell diff --git a/vim/after/ftplugin/mail.vim b/vim/after/ftplugin/mail.vim index 457135ef..15277f7b 100644 --- a/vim/after/ftplugin/mail.vim +++ b/vim/after/ftplugin/mail.vim @@ -6,11 +6,11 @@ if line('.') == 1 && col('.') == 1 " no quote, which is fine call search('\m^>', 'c') - " Check this line to see if it's a generic hello-name greeting that we can - " just strip out; delete any following lines too, if they're blank - if getline('.') =~? '^>\s*\%(<hello\|hey\+\|hi\)\s\+\S\+\s*$' + " Check this line to see if it's a generic hello or hello-name greeting that + " we can just strip out; delete any following lines too, if they're blank + if getline('.') =~? '^>\s*\%(<hello\|hey\+\|hi\)\(\s\+\S\+\)\=[,;]*\s*$' delete - while getline('.') =~# '^>$' + while getline('.') =~# '^>\s*$' delete endwhile endif @@ -20,15 +20,37 @@ if line('.') == 1 && col('.') == 1 endif +" Normalise quoting +for lnum in range(1, line('$')) + + " Get current line + let line = getline(lnum) + + " Get the leading quote string, if any; stop if there isn't one + let quote = matchstr(line, '^[> \t]\+') + if strlen(quote) == 0 + break + endif + + " Normalise the quote with no intermediate and one trailing space + let quote = substitute(quote, '[^>]', '', 'g').' ' + + " Re-set the line + let line = substitute(line, '^[> \t]\+', quote, '') + call setline(lnum, line) + +endfor + " Add a space to the end of wrapped lines for format-flowed mail setlocal formatoptions+=w let b:undo_ftplugin .= '|setlocal formatoptions<' " Define what constitutes a 'blank line' for the squeeze_repeat_blanks.vim -" plugin, if loaded, to include leading quotes and spaces +" plugin, if loaded, to include leading quotes and spaces, and then do it if exists('loaded_squeeze_repeat_blanks') let b:squeeze_repeat_blanks_blank = '^[ >]*$' let b:undo_ftplugin .= '|unlet b:squeeze_repeat_blanks_blank' + silent SqueezeRepeatBlanks endif " Stop here if the user doesn't want ftplugin mappings diff --git a/vim/after/ftplugin/markdown.vim b/vim/after/ftplugin/markdown.vim deleted file mode 100644 index 6634924e..00000000 --- a/vim/after/ftplugin/markdown.vim +++ /dev/null @@ -1,39 +0,0 @@ -" Spellcheck documents we're actually editing (not just viewing) -if &modifiable && !&readonly - setlocal spell - let b:undo_ftplugin .= '|setlocal spell<' -endif - -" Tolerate leading lowercase letters in README.md files, for things like -" headings being filenames -if expand('%:t') ==# 'README.md' - setlocal spellcapcheck= - let b:undo_ftplugin .= '|setlocal spellcapcheck<' -endif - -" Stop here if the user doesn't want ftplugin mappings -if exists('no_plugin_maps') || exists('no_markdown_maps') - finish -endif - -" Quote operator -nnoremap <buffer> <expr> <LocalLeader>q - \ quote#Quote() -xnoremap <buffer> <expr> <LocalLeader>q - \ quote#Quote() -let b:undo_ftplugin .= '|nunmap <buffer> <LocalLeader>q' - \ . '|xunmap <buffer> <LocalLeader>q' - -" Quote operator with reformatting -nnoremap <buffer> <expr> <LocalLeader>Q - \ quote#QuoteReformat() -xnoremap <buffer> <expr> <LocalLeader>Q - \ quote#QuoteReformat() -let b:undo_ftplugin .= '|nunmap <buffer> <LocalLeader>Q' - \ . '|xunmap <buffer> <LocalLeader>Q' - -" Autoformat headings -nnoremap <buffer> <LocalLeader>- - \ :<C-U>call markdown#Heading('-')<CR> -nnoremap <buffer> <LocalLeader>= - \ :<C-U>call markdown#Heading('=')<CR> diff --git a/vim/after/ftplugin/sh.vim b/vim/after/ftplugin/sh.vim index 9afd5086..0327db78 100644 --- a/vim/after/ftplugin/sh.vim +++ b/vim/after/ftplugin/sh.vim @@ -44,12 +44,3 @@ nnoremap <buffer> <LocalLeader>l \ :<C-U>compiler shellcheck<CR> let b:undo_ftplugin .= '|nunmap <buffer> <LocalLeader>c' \ . '|nunmap <buffer> <LocalLeader>l' - -" Mapping to insert '\'' with Alt+'; not sure I'll keep this just yet -if has('gui_running') - inoremap <buffer> <M-'> '\'' - let b:undo_ftplugin .= '|iunmap <buffer> <M-''>' -else - inoremap <buffer> <Esc>' '\'' - let b:undo_ftplugin .= '|iunmap <buffer> <Esc>''' -endif diff --git a/vim/after/ftplugin/vim.vim b/vim/after/ftplugin/vim.vim index 76608691..5b4d0f95 100644 --- a/vim/after/ftplugin/vim.vim +++ b/vim/after/ftplugin/vim.vim @@ -16,6 +16,12 @@ if &keywordprg !=# ':help' let b:undo_ftplugin .= '|setlocal keywordprg<' endif +" Keywords for including files +let &l:include = '\<source\>\|\<runtime!\=\>' + +" Search runtime paths for included scripts +let &l:path = &runtimepath . ',' . &path + " Adjust the match words for the matchit plugin; the default filetype plugin " matches e.g. an opening "function" with the first "return" within, which I " don't like diff --git a/vim/ftplugin/markdown.vim b/vim/ftplugin/markdown.vim new file mode 100644 index 00000000..d119e599 --- /dev/null +++ b/vim/ftplugin/markdown.vim @@ -0,0 +1,89 @@ +" Only do this when not yet done for this buffer +if exists('b:did_ftplugin') + finish +endif +let b:did_ftplugin = 1 + +" Specify format for comments (lists, quotes) +setlocal comments+=fb:* " Bulleted lists +setlocal comments+=fb:- " Dashed lists +setlocal comments+=fb:+ " Plussed lists (?) +setlocal comments+=n:> " Mail-style quotes +let &l:commentstring = '> %s' +let b:undo_ftplugin = 'setlocal comments< commentstring<' + +" Specify format options (Tim Pope) +setlocal formatoptions+=ln +let &l:formatlistpat = '^\s*\d\+\.\s\+\|^[-*+]\s\+\|^\[^\ze[^\]]\+\]:' +let b:undo_ftplugin .= '|setlocal formatoptions< formatlistpat<' + +" Let's try this heading-based fold method out (Tim Pope) +function! MarkdownFold() + let line = getline(v:lnum) + + " Regular headers + let depth = match(line, '\(^#\+\)\@<=\( .*$\)\@=') + if depth > 0 + return '>' . depth + endif + + " Setext style headings + if line =~# '^.\+$' + let nextline = getline(v:lnum + 1) + if nextline =~# '^=\+$' + return '>1' + elseif nextline =~# '^-\+$' + return '>2' + endif + endif + + return '=' +endfunction +setlocal foldexpr=MarkdownFold() +setlocal foldmethod=expr +let b:undo_ftplugin .= '|delfunction MarkdownFold|setlocal foldexpr< foldmethod<' + +" Spellcheck documents we're actually editing (not just viewing) +if &modifiable && !&readonly + setlocal spell + let b:undo_ftplugin .= '|setlocal spell<' +endif + +" Tolerate leading lowercase letters in README.md files, for things like +" headings being filenames +if expand('%:t') ==# 'README.md' + setlocal spellcapcheck= + let b:undo_ftplugin .= '|setlocal spellcapcheck<' +endif + +" Stop here if the user doesn't want ftplugin mappings +if exists('no_plugin_maps') || exists('no_markdown_maps') + finish +endif + +" Quote operator +nnoremap <buffer> <expr> <LocalLeader>q + \ quote#Quote() +xnoremap <buffer> <expr> <LocalLeader>q + \ quote#Quote() +let b:undo_ftplugin .= '|nunmap <buffer> <LocalLeader>q' + \ . '|xunmap <buffer> <LocalLeader>q' + +" Quote operator with reformatting +nnoremap <buffer> <expr> <LocalLeader>Q + \ quote#QuoteReformat() +xnoremap <buffer> <expr> <LocalLeader>Q + \ quote#QuoteReformat() +let b:undo_ftplugin .= '|nunmap <buffer> <LocalLeader>Q' + \ . '|xunmap <buffer> <LocalLeader>Q' + +" Autoformat headings +command! -buffer -nargs=1 MarkdownHeading + \ call markdown#Heading(<f-args>) +nnoremap <buffer> <LocalLeader>= + \ :<C-U>MarkdownHeading =<CR> +nnoremap <buffer> <LocalLeader>- + \ :<C-U>MarkdownHeading -<CR> +let b:undo_ftplugin .= '|delcommand MarkdownHeading' + \ . '|nunmap <buffer> <LocalLeader>=' + \ . '|nunmap <buffer> <LocalLeader>-' @@ -5,12 +5,12 @@ runtime system.vim " Set an environment variable for the user runtime directory -if !exists('$MYVIMRUNTIME') - let $MYVIMRUNTIME = expand( - \ has('win32') || has('win64') - \ ? '~/vimfiles' - \ : '~/.vim' - \ ) +if !exists('$MYVIM') + if has('win32') || has('win64') + let $MYVIM = expand('~/vimfiles') + else + let $MYVIM = expand('~/.vim') + endif endif " The all-important default indent settings; filetypes to tweak @@ -32,16 +32,16 @@ endif " encoded path in filename (trailing double slash) if supported (v8.1.251) set backup if has('patch-8.1.251') - set backupdir^=$MYVIMRUNTIME/cache/backup// + set backupdir^=$MYVIM/cache/backup// else - set backupdir^=$MYVIMRUNTIME/cache/backup + set backupdir^=$MYVIM/cache/backup endif " Add some *nix paths not to back up if has('unix') set backupskip^=/dev/shm/* " Shared memory RAM disk - set backupskip^=/usr/tmp/* " Hard-coded path for `sudo -e` - set backupskip^=/var/tmp/* " Hard-coded path for `sudo -e` + set backupskip^=/usr/tmp/* " Hard-coded path for `sudo -e` 1/2 + set backupskip^=/var/tmp/* " Hard-coded path for `sudo -e` 2/2 endif " Indent wrapped lines if supported (v7.4.338) @@ -65,7 +65,7 @@ set cpoptions+=J " Try to keep swap files in one system-appropriate directory, including full " encoded path in filename (trailing double slash) -set directory^=$MYVIMRUNTIME/cache/swap// +set directory^=$MYVIM/cache/swap// " Use UTF-8 if we can and $LANG doesn't tell us not to if has('multi_byte') @@ -142,8 +142,8 @@ set nomodeline " Treat numbers with a leading zero as decimal, not octal set nrformats-=octal -" Search whole directory tree, and not /usr/include -set path=** +" Don't search /usr/include by default +set path-=/usr/include " Disable command line display of file position " This is Vim's default, but not NeoVim's @@ -173,8 +173,8 @@ if &term =~# '^putty' set ttyfast endif -" No terminal mouse, even if we could; the manual says to set 't_RV', but that -" doesn't seem to work +" No terminal mouse, even if we could; the manual says to set 't_RV', but +" doing that doesn't seem to prevent 'ttyfast' from being set " Not in NeoVim if exists('+ttymouse') && &ttymouse !=# '' set ttymouse= @@ -184,7 +184,7 @@ endif " (v7.2.438), including full encoded path in filename (trailing double slash) if has('persistent_undo') set undofile - set undodir^=$MYVIMRUNTIME/cache/undo// + set undodir^=$MYVIM/cache/undo// endif " Let me move beyond buffer text in visual block mode @@ -194,7 +194,7 @@ set virtualedit+=block set visualbell t_vb= " Tab completion settings -set wildignore=*~ +set wildignore=*~,#*# \,*.7z \,*.a,*.adf,*.asc,*.au,*.aup,*.avi \,*.bin,*.bmp,*.bz2 @@ -448,6 +448,9 @@ nnoremap <Leader><Delete> :bdelete<CR> " \INS edits a new buffer nnoremap <Leader><Insert> :<C-U>enew<CR> +" \TAB toggles 'autoindent' +nnoremap <Leader><Tab> :<C-U>setlocal autoindent! autoindent?<CR> + " Execution mappings; each of these clobbers register z " \@ executes line in normal mode |