Compare commits

...

2 Commits

Author SHA1 Message Date
Adam Stankiewicz
35ea4d2b90 Update 2020-01-25 16:56:10 +01:00
Chris Bandy
967486dd71 Combine ftdetect files in a predictable order (#461)
Bash expands patterns to an alphabetically sorted list of filenames, but
the order depends on LC_COLLATE. On both Linux and BSD, `sort -V` uses
the C locale.
2020-01-25 16:54:44 +01:00
15 changed files with 91 additions and 48 deletions

View File

@@ -62,18 +62,19 @@ function! s:RustfmtWriteMode()
endif
endfunction
function! s:RustfmtConfig()
function! s:RustfmtConfigOptions()
let l:rustfmt_toml = findfile('rustfmt.toml', expand('%:p:h') . ';')
if l:rustfmt_toml !=# ''
return '--config-path '.l:rustfmt_toml
return '--config-path '.fnamemodify(l:rustfmt_toml, ":p")
endif
let l:_rustfmt_toml = findfile('.rustfmt.toml', expand('%:p:h') . ';')
if l:_rustfmt_toml !=# ''
return '--config-path '.l:_rustfmt_toml
return '--config-path '.fnamemodify(l:_rustfmt_toml, ":p")
endif
return ''
" Default to edition 2018 in case no rustfmt.toml was found.
return '--edition 2018'
endfunction
function! s:RustfmtCommandRange(filename, line1, line2)
@@ -84,7 +85,7 @@ function! s:RustfmtCommandRange(filename, line1, line2)
let l:arg = {"file": shellescape(a:filename), "range": [a:line1, a:line2]}
let l:write_mode = s:RustfmtWriteMode()
let l:rustfmt_config = s:RustfmtConfig()
let l:rustfmt_config = s:RustfmtConfigOptions()
" FIXME: When --file-lines gets to be stable, add version range checking
" accordingly.
@@ -98,14 +99,9 @@ function! s:RustfmtCommandRange(filename, line1, line2)
endfunction
function! s:RustfmtCommand()
if g:rustfmt_emit_files
let l:write_mode = "--emit=stdout"
else
let l:write_mode = "--write-mode=display"
endif
" rustfmt will pick on the right config on its own due to the
" current directory change.
return g:rustfmt_command . " ". l:write_mode . " " . g:rustfmt_options
let write_mode = g:rustfmt_emit_files ? '--emit=stdout' : '--write-mode=display'
let config = s:RustfmtConfigOptions()
return join([g:rustfmt_command, write_mode, config, g:rustfmt_options])
endfunction
function! s:DeleteLines(start, end) abort

View File

@@ -1,5 +1,8 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'terraform') == -1
let s:cpo_save = &cpoptions
set cpoptions&vim
" Ensure no conflict with arguments from the environment
let $TF_CLI_ARGS_fmt=''
@@ -61,4 +64,7 @@ function! terraform#commands(ArgLead, CmdLine, CursorPos)
return join(l:commands, "\n")
endfunction
let &cpoptions = s:cpo_save
unlet s:cpo_save
endif

10
build
View File

@@ -72,8 +72,11 @@ extract() {
continue
fi
[ -d "${dir}${subtree:-/}ftdetect" ] && for f in "${dir}${subtree:-/}ftdetect/"*; do
cat <<EOF >> tmp/polyglot.vim
ftdetect=("${dir}${subtree:-/}ftdetect"/*)
if [ "$ftdetect" ] && [ "$ftdetect" != "${dir}${subtree:-/}ftdetect/*" ]; then
IFS=$'\n' ftdetect=($(sort -V <<< "${ftdetect[*]}")); unset IFS
for f in "${ftdetect[@]}"; do
cat <<EOF >> tmp/polyglot.vim
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, '${pack%%:*}') == -1
augroup filetypedetect
" ${pack%%:*}, from ${f##*/ftdetect/} in ${pack#*:}
@@ -82,7 +85,8 @@ $(cat "${f}")
endif
EOF
done
done
fi
done

View File

@@ -692,11 +692,11 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'jenkins') == -1
augroup filetypedetect
" jenkins, from Jenkinsfile.vim in martinda/Jenkinsfile-vim-syntax
" Jenkinsfile
augroup JenkinsAUGroup
autocmd BufRead,BufNewFile *Jenkins* set ft=Jenkinsfile
autocmd BufRead,BufNewFile *jenkins* set ft=Jenkinsfile
augroup END
autocmd BufRead,BufNewFile Jenkinsfile set ft=Jenkinsfile
autocmd BufRead,BufNewFile Jenkinsfile* setf Jenkinsfile
autocmd BufRead,BufNewFile *.jenkinsfile set ft=Jenkinsfile
autocmd BufRead,BufNewFile *.jenkinsfile setf Jenkinsfile
autocmd BufRead,BufNewFile *.Jenkinsfile setf Jenkinsfile
augroup end
endif
@@ -769,15 +769,15 @@ endif
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'llvm') == -1
augroup filetypedetect
" llvm, from llvm-lit.vim in rhysd/vim-llvm
au BufRead,BufNewFile lit.*cfg set filetype=python
" llvm, from llvm.vim in rhysd/vim-llvm
au BufRead,BufNewFile *.ll set filetype=llvm
augroup end
endif
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'llvm') == -1
augroup filetypedetect
" llvm, from llvm.vim in rhysd/vim-llvm
au BufRead,BufNewFile *.ll set filetype=llvm
" llvm, from llvm-lit.vim in rhysd/vim-llvm
au BufRead,BufNewFile lit.*cfg set filetype=python
augroup end
endif
@@ -854,6 +854,7 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'meson') == -1
" meson, from meson.vim in mesonbuild/meson:_ALL:/data/syntax-highlighting/vim/
au BufNewFile,BufRead meson.build set filetype=meson
au BufNewFile,BufRead meson_options.txt set filetype=meson
au BufNewFile,BufRead *.wrap set filetype=dosini
augroup end
endif
@@ -1296,6 +1297,9 @@ au BufNewFile,BufRead [rR]outefile call s:setf('ruby')
" SimpleCov
au BufNewFile,BufRead .simplecov call s:setf('ruby')
" Sorbet RBI files
au BufNewFile,BufRead *.rbi call s:setf('ruby')
" Thor
au BufNewFile,BufRead [tT]horfile,*.thor call s:setf('ruby')
@@ -1420,7 +1424,7 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'terraform') ==
augroup filetypedetect
" terraform, from terraform.vim in hashivim/vim-terraform
" By default, Vim associates .tf files with TinyFugue - tell it not to.
autocmd! filetypedetect BufRead,BufNewFile *.tf
silent! autocmd! filetypedetect BufRead,BufNewFile *.tf
autocmd BufRead,BufNewFile *.tf set filetype=terraform
autocmd BufRead,BufNewFile *.tfvars set filetype=terraform
autocmd BufRead,BufNewFile *.tfstate set filetype=json
@@ -1532,17 +1536,17 @@ endif
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'vifm') == -1
augroup filetypedetect
" vifm, from vifm-rename.vim in vifm/vifm.vim
autocmd BufRead,BufNewFile vifm.rename* :set filetype=vifm-rename
" vifm, from vifm.vim in vifm/vifm.vim
autocmd BufRead,BufNewFile vifmrc :set filetype=vifm
autocmd BufRead,BufNewFile *vifm/colors/* :set filetype=vifm
autocmd BufRead,BufNewFile *.vifm :set filetype=vifm
augroup end
endif
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'vifm') == -1
augroup filetypedetect
" vifm, from vifm.vim in vifm/vifm.vim
autocmd BufRead,BufNewFile vifmrc :set filetype=vifm
autocmd BufRead,BufNewFile *vifm/colors/* :set filetype=vifm
autocmd BufRead,BufNewFile *.vifm :set filetype=vifm
" vifm, from vifm-rename.vim in vifm/vifm.vim
autocmd BufRead,BufNewFile vifm.rename* :set filetype=vifm-rename
augroup end
endif

View File

@@ -34,14 +34,16 @@ endif
function! DhallFormat()
let cursor = getpos('.')
exec 'silent %!dhall format'
exec 'normal! gg'
exec 'silent !dhall format --inplace ' . expand('%')
exec 'e'
call setpos('.', cursor)
endfunction
if exists('g:dhall_format')
if g:dhall_format == 1
augroup dhall
au BufWritePre *.dhall call DhallFormat()
au BufWritePost *.dhall call DhallFormat()
augroup END
endif
endif

View File

@@ -54,7 +54,7 @@ function! s:HandleRunResults(exitcode, listf)
if filereadable(a:listf) && l:insert_pos != 0
for line in readfile(a:listf)
call append(l:insert_pos, 'Attach: '.line)
call append(l:insert_pos, 'Attach: '.escape(line, " "))
let l:insert_pos += 1
endfor
endif

View File

@@ -1,7 +1,7 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'typescript') == -1
syntax match typescriptDecorator /@\([_$a-zA-Z][_$a-zA-Z0-9]*\.\)*[_$a-zA-Z][_$a-zA-Z0-9]*\>/
\ nextgroup=typescriptArgumentList,typescriptTypeArguments
\ nextgroup=typescriptFuncCallArg,typescriptTypeArguments
\ contains=@_semantic,typescriptDotNotation
endif

View File

@@ -40,7 +40,7 @@ syntax match typescriptArrowFuncDef contained /\K\k*\s*=>/
\ skipwhite skipempty
" TODO: optimize this pattern
syntax region typescriptArrowFuncDef contained start=/(\_[^)]*):/ end=/=>/
syntax region typescriptArrowFuncDef contained start=/(\_[^(^)]*):/ end=/=>/
\ contains=typescriptArrowFuncArg,typescriptArrowFunc,typescriptTypeAnnotation
\ nextgroup=@typescriptExpression,typescriptBlock
\ skipwhite skipempty keepend

View File

@@ -1,8 +1,17 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'typescript') == -1
"Import
syntax keyword typescriptImport from as import
syntax keyword typescriptImport from as
syntax keyword typescriptImport import
\ nextgroup=typescriptImportType
\ skipwhite
syntax keyword typescriptImportType type
\ contained
syntax keyword typescriptExport export
\ nextgroup=typescriptExportType
\ skipwhite
syntax match typescriptExportType /\<type\s*{\@=/
\ contained skipwhite skipempty skipnl
syntax keyword typescriptModule namespace module
"this

View File

@@ -7,7 +7,7 @@ syntax keyword typescriptConstructor contained constructor
syntax cluster memberNextGroup contains=typescriptMemberOptionality,typescriptTypeAnnotation,@typescriptCallSignature
syntax match typescriptMember /\K\k*/
syntax match typescriptMember /#\?\K\k*/
\ nextgroup=@memberNextGroup
\ contained skipwhite

View File

@@ -13,6 +13,8 @@ if main_syntax == 'typescript' || main_syntax == 'typescriptreact'
setlocal iskeyword+=$
" syntax cluster htmlJavaScript contains=TOP
endif
" For private field added from TypeScript 3.8
setlocal iskeyword+=#
" lowest priority on least used feature
syntax match typescriptLabel /[a-zA-Z_$]\k*:/he=e-1 contains=typescriptReserved nextgroup=@typescriptStatement skipwhite skipempty
@@ -101,8 +103,10 @@ if exists("did_typescript_hilink")
HiLink typescriptLabel Label
HiLink typescriptStringProperty String
HiLink typescriptImport Special
HiLink typescriptImportType Special
HiLink typescriptAmbientDeclaration Special
HiLink typescriptExport Special
HiLink typescriptExportType Special
HiLink typescriptModule Special
HiLink typescriptTry Special
HiLink typescriptExceptions Special

View File

@@ -395,6 +395,24 @@ function! s:hi()
hi def link goDiagnosticError SpellBad
hi def link goDiagnosticWarning SpellRare
" TODO(bc): is it appropriate to define text properties in a syntax file?
" The highlight groups need to be defined before the text properties types
" are added, and when users have syntax enabled in their vimrc after
" filetype plugin on, the highlight groups won't be defined when
" ftplugin/go.vim is executed when the first go file is opened.
" See https://github.com/fatih/vim-go/issues/2658.
if exists('*prop_type_add')
if empty(prop_type_get('goSameId'))
call prop_type_add('goSameId', {'highlight': 'goSameId'})
endif
if empty(prop_type_get('goDiagnosticError'))
call prop_type_add('goDiagnosticError', {'highlight': 'goDiagnosticError'})
endif
if empty(prop_type_get('goDiagnosticWarning'))
call prop_type_add('goDiagnosticWarning', {'highlight': 'goDiagnosticWarning'})
endif
endif
hi def link goDeclsFzfKeyword Keyword
hi def link goDeclsFzfFunction Function
hi def link goDeclsFzfSpecialComment SpecialComment

View File

@@ -81,10 +81,10 @@ hi def link gotplFunctions Function
hi def link goSprigFunctions Function
hi def link goTplVariable Special
syn region gotplAction start="{{" end="}}" contains=@gotplLiteral,gotplControl,gotplFunctions,goSprigFunctions,gotplVariable,goTplIdentifier containedin=yamlFlowString display
syn region gotplAction start="\[\[" end="\]\]" contains=@gotplLiteral,gotplControl,gotplFunctions,goSprigFunctions,gotplVariable containedin=yamlFlowString display
syn region goTplComment start="{{\(- \)\?/\*" end="\*/\( -\)\?}}" display
syn region goTplComment start="\[\[\(- \)\?/\*" end="\*/\( -\)\?\]\]" display
syn region gotplAction start="{{\(-? \)\?" end="\( -?\)\?}}" contains=@gotplLiteral,gotplControl,gotplFunctions,goSprigFunctions,gotplVariable,goTplIdentifier containedin=yamlFlowString display
syn region gotplAction start="\[\[\(-? \)\?" end="\( -?\)\?\]\]" contains=@gotplLiteral,gotplControl,gotplFunctions,goSprigFunctions,gotplVariable containedin=yamlFlowString display
syn region goTplComment start="{{\(-? \)\?/\*" end="\*/\( -?\)\?}}" display
syn region goTplComment start="\[\[\(-? \)\?/\*" end="\*/\( -?\)\?\]\]" display
hi def link gotplAction PreProc
hi def link goTplComment Comment

View File

@@ -201,7 +201,7 @@ syntax match jsDestructuringNoise contained /[,[\]]/
syntax region jsDestructuringPropertyComputed contained matchgroup=jsDestructuringBraces start=/\[/ end=/]/ contains=@jsExpression skipwhite skipempty nextgroup=jsDestructuringValue,jsDestructuringValueAssignment,jsDestructuringNoise extend fold
" Comments
syntax keyword jsCommentTodo contained TODO FIXME XXX TBD
syntax keyword jsCommentTodo contained TODO FIXME XXX TBD NOTE
syntax region jsComment start=+//+ end=/$/ contains=jsCommentTodo,@Spell extend keepend
syntax region jsComment start=+/\*+ end=+\*/+ contains=jsCommentTodo,@Spell fold extend keepend
syntax region jsEnvComment start=/\%^#!/ end=/$/ display

View File

@@ -10,7 +10,7 @@ if exists("b:current_syntax")
endif
let b:current_syntax = "zig"
syn keyword zigStorage const var extern packed export pub noalias inline noinline comptime nakedcc stdcallcc volatile allowzero align linksection threadlocal
syn keyword zigStorage const var extern packed export pub noalias inline noinline comptime callconv volatile allowzero align linksection threadlocal
syn keyword zigStructure struct enum union error
syn keyword zigStatement break return continue asm defer errdefer unreachable try catch async noasync await suspend resume
syn keyword zigConditional if else switch and or orelse
@@ -29,7 +29,7 @@ syn match zigType "\v<[iu][1-9]\d*>"
syn match zigOperator display "\%(+%\?\|-%\?\|/\|*%\?\|=\|\^\|&\|?\||\|!\|>\|<\|%\|<<%\?\|>>\)=\?"
syn match zigArrowCharacter display "->"
syn match zigBuiltinFn "\v\@(addWithOverflow|ArgType|atomicLoad|bitCast|breakpoint)>"
syn match zigBuiltinFn "\v\@(addWithOverflow|ArgType|atomicLoad|atomicStore|bitCast|breakpoint)>"
syn match zigBuiltinFn "\v\@(alignCast|alignOf|cDefine|cImport|cInclude)>"
syn match zigBuiltinFn "\v\@(cUndef|canImplicitCast|clz|cmpxchgWeak|cmpxchgStrong|compileError)>"
syn match zigBuiltinFn "\v\@(compileLog|ctz|popCount|divExact|divFloor|divTrunc)>"
@@ -42,10 +42,10 @@ 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)>"
syn match zigBuiltinFn "\v\@(setGlobalLinkage|setGlobalSection|shlExact|This|hasDecl|hasField)>"
syn match zigBuiltinFn "\v\@(shlWithOverflow|shrExact|sizeOf|sqrt|byteSwap|subWithOverflow|intCast|floatCast|intToFloat|floatToInt|boolToInt|errSetCast)>"
syn match zigBuiltinFn "\v\@(shlWithOverflow|shrExact|sizeOf|bitSizeOf|sqrt|byteSwap|subWithOverflow|intCast|floatCast|intToFloat|floatToInt|boolToInt|errSetCast)>"
syn match zigBuiltinFn "\v\@(truncate|typeId|typeInfo|typeName|TypeOf|atomicRmw|bytesToSlice|sliceToBytes)>"
syn match zigBuiltinFn "\v\@(intToError|errorToInt|intToEnum|enumToInt|setAlignStack|frame|Frame|frameSize|bitReverse|Vector)>"
syn match zigBuiltinFn "\v\@(sin|cos|exp|exp2|ln|log2|log10|fabs|floor|ceil|trunc|round)>"
syn match zigBuiltinFn "\v\@(sin|cos|exp|exp2|log|log2|log10|fabs|floor|ceil|trunc|round)>"
syn match zigDecNumber display "\<[0-9]\+\%(.[0-9]\+\)\=\%([eE][+-]\?[0-9]\+\)\="
syn match zigHexNumber display "\<0x[a-fA-F0-9]\+\%([a-fA-F0-9]\+\%([pP][+-]\?[0-9]\+\)\?\)\="