From bb6b0a9641128176f7a0c515d19005387f09ed47 Mon Sep 17 00:00:00 2001 From: "Andrew R. M" Date: Thu, 6 Apr 2017 07:28:34 -0400 Subject: [PATCH] Added nix filetype recognition as a submodule --- .gitmodules | 3 + vim/.vim/bundle/filetype-nix | 1 + vim/.vim/bundle/filetype-nix/.travis.yml | 6 - vim/.vim/bundle/filetype-nix/LICENSE | 19 - vim/.vim/bundle/filetype-nix/README.md | 48 --- vim/.vim/bundle/filetype-nix/default.nix | 47 --- vim/.vim/bundle/filetype-nix/ftdetect/nix.vim | 7 - vim/.vim/bundle/filetype-nix/ftplugin/nix.vim | 13 - vim/.vim/bundle/filetype-nix/indent/nix.vim | 62 ---- vim/.vim/bundle/filetype-nix/syntax/nix.vim | 183 ---------- vim/.vim/bundle/filetype-nix/test/nix.vader | 326 ------------------ .../bundle/filetype-nix/test/run-tests.sh | 3 - vim/.vim/bundle/filetype-nix/test/vimrc | 5 - 13 files changed, 4 insertions(+), 719 deletions(-) create mode 160000 vim/.vim/bundle/filetype-nix delete mode 100644 vim/.vim/bundle/filetype-nix/.travis.yml delete mode 100644 vim/.vim/bundle/filetype-nix/LICENSE delete mode 100644 vim/.vim/bundle/filetype-nix/README.md delete mode 100644 vim/.vim/bundle/filetype-nix/default.nix delete mode 100644 vim/.vim/bundle/filetype-nix/ftdetect/nix.vim delete mode 100644 vim/.vim/bundle/filetype-nix/ftplugin/nix.vim delete mode 100644 vim/.vim/bundle/filetype-nix/indent/nix.vim delete mode 100644 vim/.vim/bundle/filetype-nix/syntax/nix.vim delete mode 100644 vim/.vim/bundle/filetype-nix/test/nix.vader delete mode 100755 vim/.vim/bundle/filetype-nix/test/run-tests.sh delete mode 100644 vim/.vim/bundle/filetype-nix/test/vimrc diff --git a/.gitmodules b/.gitmodules index 796e662..15eafc1 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "vim/.vim/bundle/slime"] path = vim/.vim/bundle/slime url = http://github.com/jpalardy/vim-slime +[submodule "vim/.vim/bundle/filetype-nix"] + path = vim/.vim/bundle/filetype-nix + url = https://github.com/LnL7/vim-nix diff --git a/vim/.vim/bundle/filetype-nix b/vim/.vim/bundle/filetype-nix new file mode 160000 index 0000000..b06cccd --- /dev/null +++ b/vim/.vim/bundle/filetype-nix @@ -0,0 +1 @@ +Subproject commit b06cccd8ff61149b13d3fc8b7e0d06caa55c9888 diff --git a/vim/.vim/bundle/filetype-nix/.travis.yml b/vim/.vim/bundle/filetype-nix/.travis.yml deleted file mode 100644 index 27e8060..0000000 --- a/vim/.vim/bundle/filetype-nix/.travis.yml +++ /dev/null @@ -1,6 +0,0 @@ -language: vim - -before_script: | - git clone https://github.com/junegunn/vader.vim.git -script: | - ./test/run-tests.sh diff --git a/vim/.vim/bundle/filetype-nix/LICENSE b/vim/.vim/bundle/filetype-nix/LICENSE deleted file mode 100644 index 16dc3e8..0000000 --- a/vim/.vim/bundle/filetype-nix/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2014 - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/vim/.vim/bundle/filetype-nix/README.md b/vim/.vim/bundle/filetype-nix/README.md deleted file mode 100644 index e5bcc3c..0000000 --- a/vim/.vim/bundle/filetype-nix/README.md +++ /dev/null @@ -1,48 +0,0 @@ -# vim-nix - -[![Build Status](https://travis-ci.org/LnL7/vim-nix.svg?branch=master)](https://travis-ci.org/LnL7/vim-nix) - -Support for writing [Nix expressions](http://nixos.org/nix/manual/#chap-writing-nix-expressions) in vim. - -Features included so far: - -* Syntax highlighting for Nix -* Filetype detection for `.nix` files -* Automatic indentation - - -## Installation - -### Plugin managers - -The most common plugin managers include [vim-plug][vim-plug], -[NeoBundle][neobundle], [Vundle][vundle] and [pathogen.vim][pathogen]. - -With pathogen.vim, just clone this repository inside `~/.vim/bundle`: - -```bash -git clone https://github.com/LnL7/vim-nix.git ~/.vim/bundle -``` - -With the other plugin managers, just follow the instructions on the homepage of -each plugin. In general, you have to add a line to your `~/.vimrc`: - -```viml -" vim-plug -Plug 'LnL7/vim-nix' -" NeoBundle -NeoBundle 'LnL7/vim-nix' -" Vundle -Plugin 'LnL7/vim-nix' -``` - -### Manual installation - -Copy the contents of each directory in the respective directories inside -`~/.vim`. - - -[vim-plug]: https://github.com/junegunn/vim-plug -[vundle]: https://github.com/gmarik/Vundle.vim -[neobundle]: https://github.com/Shougo/neobundle.vim -[pathogen]: https://github.com/tpope/vim-pathogen diff --git a/vim/.vim/bundle/filetype-nix/default.nix b/vim/.vim/bundle/filetype-nix/default.nix deleted file mode 100644 index 70f3fc0..0000000 --- a/vim/.vim/bundle/filetype-nix/default.nix +++ /dev/null @@ -1,47 +0,0 @@ -{ pkgs ? import {} }: - -let - inherit (pkgs) stdenv fetchFromGitHub writeText runCommand; - - vim-vader = fetchFromGitHub { - owner = "junegunn"; - repo = "vader.vim"; - rev = "ad2c752435baba9e7544d0046f0277c3573439bd"; - sha256 = "0yvnah4lxk5w5qidc3y5nvl6lpi8rcv26907b3w7vjskqc935b8f"; - }; - - vim-nix = ./.; - - rcFile = writeText "vimrc" '' - filetype off - set rtp+=${vim-vader} - set rtp+=${vim-nix} - filetype plugin indent on - syntax enable - ''; - - vim = "${pkgs.vim}/bin/vim"; - - env = stdenv.mkDerivation { - name = "build-environment"; - shellHook = '' - alias vim='${vim} -XNu ${rcFile} -i NONE' - ''; - }; - -in stdenv.mkDerivation { - name = "vim-nix-2016-08-07"; - - src = ./.; - - installPhase = '' - mkdir -p $out - cp -r ftdetect ftplugin indent syntax $out - ''; - - checkPhase = '' - ( ${vim} -XNu ${rcFile} -i NONE -c 'Vader! test/*.vader' ) |& tee vim-nix-test.log >&2 - ''; - - doCheck = true; -} // { inherit env; } diff --git a/vim/.vim/bundle/filetype-nix/ftdetect/nix.vim b/vim/.vim/bundle/filetype-nix/ftdetect/nix.vim deleted file mode 100644 index bb03a89..0000000 --- a/vim/.vim/bundle/filetype-nix/ftdetect/nix.vim +++ /dev/null @@ -1,7 +0,0 @@ -" Vim filetype detect -" Language: Nix -" Maintainer: Daiderd Jordan -" URL: https://github.com/LnL7/vim-nix - -au BufRead,BufNewFile *.nix set filetype=nix -au FileType nix setl sw=2 sts=2 et iskeyword+=- diff --git a/vim/.vim/bundle/filetype-nix/ftplugin/nix.vim b/vim/.vim/bundle/filetype-nix/ftplugin/nix.vim deleted file mode 100644 index b739fc7..0000000 --- a/vim/.vim/bundle/filetype-nix/ftplugin/nix.vim +++ /dev/null @@ -1,13 +0,0 @@ -" Vim filetype plugin -" Language: Nix -" Maintainer: Daiderd Jordan -" URL: https://github.com/LnL7/vim-nix - -if (exists("b:did_ftplugin")) - finish -endif -let b:did_ftplugin = 1 - - -setlocal comments=:# -setlocal commentstring=#\ %s diff --git a/vim/.vim/bundle/filetype-nix/indent/nix.vim b/vim/.vim/bundle/filetype-nix/indent/nix.vim deleted file mode 100644 index e5a4eb0..0000000 --- a/vim/.vim/bundle/filetype-nix/indent/nix.vim +++ /dev/null @@ -1,62 +0,0 @@ -" Vim indent file -" Language: Nix -" Maintainer: Daiderd Jordan -" URL: https://github.com/LnL7/vim-nix - -if exists("b:did_indent") - finish -endif -let b:did_indent = 1 - -setlocal indentexpr=GetNixIndent() - -if exists("*GetNixIndent") - finish -endif - -let s:cpo_save = &cpo -set cpo&vim - -let s:skip_syntax = '\%(Comment\|String\)$' -let s:block_open = '\%({\|[\)' -let s:block_close = '\%(}\|]\)' - -function! GetNixIndent() - let lnum = prevnonblank(v:lnum - 1) - let ind = indent(lnum) - - " At the start of the file use zero indent. - if lnum == 0 - return 0 - endif - - if synIDattr(synID(v:lnum, 1, 1), "name") !~ s:skip_syntax - let current_line = getline(v:lnum) - let last_line = getline(lnum) - - if last_line =~ s:block_open . '\s*$' - let ind += &sw - endif - - if current_line =~ '^\s*' . s:block_close - let ind -= &sw - endif - - if last_line =~ '\' - let ind -= &sw - endif - endif - - return ind -endfunction - -let &cpo = s:cpo_save -unlet s:cpo_save diff --git a/vim/.vim/bundle/filetype-nix/syntax/nix.vim b/vim/.vim/bundle/filetype-nix/syntax/nix.vim deleted file mode 100644 index c7d8d20..0000000 --- a/vim/.vim/bundle/filetype-nix/syntax/nix.vim +++ /dev/null @@ -1,183 +0,0 @@ -" Vim syntax file -" Language: Nix -" Maintainer: Daiderd Jordan -" URL: https://github.com/LnL7/vim-nix - -if exists("b:current_syntax") - finish -endif - -syn keyword nixBoolean true false -syn keyword nixNull null -syn keyword nixRecKeyword rec - -syn keyword nixOperator or -syn match nixOperator '!=\|!' -syn match nixOperator '<=\?' -syn match nixOperator '>=\?' -syn match nixOperator '&&' -syn match nixOperator '//\=' -syn match nixOperator '==' -syn match nixOperator '?' -syn match nixOperator '||' -syn match nixOperator '++\=' -syn match nixOperator '-' -syn match nixOperator '\*' -syn match nixOperator '->' - -syn match nixParen '[()]' -syn match nixInteger '\d\+' - -syn keyword nixTodo FIXME NOTE TODO OPTIMIZE XXX HACK contained -syn match nixComment '#.*' contains=nixTodo,@Spell -syn region nixComment start=+/\*+ end=+\*/+ contains=nixTodo,@Spell - -syn region nixInterpolation matchgroup=nixInterpolationDelimiter start="\${" end="}" contained contains=@nixExpr,nixInterpolationParam - -syn match nixSimpleStringSpecial /\\["nrt\\$]/ contained -syn match nixInterpolationSpecial /''['$]/ contained - -syn region nixSimpleString matchgroup=nixStringDelimiter start=+"+ skip=+\\"+ end=+"+ contains=nixInterpolation,nixSimpleStringSpecial -syn region nixString matchgroup=nixStringDelimiter start=+''+ skip=+''['$]+ end=+''+ contains=nixInterpolation,nixInterpolationSpecial - -syn match nixFunctionCall "[a-zA-Z_][a-zA-Z0-9_'-]*" - -syn match nixPath "[a-zA-Z0-9._+-]*\%(/[a-zA-Z0-9._+-]\+\)\+" -syn match nixHomePath "\~\%(/[a-zA-Z0-9._+-]\+\)\+" -syn match nixSearchPath "[a-zA-Z0-9._+-]\+\%(\/[a-zA-Z0-9._+-]\+\)*" contained -syn match nixPathDelimiter "[<>]" contained -syn match nixSearchPathRef "<[a-zA-Z0-9._+-]\+\%(\/[a-zA-Z0-9._+-]\+\)*>" contains=nixSearchPath,nixPathDelimiter -syn match nixURI "[a-zA-Z][a-zA-Z0-9.+-]*:[a-zA-Z0-9%/?:@&=$,_.!~*'+-]\+" - -syn match nixAttributeDot "\." contained -syn match nixAttribute "[a-zA-Z_][a-zA-Z0-9_'-]*\ze\%([^a-zA-Z0-9_'-.]\|$\)" contained -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 nixAttributeDefinition matchgroup=nixInherit start="\" matchgroup=NONE end=";" contained contains=nixComment,nixInheritAttributeScope,nixAttribute - -syn region nixAttributeSet start="{" end="}" contains=nixComment,nixAttributeDefinition - -" vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv -syn region nixArgumentDefinitionWithDefault matchgroup=nixArgumentDefinition start="[a-zA-Z_][a-zA-Z0-9_'-]*\ze\%(\s\|#.\{-\}\n\|\n\|/\*\_.\{-\}\*/\)*?\@=" matchgroup=NONE end="[,}]\@=" transparent contained contains=@nixExpr -" vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv -syn match nixArgumentDefinition "[a-zA-Z_][a-zA-Z0-9_'-]*\ze\%(\s\|#.\{-\}\n\|\n\|/\*\_.\{-\}\*/\)*[,}]\@=" contained -syn match nixArgumentEllipsis "\.\.\." contained -syn match nixArgumentSeparator "," contained - -" vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv -syn match nixArgOperator '@\%(\s\|#.\{-\}\n\|\n\|/\*\_.\{-\}\*/\)*[a-zA-Z_][a-zA-Z0-9_'-]*\%(\s\|#.\{-\}\n\|\n\|/\*\_.\{-\}\*/\)*:'he=s+1 contained contains=nixAttribute - -" vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv -syn match nixArgOperator '[a-zA-Z_][a-zA-Z0-9_'-]*\%(\s\|#.\{-\}\n\|\n\|/\*\_.\{-\}\*/\)*@'hs=e-1 contains=nixAttribute nextgroup=nixFunctionArgument - -" This is a bit more complicated, because function arguments can be passed in a -" very similar form on how attribute sets are defined and two regions with the -" same start patterns will shadow each other. Instead of a region we could use a -" match on {\_.\{-\}}, which unfortunately doesn't take nesting into account. -" -" So what we do instead is that we look forward until we are sure that it's a -" function argument. Unfortunately, we need to catch comments and both vertical -" and horizontal white space, which the following regex should hopefully do: -" -" "\%(\s\|#.\{-\}\n\|\n\|/\*\_.\{-\}\*/\)*" -" -" It is also used throught the whole file and is marked with 'v's as well. -" -" Fortunately the matching rules for function arguments are much simpler than -" for real attribute sets, because we can stop when we hit the first ellipsis or -" default value operator, but we also need to paste the "whitespace & comments -" eating" regex all over the place (marked with 'v's): -" -" Region match 1: { foo ? ... } or { foo, ... } or { ... } (ellipsis) -" vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv {----- identifier -----}vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv -syn region nixFunctionArgument start="{\ze\%(\s\|#.\{-\}\n\|\n\|/\*\_.\{-\}\*/\)*\%([a-zA-Z_][a-zA-Z0-9_'-]*\%(\s\|#.\{-\}\n\|\n\|/\*\_.\{-\}\*/\)*[,?}]\|\.\.\.\)" end="}" contains=nixComment,nixArgumentDefinitionWithDefault,nixArgumentDefinition,nixArgumentEllipsis,nixArgumentSeparator nextgroup=nixArgOperator - -" Now it gets more tricky, because we need to look forward for the colon, but -" there could be something like "{}@foo:", even though it's highly unlikely. -" -" Region match 2: {} -" vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv@vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv{----- identifier -----} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv -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 region nixList matchgroup=nixListBracket start="\[" end="\]" contains=@nixExpr - -syn region nixLetExpr matchgroup=nixLetExprKeyword start="\" end="\" contains=nixComment,nixAttributeDefinition - -syn keyword nixIfExprKeyword then contained -syn region nixIfExpr matchgroup=nixIfExprKeyword start="\" end="\" contains=@nixExpr,nixIfExprKeyword - -syn region nixWithExpr matchgroup=nixWithExprKeyword start="\" matchgroup=NONE end=";" contains=@nixExpr - -syn region nixAssertExpr matchgroup=nixAssertKeyword start="\" 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 - -" These definitions override @nixExpr and have to come afterwards: - -syn match nixInterpolationParam "[a-zA-Z_][a-zA-Z0-9_'-]*\%(\.[a-zA-Z_][a-zA-Z0-9_'-]*\)*" contained - -" Non-namespaced Nix builtins as of version 1.10: -syn keyword nixSimpleBuiltin - \ abort baseNameOf derivation dirOf fetchTarball import map removeAttrs - \ throw toString - -" Namespaced and non-namespaced Nix builtins as of version 1.10: -syn keyword nixNamespacedBuiltin contained - \ abort add all any attrNames attrValues baseNameOf compareVersions - \ concatLists currentSystem deepSeq derivation dirOf div elem elemAt - \ fetchTarball fetchurl filter filterSource foldl' fromJSON genList - \ getAttr getEnv hasAttr hashString head import intersectAttrs isAttrs - \ isBool isFunction isInt isList isString length lessThan listToAttrs map - \ mul parseDrvName pathExists readDir readFile removeAttrs replaceStrings - \ seq sort stringLength sub substring tail throw toFile toJSON toPath - \ toString toXML trace typeOf - -syn match nixBuiltin "builtins\.[a-zA-Z']\+"he=s+9 contains=nixComment,nixNamespacedBuiltin - -hi def link nixArgOperator Operator -hi def link nixArgumentDefinition Identifier -hi def link nixArgumentEllipsis Operator -hi def link nixAssertKeyword Keyword -hi def link nixAttribute Identifier -hi def link nixAttributeDot Operator -hi def link nixBoolean Boolean -hi def link nixBuiltin Special -hi def link nixComment Comment -hi def link nixConditional Conditional -hi def link nixHomePath Include -hi def link nixIfExprKeyword Keyword -hi def link nixInherit Keyword -hi def link nixInteger Integer -hi def link nixInterpolation Macro -hi def link nixInterpolationDelimiter Delimiter -hi def link nixInterpolationParam Macro -hi def link nixInterpolationSpecial Special -hi def link nixLetExprKeyword Keyword -hi def link nixNamespacedBuiltin Special -hi def link nixNull Constant -hi def link nixOperator Operator -hi def link nixPath Include -hi def link nixPathDelimiter Delimiter -hi def link nixRecKeyword Keyword -hi def link nixSearchPath Include -hi def link nixSimpleBuiltin Keyword -hi def link nixSimpleFunctionArgument Identifier -hi def link nixSimpleString String -hi def link nixSimpleStringSpecial SpecialChar -hi def link nixString String -hi def link nixStringDelimiter Delimiter -hi def link nixTodo Todo -hi def link nixURI Include -hi def link nixWithExprKeyword Keyword - -" This could lead up to slow syntax highlighting for large files, but usually -" large files such as all-packages.nix are one large attribute set, so if we'd -" use sync patterns we'd have to go back to the start of the file anyway -syn sync fromstart - -let b:current_syntax = "nix" diff --git a/vim/.vim/bundle/filetype-nix/test/nix.vader b/vim/.vim/bundle/filetype-nix/test/nix.vader deleted file mode 100644 index 6efb17b..0000000 --- a/vim/.vim/bundle/filetype-nix/test/nix.vader +++ /dev/null @@ -1,326 +0,0 @@ -Given nix (attribute): - { - foo = pkgs.callPackage ./examples/foo {}; - } - -Do (reindent): - vip= - -Expect (indentation): -~~~~~~~ - { - foo = pkgs.callPackage ./examples/foo {}; - } -~~~~~~~ - -Execute (syntax): - AssertEqual SyntaxOf('foo'), 'nixAttribute' - -Given nix (attribute-assignment): - { - foo = rec { }; - } - -Execute (syntax): - AssertEqual SyntaxOf('foo'), 'nixAttribute' - AssertEqual SyntaxOf('rec'), 'nixRecKeyword' - -Given nix (attribute-path): - { - foo.bar.baz = 2; - } - -Execute (syntax): - AssertNotEqual SyntaxOf('foo'), 'nixAttribute' - AssertNotEqual SyntaxOf('bar'), 'nixAttribute' - AssertEqual SyntaxOf('\.'), 'nixAttributeDot' - AssertEqual SyntaxOf('baz'), 'nixAttribute' - AssertEqual SyntaxOf('2'), 'nixInteger' - -Given nix (attribute-nested): - { - a = { - b = { - c = "2}"; - }; - }; - } - -Execute (syntax): - AssertEqual SyntaxOf('a'), 'nixAttribute' - AssertEqual SyntaxOf('b'), 'nixAttribute' - AssertEqual SyntaxOf('c'), 'nixAttribute' - AssertEqual SyntaxOf('2}'), 'nixSimpleString' - -Given nix (attribute-inherit): - { - inherit (a.b.c) foo; - inherit bar baz; - } - -Execute (syntax): - AssertNotEqual SyntaxOf('c'), 'nixAttribute' - AssertEqual SyntaxOf('inherit'), 'nixInherit' - AssertEqual SyntaxOf('('), 'nixInheritAttributeScope' - AssertEqual SyntaxOf(')'), 'nixInheritAttributeScope' - AssertEqual SyntaxOf('\.'), 'nixAttributeDot' - AssertEqual SyntaxOf('foo'), 'nixAttribute' - AssertEqual SyntaxOf('bar'), 'nixAttribute' - AssertEqual SyntaxOf('baz'), 'nixAttribute' - -Given nix (list): - { - foo = [ - a - b - ]; - } - -Do (reindent): - vip= - -Expect (indentation): -~~~~~~~ - { - foo = [ - a - b - ]; - } -~~~~~~~ - -Execute (syntax): - AssertEqual SyntaxOf('foo'), 'nixAttribute' - AssertEqual SyntaxOf('a'), 'nixFunctionCall' - AssertEqual SyntaxOf('b'), 'nixFunctionCall' - -Given nix (string): - "https://github.com/${owner}/${repo}/archive/${rev}.tar.gz" - -Execute (syntax): - AssertEqual SyntaxOf('"'), 'nixStringDelimiter' - AssertEqual SyntaxOf('https'), 'nixSimpleString' - AssertEqual SyntaxOf('${'), 'nixInterpolationDelimiter' - AssertEqual SyntaxOf('}'), 'nixInterpolationDelimiter' - AssertEqual SyntaxOf('owner'), 'nixInterpolationParam' - AssertEqual SyntaxOf('repo'), 'nixInterpolationParam' - AssertEqual SyntaxOf('rev'), 'nixInterpolationParam' - -Given nix (multiline-string): - '' - line1 ${ref1} - ${ref2} line2 - line3 ${ref3} - '' - -Execute (syntax): - AssertEqual SyntaxOf('line1'), 'nixString' - AssertEqual SyntaxOf('line2'), 'nixString' - AssertEqual SyntaxOf('line3'), 'nixString' - AssertEqual SyntaxOf('ref1'), 'nixInterpolationParam' - AssertEqual SyntaxOf('ref2'), 'nixInterpolationParam' - AssertEqual SyntaxOf('ref3'), 'nixInterpolationParam' - -Given nix (url): - https://github.com/LnL7/vim-nix - -Execute (syntax): - AssertEqual SyntaxOf('https'), 'nixURI' - AssertEqual SyntaxOf('github'), 'nixURI' - AssertEqual SyntaxOf('nix'), 'nixURI' - -Given nix (nix-search-path): - assert ; - -Execute (syntax): - AssertEqual SyntaxOf('<'), 'nixPathDelimiter' - AssertEqual SyntaxOf('foo'), 'nixSearchPath' - AssertEqual SyntaxOf('-'), 'nixSearchPath' - AssertEqual SyntaxOf('bar'), 'nixSearchPath' - AssertEqual SyntaxOf('/'), 'nixSearchPath' - AssertEqual SyntaxOf('\.'), 'nixSearchPath' - AssertEqual SyntaxOf('>'), 'nixPathDelimiter' - -Given nix (nix-paths): - [ ~/homefile ./. /etc/passwd ] - -Execute (syntax): - AssertEqual SyntaxOf('\~/homefile'), 'nixHomePath' - AssertEqual SyntaxOf('\./\.'), 'nixPath' - AssertEqual SyntaxOf('/etc/passwd'), 'nixPath' - -Given nix (let): - let - foo = true; - bar = false; - in { - result = foo && bar; - } - -Do (reindent): - vip= - -Expect (indentation): -~~~~~~~ - let - foo = true; - bar = false; - in { - result = foo && bar; - } -~~~~~~~ - -Execute (syntax): - AssertEqual SyntaxOf('let'), 'nixLetExprKeyword' - AssertEqual SyntaxOf('in'), 'nixLetExprKeyword' - AssertEqual SyntaxOf('foo'), 'nixAttribute' - AssertEqual SyntaxOf('bar'), 'nixAttribute' - AssertEqual SyntaxOf('result'), 'nixAttribute' - AssertEqual SyntaxOf('&&'), 'nixOperator' - -Given nix (builtins): - builtins.doesntexist (builtins.map id [ - hashString (builtins.fetchurl (toString "abort")) - ]) - -Execute (syntax): - AssertNotEqual SyntaxOf('doesntexist'), 'nixBuiltin' - AssertEqual SyntaxOf('map'), 'nixNamespacedBuiltin' - AssertNotEqual SyntaxOf('hashString'), 'nixBuiltin' - AssertNotEqual SyntaxOf('hashString'), 'nixNamespacedBuiltin' - AssertEqual SyntaxOf('builtins'), 'nixBuiltin' - AssertEqual SyntaxOf('\.'), 'nixBuiltin' - AssertEqual SyntaxOf('fetchurl'), 'nixNamespacedBuiltin' - AssertEqual SyntaxOf('toString'), 'nixSimpleBuiltin' - AssertEqual SyntaxOf('abort'), 'nixSimpleString' - -Given nix (simple-string-escape): - "foo\nbar\"end\${xxx}" - -Execute (syntax): - AssertEqual SyntaxAt(1, 1), 'nixStringDelimiter' - AssertEqual SyntaxOf('foo'), 'nixSimpleString' - AssertEqual SyntaxOf('\\n'), 'nixSimpleStringSpecial' - AssertEqual SyntaxOf('bar'), 'nixSimpleString' - AssertEqual SyntaxOf('\\"'), 'nixSimpleStringSpecial' - AssertEqual SyntaxOf('end'), 'nixSimpleString' - AssertEqual SyntaxOf('\$'), 'nixSimpleStringSpecial' - AssertEqual SyntaxOf('{'), 'nixSimpleString' - AssertEqual SyntaxOf('xxx'), 'nixSimpleString' - AssertEqual SyntaxOf('}'), 'nixSimpleString' - AssertEqual SyntaxAt(1, 22), 'nixStringDelimiter' - -Given nix (multiline-string-escape): - '' - foo'''bar - ''${xxx} - '' - -Execute (syntax): - AssertEqual SyntaxOf('foo'), 'nixString' - AssertEqual SyntaxOf("'''"), 'nixInterpolationSpecial' - AssertEqual SyntaxOf('bar'), 'nixString' - AssertEqual SyntaxOf("''\\$"), 'nixInterpolationSpecial' - AssertEqual SyntaxOf('{'), 'nixString' - AssertEqual SyntaxOf('xxx'), 'nixString' - AssertEqual SyntaxOf('}'), 'nixString' - -Given nix (lambda-attrs): - { # very descriptive comment - foo - /**/ - ? # another comment - /* yet another comment */ - # default value here: - 1 - , bar ? "xxx" - , yyy - # last comment - , ... - }: { - result = null; - } - -Execute (syntax): - AssertEqual SyntaxOf('very descriptive comment'), 'nixComment' - AssertEqual SyntaxOf('foo'), 'nixArgumentDefinition' - AssertEqual SyntaxOf('?'), 'nixOperator' - AssertEqual SyntaxOf('/\*\*/'), 'nixComment' - AssertEqual SyntaxOf('another comment'), 'nixComment' - AssertEqual SyntaxOf('yet another comment'), 'nixComment' - AssertEqual SyntaxOf('default value here:'), 'nixComment' - AssertEqual SyntaxOf('1'), 'nixInteger' - AssertEqual SyntaxOf('bar'), 'nixArgumentDefinition' - AssertEqual SyntaxOf('xxx'), 'nixSimpleString' - AssertEqual SyntaxOf('yyy'), 'nixArgumentDefinition' - AssertEqual SyntaxOf('last comment'), 'nixComment' - AssertEqual SyntaxOf('\.\.\.'), 'nixArgumentEllipsis' - AssertEqual SyntaxOf('result'), 'nixAttribute' - AssertEqual SyntaxOf('null'), 'nixNull' - -Given nix (ifexpr): - if true then 111 else { a = 222; } - -Execute (syntax): - AssertEqual SyntaxOf('if'), 'nixIfExprKeyword' - AssertEqual SyntaxOf('true'), 'nixBoolean' - AssertEqual SyntaxOf('then'), 'nixIfExprKeyword' - AssertEqual SyntaxOf('111'), 'nixInteger' - AssertEqual SyntaxOf('else'), 'nixIfExprKeyword' - AssertEqual SyntaxOf('a'), 'nixAttribute' - AssertEqual SyntaxOf('222'), 'nixInteger' - -Given nix (with-expr): - with foo; withfoo - -Execute (syntax): - AssertEqual SyntaxOf('with'), 'nixWithExprKeyword' - AssertEqual SyntaxOf('foo'), 'nixFunctionCall' - AssertEqual SyntaxOf('withfoo'), 'nixFunctionCall' - -Given nix (assert-expr): - assert true -> false; null - -Execute (syntax): - AssertEqual SyntaxOf('assert'), 'nixAssertKeyword' - AssertEqual SyntaxOf('true'), 'nixBoolean' - AssertEqual SyntaxOf('->'), 'nixOperator' - AssertEqual SyntaxOf('false'), 'nixBoolean' - AssertEqual SyntaxOf('null'), 'nixNull' - -Given nix (funarg-let-attrset): - { xxx ? null }@yyy: - - bbb@{ ccc, ... }: - - let foo = 11; in let xxx = 22; in { - bar = foo + zzz; - } - -Execute (syntax): - AssertEqual SyntaxOf('xxx'), 'nixArgumentDefinition' - AssertEqual SyntaxOf('?'), 'nixOperator' - AssertEqual SyntaxOf('null'), 'nixNull' - AssertEqual SyntaxOf('@'), 'nixArgOperator' - AssertEqual SyntaxOf('yyy'), 'nixAttribute' - AssertEqual SyntaxOf('bbb'), 'nixAttribute' - AssertEqual SyntaxOf('ccc'), 'nixArgumentDefinition' - AssertEqual SyntaxOf('let'), 'nixLetExprKeyword' - AssertEqual SyntaxOf('bar'), 'nixAttribute' - -Given nix (searchpath-versus-lt): - { - alwaysTrue = 4 < 5; - alwaysFalse = 4 > 5; - somePath = ; - tailTrue = 4 <= 5; - tailFalse = 4 >= 5; - } - -Execute (syntax): - AssertEqual SyntaxOf('alwaysTrue.*\zs<'), 'nixOperator' - AssertEqual SyntaxOf('alwaysFalse.*\zs>'), 'nixOperator' - AssertEqual SyntaxOf('somePath.*\zs<'), 'nixPathDelimiter' - AssertEqual SyntaxOf('somePath.*\zs>'), 'nixPathDelimiter' - AssertEqual SyntaxOf('tailTrue.*\zs<'), 'nixOperator' - AssertEqual SyntaxOf('tailFalse.*\zs>'), 'nixOperator' diff --git a/vim/.vim/bundle/filetype-nix/test/run-tests.sh b/vim/.vim/bundle/filetype-nix/test/run-tests.sh deleted file mode 100755 index c68c905..0000000 --- a/vim/.vim/bundle/filetype-nix/test/run-tests.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash - -cd "$( dirname "${BASH_SOURCE[0]}" )" && vim -Nu vimrc -c 'Vader! *' diff --git a/vim/.vim/bundle/filetype-nix/test/vimrc b/vim/.vim/bundle/filetype-nix/test/vimrc deleted file mode 100644 index 3fdd6ea..0000000 --- a/vim/.vim/bundle/filetype-nix/test/vimrc +++ /dev/null @@ -1,5 +0,0 @@ -filetype off -set rtp+=../vader.vim -set rtp+=../ -filetype plugin indent on -syntax enable