aboutsummaryrefslogtreecommitdiff
path: root/vim/plugin
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2017-11-12 14:42:59 +1300
committerTom Ryder <tom@sanctum.geek.nz>2017-11-12 20:27:54 +1300
commit6e9eb56edb2c5ec48e6daac0b46219c8a2bd24c0 (patch)
treebe1d47def25a5cfbfd4e10905c05a2ec26803f33 /vim/plugin
parentd5e2cbaebbd16fb17c4bcbad5b458514bd703db1 (diff)
downloaddotfiles-6e9eb56edb2c5ec48e6daac0b46219c8a2bd24c0.tar.gz
dotfiles-6e9eb56edb2c5ec48e6daac0b46219c8a2bd24c0.zip
Move lots of local Vim config into vim/after
This is a relatively drastic change that should have been done progressively, but I got carried away in ripping everything out and putting it back in again. Reading the documentation for writing a Vim script (:help usr_41.txt), I am convinced that all of the content that was in the vim/ftplugin directory and some of the vim/indent directory actually belonged in vim/after/ftplugin and vim/after/indent respectively. This is because the section on filetypes makes the distinction between replacing the core filetype or indent plugins and merely adding to or editing them after the fact; from :help ftplugin: > If you do want to use the default plugin, but overrule one of the > settings, you can write the different setting in a script: > > setlocal textwidth=70 > > Now write this in the "after" directory, so that it gets sourced after > the distributed "vim.vim" ftplugin after-directory. For Unix this > would be "~/.vim/after/ftplugin/vim.vim". Note that the default > plugin will have set "b:did_ftplugin", but it is ignored here. Therefore, I have deleted the user_indent.vim and user_ftplugin.vim plugins and their documentation that I wrote, and their ftplugin.vim and indent.vim shims in ~/.vim, in an attempt to make these plugins elegantly undo-ready, and instead embraced the way the documentation and $VIMRUNTIME structure seems to suggest. I broke the ftplugin files up by function and put them under subdirectories of vim/after named by filetype, as the 'runtimepath' layout permits. In doing so, I also carefully applied the documentation's advice: * Short-circuiting repeated loads * Checking for existing mappings using the <Plug> prefix approach * Avoiding repeated function declarations overwriting each other * Guarding against 'cpotions' mangling things (by simply short-circuiting if 'compatible' is set). I've made the b:undo_ftplugin and b:undo_indent commands less forgiving, and append commands to it inline with the initial establishment of the setup they're reversing, including checking that the b:undo_* variable actually exists in the first place. For the indentation scripts, however, three of the four files originally in vim/indent actually do belong there: 1. csv.vim, because it doesn't have an indent file in the core. 2. tsv.vim, because it doesn't have an indent file in the core. 3. php.vim, because it does what ftplugins are allowed to do in preventing the core indent rules from running at all. The indent/vim.vim rules, however, have been moved to after/indent/vim.vim, because the tweaks it makes for two-space indentation are designed to supplement the core indent rules, not replace them. Finally, I've adjusted Makefile targets accordingly for the above, given the vim/ftplugin directory is now empty and there are three new directories in vim/after to install. We wrap these under a single `install-vim-after` parent target for convenience. The `install-vim-after-ftplugin` target accommodates the additional level of filetype directories beneath it.
Diffstat (limited to 'vim/plugin')
-rw-r--r--vim/plugin/auto_backupdir.vim3
-rw-r--r--vim/plugin/auto_swapdir.vim3
-rw-r--r--vim/plugin/auto_undodir.vim4
-rw-r--r--vim/plugin/big_file_options.vim4
-rw-r--r--vim/plugin/command_typos.vim4
-rw-r--r--vim/plugin/copy_linebreak.vim4
-rw-r--r--vim/plugin/fixed_join.vim3
-rw-r--r--vim/plugin/mail_mutt.vim4
-rw-r--r--vim/plugin/strip_trailing_whitespace.vim3
-rw-r--r--vim/plugin/toggle_option_flag.vim4
-rw-r--r--vim/plugin/user_ftplugin.vim27
-rw-r--r--vim/plugin/user_indent.vim27
12 files changed, 10 insertions, 80 deletions
diff --git a/vim/plugin/auto_backupdir.vim b/vim/plugin/auto_backupdir.vim
index f15e7ce6..d15c3150 100644
--- a/vim/plugin/auto_backupdir.vim
+++ b/vim/plugin/auto_backupdir.vim
@@ -5,8 +5,7 @@
" Author: Tom Ryder <tom@sanctum.geek.nz>
" License: Same as Vim itself
"
-if exists('g:loaded_auto_backupdir')
- \ || &compatible
+if exists('g:loaded_auto_backupdir') || &compatible
finish
endif
let g:loaded_auto_backupdir = 1
diff --git a/vim/plugin/auto_swapdir.vim b/vim/plugin/auto_swapdir.vim
index ea41a0f0..b5f9ce3a 100644
--- a/vim/plugin/auto_swapdir.vim
+++ b/vim/plugin/auto_swapdir.vim
@@ -5,8 +5,7 @@
" Author: Tom Ryder <tom@sanctum.geek.nz>
" License: Same as Vim itself
"
-if exists('g:loaded_auto_swapdir')
- \ || &compatible
+if exists('g:loaded_auto_swapdir') || &compatible
finish
endif
let g:loaded_auto_swapdir = 1
diff --git a/vim/plugin/auto_undodir.vim b/vim/plugin/auto_undodir.vim
index 1d20ba95..9a686fb1 100644
--- a/vim/plugin/auto_undodir.vim
+++ b/vim/plugin/auto_undodir.vim
@@ -5,9 +5,7 @@
" Author: Tom Ryder <tom@sanctum.geek.nz>
" License: Same as Vim itself
"
-if exists('g:loaded_auto_undodir')
- \ || !has('persistent_undo')
- \ || &compatible
+if exists('g:loaded_auto_undodir') || &compatible || !has('persistent_undo')
finish
endif
let g:loaded_auto_undodir = 1
diff --git a/vim/plugin/big_file_options.vim b/vim/plugin/big_file_options.vim
index cdced67d..cbbacc42 100644
--- a/vim/plugin/big_file_options.vim
+++ b/vim/plugin/big_file_options.vim
@@ -5,9 +5,7 @@
" Author: Tom Ryder <tom@sanctum.geek.nz>
" License: Same as Vim itself
"
-if exists('g:loaded_big_file_options')
- \ || !has('autocmd')
- \ || &compatible
+if exists('g:loaded_big_file_options') || &compatible || !has('autocmd')
finish
endif
let g:loaded_big_file_options = 1
diff --git a/vim/plugin/command_typos.vim b/vim/plugin/command_typos.vim
index 60245a30..afc04ed3 100644
--- a/vim/plugin/command_typos.vim
+++ b/vim/plugin/command_typos.vim
@@ -7,9 +7,7 @@
" Author: Tom Ryder <tom@sanctum.geek.nz>
" License: Same as Vim itself
"
-if exists('g:loaded_command_typos')
- \ || !has('user_commands')
- \ || &compatible
+if exists('g:loaded_command_typos') || &compatible || !has('user_commands')
finish
endif
let g:loaded_command_typos = 1
diff --git a/vim/plugin/copy_linebreak.vim b/vim/plugin/copy_linebreak.vim
index 732acfea..158282bf 100644
--- a/vim/plugin/copy_linebreak.vim
+++ b/vim/plugin/copy_linebreak.vim
@@ -6,9 +6,7 @@
" Author: Tom Ryder <tom@sanctum.geek.nz>
" License: Same as Vim itself
"
-if exists('g:loaded_copy_linebreak')
- \ || !has('linebreak')
- \ || &compatible
+if exists('g:loaded_copy_linebreak') || &compatible || !has('linebreak')
finish
endif
let g:loaded_copy_linebreak = 1
diff --git a/vim/plugin/fixed_join.vim b/vim/plugin/fixed_join.vim
index 2c9e1d92..83977c2f 100644
--- a/vim/plugin/fixed_join.vim
+++ b/vim/plugin/fixed_join.vim
@@ -5,8 +5,7 @@
" Author: Tom Ryder <tom@sanctum.geek.nz>
" License: Same as Vim itself
"
-if exists('g:loaded_fixed_join')
- \ || &compatible
+if exists('g:loaded_fixed_join') || &compatible
finish
endif
let g:loaded_fixed_join = 1
diff --git a/vim/plugin/mail_mutt.vim b/vim/plugin/mail_mutt.vim
index 9bb4abd4..24ce01dd 100644
--- a/vim/plugin/mail_mutt.vim
+++ b/vim/plugin/mail_mutt.vim
@@ -5,9 +5,7 @@
" Author: Tom Ryder <tom@sanctum.geek.nz>
" License: Same as Vim itself
"
-if exists('g:loaded_mail_mutt')
- \ || !has('user_commands')
- \ || &compatible
+if exists('g:loaded_mail_mutt') || &compatible || !has('user_commands')
finish
endif
let g:loaded_mail_mutt = 1
diff --git a/vim/plugin/strip_trailing_whitespace.vim b/vim/plugin/strip_trailing_whitespace.vim
index 1264a11f..1b6d2f38 100644
--- a/vim/plugin/strip_trailing_whitespace.vim
+++ b/vim/plugin/strip_trailing_whitespace.vim
@@ -5,8 +5,7 @@
" Author: Tom Ryder <tom@sanctum.geek.nz>
" License: Same as Vim itself
"
-if exists('g:loaded_strip_trailing_whitespace')
- \ || &compatible
+if exists('g:loaded_strip_trailing_whitespace') || &compatible
finish
endif
let g:loaded_strip_trailing_whitespace = 1
diff --git a/vim/plugin/toggle_option_flag.vim b/vim/plugin/toggle_option_flag.vim
index dcc26cce..5c848368 100644
--- a/vim/plugin/toggle_option_flag.vim
+++ b/vim/plugin/toggle_option_flag.vim
@@ -5,9 +5,7 @@
" Author: Tom Ryder <tom@sanctum.geek.nz>
" License: Same as Vim itself
"
-if exists('g:loaded_toggle_option_flag')
- \ || !has('user_commands')
- \ || &compatible
+if exists('g:loaded_toggle_option_flag') || &compatible || !has('user_commands')
finish
endif
let g:loaded_toggle_option_flag = 1
diff --git a/vim/plugin/user_ftplugin.vim b/vim/plugin/user_ftplugin.vim
deleted file mode 100644
index d19348ae..00000000
--- a/vim/plugin/user_ftplugin.vim
+++ /dev/null
@@ -1,27 +0,0 @@
-"
-" user_ftplugin.vim: When switching filetypes, look for a b:undo_user_ftplugin
-" variable and use it in much the same way the core's ftplugin.vim does
-" b:undo_ftplugin in Vim >= 7.0. This allows you to undo your own ftplugin
-" files the same way you can the core ones.
-"
-" Author: Tom Ryder <tom@sanctum.geek.nz>
-" License: Same as Vim itself
-"
-if exists('g:loaded_user_ftplugin')
- \ || !has('autocmd')
- \ || &compatible
- finish
-endif
-let g:loaded_user_ftplugin = 1
-
-function! s:LoadUserFtplugin()
- if exists('b:undo_user_ftplugin')
- execute b:undo_user_ftplugin
- unlet b:undo_user_ftplugin
- endif
-endfunction
-
-augroup user_ftplugin
- autocmd!
- autocmd FileType * call s:LoadUserFtplugin()
-augroup END
diff --git a/vim/plugin/user_indent.vim b/vim/plugin/user_indent.vim
deleted file mode 100644
index 84b966d6..00000000
--- a/vim/plugin/user_indent.vim
+++ /dev/null
@@ -1,27 +0,0 @@
-"
-" user_indent.vim: When switching filetypes, look for a b:undo_user_indent
-" variable and use it in much the same way the core's indent.vim does
-" b:undo_indent in Vim >= 7.0. This allows you to undo your own indent files
-" the same way you can the core ones.
-"
-" Author: Tom Ryder <tom@sanctum.geek.nz>
-" License: Same as Vim itself
-"
-if exists('g:loaded_user_indent')
- \ || !has('autocmd')
- \ || &compatible
- finish
-endif
-let g:loaded_user_indent = 1
-
-function! s:LoadUserIndent()
- if exists('b:undo_user_indent')
- execute b:undo_user_indent
- unlet b:undo_user_indent
- endif
-endfunction
-
-augroup user_indent
- autocmd!
- autocmd FileType * call s:LoadUserIndent()
-augroup END