aboutsummaryrefslogtreecommitdiff
path: root/vim/after/ftplugin
diff options
context:
space:
mode:
Diffstat (limited to 'vim/after/ftplugin')
-rw-r--r--vim/after/ftplugin/gitcommit.vim16
-rw-r--r--vim/after/ftplugin/html.vim2
-rw-r--r--vim/after/ftplugin/mail.vim16
-rw-r--r--vim/after/ftplugin/python.vim35
-rw-r--r--vim/after/ftplugin/vim.vim6
5 files changed, 61 insertions, 14 deletions
diff --git a/vim/after/ftplugin/gitcommit.vim b/vim/after/ftplugin/gitcommit.vim
index 4a1c3814..093dc5f5 100644
--- a/vim/after/ftplugin/gitcommit.vim
+++ b/vim/after/ftplugin/gitcommit.vim
@@ -4,13 +4,15 @@ setlocal formatoptions+=coqr
let b:undo_ftplugin .= '|setlocal comments< formatoptions<'
" Choose the color column depending on non-comment line count
-augroup gitcommit_cursorcolumn
- autocmd CursorMoved,CursorMovedI <buffer>
- \ let &l:colorcolumn = gitcommit#CursorColumn()
-augroup END
-let b:undo_ftplugin .= '|execute ''autocmd! gitcommit_cursorcolumn'''
- \ . '|augroup! gitcommit_cursorcolumn'
- \ . '|setlocal colorcolumn<'
+if exists('&colorcolumn')
+ augroup gitcommit_cursorcolumn
+ autocmd CursorMoved,CursorMovedI <buffer>
+ \ let &l:colorcolumn = gitcommit#CursorColumn()
+ augroup END
+ let b:undo_ftplugin .= '|execute ''autocmd! gitcommit_cursorcolumn'''
+ \ . '|augroup! gitcommit_cursorcolumn'
+ \ . '|setlocal colorcolumn<'
+endif
" Stop here if the user doesn't want ftplugin mappings
if exists('no_plugin_maps') || exists('no_gitcommit_maps')
diff --git a/vim/after/ftplugin/html.vim b/vim/after/ftplugin/html.vim
index 7e2ba439..21a84a42 100644
--- a/vim/after/ftplugin/html.vim
+++ b/vim/after/ftplugin/html.vim
@@ -4,7 +4,7 @@ if &filetype !=# 'html'
finish
endif
-" Spellcheck documents we're actually editing (not just viewing)
+" Check the spelling of documents we're actually editing (not just viewing)
if &modifiable && !&readonly
setlocal spell
let b:undo_ftplugin .= '|setlocal spell<'
diff --git a/vim/after/ftplugin/mail.vim b/vim/after/ftplugin/mail.vim
index 738f17ec..4c07bac3 100644
--- a/vim/after/ftplugin/mail.vim
+++ b/vim/after/ftplugin/mail.vim
@@ -1,3 +1,13 @@
+" Restore global value for no_mail_maps that we set in
+" ~/.vim/ftplugin/mail.vim to work around the bad maps set in
+" $VIMRUNTIME/ftplugin/mail.vim
+"
+if exists('b:no_mail_maps')
+ let no_mail_maps = b:no_mail_maps
+elseif exists('no_mail_maps')
+ unlet no_mail_maps
+endif
+
" Don't append spaces after quote chars, for strict compliance with
" format=flowed
let b:quote_space = 0
@@ -8,7 +18,7 @@ command -bar -buffer SuggestStart
let b:undo_ftplugin .= '|delcommand SuggestStart'
SuggestStart
-" Normalise quoting
+" Normalize quoting
command -bar -buffer -range=% StrictQuote
\ call mail#StrictQuote(<q-line1>, <q-line2>)
let b:undo_ftplugin .= '|delcommand StrictQuote'
@@ -66,9 +76,9 @@ let b:undo_ftplugin .= '|nunmap <buffer> <LocalLeader>Q'
\ . '|xunmap <buffer> <LocalLeader>Q'
" Mappings for enforcing strict quoting
-nnoremap <LocalLeader>s
+nnoremap <buffer> <LocalLeader>s
\ :StrictQuote<CR>
-xnoremap <LocalLeader>s
+xnoremap <buffer> <LocalLeader>s
\ :StrictQuote<CR>
let b:undo_ftplugin .= '|nunmap <buffer> <LocalLeader>s'
\ . '|xunmap <buffer> <LocalLeader>s'
diff --git a/vim/after/ftplugin/python.vim b/vim/after/ftplugin/python.vim
new file mode 100644
index 00000000..2ca1ae89
--- /dev/null
+++ b/vim/after/ftplugin/python.vim
@@ -0,0 +1,35 @@
+" The Python runtime files didn't define b:undo_ftplugin until Vim v8.1.1048;
+" if it's not set yet, set it here (to something innoccuous) so that the
+" appending :let commands in the rest of this file don't break.
+"
+if !exists('b:undo_ftplugin')
+ let b:undo_ftplugin = 'setlocal tabstop<'
+endif
+
+" Use pyflakes for syntax checking and autopep8 for tidying
+compiler pyflakes
+if executable('autopep8')
+ setlocal equalprg=autopep8\ -aaa\ --\ -
+ let b:undo_ftplugin .= '|setlocal equalprg<'
+endif
+
+" Stop here if the user doesn't want ftplugin mappings
+if exists('no_plugin_maps') || exists('no_python_maps')
+ finish
+endif
+
+" Mappings to choose compiler
+nnoremap <buffer> <LocalLeader>c
+ \ :<C-U>compiler pyflakes<CR>
+nnoremap <buffer> <LocalLeader>l
+ \ :<C-U>compiler pylint<CR>
+let b:undo_ftplugin .= '|nunmap <buffer> <LocalLeader>c'
+ \ . '|nunmap <buffer> <LocalLeader>l'
+
+" Mappings to choose 'equalprg'
+nnoremap <buffer> <LocalLeader>t
+ \ :<C-U>setlocal equalprg=autopep8\ -aaa\ --\ -<CR>
+nnoremap <buffer> <LocalLeader>i
+ \ :<C-U>setlocal equalprg<<CR>
+let b:undo_ftplugin .= '|nunmap <buffer> <LocalLeader>t'
+ \ . '|nunmap <buffer> <LocalLeader>i'
diff --git a/vim/after/ftplugin/vim.vim b/vim/after/ftplugin/vim.vim
index 01f971b9..112523da 100644
--- a/vim/after/ftplugin/vim.vim
+++ b/vim/after/ftplugin/vim.vim
@@ -26,9 +26,9 @@ 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
+" Adjust the match words for the matchit.vim plugin; the default filetype
+" plugin matches e.g. an opening "function" with the first "return" within,
+" which I don't like
if exists('loaded_matchit')
let b:match_words = '\<fu\%[nction]\>:\<endf\%[unction]\>,'
\ . '\<\(wh\%[ile]\|for\)\>:\<end\(w\%[hile]\|fo\%[r]\)\>,'