This commit is contained in:
Adam Stankiewicz
2020-06-25 13:38:07 +02:00
parent 8b6c06e723
commit abca7c2014
17 changed files with 372 additions and 111 deletions

View File

@@ -194,7 +194,7 @@ If you need full functionality of any plugin, please use it directly with your p
- [yaml](https://github.com/stephpy/vim-yaml) (syntax, ftplugin)
- [yard](https://github.com/sheerun/vim-yardoc) (syntax)
- [zephir](https://github.com/xwsoul/vim-zephir) (syntax)
- [zig](https://github.com/ziglang/zig.vim) (syntax, autoload, ftplugin)
- [zig](https://github.com/ziglang/zig.vim) (syntax, indent, autoload, ftplugin)
- [zinit](https://github.com/zinit-zsh/zplugin-vim-syntax) (syntax)
<!--/Language Packs-->

View File

@@ -4,7 +4,7 @@ let s:highlight_close_tag = get(g:, 'vim_jsx_pretty_highlight_close_tag', 0)
" detect jsx region
syntax region jsxRegion
\ start=+\%(\%(\_[([,?:=+\-*/>{}]\|<\s\+\|&&\|||\|=>\|\<return\|\<default\|\<await\|\<yield\)\_s*\)\@<=<\_s*\%(>\|\z(\%(script\|T\s*>\s*(\)\@!\<[_$A-Za-z][-:._$A-Za-z0-9]*\>\)\%(\_s*\%([-+*)\]}&|?,]\|/\%([/*]\|\_s*>\)\@!\)\)\@!\)+
\ start=+\%(\%(\_[([,?:=+\-*/>{}]\|<\s\+\|&&\|||\|=>\|\<return\|\<default\|\<await\|\<yield\)\_s*\)\@<=<\_s*\%(>\|\z(\%(script\|\s*\<T\>\)\@!\<[_$A-Za-z][-:._$A-Za-z0-9]*\>\)\%(\_s*\%([-+*)\]}&|?,]\|/\%([/*]\|\_s*>\)\@!\)\)\@!\)+
\ end=++
\ contains=jsxElement

View File

@@ -1507,10 +1507,10 @@ fu! csv#AvgColumn(list) "{{{3
endfor
if has("float")
let b:csv_result = printf("%.2f", sum/cnt)
return b:csv_result
return str2float(b:csv_result)
else
let b:csv_result = printf("%s", sum/cnt)
return sum/cnt
return b:csv_result + 0
endif
endif
endfu
@@ -1543,7 +1543,7 @@ fu! csv#VarianceColumn(list, is_population) "{{{3
let cnt = cnt-1
endif
if has("float")
let b:csv_result = printf("%.2f", sum/cnt)
let b:csv_result = printf("%." . get(b:, 'csv_accuracy', get(g:, 'csv_accuracy', 2)) . "f", sum/cnt)
return b:csv_result
else
let b:csv_result = printf("%s", sum/cnt)
@@ -2263,7 +2263,7 @@ fu! csv#CommandDefinitions() "{{{3
\ ':echo csv#EvalColumn(<q-args>, "csv#SmplStdDevColumn", <line1>,<line2>)',
\ '-nargs=? -range=% -complete=custom,csv#SortComplete')
call csv#LocalCmd("PopStdCol",
\ ':echo csv#EvalColumn(<q-args>, "csv#SmplStdDevColumn", <line1>,<line2>)',
\ ':echo csv#EvalColumn(<q-args>, "csv#PopStdDevColumn", <line1>,<line2>)',
\ '-nargs=? -range=% -complete=custom,csv#SortComplete')
call csv#LocalCmd("UnArrangeColumn",
\':call csv#PrepUnArrangeCol(<line1>, <line2>)',

View File

@@ -371,7 +371,7 @@ function! go#config#RenameCommand() abort
endfunction
function! go#config#GorenameBin() abort
return get(g:, "go_gorename_bin", "gorename")
return get(g:, "go_gorename_bin", "gopls")
endfunction
function! go#config#GorenamePrefill() abort

View File

@@ -2,7 +2,7 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'vifm') == -1
" Mail file type extension to pick files for attachments via vifm
" Maintainer: xaizek <xaizek@posteo.net>
" Last Change: January 02, 2018
" Last Change: June 22, 2020
" Insert attachment picked via vifm after 'Subject' header
function! s:AddMailAttachments()
@@ -43,9 +43,7 @@ endfunction
function! s:HandleRunResults(exitcode, listf)
if a:exitcode != 0
echohl WarningMsg
echo 'Got non-zero code from vifm: ' . a:exitcode
echohl None
echoerr 'Got non-zero code from vifm: ' . a:exitcode
call delete(a:listf)
return
endif

View File

@@ -156,6 +156,58 @@ function! s:GetHeaderLevel(...)
endif
endfunction
" Return list of headers and their levels.
"
function! s:GetHeaderList()
let l:bufnr = bufnr('%')
let l:fenced_block = 0
let l:front_matter = 0
let l:header_list = []
let l:vim_markdown_frontmatter = get(g:, "vim_markdown_frontmatter", 0)
for i in range(1, line('$'))
let l:lineraw = getline(i)
let l:l1 = getline(i+1)
let l:line = substitute(l:lineraw, "#", "\\\#", "g")
" exclude lines in fenced code blocks
if l:line =~ '````*' || l:line =~ '\~\~\~\~*'
if l:fenced_block == 0
let l:fenced_block = 1
elseif l:fenced_block == 1
let l:fenced_block = 0
endif
" exclude lines in frontmatters
elseif l:vim_markdown_frontmatter == 1
if l:front_matter == 1
if l:line == '---'
let l:front_matter = 0
endif
elseif i == 1
if l:line == '---'
let l:front_matter = 1
endif
endif
endif
" match line against header regex
if join(getline(i, i + 1), "\n") =~ s:headersRegexp && l:line =~ '^\S'
let l:is_header = 1
else
let l:is_header = 0
endif
if l:is_header == 1 && l:fenced_block == 0 && l:front_matter == 0
" remove hashes from atx headers
if match(l:line, "^#") > -1
let l:line = substitute(l:line, '\v^#*[ ]*', '', '')
let l:line = substitute(l:line, '\v[ ]*#*$', '', '')
endif
" append line to list
let l:level = s:GetHeaderLevel(i)
let l:item = {'level': l:level, 'text': l:line, 'lnum': i, 'bufnr': bufnr}
let l:header_list = l:header_list + [l:item]
endif
endfor
return l:header_list
endfunction
" Returns the level of the header at the given line.
"
" If there is no header at the given line, returns `0`.
@@ -177,6 +229,7 @@ endfunction
function! s:MoveToParentHeader()
let l:linenum = s:GetParentHeaderLineNumber()
if l:linenum != 0
call setpos("''", getpos('.'))
call cursor(l:linenum, 1)
else
echo 'no parent header'
@@ -305,65 +358,38 @@ function! s:Toc(...)
endif
let l:bufnr = bufnr('%')
let l:cursor_line = line('.')
let l:cursor_header = 0
let l:fenced_block = 0
let l:front_matter = 0
let l:header_list = []
let l:header_max_len = 0
let l:vim_markdown_toc_autofit = get(g:, "vim_markdown_toc_autofit", 0)
let l:vim_markdown_frontmatter = get(g:, "vim_markdown_frontmatter", 0)
for i in range(1, line('$'))
let l:lineraw = getline(i)
let l:l1 = getline(i+1)
let l:line = substitute(l:lineraw, "#", "\\\#", "g")
if l:line =~ '````*' || l:line =~ '\~\~\~\~*'
if l:fenced_block == 0
let l:fenced_block = 1
elseif l:fenced_block == 1
let l:fenced_block = 0
endif
elseif l:vim_markdown_frontmatter == 1
if l:front_matter == 1
if l:line == '---'
let l:front_matter = 0
endif
elseif i == 1
if l:line == '---'
let l:front_matter = 1
endif
endif
endif
if l:line =~ '^#\+' || (l:l1 =~ '^=\+\s*$' || l:l1 =~ '^-\+\s*$') && l:line =~ '^\S'
let l:is_header = 1
else
let l:is_header = 0
endif
if l:is_header == 1 && l:fenced_block == 0 && l:front_matter == 0
" append line to location list
let l:item = {'lnum': i, 'text': l:line, 'valid': 1, 'bufnr': l:bufnr, 'col': 1}
let l:header_list = l:header_list + [l:item]
" set header number of the cursor position
if l:cursor_header == 0
if i == l:cursor_line
let l:cursor_header = len(l:header_list)
elseif i > l:cursor_line
let l:cursor_header = len(l:header_list) - 1
endif
endif
" keep track of the longest header size (heading level + title)
let l:total_len = stridx(l:line, ' ') + strdisplaywidth(l:line)
if l:total_len > l:header_max_len
let l:header_max_len = l:total_len
endif
endif
endfor
call setloclist(0, l:header_list)
let l:header_list = s:GetHeaderList()
let l:indented_header_list = []
if len(l:header_list) == 0
echom "Toc: No headers."
return
endif
let l:header_max_len = 0
let l:vim_markdown_toc_autofit = get(g:, "vim_markdown_toc_autofit", 0)
for h in l:header_list
" set header number of the cursor position
if l:cursor_header == 0
let l:header_line = h.lnum
if l:header_line == l:cursor_line
let l:cursor_header = index(l:header_list, h) + 1
elseif l:header_line > l:cursor_line
let l:cursor_header = index(l:header_list, h)
endif
endif
" indent header based on level
let l:text = repeat(' ', h.level-1) . h.text
" keep track of the longest header size (heading level + title)
let l:total_len = strdisplaywidth(l:text)
if l:total_len > l:header_max_len
let l:header_max_len = l:total_len
endif
" append indented line to list
let l:item = {'lnum': h.lnum, 'text': l:text, 'valid': 1, 'bufnr': h.bufnr, 'col': 1}
let l:indented_header_list = l:indented_header_list + [l:item]
endfor
call setloclist(0, l:indented_header_list)
if l:window_type ==# 'horizontal'
lopen
@@ -371,7 +397,8 @@ function! s:Toc(...)
vertical lopen
" auto-fit toc window when possible to shrink it
if (&columns/2) > l:header_max_len && l:vim_markdown_toc_autofit == 1
execute 'vertical resize ' . (l:header_max_len + 1)
" header_max_len + 1 space for first header + 3 spaces for line numbers
execute 'vertical resize ' . (l:header_max_len + 1 + 3)
else
execute 'vertical resize ' . (&columns/2)
endif
@@ -384,27 +411,84 @@ function! s:Toc(...)
for i in range(1, line('$'))
" this is the location-list data for the current item
let d = getloclist(0)[i-1]
" atx headers
if match(d.text, "^#") > -1
let l:level = len(matchstr(d.text, '#*', 'g'))-1
let d.text = substitute(d.text, '\v^#*[ ]*', '', '')
let d.text = substitute(d.text, '\v[ ]*#*$', '', '')
" setex headers
else
let l:next_line = getbufline(d.bufnr, d.lnum+1)
if match(l:next_line, "=") > -1
let l:level = 0
elseif match(l:next_line, "-") > -1
let l:level = 1
endif
endif
call setline(i, repeat(' ', l:level). d.text)
call setline(i, d.text)
endfor
setlocal nomodified
setlocal nomodifiable
execute 'normal! ' . l:cursor_header . 'G'
endfunction
function! s:InsertToc(format, ...)
if a:0 > 0
if type(a:1) != type(0)
echohl WarningMsg
echomsg '[vim-markdown] Invalid argument, must be an integer >= 2.'
echohl None
return
endif
let l:max_level = a:1
if l:max_level < 2
echohl WarningMsg
echomsg '[vim-markdown] Maximum level cannot be smaller than 2.'
echohl None
return
endif
else
let l:max_level = 0
endif
let l:toc = []
let l:header_list = s:GetHeaderList()
if len(l:header_list) == 0
echom "InsertToc: No headers."
return
endif
if a:format ==# 'numbers'
let l:h2_count = 0
for header in l:header_list
if header.level == 2
let l:h2_count += 1
endif
endfor
let l:max_h2_number_len = strlen(string(l:h2_count))
else
let l:max_h2_number_len = 0
endif
let l:h2_count = 0
for header in l:header_list
let l:level = header.level
if l:level == 1
" skip level-1 headers
continue
elseif l:max_level != 0 && l:level > l:max_level
" skip unwanted levels
continue
elseif l:level == 2
" list of level-2 headers can be bullets or numbers
if a:format ==# 'bullets'
let l:indent = ''
let l:marker = '* '
else
let l:h2_count += 1
let l:number_len = strlen(string(l:h2_count))
let l:indent = repeat(' ', l:max_h2_number_len - l:number_len)
let l:marker = l:h2_count . '. '
endif
else
let l:indent = repeat(' ', l:max_h2_number_len + 2 * (l:level - 2))
let l:marker = '* '
endif
let l:text = '[' . header.text . ']'
let l:link = '(#' . substitute(tolower(header.text), '\v[ ]+', '-', 'g') . ')'
let l:line = l:indent . l:marker . l:text . l:link
let l:toc = l:toc + [l:line]
endfor
call append(line('.'), l:toc)
endfunction
" Convert Setex headers in range `line1 .. line2` to Atx.
"
" Return the number of conversions.
@@ -681,6 +765,8 @@ command! -buffer Toc call s:Toc()
command! -buffer Toch call s:Toc('horizontal')
command! -buffer Tocv call s:Toc('vertical')
command! -buffer Toct call s:Toc('tab')
command! -buffer -nargs=? InsertToc call s:InsertToc('bullets', <args>)
command! -buffer -nargs=? InsertNToc call s:InsertToc('numbers', <args>)
" Heavily based on vim-notes - http://peterodding.com/code/vim/notes/
if exists('g:vim_markdown_fenced_languages')

View File

@@ -4,6 +4,11 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'racket') == -1
" Maintainer: Will Langstroth <will@langstroth.com>
" URL: http://github.com/wlangstroth/vim-racket
if exists("b:did_ftplugin")
finish
endif
let b:did_ftplugin = 1
setl iskeyword+=#,%,^
setl lispwords+=module,module*,module+,parameterize,let-values,let*-values,letrec-values,local
setl lispwords+=define-values,opt-lambda,case-lambda,syntax-rules,with-syntax,syntax-case,syntax-parse
@@ -37,7 +42,10 @@ setl makeprg=raco\ make\ --\ %
" but then vim says:
" "press ENTER or type a command to continue"
" We avoid the annoyance of having to hit enter by remapping K directly.
nnoremap <buffer> K :silent !raco docs <cword><cr>:redraw!<cr>
nnoremap <buffer> <Plug>RacketDoc :silent !raco docs <cword><cr>:redraw!<cr>
if maparg("K", "n") == ""
nmap <buffer> K <Plug>RacketDoc
endif
" For the visual mode K mapping, it's slightly more convoluted to get the
" selected text:
@@ -53,9 +61,20 @@ function! s:Racket_visual_doc()
endtry
endfunction
vnoremap <buffer> K :call <SID>Racket_visual_doc()<cr>
vnoremap <buffer> <Plug>RacketDoc :call <SID>Racket_visual_doc()<cr>
if maparg("K", "v") == ""
vmap <buffer> K <Plug>RacketDoc
endif
"setl commentstring=;;%s
setl commentstring=#\|\ %s\ \|#
" Undo our settings when the filetype changes away from Racket
" (this should be amended if settings/mappings are added above!)
let b:undo_ftplugin =
\ "setl iskeyword< lispwords< lisp< comments< formatoptions<"
\. "| setl makeprg< commentstring<"
\. "| nunmap <buffer> K"
\. "| vunmap <buffer> K"
endif

View File

@@ -16,4 +16,9 @@ setlocal suffixesadd=.zir
setlocal commentstring=//\ %s
setlocal makeprg=zig\ build
if (has("comments"))
set comments=:///,://,:\\\\
set formatoptions=tcqor
endif
endif

80
indent/zig.vim Normal file
View File

@@ -0,0 +1,80 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'zig') == -1
" indent/zig.vim
" Only load this indent file when no other was loaded.
if exists("b:did_indent")
finish
endif
let b:did_indent = 1
if (!has("cindent") || !has("eval"))
finish
endif
setlocal cindent
" L0 -> 0 indent for jump labels (i.e. case statement in c).
" j1 -> indenting for "javascript object declarations"
" J1 -> see j1
" w1 -> starting a new line with `(` at the same indent as `(`
" m1 -> if `)` starts a line, match its indent with the first char of its
" matching `(` line
" (s -> use one indent, when starting a new line after a trailing `(`
setlocal cinoptions=L0,m1,(s,j1,J1,l1
" cinkeys: controls what keys trigger indent formatting
" 0{ -> {
" 0} -> }
" 0) -> )
" 0] -> ]
" !^F -> make CTRL-F (^F) reindent the current line when typed
" o -> when <CR> or `o` is used
" O -> when the `O` command is used
setlocal cinkeys=0{,0},0),0],!^F,o,O
setlocal indentexpr=GetZigIndent(v:lnum)
function! GetZigIndent(lnum)
let curretLineNum = a:lnum
let currentLine = getline(a:lnum)
" cindent doesn't handle multi-line strings properly, so force no indent
if currentLine =~ '^\s*\\\\.*'
return -1
endif
let prevLineNum = prevnonblank(a:lnum-1)
let prevLine = getline(prevLineNum)
" for lines that look line
" },
" };
" try treat them the same as a }
if prevLine =~ '\v^\s*},$'
if currentLine =~ '\v^\s*};$' || currentLine =~ '\v^\s*}$'
return indent(prevLineNum) - 4
endif
return indent(prevLineNum-1) - 4
endif
if currentLine =~ '\v^\s*},$'
return indent(prevLineNum) - 4
endif
if currentLine =~ '\v^\s*};$'
return indent(prevLineNum) - 4
endif
" cindent doesn't handle this case correctly:
" switch (1): {
" 1 => true,
" ~
" ^---- indents to here
if prevLine =~ '.*=>.*,$' && currentLine !~ '.*}$'
return indent(prevLineNum)
endif
return cindent(a:lnum)
endfunction
endif

View File

@@ -51,7 +51,7 @@ endif
syn keyword arduinoFunc Wire1
"}}}
"C:/Program Files (x86)/Arduino\lib\keywords.txt{{{
syn keyword arduinoConstant HIGH LOW INPUT INPUT_PULLUP OUTPUT DEC BIN HEX OCT PI
syn keyword arduinoConstant HIGH LOW INPUT INPUT_PULLUP INPUT_PULLDOWN OUTPUT DEC BIN HEX OCT PI
syn keyword arduinoConstant HALF_PI TWO_PI LSBFIRST MSBFIRST CHANGE FALLING RISING DEFAULT EXTERNAL INTERNAL
syn keyword arduinoConstant INTERNAL1V1 INTERNAL2V56
syn keyword arduinoType boolean break byte case char class const continue default do

View File

@@ -52,7 +52,7 @@ syntax region typescriptArrowFuncArg contained start=/<\|(/ end=/\ze=>
syntax region typescriptReturnAnnotation contained start=/:/ end=/{/me=e-1 contains=@typescriptType nextgroup=typescriptBlock
syntax region typescriptFuncImpl contained start=/function/ end=/{/me=e-1
syntax region typescriptFuncImpl contained start=/function\>/ end=/{/me=e-1
\ contains=typescriptFuncKeyword
\ nextgroup=typescriptBlock

View File

@@ -158,6 +158,7 @@ syntax match typescriptTypeAnnotation /:/
syntax cluster typescriptParameterList contains=
\ typescriptTypeAnnotation,
\ typescriptAccessibilityModifier,
\ typescriptReadonlyModifier,
\ typescriptOptionalMark,
\ typescriptRestOrSpread,
\ typescriptFuncComma,

View File

@@ -13,6 +13,11 @@ if !exists("main_syntax")
let main_syntax = 'lua'
endif
if exists('g:lua_syntax_fancynotequal') && !has('conceal')
unlet g:lua_syntax_fancynotequal
endif
syntax sync fromstart
function! s:FoldableRegion(tag, name, expr)
@@ -40,7 +45,11 @@ syntax region luaBracket transparent matchgroup=luaBrackets start="\[" end="\]"
syntax match luaComma ","
syntax match luaSemiCol ";"
if !exists('g:lua_syntax_nosymboloperator')
syntax match luaSymbolOperator "[#<>=~^&|*/%+-]\|\.\."
if exists('g:lua_syntax_fancynotequal')
syntax match luaNotEqOperator "\V~=" conceal cchar=
setlocal conceallevel=2
endi
syntax match luaSymbolOperator "[#<>=~^&|*/%+-]\|\.\." contains=luaNotEqOperator
endi
syntax match luaEllipsis "\.\.\."
@@ -229,6 +238,7 @@ if version >= 508 || !exists("did_lua_syn_inits")
HiLink luaLocal Type
HiLink luaNumber Number
HiLink luaSymbolOperator luaOperator
HiLink luaNotEqOperator luaOperator
HiLink luaOperator Operator
HiLink luaRepeat Repeat
HiLink luaSemiCol Delimiter
@@ -240,6 +250,10 @@ if version >= 508 || !exists("did_lua_syn_inits")
HiLink luaStringSpecial SpecialChar
HiLink luaErrHand Exception
if exists('g:lua_syntax_fancynotequal')
hi! link Conceal luaOperator
endi
delcommand HiLink
end

View File

@@ -72,10 +72,10 @@ execute 'syn region mkdLink matchgroup=mkdDelimiter start="\\\@<!!\?\[\ze[^]\n]
" Autolink without angle brackets.
" mkd inline links: protocol optional user:pass@ sub/domain .com, .co.uk, etc optional port path/querystring/hash fragment
" ------------ _____________________ ----------------------------- _________________________ ----------------- __
syn match mkdInlineURL /https\?:\/\/\(\w\+\(:\w\+\)\?@\)\?\([A-Za-z0-9][-_0-9A-Za-z]*\.\)\{1,}\(\w\{2,}\.\?\)\{1,}\(:[0-9]\{1,5}\)\?\S*/
syn match mkdInlineURL /https\?:\/\/\(\w\+\(:\w\+\)\?@\)\?\([A-Za-z0-9][-_0-9A-Za-z]*\.\)\{1,}\(\w\{2,}\.\?\)\{1,}\(:[0-9]\{1,5}\)\?[^] \t]*/
" Autolink with parenthesis.
syn region mkdInlineURL matchgroup=mkdDelimiter start="(\(https\?:\/\/\(\w\+\(:\w\+\)\?@\)\?\([A-Za-z0-9][-_0-9A-Za-z]*\.\)\{1,}\(\w\{2,}\.\?\)\{1,}\(:[0-9]\{1,5}\)\?\S*)\)\@=" end=")"
syn region mkdInlineURL matchgroup=mkdDelimiter start="(\(https\?:\/\/\(\w\+\(:\w\+\)\?@\)\?\([A-Za-z0-9][-_0-9A-Za-z]*\.\)\{1,}\(\w\{2,}\.\?\)\{1,}\(:[0-9]\{1,5}\)\?[^] \t]*)\)\@=" end=")"
" Autolink with angle brackets.
syn region mkdInlineURL matchgroup=mkdDelimiter start="\\\@<!<\ze[a-z][a-z0-9,.-]\{1,22}:\/\/[^> ]*>" end=">"

View File

@@ -109,7 +109,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
@@ -149,7 +149,7 @@ syn keyword nixNamespacedBuiltin contained
\ 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
syn match nixBuiltin "builtins\.[a-zA-Z']\+"he=s+9 contains=nixComment,nixNamespacedBuiltin

View File

@@ -26,7 +26,7 @@ syn match sdFormatStr contained /%[bCEfhHiIjJLmnNpPsStTgGuUvV%]/ containedin=ALL
syn match sdUInt contained nextgroup=sdErr /\d\+/
syn match sdInt contained nextgroup=sdErr /-\=\d\+/
syn match sdOctal contained nextgroup=sdErr /0\o\{3,4}/
" sdDuration: see systemd.time(7)
" sdDuration, sdCalendar: see systemd.time(7)
syn match sdDuration contained nextgroup=sdErr /\d\+/
syn match sdDuration contained nextgroup=sdErr /\%(\d\+\s*\%(usec\|msec\|seconds\=\|minutes\=\|hours\=\|days\=\|weeks\=\|months\=\|years\=\|us\|ms\|sec\|min\|hr\|[smhdwMy]\)\s*\)\+/
syn match sdDatasize contained nextgroup=sdErr /\d\+[KMGT]/
@@ -35,6 +35,29 @@ syn match sdPercent contained nextgroup=sdErr /\d\+%/
syn keyword sdBool contained nextgroup=sdErr 1 yes true on 0 no false off
syn match sdUnitName contained /\S\+\.\(automount\|mount\|swap\|socket\|service\|target\|path\|timer\|device\|slice\|scope\)\_s/
" type identifiers used in `systemd --dump-config`, from most to least common:
" 189 OTHER
" 179 BOOLEAN
" 136 LIMIT
" 46 CONDITION
" 36 WEIGHT
" 30 MODE
" 27 PATH
" 25 PATH [...]
" 24 SECONDS, STRING
" 20 SIGNAL
" 15 UNIT [...]
" 12 BANDWIDTH, DEVICEWEIGHT, SHARES, UNSIGNED
" 11 PATH [ARGUMENT [...]]
" 8 BOUNDINGSET, LEVEL, OUTPUT, PATH[:PATH[:OPTIONS]] [...], SOCKET [...]
" 6 ACTION, DEVICE, DEVICELATENCY, POLICY, SLICE, TIMER
" 5 KILLMODE
" 4 ARCHS, CPUAFFINITY, CPUSCHEDPOLICY, CPUSCHEDPRIO, ENVIRON, ERRNO, FACILITY, FAMILIES, FILE, INPUT, IOCLASS, IOPRIORITY, LABEL, MOUNTFLAG [...], NAMESPACES, NANOSECONDS, NICE, NOTSUPPORTED, OOMSCOREADJUST, PERSONALITY, SECUREBITS, SYSCALLS
" 3 INTEGER, SIZE, STATUS
" 2 LONG, UNIT
" 1 ACCESS, NETWORKINTERFACE, SERVICE, SERVICERESTART, SERVICETYPE, SOCKETBIND, SOCKETS, TOS, URL
" .include
syn match sdInclude /^.include/ nextgroup=sdFilename
@@ -48,48 +71,76 @@ syn region sdUnitBlock matchgroup=sdHeader start=/^\[Unit\]/ end=/^\[/me=e-2 con
syn match sdUnitKey contained /^Description=/
syn match sdUnitKey contained /^Documentation=/ nextgroup=sdDocURI
syn match sdUnitKey contained /^SourcePath=/ nextgroup=sdFilename,sdErr
syn match sdUnitKey contained /^\%(Requires\|RequiresOverridable\|Requisite\|RequisiteOverridable\|Wants\|Binds\=To\|PartOf\|Conflicts\|Before\|After\|OnFailure\|Names|PropagatesReloadTo\|ReloadPropagatedFrom\)=/ nextgroup=sdUnitList
syn match sdUnitKey contained /^\%(Requires\|RequiresOverridable\|Requisite\|RequisiteOverridable\|Wants\|Binds\=To\|PartOf\|Conflicts\|Before\|After\|OnFailure\|Names\|Propagates\=ReloadTo\|ReloadPropagatedFrom\|PropagateReloadFrom\|JoinsNamespaceOf\)=/ nextgroup=sdUnitList
syn match sdUnitKey contained /^\%(OnFailureIsolate\|IgnoreOnIsolate\|IgnoreOnSnapshot\|StopWhenUnneeded\|RefuseManualStart\|RefuseManualStop\|AllowIsolate\|DefaultDependencies\)=/ nextgroup=sdBool,sdErr
syn match sdUnitKey contained /^OnFailureJobMode=/ nextgroup=sdFailJobMode,sdErr
syn match sdUnitKey contained /^\%(StartLimitInterval\|StartLimitIntervalSec\|JobTimeoutSec\)=/ nextgroup=sdDuration,sdErr
syn match sdUnitKey contained /^\%(StartLimitAction\|JobTimeoutAction\)=/ nextgroup=sdLimitAction,sdErr
syn match sdUnitKey contained /^StartLimitBurst=/ nextgroup=sdUInt,sdErr
syn match sdUnitKey contained /^\%(FailureAction\|SuccessAction\)=/ nextgroup=sdLimitAction,sdFailAction,sdErr
syn match sdUnitKey contained /^\%(FailureAction\|SuccessAction\)ExitStatus=/ nextgroup=sdExitStatus,sdErr
syn match sdUnitKey contained /^\%(RebootArgument\|JobTimeoutRebootArgument\)=/
" ConditionXXX. Note that they all have an optional '|' after the '='.
syn match sdUnitKey contained /^Condition\(PathExists\|PathExistsGlob\|PathIsDirectory\|PathIsMountPoint\|PathIsReadWrite\|PathIsSymbolicLink\|DirectoryNotEmpty\|FileNotEmpty\|FileIsExecutable\)=|\=!\=/ contains=sdConditionFlag nextgroup=sdFilename,sdErr
syn match sdUnitKey contained /^ConditionVirtualization=|\=!\=/ contains=sdConditionFlag nextgroup=sdVirtType,sdErr
syn match sdUnitKey contained /^ConditionSecurity=|\=!\=/ contains=sdConditionFlag nextgroup=sdSecurityType,sdErr
syn match sdUnitKey contained /^ConditionCapability=|\=!\=/ contains=sdConditionFlag nextgroup=sdAnyCapName,sdErr
syn match sdUnitKey contained /^Condition\%(KernelCommandLine\|Host\)=|\=!\=/ contains=sdConditionFlag
syn match sdUnitKey contained /^Condition\%(ACPower\|Null\|FirstBoot\)=|\=/ contains=sdConditionFlag nextgroup=sdBool,sdErr
syn match sdUnitKey contained /^ConditionNeedsUpdate=|\=!\=/ contains=sdConditionFlag nextgroup=sdCondUpdateDir,sdErr
syn match sdUnitKey contained /^RequiresMountsFor=/ nextgroup=sdFileList,sdErr
" TODO: JobRunningTimeoutSec
" ConditionXXX/AssertXXX. Note that they all have an optional '|' after the '='.
syn match sdUnitKey contained /^\%(Condition\|Assert\)\(PathExists\|PathExistsGlob\|PathIsDirectory\|PathIsMountPoint\|PathIsReadWrite\|PathIsSymbolicLink\|DirectoryNotEmpty\|FileNotEmpty\|FileIsExecutable\)=|\=!\=/ contains=sdConditionFlag nextgroup=sdFilename,sdErr
syn match sdUnitKey contained /^\%(Condition\|Assert\)Virtualization=|\=!\=/ contains=sdConditionFlag nextgroup=sdVirtType,sdErr
syn match sdUnitKey contained /^\%(Condition\|Assert\)Security=|\=!\=/ contains=sdConditionFlag nextgroup=sdSecurityType,sdErr
syn match sdUnitKey contained /^\%(Condition\|Assert\)Capability=|\=!\=/ contains=sdConditionFlag nextgroup=sdAnyCapName,sdErr
syn match sdUnitKey contained /^\%(Condition\|Assert\)\%(KernelCommandLine\|Host\)=|\=!\=/ contains=sdConditionFlag
syn match sdUnitKey contained /^\%(Condition\|Assert\)\%(ACPower\|Null\|FirstBoot\)=|\=/ contains=sdConditionFlag nextgroup=sdBool,sdErr
syn match sdUnitKey contained /^\%(Condition\|Assert\)NeedsUpdate=|\=!\=/ contains=sdConditionFlag nextgroup=sdCondUpdateDir,sdErr
syn match sdUnitKey contained /^\%(Condition\|Assert\)Architecture=|\=!\=/ contains=sdConditionFlag nextgroup=sdArch,sdErr
syn match sdUnitKey contained /^\%(Condition\|Assert\)User=|\=/ contains=sdConditionFlag nextgroup=sdUser,sdCondUser,sdErr
syn match sdUnitKey contained /^\%(Condition\|Assert\)Group=|\=/ contains=sdConditionFlag nextgroup=sdUser,sdErr
syn match sdUnitKey contained /^\%(Condition\|Assert\)ControlGroupController=|\=/ contains=sdConditionFlag nextgroup=sdController,sdErr
syn match sdUnitKey contained /^\%(Condition\|Assert\)KernelVersion=|\=/ contains=sdConditionFlag nextgroup=sdKernelVersion,sdErr
" extra bits
syn match sdUnitList contained /.*/ contains=sdUnitName,sdErr
syn match sdConditionFlag contained /[!|]/
syn match sdCondUpdateDir contained nextgroup=sdErr /\%(\/etc\|\/var\)/
syn keyword sdVirtType contained nextgroup=sdErr vm container qemu kvm vmware microsoft oracle xen bochs chroot openvz lxc lxc-libvirt systemd-nspawn
syn keyword sdSecurityType contained nextgroup=sdErr selinux
syn keyword sdVirtType contained nextgroup=sdErr vm container qemu kvm zvm vmware microsoft oracle xen bochs uml bhyve qnx openvz openvz lxc lxc-libvirt systemd-nspawn docker podman rkt wsl acrn private-users
syn keyword sdSecurityType contained nextgroup=sdErr selinux apparmor tomoyo ima smack audit uefi-secureboot
syn keyword sdFailJobMode contained nextgroup=sdErr fail replace replace-irreversibly
syn keyword sdLimitAction contained nextgroup=sdErr none reboot reboot-force reboot-immediate poweroff poweroff-force poweroff-immediate
syn keyword sdFailAction contained nextgroup=sdErr exit exit-force
syn keyword sdArch contained nextgroup=sdErr x86 x86_64 ppc ppc-le ppc64 ppc64-le ia64 parisc parisc64 s390 s390x sparc sparc64 mips mips-le mips64 mips64-le alpha arm arm-be arm64 arm64-be sh sh64 m68k tilegx cris arc arc-be native
syn keyword sdController contained cpu cpuacct io blkio memory devices pids nextgroup=sdController,sdErr
syn match sdCondUser contained /@system/
syn match sdUser contained nextgroup=sdErr /\d\+\|[A-Za-z_][A-Za-z0-9_-]*/
syn match sdExitStatus contained nextgroup=sdErr /\d\|\d\d\|[01]\d\d\|2[0-4]\d\|25[0-5]/
syn match sdDocUri contained /\%(https\=:\/\/\|file:\|info:\|man:\)\S\+\s*/ nextgroup=sdDocUri,sdErr
" [Install] {{{1
" see systemd.unit(5)
syn region sdInstallBlock matchgroup=sdHeader start=/^\[Install\]/ end=/^\[/me=e-2 contains=sdInstallKey
syn match sdInstallKey contained /^\%(WantedBy\|Alias\|Also\|RequiredBy\)=/ nextgroup=sdUnitList
syn match sdInstallKey contained /^DefaultInstance=/ nextgroup=sdInstance
" TODO: sdInstance - what's valid there? probably [^@/]\+, but that's a guess
" Execution options common to [Service|Socket|Mount|Swap] {{{1
" see systemd.exec(5)
syn match sdExecKey contained /^Exec\%(Start\%(Pre\|Post\|\)\|Reload\|Stop\|StopPost\)=/ nextgroup=sdExecFlag,sdExecFile,sdErr
syn match sdExecKey contained /^\%(WorkingDirectory\|RootDirectory\|TTYPath\)=/ nextgroup=sdFilename,sdErr
syn match sdExecKey contained /^Exec\%(Start\%(Pre\|Post\|\)\|Reload\|Stop\|StopPost\|Condition\)=/ nextgroup=sdExecFlag,sdExecFile,sdErr
syn match sdExecKey contained /^\%(WorkingDirectory\|RootDirectory\|TTYPath\|RootImage\)=/ nextgroup=sdFilename,sdErr
syn match sdExecKey contained /^\%(Runtime\|State\|Cache\|Logs\|Configuration\)Directory=/ nextgroup=sdFilename,sdErr
syn match sdExecKey contained /^\%(Runtime\|State\|Cache\|Logs\|Configuration\)DirectoryMode=/ nextgroup=sdOctal,sdErr
syn match sdExecKey contained /^User=/ nextgroup=sdUser,sdErr
syn match sdExecKey contained /^Group=/ nextgroup=sdUser,sdErr
" TODO: NUMAPolicy, NUMAMask
" TODO: Pass/UnsetEnvironment
" TODO: StandardInput\%(Text\|Data\)
" TODO: Generally everything from 'WorkingDirectory' on down
" TODO: handle some of these better
" FIXME: some of these have moved to Resource Control
" CPUAffinity is: list of uint
" BlockIOWeight is: uint\|filename uint
" BlockIO\%(Read\|Write\)Bandwidth is: filename datasize
syn match sdExecKey contained /^\%(User\|Group\|SupplementaryGroups\|CPUAffinity\|SyslogIdentifier\|PAMName\|TCPWrapName\|ControlGroup\|ControlGroupAttribute\|UtmpIdentifier\)=/
syn match sdExecKey contained /^\%(SupplementaryGroups\|CPUAffinity\|SyslogIdentifier\|PAMName\|TCPWrapName\|ControlGroup\|ControlGroupAttribute\|UtmpIdentifier\)=/
syn match sdExecKey contained /^Limit\%(CPU\|FSIZE\|DATA\|STACK\|CORE\|RSS\|NOFILE\|AS\|NPROC\|MEMLOCK\|LOCKS\|SIGPENDING\|MSGQUEUE\|NICE\|RTPRIO\|RTTIME\)=/ nextgroup=sdRlimit
syn match sdExecKey contained /^\%(CPUSchedulingResetOnFork\|TTYReset\|TTYVHangup\|TTYVTDisallocate\|SyslogLevelPrefix\|ControlGroupModify\|PrivateTmp\|PrivateNetwork\|PrivateDevices\)=/ nextgroup=sdBool,sdErr
syn match sdExecKey contained /^\%(CPUSchedulingResetOnFork\|TTYReset\|TTYVHangup\|TTYVTDisallocate\|SyslogLevelPrefix\|ControlGroupModify\|DynamicUser\|RemoveIPC\|NoNewPrivileges\|RestrictRealtime\|RestrictSUIDSGID\|LockPersonality\|MountAPIVFS\)=/ nextgroup=sdBool,sdErr
syn match sdExecKey contained /^Private\%(Tmp\|Network\|Devices\|Users\|Mounts\)=/ nextgroup=sdBool,sdErr
syn match sdExecKey contained /^Protect\%(KernelTunables\|KernelModules\|KernelLogs\|Clock\|ControlGroups\|Hostname\)=/ nextgroup=sdBool,sdErr
syn match sdExecKey contained /^\%(Nice\|OOMScoreAdjust\)=/ nextgroup=sdInt,sdErr
syn match sdExecKey contained /^\%(CPUSchedulingPriority\|TimerSlackNSec\)=/ nextgroup=sdUInt,sdErr
syn match sdExecKey contained /^\%(ReadWrite\|ReadOnly\|Inaccessible\)Directories=/ nextgroup=sdFileList
@@ -162,7 +213,7 @@ syn match sdKillMode contained nextgroup=sdErr /\%(control-group\|process\|
" Resource Control options for [Service|Socket|Mount|Swap|Slice|Scope] {{{1
" see systemd.resource-control(5)
syn match sdResCtlKey contained /^Slice=/ nextgroup=sdSliceName,sdErr
syn match sdResCtlKey contained /^\%(CPUAccounting\|MemoryAccounting\|IOAccounting\|BlockIOAccounting\|TasksAccounting\|Delegate\)=/ nextgroup=sdBool,sdErr
syn match sdResCtlKey contained /^\%(CPUAccounting\|MemoryAccounting\|IOAccounting\|BlockIOAccounting\|TasksAccounting\|IPAccounting\|Delegate\)=/ nextgroup=sdBool,sdErr
syn match sdResCtlKey contained /^\%(CPUQuota\)=/ nextgroup=sdPercent,sdErr
syn match sdResCtlKey contained /^\%(CPUShares\|StartupCPUShares\)=/ nextgroup=sdUInt,sdErr
syn match sdResCtlKey contained /^MemoryLow=/ nextgroup=sdDatasize,sdPercent,sdErr
@@ -185,12 +236,18 @@ syn region sdServiceBlock matchgroup=sdHeader start=/^\[Service\]/ end=/^\[/me=e
syn match sdServiceKey contained /^BusName=/
syn match sdServiceKey contained /^\%(RemainAfterExit\|GuessMainPID\|PermissionsStartOnly\|RootDirectoryStartOnly\|NonBlocking\|ControlGroupModify\)=/ nextgroup=sdBool,sdErr
syn match sdServiceKey contained /^\%(SysVStartPriority\|FsckPassNo\)=/ nextgroup=sdUInt,sdErr
syn match sdServiceKey contained /^\%(Restart\|Timeout\|TimeoutStart\|TimeoutStop\|Watchdog\|RuntimeMax\)Sec=/ nextgroup=sdDuration,sdErr
syn match sdServiceKey contained /^\%(Restart\|Timeout\|TimeoutStart\|TimeoutStop\|TimeoutAbort\|Watchdog\|RuntimeMax\)Sec=/ nextgroup=sdDuration,sdErr
syn match sdServiceKey contained /^Sockets=/ nextgroup=sdUnitList
syn match sdServiceKey contained /^PIDFile=/ nextgroup=sdFilename,sdErr
syn match sdServiceKey contained /^Type=/ nextgroup=sdServiceType,sdErr
syn match sdServiceKey contained /^Restart=/ nextgroup=sdRestartType,sdErr
syn match sdServiceKey contained /^NotifyAccess=/ nextgroup=sdNotifyType,sdErr
syn match sdServiceKey contained /^StartLimitInterval=/ nextgroup=sdDuration,sdErr
syn match sdServiceKey contained /^StartLimitAction=/ nextgroup=sdLimitAction,sdErr
syn match sdServiceKey contained /^StartLimitBurst=/ nextgroup=sdUInt,sdErr
syn match sdServiceKey contained /^FailureAction=/ nextgroup=sdLimitAction,sdFailAction,sdErr
syn match sdServiceKey contained /^\%(RestartPrevent\|RestartForce\|Success\)ExitStatus=/ nextgroup=sdExitStatus,sdErr
syn match sdServiceKey contained /^RebootArgument=/
syn keyword sdServiceType contained nextgroup=sdErr simple forking dbus oneshot notify idle
syn keyword sdRestartType contained nextgroup=sdErr no on-success on-failure on-abort always
syn keyword sdNotifyType contained nextgroup=sdErr none main all
@@ -201,7 +258,7 @@ syn match sdSocketKey contained /^Listen\%(Stream\|Datagram\|SequentialPacket\|F
syn match sdSocketKey contained /^Listen\%(FIFO\|Special\)=/ nextgroup=sdFilename,sdErr
syn match sdSocketKey contained /^\%(Socket\|Directory\)Mode=/ nextgroup=sdOctal,sdErr
syn match sdSocketKey contained /^\%(Backlog\|MaxConnections\|Priority\|ReceiveBuffer\|SendBuffer\|IPTTL\|Mark\|PipeSize\|MessageQueueMaxMessages\|MessageQueueMessageSize\)=/ nextgroup=sdUInt,sdErr
syn match sdSocketKey contained /^\%(Accept\|KeepAlive\|FreeBind\|Transparent\|Broadcast\|Writable\|NoDelay\)=/ nextgroup=sdBool,sdErr
syn match sdSocketKey contained /^\%(Accept\|KeepAlive\|FreeBind\|Transparent\|Broadcast\|Writable\|NoDelay\|PassCredentials\|PassSecurity\|ReusePort\|RemoveOnStop\|SELinuxContextFromNet\)=/ nextgroup=sdBool,sdErr
syn match sdSocketKey contained /^BindToDevice=/
syn match sdSocketKey contained /^Service=/ nextgroup=sdUnitList
syn match sdSocketKey contained /^BindIPv6Only=/ nextgroup=sdBindIPv6,sdErr
@@ -216,7 +273,8 @@ syn keyword sdTCPCongest contained nextgroup=sdErr westwood veno cubic lp
syn region sdTimerBlock matchgroup=sdHeader start=/^\[Timer\]/ end=/^\[/me=e-2 contains=sdTimerKey
syn match sdTimerKey contained /^On\%(Active\|Boot\|Startup\|UnitActive\|UnitInactive\)Sec=/ nextgroup=sdDuration,sdErr
syn match sdTimerKey contained /^\%(Accuracy\|RandomizedDelay\)Sec=/ nextgroup=sdDuration,sdErr
syn match sdTimerKey contained /^\%(Persistent\|WakeSystem\|RemainAfterElapse\)=/ nextgroup=sdBool,sdErr
syn match sdTimerKey contained /^\%(Persistent\|WakeSystem\|RemainAfterElapse\|OnClockChange\|OnTimezoneChange\)=/ nextgroup=sdBool,sdErr
syn match sdTimerKey contained /^OnCalendar=/ nextgroup=sdCalendar
syn match sdTimerKey contained /^Unit=/ nextgroup=sdUnitList
" TODO: sdCalendar
@@ -227,7 +285,7 @@ syn match sdAutomountKey contained /^DirectoryMode=/ nextgroup=sdOctal,sdErr
" [Mount]
syn region sdMountBlock matchgroup=sdHeader start=/^\[Mount\]/ end=/^\[/me=e-2 contains=sdMountKey,sdAutomountKey,sdExecKey,sdKillKey,sdResCtlKey
syn match sdMountKey contained /^SloppyOptions=/ nextgroup=sdBool,sdErr
syn match sdMountKey contained /^\%(SloppyOptions\|LazyUnmount\|ForceUnmount\)=/ nextgroup=sdBool,sdErr
syn match sdMountKey contained /^\%(What\|Type\|Options\)=/
" [Swap]

View File

@@ -36,7 +36,7 @@ syn match zigBuiltinFn "\v\@(compileLog|ctz|popCount|divExact|divFloor|divTrunc)
syn match zigBuiltinFn "\v\@(embedFile|export|tagName|TagType|errorName|call)>"
syn match zigBuiltinFn "\v\@(errorReturnTrace|fence|fieldParentPtr|field|unionInit)>"
syn match zigBuiltinFn "\v\@(frameAddress|import|newStackCall|asyncCall|intToPtr)>"
syn match zigBuiltinFn "\v\@(memcpy|memset|mod|mulWithOverflow|splat)>"
syn match zigBuiltinFn "\v\@(memcpy|memset|mod|mulWithOverflow|splat|src)>"
syn match zigBuiltinFn "\v\@(bitOffsetOf|byteOffsetOf|OpaqueType|panic|ptrCast)>"
syn match zigBuiltinFn "\v\@(ptrToInt|rem|returnAddress|setCold|Type|shuffle)>"
syn match zigBuiltinFn "\v\@(setRuntimeSafety|setEvalBranchQuota|setFloatMode)>"