Commit 1e6738c0 authored by Dom Sekotill's avatar Dom Sekotill
Browse files

Enhance Vim spell file management

parent 62a155d9
Loading
Loading
Loading
Loading

.vim/plugin/spell.vim

0 → 100644
+38 −0
Original line number Diff line number Diff line
" Dotfiles specific Vim spelling and spell file configuration

" File of spelling 'abbreviations'; auto-corrections in other words
source ~/.vim/spell/auto.vim

let s:spellfiles = [".local.utf8.add"]
let s:spellfiles += glob("~/.vim/spell/*.add", v:false, v:true)
let s:spellfiles += glob("~/.vim/spell/ft/*.add", v:false, v:true)
let &spellfile = join(s:spellfiles, ",")

function s:manage_spell_word(action, spellfile, word)
	let s:spellfiles = uniq(sort(
		\ s:spellfiles +
		\ split(&spellfile, ',') +
		\ [a:spellfile]
		\ ))
	let &spellfile = a:spellfile
	execute a:action." ".expand(a:word)
	let &spellfile = join(s:spellfiles, ",")
endfunction

function s:manage_ft_word(action, word)
	if &filetype == ""
		echoerr "No filetype set for this buffer"
		return
	endif
	let spellfile = expand("~/.vim/spell/ft/".&filetype.".utf8.add")
	call s:manage_spell_word(a:action, spellfile, a:word)
endfunction


command -nargs=1 SpellFtGood  :call s:manage_ft_word("spellgood", <args>)
command -nargs=1 SpellFtWrong :call s:manage_ft_word("spellwrong", <args>)
command -nargs=1 SpellFtUndo  :call s:manage_ft_word("spellundo", <args>)

nnoremap <silent> zLg :SpellFtGood  "<cword>"<CR>
nnoremap <silent> zLw :SpellFtWrong "<cword>"<CR>
nnoremap <silent> zLu :SpellFtUndo  "<cword>"<CR>
+3 −2
Original line number Diff line number Diff line
#!/bin/bash
set -eu
shopt -s globstar

if [ -z "${DEBUG-}" ]; then
	silent_flag=-s
@@ -16,9 +17,9 @@ GIT_DIR=`git rev-parse --git-dir`
declare -a FILES=()

# remove commented-out entries
sed -i.bac '/^#[^#].*/d' "$SPELL_DIR"/*.add
sed -i.bac '/^#[^#].*/d' "$SPELL_DIR"/**/*.add

for file in "$SPELL_DIR"/*.add; do
for file in "$SPELL_DIR"/**/*.add; do
	mv "${file}" "${file}.tmp"
	sort -f -u "${file}.tmp" > "${file}"
	rm "${file}.tmp"
+0 −14
Original line number Diff line number Diff line
@@ -87,20 +87,6 @@ set nocindent noautoindent nosmartindent
set copyindent preserveindent


" === SPELLING ===

source ~/.vim/spell/auto.vim
set spellfile=
	\.local.utf8.add,
	\~/.vim/spell/.local.utf8.add,
	\~/.vim/spell/env.utf8.add,
	\~/.vim/spell/proper-names.utf8.add,
	\~/.vim/spell/python.utf8.add,
	\~/.vim/spell/technologies.utf8.add,
	\~/.vim/spell/terms.utf8.add,
	\~/.vim/spell/file-ext.utf8.add


" === SYNTAX ===

if has("syntax")