From 832dfece7629ac1a6f4894e956802b456ae791ea Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Wed, 4 Sep 2019 16:06:18 +0200 Subject: Add dhall, closes #426 --- README.md | 3 ++- after/syntax/haskell.vim | 17 +++++++++++++ build | 1 + ftdetect/polyglot.vim | 9 +++++++ ftplugin/dhall.vim | 39 ++++++++++++++++++++++++++++ syntax/dhall.vim | 66 ++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 134 insertions(+), 1 deletion(-) create mode 100644 after/syntax/haskell.vim create mode 100644 ftplugin/dhall.vim create mode 100644 syntax/dhall.vim diff --git a/README.md b/README.md index 019ae44e..5f1f54b8 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ A collection of language packs for Vim. > One to rule them all, one to find them, one to bring them all and in the darkness bind them. - It **won't affect your startup time**, as scripts are loaded only on demand\*. -- It **installs and updates 120+ times faster** than the 145 packages it consists of. +- It **installs and updates 120+ times faster** than the 146 packages it consists of. - Solid syntax and indentation support (other features skipped). Only the best language packs. - All unnecessary files are ignored (like enormous documentation from php support). - No support for esoteric languages, only most popular ones (modern too, like `slim`). @@ -68,6 +68,7 @@ If you need full functionality of any plugin, please use it directly with your p - [cucumber](https://github.com/tpope/vim-cucumber) (syntax, indent, compiler, ftplugin) - [cue](https://github.com/mgrabovsky/vim-cuesheet) (syntax) - [dart](https://github.com/dart-lang/dart-vim-plugin) (syntax, indent, autoload, ftplugin) +- [dhall](https://github.com/vmchale/dhall-vim) (syntax, ftplugin) - [dlang](https://github.com/JesseKPhillips/d.vim) (syntax, indent) - [dockerfile](https://github.com/ekalinin/Dockerfile.vim) (syntax, indent, ftplugin) - [elixir](https://github.com/elixir-lang/vim-elixir) (syntax, indent, compiler, autoload, ftplugin) diff --git a/after/syntax/haskell.vim b/after/syntax/haskell.vim new file mode 100644 index 00000000..db454f2f --- /dev/null +++ b/after/syntax/haskell.vim @@ -0,0 +1,17 @@ +if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'dhall') != -1 + finish +endif + +" store and remove current syntax value +let old_syntax = b:current_syntax +unlet b:current_syntax + +syn include @dhall syntax/dhall.vim +unlet b:current_syntax + +syn region dhallBlock matchgroup=quasiQuote start=/\[\$\?staticDhallExpression|/ end=/|\]/ contains=@dhall + +hi def link quasiQuote Underlined + +" restore current syntax value +let b:current_syntax = old_syntax diff --git a/build b/build index 1361957d..43e8c893 100755 --- a/build +++ b/build @@ -178,6 +178,7 @@ PACKS=" cucumber:tpope/vim-cucumber cue:mgrabovsky/vim-cuesheet dart:dart-lang/dart-vim-plugin + dhall:vmchale/dhall-vim dlang:JesseKPhillips/d.vim dockerfile:ekalinin/Dockerfile.vim elixir:elixir-lang/vim-elixir diff --git a/ftdetect/polyglot.vim b/ftdetect/polyglot.vim index 61b9baba..af4d6941 100644 --- a/ftdetect/polyglot.vim +++ b/ftdetect/polyglot.vim @@ -289,6 +289,15 @@ autocmd BufRead,BufNewFile *.dart set filetype=dart augroup end endif +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'dhall') == -1 + augroup filetypedetect + " dhall, from dhall.vim in vmchale/dhall-vim +augroup dhall + autocmd BufNewFile,BufRead *.dhall set filetype=dhall +augroup END + augroup end +endif + if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'dlang') == -1 augroup filetypedetect " dlang, from d.vim in JesseKPhillips/d.vim diff --git a/ftplugin/dhall.vim b/ftplugin/dhall.vim new file mode 100644 index 00000000..7afad55f --- /dev/null +++ b/ftplugin/dhall.vim @@ -0,0 +1,39 @@ +if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'dhall') != -1 + finish +endif + +if exists('b:dhall_ftplugin') + finish +endif +let b:dhall_ftplugin = 1 + +setlocal commentstring=--\ %s + +set smarttab + +if exists('g:dhall_use_ctags') + if g:dhall_use_ctags == 1 + augroup dhall + autocmd BufWritePost *.dhall silent !ctags -R . + augroup END + endif +endif + +function! StripTrailingWhitespace() + let myline=line('.') + let mycolumn = col('.') + exec 'silent %s/ *$//' + call cursor(myline, mycolumn) +endfunction + +if exists('g:dhall_strip_whitespace') + if g:dhall_strip_whitespace == 1 + augroup dhall + au BufWritePre *.dhall silent! call StripTrailingWhitespace() + augroup END + endif +endif + +augroup dhall + au BufNewFile,BufRead *.dhall setl shiftwidth=2 +augroup END diff --git a/syntax/dhall.vim b/syntax/dhall.vim new file mode 100644 index 00000000..8c79b9f0 --- /dev/null +++ b/syntax/dhall.vim @@ -0,0 +1,66 @@ +if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'dhall') != -1 + finish +endif + +scriptencoding utf-8 + +if exists('b:current_syntax') + finish +endif + +syntax match dhallInterpolation "\v\$\{[^\}]*\}" +syntax keyword dhallTodo TODO FIXME +syntax match dhallBrackets "[<>|]" +syntax match dhallOperator "+\|*\|#" +syntax match dhallOperator "//\|⫽" +syntax match dhallOperator "/\\\|∧" +syntax match dhallOperator "//\\\\\|⩓" +syntax match dhallNumber "\v[0-9]" +syntax match dhallNumber "\v\+[0-9]" +syntax match dhallIndex "\v\@[0-9]+" contains=dhallNumber +syntax match dhallLambda "∀\|λ\|→\|->\|\\" +syntax match dhallType "\v[A-Z][a-z0-9A-Z_]*" +syntax match dhallSpecialLabel "\v`[A-Z][a-z]*`" +syntax match dhallLabel "\v[A-Z][a-z]*/[a-z_][A-Za-z0-9\.\-]*" +syntax match dhallLabel "\v[a-z_][A-Za-z0-9\-]*" +syntax match dhallType "\v[a-zA-Z]+\.[A-Z][a-z0-9A-Z_]*" +syntax match dhallParens "(\|)\|\[\|\]\|," +syntax match dhallRecord "{\|}\|:" +syntax keyword dhallKeyword let in forall constructors if then else merge env as +syntax match dhallEsc +\\["\\abfnrtv$/]+ +syntax match dhallSingleSpecial +'''+ +syntax match dhallSingleSpecial +''${+ +syntax match dhallComment '\v--.*$' contains=@Spell,dhallTodo +syntax region dhallMultilineComment start="{-" end="-}" contains=@Spell,dhallTodo,dhallMultilineComment +syntax match dhallUrl "https://[a-zA-Z0-9/.\-_\?\=\&]*" +syntax match dhallUrl "http://[a-zA-Z0-9/.\-_\?\=\&]*" +syntax match dhallUrl "/[a-zA-Z0-9/.\-_]*" +syntax match dhallUrl "\.\./[a-zA-Z0-9/.\-_]*" +syntax match dhallUrl "\./[a-zA-Z0-9/.\-_]*" +syntax region dhallString start=+''+ end=+''+ contains=@Spell,dhallInterpolation,dhallSingleSpecial +syntax region dhallString start=+"+ end=+"+ contains=dhallInterpolation,dhallEsc +syntax region dhallString start=+"/+ end=+"+ contains=dhallInterpolation,dhallEsc +syntax keyword dhallBool True False + +highlight link dhallSingleSpecial Special +highlight link dhallIndex Special +highlight link dhallSpecialLabel Operator +highlight link dhallEsc Special +highlight link dhallInterpolation Special +highlight link dhallTodo Todo +highlight link dhallBrackets Operator +highlight link dhallBool Underlined +highlight link dhallUrl String +highlight link dhallOperator Operator +highlight link dhallNumber Number +highlight link dhallLambda Special +highlight link dhallString String +highlight link dhallLabel Identifier +highlight link dhallRecord Special +highlight link dhallKeyword Keyword +highlight link dhallType Structure +highlight link dhallParens Special +highlight link dhallComment Comment +highlight link dhallMultilineComment Comment + +let b:current_syntax = 'dhall' -- cgit v1.2.3