Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: LnL7/vim-nix
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 6affa2b211b02a907ab3bc7064821be57ae93446
Choose a base ref
..
head repository: LnL7/vim-nix
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 0def8020f152a51c011a707680780dac61a8989a
Choose a head ref
Showing with 17 additions and 7 deletions.
  1. +6 −0 README.md
  2. +2 −1 ftdetect/nix.vim
  3. +9 −6 syntax/nix.vim
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -16,6 +16,12 @@ Features included so far:

### Plugin managers

As of version 8.0 Vim supports packages. Clone this repository inside `~/.vim/pack/all/start`:

```bash
git clone https://github.com/LnL7/vim-nix.git ~/.vim/pack/all/start/vim-nix
```

The most common plugin managers include [vim-plug][vim-plug],
[NeoBundle][neobundle], [Vundle][vundle] and [pathogen.vim][pathogen].

3 changes: 2 additions & 1 deletion ftdetect/nix.vim
Original file line number Diff line number Diff line change
@@ -3,4 +3,5 @@
" Maintainer: Daiderd Jordan <daiderd@gmail.com>
" URL: https://github.com/LnL7/vim-nix

au BufRead,BufNewFile *.nix set filetype=nix
au BufRead,BufNewFile *.nix setf nix
au BufRead,BufNewFile flake.lock setf json
15 changes: 9 additions & 6 deletions syntax/nix.vim
Original file line number Diff line number Diff line change
@@ -39,6 +39,8 @@ syn match nixStringSpecial /''['$]/ contained
syn match nixStringSpecial /\$\$/ contained
syn match nixStringSpecial /''\\[nrt]/ contained

syn match nixSimpleStringSpecial /\$\$/ contained

syn match nixInvalidSimpleStringEscape /\\[^nrt"\\$]/ contained
syn match nixInvalidStringEscape /''\\[^nrt]/ contained

@@ -60,7 +62,7 @@ syn match nixAttribute "[a-zA-Z_][a-zA-Z0-9_'-]*\ze\%([^a-zA-Z0-9_'.-]\|$\)" con
syn region nixAttributeAssignment start="=" end="\ze;" contained contains=@nixExpr
syn region nixAttributeDefinition start=/\ze[a-zA-Z_"$]/ end=";" contained contains=nixComment,nixAttribute,nixInterpolation,nixSimpleString,nixAttributeDot,nixAttributeAssignment

syn region nixInheritAttributeScope start="(" end=")" contained contains=nixComment,nixAttributeDot
syn region nixInheritAttributeScope start="(" end="\ze)" contained contains=@nixExpr
syn region nixAttributeDefinition matchgroup=nixInherit start="\<inherit\>" end=";" contained contains=nixComment,nixInheritAttributeScope,nixAttribute

syn region nixAttributeSet start="{" end="}" contains=nixComment,nixAttributeDefinition
@@ -108,7 +110,7 @@ syn region nixFunctionArgument start="{\ze\%(\s\|#.\{-\}\n\|\n\|/\*\_.\{-\}\*/\)
syn region nixFunctionArgument start="{\ze\%(\s\|#.\{-\}\n\|\n\|/\*\_.\{-\}\*/\)*}\%(\%(\s\|#.\{-\}\n\|\n\|/\*\_.\{-\}\*/\)*@\%(\s\|#.\{-\}\n\|\n\|/\*\_.\{-\}\*/\)*[a-zA-Z_][a-zA-Z0-9_'-]*\)\%(\s\|#.\{-\}\n\|\n\|/\*\_.\{-\}\*/\)*:" end="}" contains=nixComment nextgroup=nixArgOperator

" vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
syn match nixSimpleFunctionArgument "[a-zA-Z_][a-zA-Z0-9_'-]*\ze\%(\s\|#.\{-\}\n\|\n\|/\*\_.\{-\}\*/\)*:/\@!"
syn match nixSimpleFunctionArgument "[a-zA-Z_][a-zA-Z0-9_'-]*\ze\%(\s\|#.\{-\}\n\|\n\|/\*\_.\{-\}\*/\)*:\([\n ]\)\@="

syn region nixList matchgroup=nixListBracket start="\[" end="\]" contains=@nixExpr

@@ -121,7 +123,7 @@ syn region nixWithExpr matchgroup=nixWithExprKeyword start="\<with\>" matchgroup

syn region nixAssertExpr matchgroup=nixAssertKeyword start="\<assert\>" matchgroup=NONE end=";" contains=@nixExpr

syn cluster nixExpr contains=nixBoolean,nixNull,nixOperator,nixParen,nixInteger,nixRecKeyword,nixConditional,nixBuiltin,nixSimpleBuiltin,nixComment,nixFunctionCall,nixFunctionArgument,nixSimpleFunctionArgument,nixPath,nixHomePath,nixSearchPathRef,nixURI,nixAttributeSet,nixList,nixSimpleString,nixString,nixLetExpr,nixIfExpr,nixWithExpr,nixAssertExpr,nixInterpolation
syn cluster nixExpr contains=nixBoolean,nixNull,nixOperator,nixParen,nixInteger,nixRecKeyword,nixConditional,nixBuiltin,nixSimpleBuiltin,nixComment,nixFunctionCall,nixFunctionArgument,nixArgOperator,nixSimpleFunctionArgument,nixPath,nixHomePath,nixSearchPathRef,nixURI,nixAttributeSet,nixList,nixSimpleString,nixString,nixLetExpr,nixIfExpr,nixWithExpr,nixAssertExpr,nixInterpolation

" These definitions override @nixExpr and have to come afterwards:

@@ -130,7 +132,7 @@ syn match nixInterpolationParam "[a-zA-Z_][a-zA-Z0-9_'-]*\%(\.[a-zA-Z_][a-zA-Z0-
" Non-namespaced Nix builtins as of version 2.0:
syn keyword nixSimpleBuiltin
\ abort baseNameOf derivation derivationStrict dirOf fetchGit
\ fetchMercurial fetchTarball import isNull map placeholder removeAttrs
\ fetchMercurial fetchTarball import isNull map mapAttrs placeholder removeAttrs
\ scopedImport throw toString

@@ -143,12 +145,13 @@ syn keyword nixNamespacedBuiltin contained
\ findFile foldl' fromJSON functionArgs genList \ genericClosure getAttr
\ getEnv hasAttr hasContext hashString head import intersectAttrs isAttrs
\ isBool isFloat isFunction isInt isList isNull isString langVersion
\ length lessThan listToAttrs map match mul nixPath nixVersion
\ length lessThan listToAttrs map mapAttrs match mul nixPath nixVersion
\ parseDrvName partition path pathExists placeholder readDir readFile
\ removeAttrs replaceStrings scopedImport seq sort split splitVersion
\ storeDir storePath stringLength sub substring tail throw toFile toJSON
\ toPath toString toXML trace tryEval typeOf unsafeDiscardOutputDependency
\ unsafeDiscardStringContext unsafeGetAttrPos valueSize
\ unsafeDiscardStringContext unsafeGetAttrPos valueSize fromTOML bitAnd
\ bitOr bitXor floor ceil
syn match nixBuiltin "builtins\.[a-zA-Z']\+"he=s+9 contains=nixComment,nixNamespacedBuiltin