diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 13:18:03 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 13:18:03 +0000 |
commit | afce081b90c1e2c50c3507758c7558a0dfa1f33e (patch) | |
tree | 3fb840f0bd9de41b463443ddf17131a0ad77f226 /runtime/tools/vimspell.sh | |
parent | Initial commit. (diff) | |
download | vim-afce081b90c1e2c50c3507758c7558a0dfa1f33e.tar.xz vim-afce081b90c1e2c50c3507758c7558a0dfa1f33e.zip |
Adding upstream version 2:8.2.2434.upstream/2%8.2.2434upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'runtime/tools/vimspell.sh')
-rwxr-xr-x | runtime/tools/vimspell.sh | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/runtime/tools/vimspell.sh b/runtime/tools/vimspell.sh new file mode 100755 index 0000000..d336fe6 --- /dev/null +++ b/runtime/tools/vimspell.sh @@ -0,0 +1,55 @@ +#!/bin/sh +# +# Spell a file & generate the syntax statements necessary to +# highlight in vim. Based on a program from Krishna Gadepalli +# <krishna@stdavids.picker.com>. +# +# I use the following mappings (in .vimrc): +# +# noremap <F8> :so `vimspell.sh %`<CR><CR> +# noremap <F7> :syntax clear SpellErrors<CR> +# +# Neil Schemenauer <nascheme@ucalgary.ca> +# March 1999 +# updated 2008 Jul 17 by Bram +# +# Safe method for the temp file by Javier Fernández-Sanguino_Peña + +INFILE=$1 +tmp="${TMPDIR-/tmp}" +OUTFILE=`mktemp -t vimspellXXXXXX || tempfile -p vimspell || echo none` +# If the standard commands failed then create the file +# since we cannot create a directory (we cannot remove it on exit) +# create a file in the safest way possible. +if test "$OUTFILE" = none; then + OUTFILE=$tmp/vimspell$$ + [ -e $OUTFILE ] && { echo "Cannot use temporary file $OUTFILE, it already exists!"; exit 1 ; } + (umask 077; touch $OUTFILE) +fi +# Note the copy of vimspell cannot be deleted on exit since it is +# used by vim, otherwise it should do this: +# trap "rm -f $OUTFILE" 0 1 2 3 9 11 13 15 + + +# +# local spellings +# +LOCAL_DICT=${LOCAL_DICT-$HOME/local/lib/local_dict} + +if [ -f $LOCAL_DICT ] +then + SPELL_ARGS="+$LOCAL_DICT" +fi + +spell $SPELL_ARGS $INFILE | sort -u | +awk ' + { + printf "syntax match SpellErrors \"\\<%s\\>\"\n", $0 ; + } + +END { + printf "highlight link SpellErrors ErrorMsg\n\n" ; + } +' > $OUTFILE +echo "!rm $OUTFILE" >> $OUTFILE +echo $OUTFILE |