vim: improve *.nix plugin (#4662)

- Sync syntax from source.
- Add indentation conventions.

+24 -10
+24 -10
pkgs/applications/editors/vim/ft-nix-support.patch
··· 23 23 index 0000000..a2f9918 24 24 --- /dev/null 25 25 +++ b/runtime/syntax/nix.vim 26 - @@ -0,0 +1,47 @@ 26 + @@ -0,0 +1,56 @@ 27 27 +" Vim syntax file 28 28 +" Language: nix 29 29 +" Maintainer: Marc Weber <marco-oweber@gmx.de> 30 30 +" Modify and commit if you feel that way 31 - +" Last Change: 2007 Dec 31 + +" Last Change: 2011 Jun 32 32 +" 33 33 +" this syntax file can be still be enhanced very much.. 34 34 +" Don't ask, do it :-) 35 + +" This file (github.com/MarcWeber/vim-addon-nix) is periodically synced with 36 + +" the patch found in vim_configurable (nixpkgs) 35 37 + 36 38 +" Quit when a (custom) syntax file was already loaded 37 39 +if exists("b:current_syntax") 38 40 + finish 39 41 +endif 40 42 + 41 - +syn keyword nixKeyword let in rec assert inherit import true false null with ... 42 - +syn keyword nixBuiltin import abort baseNameOf dirOf isNull builtins map removeAttrs throw toString derivation 43 + + 44 + +sy cluster nixStrings contains=nixStringParam,nixStringIndented 45 + + 46 + +syn keyword nixKeyword let throw inherit import true false null with 43 47 +syn keyword nixConditional if else then 44 48 +syn keyword nixBrace ( ) { } = 45 49 +syn keyword nixBuiltin __currentSystem __currentTime __isFunction __getEnv __trace __toPath __pathExists 46 50 + \ __readFile __toXML __toFile __filterSource __attrNames __getAttr __hasAttr __isAttrs __listToAttrs __isList 47 51 + \ __head __tail __add __sub __lessThan __substring __stringLength 48 52 + 49 - +syn match nixAttr "[a-zA-Z0-9-_]\+\ze\s*=" 50 - +syn match nixFuncArg "\zs[a-zA-Z0-9-_]\+\ze\s*:" 51 - +syn region nixStringParam start=+\${+ end=+}+ 53 + +syn region nixStringIndented start=+''+ skip=+'''\|''${\|"+ end=+''+ contains=nixStringParam 54 + +" syn region nixString start=+"+ skip=+\\"+ end=+"+ 55 + +syn match nixAttr "\w\+\ze\s*=" 56 + +syn match nixFuncArg "\zs\w\+\ze\s*:" 57 + +syn region nixStringParam start=+\${+ end=+}+ contains=@nixStrings 52 58 +syn region nixMultiLineComment start=+/\*+ skip=+\\"+ end=+\*/+ 53 59 +syn match nixEndOfLineComment "#.*$" 54 - +syn region nixStringIndented start=+''+ skip=+'''\|''${\|"+ end=+''+ contains=nixStringParam 55 - +syn region nixString start=+"+ skip=+\\"+ end=+"+ contains=nixStringParam 56 60 + 57 61 +hi def link nixKeyword Keyword 58 - +hi def link nixBuiltin Function 59 62 +hi def link nixConditional Conditional 60 63 +hi def link nixBrace Special 61 64 +hi def link nixString String ··· 66 69 +hi def link nixEndOfLineComment Comment 67 70 +hi def link nixAttr Identifier 68 71 +hi def link nixFuncArg Identifier 72 + + 73 + +syn sync maxlines=20000 74 + +syn sync minlines=50000 69 75 + 70 76 +let b:current_syntax = "nix" 71 77 + 78 + +" thanks to iElectric 72 79 +" scan backwards to find begining of multiline statements 73 80 +syn sync ccomment nixMultiLineComment minlines=10 maxlines=500 74 81 +syn sync ccomment nixStringIndented minlines=10 maxlines=500 75 82 +syn sync ccomment nixString maxlines=10 83 + diff --git a/runtime/ftplugin/nix.vim b/runtime/ftplugin/nix.vim 84 + new file mode 100644 85 + --- /dev/null 86 + +++ b/runtime/ftplugin/nix.vim 87 + @@ -0,0 +1,2 @@ 88 + +" coding conventions 89 + +setlocal sw=2 ts=2 expandtab