add vim syntax support

This commit is contained in:
Felix Neumärker
2018-12-08 15:16:42 +01:00
committed by Xavier Delaruelle
parent 2b53c068da
commit 76a4d4ce71
6 changed files with 114 additions and 2 deletions

View File

@@ -248,6 +248,14 @@ ifeq ($(compatversion),y)
cp $(COMPAT_DIR)/ChangeLog $(DESTDIR)$(docdir)/ChangeLog-compat
cp $(COMPAT_DIR)/NEWS $(DESTDIR)$(docdir)/NEWS-compat
endif
endif
ifeq ($(vimplugin),y)
mkdir -p $(DESTDIR)$(vimplugindir)/ftdetect
mkdir -p $(DESTDIR)$(vimplugindir)/ftplugin
mkdir -p $(DESTDIR)$(vimplugindir)/syntax
cp contrib/vim/ftdetect/modulefile.vim $(DESTDIR)$(vimplugindir)/ftdetect
cp contrib/vim/ftplugin/modulefile.vim $(DESTDIR)$(vimplugindir)/ftplugin
cp contrib/vim/syntax/modulefile.vim $(DESTDIR)$(vimplugindir)/syntax
endif
$(MAKE) -C init install DESTDIR=$(DESTDIR)
ifeq ($(builddoc),y)
@@ -271,6 +279,15 @@ endif
rm -f $(DESTDIR)$(bindir)/add.modules
rm -f $(DESTDIR)$(bindir)/modulecmd
rm -f $(DESTDIR)$(bindir)/mkroot
ifeq ($(vimplugin),y)
rm -f $(DESTDIR)$(vimplugindir)/ftdetect/modulefile.vim
rm -f $(DESTDIR)$(vimplugindir)/ftplugin/modulefile.vim
rm -f $(DESTDIR)$(vimplugindir)/syntax/modulefile.vim
-rmdir $(DESTDIR)$(vimplugindir)/ftdetect
-rmdir $(DESTDIR)$(vimplugindir)/ftplugin
-rmdir $(DESTDIR)$(vimplugindir)/syntax
-rmdir -p $(DESTDIR)$(vimplugindir)
endif
ifeq ($(docinstall),y)
rm -f $(addprefix $(DESTDIR)$(docdir)/,ChangeLog README COPYING.GPLv2)
ifeq ($(compatversion),y)

View File

@@ -12,6 +12,7 @@ modulefilesdir := @modulefilesdir@
datarootdir := @datarootdir@
mandir := @mandir@
docdir := @docdir@
vimplugindir := @vimplugindir@
# versioning mode installation
versioning := @versioning@
@@ -40,6 +41,7 @@ setbinpath := @setbinpath@
appendbinpath := @appendbinpath@
setdotmodulespath := @setdotmodulespath@
docinstall := @docinstall@
vimplugin := @vimplugin@
examplemodulefiles := @examplemodulefiles@
# able to build documentation?

17
configure vendored
View File

@@ -27,9 +27,9 @@ targetlist="${progdir}/Makefile.inc ${progdir}/site.exp"
# argument list
arglist="TCLSH SPHINXBUILD PS BASENAME RMDIR_IGN_NON_EMPTY VERSION \
baseprefix prefix bindir libexecdir etcdir initdir datarootdir mandir docdir \
baseprefix prefix bindir libexecdir etcdir initdir datarootdir mandir docdir vimplugindir \
modulefilesdir setmanpath appendmanpath setbinpath appendbinpath \
setdotmodulespath docinstall examplemodulefiles builddoc gitworktree \
setdotmodulespath docinstall vimplugin examplemodulefiles builddoc gitworktree \
usemanpath compatversion EXEEXT versioning silentshdbgsupport \
quarantinesupport autohandling pager pageropts modulepath loadedmodules \
quarantinevars"
@@ -48,6 +48,7 @@ setbinpath=y
appendbinpath=n
setdotmodulespath=n
docinstall=y
vimplugin=y
examplemodulefiles=y
compatversion=y
EXEEXT=
@@ -78,6 +79,7 @@ initdir=
datarootdir=
mandir=
docdir=
vimplugindir=
modulefilesdir=
modulepath=
@@ -125,6 +127,7 @@ Fine tuning of the installation directories:
--datarootdir=DIR read-only arch.-independent data root [PREFIX/share]
--mandir=DIR man documentation [DATAROOTDIR/man]
--docdir=DIR documentation root [DATAROOTDIR/doc]
--vimplugindir=DIR vim plugin directory [DATAROOTDIR/vim/vimfiles]
--modulefilesdir=DIR system modulefiles [PREFIX/modulefiles]
Optional Features:
@@ -139,6 +142,8 @@ Optional Features:
--enable-doc-install install documentation files in the documentation
directory defined with \'docdir' (no impact on
man pages installation) [yes]
--enable-vimplugin install vim plugin files in the directory
defined with \'vimplugindir' [yes]
--enable-example-modulefiles
install in 'modulefilesdir' some modulefiles
provided as examples [yes]
@@ -205,6 +210,8 @@ placed in the following directory structure:
man/
man1/
man4/
vim/
vimfiles/
modulefiles/"
}
@@ -296,6 +303,8 @@ for arg in "$@"; do
mandir="${arg#*=}" ;;
--docdir=*)
docdir="${arg#*=}" ;;
--vimplugindir=*)
vimplugindir="${arg#*=}" ;;
--modulefilesdir=*)
modulefilesdir="${arg#*=}" ;;
--enable-set-manpath*|--disable-set-manpath)
@@ -312,6 +321,9 @@ for arg in "$@"; do
--enable-doc-install*|--disable-doc-install)
docinstall=$(get_feature_value "$arg")
defdocinstall=0 ;;
--enable-vimplugin*|--disable-vimplugin)
vimplugin=$(get_feature_value "$arg")
defvimplugin=0 ;;
--enable-example-modulefiles*|--disable-example-modulefiles)
examplemodulefiles=$(get_feature_value "$arg")
defexamplemodulefiles=0 ;;
@@ -461,6 +473,7 @@ fi
[ -z "$datarootdir" ] && datarootdir=$prefix/share
[ -z "$mandir" ] && mandir=$datarootdir/man
[ -z "$docdir" ] && docdir=$datarootdir/doc
[ -z "$vimplugindir" ] && vimplugindir=$datarootdir/vim/vimfiles
[ -z "$modulefilesdir" ] && modulefilesdir=$prefix/modulefiles
# default modulepath based on MODULE_VERSION if versioning enabled
[ -z "$modulepath" -a "$versioning" = 'y' ] && modulepath=${modulefilesdir/#$prefix/$baseprefix\/\$MODULE_VERSION}

View File

@@ -0,0 +1,6 @@
au BufNewFile,BufRead *
\ if (getline(1) =~? "^#%Module") |
\ set filetype=modulefile |
\ endif

View File

@@ -0,0 +1,23 @@
if exists("b:did_modulefile_ftplugin")
finish
endif
let b:did_modulefile_ftplugin = 1
set syntax=modulefile
" adopted from tcl ftplugin:
let s:cpo_save = &cpo
set cpo-=C
setlocal comments=:#
setlocal commentstring=#%s
setlocal formatoptions+=croql
" Undo the stuff we changed.
let b:undo_ftplugin = "setlocal fo< com< cms< inc< inex< def< isf< kp<" .
\ " | unlet! b:browsefilter"
" Restore the saved compatibility options.
let &cpo = s:cpo_save
unlet s:cpo_save

View File

@@ -0,0 +1,51 @@
" include tcl syntax
set syntax=tcl
"Clear tcl keywords to match to avoid priority of keyword
" (e.g append vs append-path)
syn clear tclCommand
" set again tclCommand with `syn match`
" Basic Tcl commands: http://www.tcl.tk/man/tcl8.6/TclCmd/contents.htm
syn match tclCommand "\v<(after|append|array|bgerror|binary|cd|chan|clock|close|concat)>"
syn match tclCommand "\v<(dde|dict|encoding|eof|error|eval|exec|exit|expr|fblocked)>"
syn match tclCommand "\v<(fconfigure|fcopy|file|fileevent|flush|format|gets|glob)>"
syn match tclCommand "\v<(global|history|http|incr|info|interp|join|lappend|lassign)>"
syn match tclCommand "\v<(lindex|linsert|list|llength|lmap|load|lrange|lrepeat)>"
syn match tclCommand "\v<(lreplace|lreverse|lsearch|lset|lsort|memory|my|namespace)>"
syn match tclCommand "\v<(next|nextto|open|package|pid|puts|pwd|read|refchan|regexp)>"
syn match tclCommand "\v<(registry|regsub|rename|scan|seek|self|set|socket|source)>"
syn match tclCommand "\v<(split|string|subst|tell|time|trace|unknown|unload|unset)>"
syn match tclCommand "\v<(update|uplevel|upvar|variable|vwait)>"
" The 'Tcl Standard Library' commands: http://www.tcl.tk/man/tcl8.6/TclCmd/library.htm
syn match tclCommand "\v<(auto_execok|auto_import|auto_load|auto_mkindex|auto_reset)>"
syn match tclCommand "\v<(auto_qualify|tcl_findLibrary|parray|tcl_endOfWord)>"
syn match tclCommand "\v<(tcl_startOfNextWord|tcl_startOfPreviousWord)>"
syn match tclCommand "\v<(tcl_wordBreakAfter|tcl_wordBreakBefore)>"
" Modulefile commands: https://modules.readthedocs.io/en/stable/modulefile.html
syn match modCommand "\v<(append|prepend|remove)-path>"
syn match modCommand "\v<prereq>"
syn match modCommand "\v<(module|conflict|chdir|prereq)>"
syn match modCommand "\v<module-(alias|info|log|trace|user|verbosity|version|virtual|whatis)>"
syn match modCommand "\v<(un)?set-(alias|function)>"
syn match modCommand "\v<(un)?setenv>"
syn match modCommand "\v<getenv>"
syn match modCommand "\v<(system|uname|x-resource)>"
syn match modCommand "\v<is-(loaded|saved|used|avail)>"
hi def link modCommand tclSpecial
syn match modProc "\v<ModulesHelp>"
syn match modProc "\v<ModulesDisplay>"
syn match modProc "\v<ModulesTest>"
hi def link modProc tclSpecial
syn match modVar "\v<ModulesVersion>"
hi def link modVar tclSpecial