aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2017-11-07 11:43:02 +1300
committerTom Ryder <tom@sanctum.geek.nz>2017-11-07 11:49:39 +1300
commit09b83b6e25431fe9f3122916156f97fb0cfc2b5b (patch)
treecb5b2a92706eaa099c193095983cc0086efa6f29
parent64e0b1beef8ed360fba4f1cb405c371cc7213c00 (diff)
downloaddotfiles-09b83b6e25431fe9f3122916156f97fb0cfc2b5b.tar.gz
Use b:undo variables correctly
Setting or adding to b:undo_indent and b:undo_ftplugin variables, which I only learned about just now, allows me to avoid the _GLOBAL.vim hack and remove some files from both vim/indent/ and vim/ftplugin/. These variables aren't subjected to :execute automatically in anything older than Vim 7.0, but I don't think that's too much of a concern as the only real reason they're needed are for changing filetypes in the same buffer, which doesn't happen that often anyway.
-rw-r--r--vim/ftplugin/mail.vim7
-rw-r--r--vim/ftplugin/markdown.vim11
-rw-r--r--vim/ftplugin/sh.vim7
-rw-r--r--vim/ftplugin/text.vim11
-rw-r--r--vim/indent/_GLOBAL.vim12
-rw-r--r--vim/indent/c.vim2
-rw-r--r--vim/indent/csv.vim10
-rw-r--r--vim/indent/html.vim2
-rw-r--r--vim/indent/perl.vim2
-rw-r--r--vim/indent/php.vim3
-rw-r--r--vim/indent/sh.vim2
-rw-r--r--vim/indent/tsv.vim10
-rw-r--r--vim/indent/vim.vim10
13 files changed, 57 insertions, 32 deletions
diff --git a/vim/ftplugin/mail.vim b/vim/ftplugin/mail.vim
index 35432b96..236f25ff 100644
--- a/vim/ftplugin/mail.vim
+++ b/vim/ftplugin/mail.vim
@@ -1,2 +1,9 @@
" Use trailing whitespace to denote continued paragraph
setlocal formatoptions+=w
+
+" Undo
+if !exists('b:undo_ftplugin')
+ let b:undo_ftplugin = ''
+endif
+let b:undo_ftplugin = b:undo_ftplugin
+ \ . '|setlocal formatoptions<'
diff --git a/vim/ftplugin/markdown.vim b/vim/ftplugin/markdown.vim
new file mode 100644
index 00000000..15333202
--- /dev/null
+++ b/vim/ftplugin/markdown.vim
@@ -0,0 +1,11 @@
+" Spellcheck documents by default
+if has('syntax')
+ setlocal spell
+
+ " Undo
+ if !exists('b:undo_ftplugin')
+ let b:undo_ftplugin = ''
+ endif
+ let b:undo_ftplugin = b:undo_ftplugin
+ \ . '|setlocal spell<'
+endif
diff --git a/vim/ftplugin/sh.vim b/vim/ftplugin/sh.vim
index 8990f0fa..85251aa1 100644
--- a/vim/ftplugin/sh.vim
+++ b/vim/ftplugin/sh.vim
@@ -48,3 +48,10 @@ endif
nnoremap <buffer> <silent>
\ <LocalLeader>l
\ :<C-U>execute b:lint<CR>
+
+" Undo
+if !exists('b:undo_ftplugin')
+ let b:undo_ftplugin = ''
+endif
+let b:undo_ftplugin = b:undo_ftplugin
+ \ . '|setlocal keywordprg<'
diff --git a/vim/ftplugin/text.vim b/vim/ftplugin/text.vim
new file mode 100644
index 00000000..15333202
--- /dev/null
+++ b/vim/ftplugin/text.vim
@@ -0,0 +1,11 @@
+" Spellcheck documents by default
+if has('syntax')
+ setlocal spell
+
+ " Undo
+ if !exists('b:undo_ftplugin')
+ let b:undo_ftplugin = ''
+ endif
+ let b:undo_ftplugin = b:undo_ftplugin
+ \ . '|setlocal spell<'
+endif
diff --git a/vim/indent/_GLOBAL.vim b/vim/indent/_GLOBAL.vim
deleted file mode 100644
index d0bdea26..00000000
--- a/vim/indent/_GLOBAL.vim
+++ /dev/null
@@ -1,12 +0,0 @@
-" Source this file (probably with :runtime) to explicitly set local indent
-" settings for a buffer back to the global settings, in case it was changed
-" by a prior filetype (e.g. VimL).
-setlocal autoindent<
-setlocal expandtab<
-
-" Unfortunately, older versions of Vim (6.2 is known) accept neither the
-" `option<` nor `option=` syntax for resetting these numeric values, so we do
-" it this clunkier way.
-execute 'setlocal shiftwidth=' . &g:shiftwidth
-execute 'setlocal softtabstop=' . &g:softtabstop
-execute 'setlocal tabstop=' . &g:tabstop
diff --git a/vim/indent/c.vim b/vim/indent/c.vim
deleted file mode 100644
index fd1b26af..00000000
--- a/vim/indent/c.vim
+++ /dev/null
@@ -1,2 +0,0 @@
-" Restore local indent settings to the global values
-runtime indent/_GLOBAL.vim
diff --git a/vim/indent/csv.vim b/vim/indent/csv.vim
index 8f98d915..24ef53ce 100644
--- a/vim/indent/csv.vim
+++ b/vim/indent/csv.vim
@@ -1,6 +1,10 @@
-" Restore local indent settings to the global values
-runtime indent/_GLOBAL.vim
-
" Manual indenting and literal tabs for CSVs
setlocal noautoindent
setlocal noexpandtab
+
+" Undo
+if !exists('b:undo_indent')
+ let b:undo_indent = ''
+endif
+let b:undo_indent = b:undo_indent
+ \ . '|setlocal autoindent< expandtab<'
diff --git a/vim/indent/html.vim b/vim/indent/html.vim
deleted file mode 100644
index fd1b26af..00000000
--- a/vim/indent/html.vim
+++ /dev/null
@@ -1,2 +0,0 @@
-" Restore local indent settings to the global values
-runtime indent/_GLOBAL.vim
diff --git a/vim/indent/perl.vim b/vim/indent/perl.vim
deleted file mode 100644
index fd1b26af..00000000
--- a/vim/indent/perl.vim
+++ /dev/null
@@ -1,2 +0,0 @@
-" Restore local indent settings to the global values
-runtime indent/_GLOBAL.vim
diff --git a/vim/indent/php.vim b/vim/indent/php.vim
index 025bf3f1..d0fb1f8f 100644
--- a/vim/indent/php.vim
+++ b/vim/indent/php.vim
@@ -1,6 +1,3 @@
-" Restore local indent settings to the global values
-runtime indent/_GLOBAL.vim
-
" Lie to the php.vim indent file and tell it that it's already loaded itself,
" to stop it processing its ridiculous expression-based indenting that never
" seems to do what I want. Just plain autoindent is fine.
diff --git a/vim/indent/sh.vim b/vim/indent/sh.vim
deleted file mode 100644
index fd1b26af..00000000
--- a/vim/indent/sh.vim
+++ /dev/null
@@ -1,2 +0,0 @@
-" Restore local indent settings to the global values
-runtime indent/_GLOBAL.vim
diff --git a/vim/indent/tsv.vim b/vim/indent/tsv.vim
index a38e53e8..161fbbe3 100644
--- a/vim/indent/tsv.vim
+++ b/vim/indent/tsv.vim
@@ -1,6 +1,10 @@
-" Restore local indent settings to the global values
-runtime indent/_GLOBAL.vim
-
" Manual indenting and literal tabs for TSVs
setlocal noautoindent
setlocal noexpandtab
+
+" Undo
+if !exists('b:undo_indent')
+ let b:undo_indent = ''
+endif
+let b:undo_indent = b:undo_indent
+ \ . '|setlocal autoindent< expandtab<'
diff --git a/vim/indent/vim.vim b/vim/indent/vim.vim
index 3b038349..f9a8f211 100644
--- a/vim/indent/vim.vim
+++ b/vim/indent/vim.vim
@@ -1,7 +1,11 @@
-" Restore local indent settings to the global values
-runtime indent/_GLOBAL.vim
-
" Observe VimL conventions for two-space indents
setlocal shiftwidth=2
setlocal softtabstop=2
setlocal tabstop=2
+
+" Undo
+if !exists('b:undo_indent')
+ let b:undo_indent = ''
+endif
+let b:undo_indent = b:undo_indent
+ \ . '|setlocal shiftwidth< softtabstop< tabstop<'