From 0c91e0fb9ea53938bc552a13ed5201fb79887690 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 9 Jun 2019 01:54:26 +1200 Subject: Restore simple comma blocking --- vim/vimrc | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/vim/vimrc b/vim/vimrc index 1d436cd5..4108ede0 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -89,11 +89,8 @@ endif " " So, if there's a comma, we just raise an error and end the script. " -" Similarly, the 'thesaurus' option, and possibly others, won't accept a path -" with a pipe in its name, so don't allow that, either. -" -if $MYVIM =~# '[,|]' - echoerr 'Illegal characters in $MYVIM path' +if stridx($MYVIM, ',') != -1 + echoerr '$MYVIM contains a comma, refusing to proceed' finish endif -- cgit v1.2.3 From e1bdcc5e769bc2df8890f59b7f5e1e7d5b26b8bf Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 9 Jun 2019 02:12:55 +1200 Subject: Restrict allowed characters of $MYVIM even more --- vim/vimrc | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/vim/vimrc b/vim/vimrc index 4108ede0..53033d90 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -78,19 +78,26 @@ if !exists('$MYVIM') && &runtimepath !=# '' let $MYVIM = split(&runtimepath, s:option_split_pattern)[0] endif -" If the path specified in the MYVIM environment variable contains a comma, -" its use in comma-separated option values will confuse Vim into thinking more -" than one directory is being specified, per normal :set semantics. +" The MYVIM user runtime directory can't be blank. +" +" The 'dictionary' and 'thesaurus' options have a blacklist of characters that +" they don't allow. None of them are a particularly good idea for use in +" a filename, so don't allow their use in this vimrc at all, even though +" options like 'backupdir' will accept them. +" +" The comma character isn't actually part of that blacklist, but it has its +" own problems; if the path specified in the MYVIM environment variable +" contains a comma, its use in comma-separated option values will confuse Vim +" into thinking more than one directory is being specified, per normal :set +" semantics. " " It's possible to work around this with some careful escaping, either at :set " time with an :execute abstraction or with a separate environment variable " for that particular context, but it's not really worth the extra complexity " for such a niche situation. " -" So, if there's a comma, we just raise an error and end the script. -" -if stridx($MYVIM, ',') != -1 - echoerr '$MYVIM contains a comma, refusing to proceed' +if $MYVIM != '' || $MYVIM =~# '[*?[|;&<>\r\n,]' + echoerr 'Illegal user runtime path, halting user init' finish endif -- cgit v1.2.3 From b3d832134eeba6b7e5befb2c49c784a38e9a2d77 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 9 Jun 2019 02:13:18 +1200 Subject: Explain the 'backupskip' problem a bit more --- vim/vimrc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/vim/vimrc b/vim/vimrc index 53033d90..47326b8d 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -303,8 +303,9 @@ call s:Mkdir(split(&backupdir, s:option_split_pattern)[0]) if has('unix') " Vim doesn't seem to check patterns added to 'backupskip' for uniqueness, - " so adding them repeatedly if this file is reloaded results in duplicates. - " This might be a bug in Vim. To work around this, we reset the path back + " so adding them repeatedly if this file is reloaded results in duplicates, + " due to the absence of the P_NODUP flag for its definition in src/option.c. + " This is likely a bug in Vim. To work around this, we reset the path back " to its default first. " set backupskip& -- cgit v1.2.3 From df172bc02228e6c5c8a0f842d7fdd033bb727fc9 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 9 Jun 2019 02:13:37 +1200 Subject: Add user-local 'dictionary' path --- vim/vimrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vim/vimrc b/vim/vimrc index 47326b8d..13cae065 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -366,7 +366,7 @@ set cpoptions+=J " It's not an error if this file doesn't exist; indeed, on some systems I use, " it doesn't. " -set dictionary^=/usr/share/dict/words +set dictionary^=$MYVIM/ref/dictionary.txt,/usr/share/dict/words " Keep swap files for file buffers in a dedicated directory, rather than the " default of writing them to the same directory as the buffer file. Add two -- cgit v1.2.3 From 4a545c2d4ff69dbdf8bb74270e9ae48fa2440bb7 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 9 Jun 2019 02:29:17 +1200 Subject: Reorder some vimrc blocks --- vim/vimrc | 78 +++++++++++++++++++++++++++++++-------------------------------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/vim/vimrc b/vim/vimrc index 13cae065..3575eb53 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -101,45 +101,6 @@ if $MYVIM != '' || $MYVIM =~# '[*?[|;&<>\r\n,]' finish endif -" We're going to be creating a few directories, and the code to do so in -" a compatible way is surprisingly verbose, because we need to check the -" mkdir() function is actually available, and also whether the directory -" concerned already exists, even if we specify the special 'p' value for its -" optional {path} argument. -" -" This is because the meaning of mkdir(..., 'p') is not the same as `mkdir -p` -" in shell script, or at least, it isn't in versions of Vim before v8.0.1708. -" Even with the magic 'p' sauce, these versions throw errors if the directory -" already exists, despite what someone familiar with `mkdir -p`'s behaviour in -" shell script might expect. -" -" So, let's wrap all that nonsense in a script-local function. We'll make all -" the directories we create have restrictive permissions, too, with a {prot} -" argument of 0700. -" -function! s:Mkdir(path) abort - if exists('*mkdir') && !isdirectory(a:path) - call mkdir(a:path, 'p', 0700) - endif -endfunction - -" Keep the viminfo file in a cache subdirectory of $MYVIM, creating that -" subdirectory if necessary. -" -" Using this location for viminfo has the nice benefit of preventing history -" from getting clobbered when something runs Vim without using this vimrc, -" because it writes its history to the default viminfo path instead. It also -" means that everything Vim-related in the user's home directory should be -" encapsulated in the one ~/.vim or ~/vimfiles directory. -" -" The normal method of specifying the path to the viminfo file used here is an -" addendum to the 'viminfo' option, which works OK. Vim v8.1.716 introduced -" a nicer way to set it with a 'viminfofile' option, but there's no particular -" reason to use it until it's in a few more stable versions. -" -call s:Mkdir($MYVIM.'/cache') -set viminfo+=n$MYVIM/cache/viminfo - " Create a 'vimrc' automatic command hook group, if it already exists, and " clear away any automatic command hooks already defined within it if it does, " so that we don't end up collecting multiple copies of the hooks configured @@ -188,6 +149,45 @@ if exists('##SourceCmd') \|endif endif +" We're going to be creating a few directories, and the code to do so in +" a compatible way is surprisingly verbose, because we need to check the +" mkdir() function is actually available, and also whether the directory +" concerned already exists, even if we specify the special 'p' value for its +" optional {path} argument. +" +" This is because the meaning of mkdir(..., 'p') is not the same as `mkdir -p` +" in shell script, or at least, it isn't in versions of Vim before v8.0.1708. +" Even with the magic 'p' sauce, these versions throw errors if the directory +" already exists, despite what someone familiar with `mkdir -p`'s behaviour in +" shell script might expect. +" +" So, let's wrap all that nonsense in a script-local function. We'll make all +" the directories we create have restrictive permissions, too, with a {prot} +" argument of 0700. +" +function! s:Mkdir(path) abort + if exists('*mkdir') && !isdirectory(a:path) + call mkdir(a:path, 'p', 0700) + endif +endfunction + +" Keep the viminfo file in a cache subdirectory of $MYVIM, creating that +" subdirectory if necessary. +" +" Using this location for viminfo has the nice benefit of preventing history +" from getting clobbered when something runs Vim without using this vimrc, +" because it writes its history to the default viminfo path instead. It also +" means that everything Vim-related in the user's home directory should be +" encapsulated in the one ~/.vim or ~/vimfiles directory. +" +" The normal method of specifying the path to the viminfo file used here is an +" addendum to the 'viminfo' option, which works OK. Vim v8.1.716 introduced +" a nicer way to set it with a 'viminfofile' option, but there's no particular +" reason to use it until it's in a few more stable versions. +" +call s:Mkdir($MYVIM.'/cache') +set viminfo+=n$MYVIM/cache/viminfo + " We'll start our options by modernising a little in adjusting some options " with language-specific defaults. " -- cgit v1.2.3 From 6563582f2d85c9fc0cd410889ddcbc65e9fc94a4 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 9 Jun 2019 02:34:52 +1200 Subject: Add explanations for 'ttymouse' and 'split*' opts --- vim/vimrc | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/vim/vimrc b/vim/vimrc index 3575eb53..6c1875fe 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -602,9 +602,13 @@ set shortmess+=I " Prefix wrapped rows with three dots set showbreak=... -" New window positioning -set splitbelow " Below the current window, not above -set splitright " Right of the current window, not left +" By default, the positioning of new Vim windows differs from the i3 and tmux +" window management to which I'm accustomed, in that new windows are created +" above or to the left of existing ones. I have tried to get used to this, +" but haven't managed to, so we configure it to behave more consistently +" instead. +" +set splitbelow splitright " Don't try to syntax highlight run-on lines set synmaxcol=500 @@ -617,9 +621,14 @@ if &term =~# '^putty' set ttyfast endif -" Don't use terminal mouse support, even if it would work; the manual says to -" set 't_RV' to do this, but that doesn't seem to work -if exists('+ttymouse') " No such option in Neovim +" We don't want a mouse. Don't use terminal mouse support, even if it would +" work. The manual suggests this should be done by clearing 't_RV', but that +" doesn't seem to work. +" +" We have to check for the existence of the option first, as it doesn't exist +" in Neovim. +" +if exists('+ttymouse') set ttymouse= endif -- cgit v1.2.3 From 3f358e5f8241645e835f96b8c2f93a1747aad130 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 9 Jun 2019 02:35:45 +1200 Subject: Remove 'splitbelow' and 'splitright' settings Just experimentally; let's see what we think. --- vim/vimrc | 8 -------- 1 file changed, 8 deletions(-) diff --git a/vim/vimrc b/vim/vimrc index 6c1875fe..ff6ac208 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -602,14 +602,6 @@ set shortmess+=I " Prefix wrapped rows with three dots set showbreak=... -" By default, the positioning of new Vim windows differs from the i3 and tmux -" window management to which I'm accustomed, in that new windows are created -" above or to the left of existing ones. I have tried to get used to this, -" but haven't managed to, so we configure it to behave more consistently -" instead. -" -set splitbelow splitright - " Don't try to syntax highlight run-on lines set synmaxcol=500 -- cgit v1.2.3 From 596d316a690cc3de6891f2c7ebc16acec39b91be Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 9 Jun 2019 02:36:12 +1200 Subject: Bump VERSION --- VERSION | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/VERSION b/VERSION index b016b659..4110cfae 100644 --- a/VERSION +++ b/VERSION @@ -1,2 +1,2 @@ -tejr dotfiles v5.24.0 -Sat Jun 8 13:38:47 UTC 2019 +tejr dotfiles v5.25.0 +Sat Jun 8 14:36:12 UTC 2019 -- cgit v1.2.3