aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2018-01-21 23:38:04 +1300
committerTom Ryder <tom@sanctum.geek.nz>2018-01-21 23:38:04 +1300
commit76082ffecb2dbc0f12f11acfb561de886f42a983 (patch)
tree3de06ca0cc53dacac71f9b0beb858bfe12c3f079
parentb26ecdb89212c7b2af3219a5b59a8f9f9a4a9245 (diff)
parentec775b023b0e83f413708d1bf294ab3abcaed666 (diff)
downloaddotfiles-76082ffecb2dbc0f12f11acfb561de886f42a983.tar.gz
dotfiles-76082ffecb2dbc0f12f11acfb561de886f42a983.zip
Merge branch 'feature/vimrc-review' into develop
* feature/vimrc-review: Suspend 'C' from 'cpoptions' for sh syn extensions Join short-circuit line in detect_background.vim Break some continued lines in Vim indent files Remove 'mac' from 'fileformats' Tweak 'cpoptions' C flag instead of 'nocompatible' Remove a baseless assertion I made in a config Make entire syntax config dependent on load state Activate syntax settings conditionally
-rw-r--r--vim/after/indent/vim.vim4
-rw-r--r--vim/after/syntax/sh.vim12
-rw-r--r--vim/autoload/detect_background.vim3
-rw-r--r--vim/config/files.vim4
-rw-r--r--vim/config/syntax.vim2
-rw-r--r--vim/config/whitespace.vim3
-rw-r--r--vim/indent/csv.vim3
-rw-r--r--vim/indent/tsv.vim3
-rw-r--r--vim/vimrc16
9 files changed, 33 insertions, 17 deletions
diff --git a/vim/after/indent/vim.vim b/vim/after/indent/vim.vim
index 0cb1d397..bfd92aeb 100644
--- a/vim/after/indent/vim.vim
+++ b/vim/after/indent/vim.vim
@@ -2,6 +2,6 @@
setlocal shiftwidth=2
setlocal softtabstop=2
if exists('b:undo_indent')
- let b:undo_indent = b:undo_indent
- \ . '|setlocal shiftwidth< softtabstop<'
+ let s:ui = '|setlocal shiftwidth< softtabstop<'
+ let b:undo_indent = b:undo_indent . s:ui
endif
diff --git a/vim/after/syntax/sh.vim b/vim/after/syntax/sh.vim
index 08dbd857..026e4ebd 100644
--- a/vim/after/syntax/sh.vim
+++ b/vim/after/syntax/sh.vim
@@ -1,3 +1,9 @@
+" Support line continuation for this file
+if &compatible
+ let s:cpoptions_save = &cpoptions
+ set cpoptions-=C
+endif
+
" If we know we have another shell type, clear away the others completely, now
" that core syntax/sh.vim is done prodding /bin/sh to determine the system
" shell type (which I don't care about).
@@ -210,3 +216,9 @@ if exists('b:is_bash')
\ variables
\ wait
endif
+
+" Restore 'cpoptions' setting if we touched it
+if exists('s:cpoptions_save')
+ let &cpoptions = s:cpoptions_save
+ unlet s:cpoptions_save
+endif
diff --git a/vim/autoload/detect_background.vim b/vim/autoload/detect_background.vim
index c010dc53..e4163a43 100644
--- a/vim/autoload/detect_background.vim
+++ b/vim/autoload/detect_background.vim
@@ -9,8 +9,7 @@
" Author: Tom Ryder <tom@sanctum.geek.nz>
" License: Same as Vim itself
"
-if exists('g:loaded_detect_background')
- \ || &compatible
+if exists('g:loaded_detect_background') || &compatible
finish
endif
let g:loaded_detect_background = 1
diff --git a/vim/config/files.vim b/vim/config/files.vim
index 7a23b4c5..61c3b6cb 100644
--- a/vim/config/files.vim
+++ b/vim/config/files.vim
@@ -18,10 +18,6 @@ if has('file_in_path')
set path=**
endif
-" Try Mac line-endings if UNIX or DOS don't make sense; this has never
-" happened to me but who knows, it might one day
-set fileformats+=mac
-
" If the Vim buffer for a file doesn't have any changes and Vim detects the
" file has been altered, quietly update it
set autoread
diff --git a/vim/config/syntax.vim b/vim/config/syntax.vim
index b493c0a9..00004e35 100644
--- a/vim/config/syntax.vim
+++ b/vim/config/syntax.vim
@@ -1,5 +1,5 @@
" Options dependent on the syntax feature
-if has('syntax')
+if has('syntax') && !has('g:syntax_on')
" Use syntax highlighting with 100 lines of context
silent! syntax enable
diff --git a/vim/config/whitespace.vim b/vim/config/whitespace.vim
index 981def81..0d985f15 100644
--- a/vim/config/whitespace.vim
+++ b/vim/config/whitespace.vim
@@ -1,5 +1,4 @@
-" Adopt the indent of the last line on new lines; interestingly, plugins that
-" do clever things with indenting will often assume this is set
+" Adopt the indent of the last line on new lines
set autoindent
" Use spaces instead of tabs
diff --git a/vim/indent/csv.vim b/vim/indent/csv.vim
index d092838f..938bc99d 100644
--- a/vim/indent/csv.vim
+++ b/vim/indent/csv.vim
@@ -7,5 +7,4 @@ let b:did_indent = 1
" Manual indenting and literal tabs for CSVs
setlocal noautoindent
setlocal noexpandtab
-let b:undo_indent
- \ = 'setlocal autoindent< expandtab<'
+let b:undo_indent = 'setlocal autoindent< expandtab<'
diff --git a/vim/indent/tsv.vim b/vim/indent/tsv.vim
index 56721a4c..6f70276d 100644
--- a/vim/indent/tsv.vim
+++ b/vim/indent/tsv.vim
@@ -7,5 +7,4 @@ let b:did_indent = 1
" Manual indenting and literal tabs for TSVs
setlocal noautoindent
setlocal noexpandtab
-let b:undo_indent
- \ = 'setlocal autoindent< expandtab<'
+let b:undo_indent = 'setlocal autoindent< expandtab<'
diff --git a/vim/vimrc b/vim/vimrc
index 5d195427..18363956 100644
--- a/vim/vimrc
+++ b/vim/vimrc
@@ -1,5 +1,10 @@
-" Don't try to be vi-compatible, even if invoked as ex or with -u specified
-set nocompatible
+" If we're in compatible mode, ensure that the 'C' option that disallows line
+" continuations is stripped out, as they're heavily used in this
+" configuration for readability; we'll put it back later
+if &compatible
+ let s:cpoptions_save = &cpoptions
+ set cpoptions-=C
+endif
" Use different keys for global and local leaders
if has('eval')
@@ -29,3 +34,10 @@ if v:version >= 701
silent! colorscheme sahara
endif
endif
+
+" If we're in compatible mode, put 'cpoptions' back the way we found it at the
+" start of this configuration, even though it's the current year
+if exists('s:cpoptions_save')
+ let &cpoptions = s:cpoptions_save
+ unlet s:cpoptions_save
+endif