summary refs log tree commit diff
path: root/pkgs/applications/editors/vim/ft-nix-support.patch
blob: 416ec18cf2cad7aa4c7a508d42669ee126428117 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
diff --git a/runtime/filetype.vim b/runtime/filetype.vim
index a8e6261..2b008fc 100644
--- a/runtime/filetype.vim
+++ b/runtime/filetype.vim
@@ -2258,6 +2258,9 @@ au BufNewFile,BufRead *.zsql			call s:SQL()
 " Z80 assembler asz80
 au BufNewFile,BufRead *.z8a			setf z8a
 
+" NIX
+au BufNewFile,BufRead *.nix		setf nix
+
 augroup END
 
 
@@ -2440,3 +2443,5 @@ endfunc
 " Restore 'cpoptions'
 let &cpo = s:cpo_save
 unlet s:cpo_save
+
+
diff --git a/runtime/syntax/nix.vim b/runtime/syntax/nix.vim
new file mode 100644
index 0000000..a2f9918
--- /dev/null
+++ b/runtime/syntax/nix.vim
@@ -0,0 +1,56 @@
+" Vim syntax file
+" Language:	nix
+" Maintainer:	Marc Weber <marco-oweber@gmx.de>
+"               Modify and commit if you feel that way
+" Last Change:	2011 Jun
+"
+" this syntax file can be still be enhanced very much..
+" Don't ask, do it :-)
+" This file (github.com/MarcWeber/vim-addon-nix) is periodically synced with
+" the patch found in vim_configurable (nixpkgs)
+
+" Quit when a (custom) syntax file was already loaded
+if exists("b:current_syntax")
+  finish
+endif
+
+
+sy cluster nixStrings contains=nixStringParam,nixStringIndented
+
+syn keyword	nixKeyword	let throw inherit import true false null with
+syn keyword	nixConditional	if else then
+syn keyword     nixBrace        ( ) { } =
+syn keyword     nixBuiltin         __currentSystem __currentTime __isFunction __getEnv __trace __toPath __pathExists 
+  \ __readFile __toXML __toFile __filterSource __attrNames __getAttr __hasAttr __isAttrs __listToAttrs __isList 
+  \ __head __tail __add __sub __lessThan __substring __stringLength
+
+syn region nixStringIndented start=+''+ skip=+'''\|''${\|"+ end=+''+ contains=nixStringParam
+" syn region nixString         start=+"+ skip=+\\"+ end=+"+
+syn match nixAttr "\w\+\ze\s*="
+syn match nixFuncArg "\zs\w\+\ze\s*:"
+syn region nixStringParam start=+\${+ end=+}+ contains=@nixStrings
+syn region nixMultiLineComment start=+/\*+ skip=+\\"+ end=+\*/+
+syn match  nixEndOfLineComment "#.*$"
+
+hi def link nixKeyword       Keyword
+hi def link nixConditional   Conditional
+hi def link nixBrace         Special
+hi def link nixString        String
+hi def link nixStringIndented String
+hi def link nixBuiltin       Special
+hi def link nixStringParam   Macro
+hi def link nixMultiLineComment Comment
+hi def link nixEndOfLineComment Comment
+hi def link nixAttr        Identifier
+hi def link nixFuncArg     Identifier
+
+syn sync maxlines=20000
+syn sync minlines=50000
+
+let b:current_syntax = "nix"
+
+" thanks to domenkozar
+" scan backwards to find begining of multiline statements
+syn sync ccomment nixMultiLineComment minlines=10 maxlines=500
+syn sync ccomment nixStringIndented minlines=10 maxlines=500
+syn sync ccomment nixString maxlines=10
diff --git a/runtime/ftplugin/nix.vim b/runtime/ftplugin/nix.vim
new file mode 100644
--- /dev/null
+++ b/runtime/ftplugin/nix.vim
@@ -0,0 +1,2 @@
+" coding conventions
+setlocal sw=2 ts=2 expandtab