aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2022-05-09 22:18:20 +1200
committerTom Ryder <tom@sanctum.geek.nz>2022-05-09 22:18:20 +1200
commit641b837f1128984e70d687e762ffce9e48aa9cf7 (patch)
tree06869606737508c6fe2f366446dfa231b88742a7
parentMerge branch 'release/v12.1.0' (diff)
parentBump VERSION (diff)
downloaddotfiles-641b837f1128984e70d687e762ffce9e48aa9cf7.tar.gz
dotfiles-641b837f1128984e70d687e762ffce9e48aa9cf7.zip
Merge branch 'release/v12.2.0'v12.2.0
* release/v12.2.0: Correct a comment's XDG description Move everything else in XDG cache into state Move saved views into $XDG_STATE_HOME Move persistent undo files into $XDG_STATE_HOME Add XDG_STATE_HOME to XDG support Update html_spelllang.vim to v0.2.0 Spin Vim HTML lang switching out into plugin
-rw-r--r--.gitmodules3
-rw-r--r--VERSION4
-rw-r--r--vim/after/ftplugin/html.vim18
-rw-r--r--vim/autoload/html/spelllang.vim57
-rw-r--r--vim/autoload/xdg.vim5
m---------vim/bundle/html_spelllang0
-rw-r--r--vim/vimrc46
7 files changed, 33 insertions, 100 deletions
diff --git a/.gitmodules b/.gitmodules
index 4a63f718..e0ef1bf5 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -26,6 +26,9 @@
[submodule "vim/bundle/foldlevelstart_stdin"]
path = vim/bundle/foldlevelstart_stdin
url = https://dev.sanctum.geek.nz/code/vim-foldlevelstart-stdin.git
+[submodule "vim/bundle/html_spelllang"]
+ path = vim/bundle/html_spelllang
+ url = https://dev.sanctum.geek.nz/code/vim-html-spelllang.git
[submodule "vim/bundle/insert_cancel"]
path = vim/bundle/insert_cancel
url = https://dev.sanctum.geek.nz/code/vim-insert-cancel.git
diff --git a/VERSION b/VERSION
index e0e0fe1e..9f382088 100644
--- a/VERSION
+++ b/VERSION
@@ -1,2 +1,2 @@
-tejr dotfiles v12.1.0
-Mon, 09 May 2022 04:24:48 +0000
+tejr dotfiles v12.2.0
+Mon, 09 May 2022 10:18:14 +0000
diff --git a/vim/after/ftplugin/html.vim b/vim/after/ftplugin/html.vim
index 741f7b65..21a84a42 100644
--- a/vim/after/ftplugin/html.vim
+++ b/vim/after/ftplugin/html.vim
@@ -32,24 +32,6 @@ augroup END
let b:undo_ftplugin .= '|execute ''autocmd! html_timestamp'''
\ . '|augroup! html_timestamp'
-" Set up hooks for divining 'spelllang' from lang= attributes
-augroup html_spelllang
- if exists('##TextChanged')
- autocmd TextChanged *
- \ if &modified
- \| call html#spelllang#Set()
- \|endif
- else
- autocmd InsertLeave *
- \ if &modified
- \| call html#spelllang#Set()
- \|endif
- endif
-augroup END
-call html#spelllang#Set()
-let b:undo_ftplugin .= '|execute ''autocmd! html_spelllang'''
- \ . '|augroup! html_spelllang'
-
" Stop here if the user doesn't want ftplugin mappings
if exists('no_plugin_maps') || exists('no_html_maps')
finish
diff --git a/vim/autoload/html/spelllang.vim b/vim/autoload/html/spelllang.vim
deleted file mode 100644
index e451f8a1..00000000
--- a/vim/autoload/html/spelllang.vim
+++ /dev/null
@@ -1,57 +0,0 @@
-" Crude regular expression to match an <html>, <body>, or <main> tag on one
-" line with a lang= attribute set. This isn't exact, by any means, but
-" I don't want to write an actual HTML parser for a mere 'spelllang' hook
-" nicety that fails silently anyway.
-"
-" The first submatch is the language code, e.g. "en", "es". The second
-" submatch is optional and follows a hyphen and is for the regional code,
-" e.g. "US", "GB", "AR".
-"
-let s:pattern = '\m\c<\%(html\|body\|main\)\>[^>]*\<lang=["'']\='
- \ . '\([a-z-]\{2,}\)\%(-\([a-z]\{2,}\)\)'
-
-" The line count limit for looking for the pattern; no sense churning through
-" the whole document every time it's changed.
-"
-let s:lines = 128
-
-" Look for a language code in the first lines of the current buffer, and if it
-" looks understandable, adopt an appropriate spelling language.
-"
-function! html#spelllang#Set() abort
-
- " Loop through the first s:lines of the buffer
- for line in getline(1, s:lines)
-
- " Check if this line has an <html lang=""> tag, or skip it
- let matches = matchlist(line, s:pattern)
- if empty(matches)
- continue
- endif
-
- " The line seems to match our pattern, and so we have a language code in
- " matches[1], and possibly a region code in matches[2].
- "
- " Next we need to check whether we'll attempt to use this to set
- " a spelling language. Build the expected path for a spellfile; looks
- " like `$VIMRUNTIME/spell/en.utf-8.spl`. Note that this path doesn't
- " include any language region, per documentation.
- "
- let spellfile = 'spell/' . join([
- \ tolower(matches[1]),
- \ &encoding,
- \ 'spl',
- \], '.')
-
- " If a spelling list file of the expected name exists in &runtimepath, try
- " setting the local value of 'spelllang' to reflect what was in the lang=
- " attribute; force it to lowercase and separate the region with an
- " underscore rather than a hyphen (if there is a region).
- "
- if strlen(globpath(&runtimepath, spellfile))
- let &l:spelllang = tolower(join(matches[1:2], '_'))
- endif
-
- endfor
-
-endfunction
diff --git a/vim/autoload/xdg.vim b/vim/autoload/xdg.vim
index 67a9c5b2..90ea9c2f 100644
--- a/vim/autoload/xdg.vim
+++ b/vim/autoload/xdg.vim
@@ -5,6 +5,7 @@ let s:defaults = {
\ 'XDG_CONFIG_DIRS': '/etc/xdg',
\ 'XDG_DATA_HOME': $HOME.'/.local/share',
\ 'XDG_DATA_DIRS': '/usr/local/share:/usr/share',
+ \ 'XDG_STATE_HOME': $HOME.'/.local/state',
\}
function! s:Get(name) abort
@@ -53,6 +54,10 @@ function! xdg#DataHome() abort
return s:Home('XDG_DATA_HOME')
endfunction
+function! xdg#StateHome() abort
+ return s:Home('XDG_STATE_HOME')
+endfunction
+
function! xdg#ConfigDirs() abort
return s:Dirs('XDG_CONFIG_DIRS')
endfunction
diff --git a/vim/bundle/html_spelllang b/vim/bundle/html_spelllang
new file mode 160000
+Subproject 161e47f00cd5a1bdcef61097b7ba100ffd69a48
diff --git a/vim/vimrc b/vim/vimrc
index f5cb107f..fb26b75e 100644
--- a/vim/vimrc
+++ b/vim/vimrc
@@ -138,8 +138,6 @@ let $MYVIM = option#Split(&runtimepath)[0]
" defaults, using autoloaded xdg# functions.
"
if has('unix')
- let s:xdgcachehome
- \ = xdg#CacheHome()
let s:xdgconfigdirs
\ = xdg#ConfigDirs()
let s:xdgconfighome
@@ -148,6 +146,8 @@ if has('unix')
\ = xdg#DataDirs()
let s:xdgdatahome
\ = xdg#DataHome()
+ let s:xdgstatehome
+ \ = xdg#StateHome()
endif
" We put XDG_CONFIG_HOME at the front of the 'runtimepath' list with insert(),
@@ -191,12 +191,12 @@ endif
" v8.1.716 introduced a way to set this with an option named 'viminfofile',
" but I don't see a reason to use that.
"
-if exists('s:xdgcachehome') && s:xdgcachehome !=# ''
- if !isdirectory(s:xdgcachehome)
- call mkdir(s:xdgcachehome, 'p', 0700)
+if exists('s:xdgstatehome') && s:xdgstatehome !=# ''
+ if !isdirectory(s:xdgstatehome)
+ call mkdir(s:xdgstatehome, 'p', 0700)
endif
execute 'set viminfo+='.option#Escape(
- \ 'n'.s:xdgcachehome.'/viminfo'
+ \ 'n'.s:xdgstatehome.'/viminfo'
\)
endif
@@ -241,12 +241,12 @@ set history=300
" 'backupfullname', 'swapfilefullname' would have been clearer.
"
set backup
-if exists('s:xdgcachehome') && s:xdgcachehome !=# ''
- if !isdirectory(s:xdgcachehome.'/backup')
- call mkdir(s:xdgcachehome.'/backup', 'p', 0700)
+if exists('s:xdgstatehome') && s:xdgstatehome !=# ''
+ if !isdirectory(s:xdgstatehome.'/backup')
+ call mkdir(s:xdgstatehome.'/backup', 'p', 0700)
endif
execute 'set backupdir^='.option#Escape(option#item#Escape(
- \ s:xdgcachehome.'/backup'.(patch#('8.1.251') ? '//' : '')
+ \ s:xdgstatehome.'/backup'.(patch#('8.1.251') ? '//' : '')
\))
endif
@@ -302,12 +302,12 @@ endif
" its name, in order to avoid filename collisions, since the 'directory'
" option has supported that hint for much longer than 'backupdir' has.
"
-if exists('s:xdgcachehome') && s:xdgcachehome !=# ''
- if !isdirectory(s:xdgcachehome.'/swap')
- call mkdir(s:xdgcachehome.'/swap', 'p', 0700)
+if exists('s:xdgstatehome') && s:xdgstatehome !=# ''
+ if !isdirectory(s:xdgstatehome.'/swap')
+ call mkdir(s:xdgstatehome.'/swap', 'p', 0700)
endif
execute 'set directory^='.option#Escape(option#item#Escape(
- \ s:xdgcachehome.'/swap//'
+ \ s:xdgstatehome.'/swap//'
\))
endif
@@ -323,13 +323,13 @@ endif
" Support for these persistent undo file caches was not released until v7.3.0,
" so we need to check for the feature's presence before we enable it.
"
-if exists('s:xdgcachehome') && s:xdgcachehome !=# '' && has('persistent_undo')
+if exists('s:xdgstatehome') && s:xdgstatehome !=# '' && has('persistent_undo')
set undofile
- if !isdirectory(s:xdgcachehome.'/undo')
- call mkdir(s:xdgcachehome.'/undo', 'p', 0700)
+ if !isdirectory(s:xdgstatehome.'/undo')
+ call mkdir(s:xdgstatehome.'/undo', 'p', 0700)
endif
execute 'set undodir^='.option#Escape(option#item#Escape(
- \ s:xdgcachehome.'/undo//'
+ \ s:xdgstatehome.'/undo//'
\))
endif
@@ -338,12 +338,12 @@ endif
" directories of this type. This isn't a comma-separated list like the others
" ('backupdir', 'directory', 'spell', 'undodir')
"
-if exists('s:xdgcachehome') && s:xdgcachehome !=# '' && has('mksession')
- if !isdirectory(s:xdgcachehome.'/view')
- call mkdir(s:xdgcachehome.'/view', 'p', 0700)
+if exists('s:xdgstatehome') && s:xdgstatehome !=# '' && has('mksession')
+ if !isdirectory(s:xdgstatehome.'/view')
+ call mkdir(s:xdgstatehome.'/view', 'p', 0700)
endif
execute 'set viewdir='.option#Escape(option#item#Escape(
- \ s:xdgcachehome.'/view'
+ \ s:xdgstatehome.'/view'
\))
endif
@@ -441,7 +441,7 @@ endif
" At some point, I may end up having to set this option along with 'spellfile'
" a bit more intelligently to ensure that spell checking and dictionary
" function consistently, and with reference to the same resources. For the
-" moment, I've just added additional entries referring to the user runtime
+" moment, I've just added additional entries referring to the user's data
" directory.
"
set dictionary^=/usr/share/dict/words