Add svelte support, closes #410
This commit is contained in:
parent
2edc785a5e
commit
6b169212f8
@ -10,7 +10,7 @@ A collection of language packs for Vim.
|
|||||||
> One to rule them all, one to find them, one to bring them all and in the darkness bind them.
|
> One to rule them all, one to find them, one to bring them all and in the darkness bind them.
|
||||||
|
|
||||||
- It **won't affect your startup time**, as scripts are loaded only on demand\*.
|
- It **won't affect your startup time**, as scripts are loaded only on demand\*.
|
||||||
- It **installs and updates 120+ times faster** than the <!--Package Count-->143<!--/Package Count--> packages it consists of.
|
- It **installs and updates 120+ times faster** than the <!--Package Count-->144<!--/Package Count--> packages it consists of.
|
||||||
- Solid syntax and indentation support (other features skipped). Only the best language packs.
|
- Solid syntax and indentation support (other features skipped). Only the best language packs.
|
||||||
- All unnecessary files are ignored (like enormous documentation from php support).
|
- All unnecessary files are ignored (like enormous documentation from php support).
|
||||||
- No support for esoteric languages, only most popular ones (modern too, like `slim`).
|
- No support for esoteric languages, only most popular ones (modern too, like `slim`).
|
||||||
@ -162,6 +162,7 @@ If you need full functionality of any plugin, please use it directly with your p
|
|||||||
- [solidity](https://github.com/tomlion/vim-solidity) (syntax, indent, ftplugin)
|
- [solidity](https://github.com/tomlion/vim-solidity) (syntax, indent, ftplugin)
|
||||||
- [styled-components](https://github.com/styled-components/vim-styled-components#main) (syntax, indent, ftplugin)
|
- [styled-components](https://github.com/styled-components/vim-styled-components#main) (syntax, indent, ftplugin)
|
||||||
- [stylus](https://github.com/wavded/vim-stylus) (syntax, indent, ftplugin)
|
- [stylus](https://github.com/wavded/vim-stylus) (syntax, indent, ftplugin)
|
||||||
|
- [svelte](https://github.com/evanleck/vim-svelte) (syntax, indent)
|
||||||
- [svg-indent](https://github.com/jasonshell/vim-svg-indent) (indent)
|
- [svg-indent](https://github.com/jasonshell/vim-svg-indent) (indent)
|
||||||
- [svg](https://github.com/vim-scripts/svg.vim) (syntax)
|
- [svg](https://github.com/vim-scripts/svg.vim) (syntax)
|
||||||
- [swift](https://github.com/keith/swift.vim) (syntax, indent, ftplugin)
|
- [swift](https://github.com/keith/swift.vim) (syntax, indent, ftplugin)
|
||||||
|
@ -182,6 +182,9 @@ function! go#config#DocUrl() abort
|
|||||||
return godoc_url
|
return godoc_url
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! go#config#DocPopupWindow() abort
|
||||||
|
return get(g:, 'go_doc_popup_window', 0)
|
||||||
|
endfunction
|
||||||
function! go#config#DefReuseBuffer() abort
|
function! go#config#DefReuseBuffer() abort
|
||||||
return get(g:, 'go_def_reuse_buffer', 0)
|
return get(g:, 'go_def_reuse_buffer', 0)
|
||||||
endfunction
|
endfunction
|
||||||
|
@ -7,7 +7,7 @@ function! jsx_pretty#comment#update_commentstring(original)
|
|||||||
let syn_start = s:syn_name(line('.'), 1)
|
let syn_start = s:syn_name(line('.'), 1)
|
||||||
let save_cursor = getcurpos()
|
let save_cursor = getcurpos()
|
||||||
|
|
||||||
if syn_start =~ '^jsx'
|
if syn_start =~? '^jsx'
|
||||||
let line = getline(".")
|
let line = getline(".")
|
||||||
let start = len(matchstr(line, '^\s*'))
|
let start = len(matchstr(line, '^\s*'))
|
||||||
let syn_name = s:syn_name(line('.'), start + 1)
|
let syn_name = s:syn_name(line('.'), start + 1)
|
||||||
@ -16,7 +16,7 @@ function! jsx_pretty#comment#update_commentstring(original)
|
|||||||
let &l:commentstring = '// %s'
|
let &l:commentstring = '// %s'
|
||||||
elseif s:syn_contains(line('.'), col('.'), 'jsxTaggedRegion')
|
elseif s:syn_contains(line('.'), col('.'), 'jsxTaggedRegion')
|
||||||
let &l:commentstring = '<!-- %s -->'
|
let &l:commentstring = '<!-- %s -->'
|
||||||
elseif syn_name =~ '^jsxAttrib'
|
elseif syn_name =~? '^jsxAttrib'
|
||||||
let &l:commentstring = '// %s'
|
let &l:commentstring = '// %s'
|
||||||
else
|
else
|
||||||
let &l:commentstring = '{/* %s */}'
|
let &l:commentstring = '{/* %s */}'
|
||||||
|
@ -37,7 +37,7 @@ function! s:prev_line(lnum)
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:syn_attr_jsx(synattr)
|
function! s:syn_attr_jsx(synattr)
|
||||||
return a:synattr =~ "^jsx"
|
return a:synattr =~? "^jsx"
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:syn_xmlish(syns)
|
function! s:syn_xmlish(syns)
|
||||||
@ -45,21 +45,21 @@ function! s:syn_xmlish(syns)
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:syn_jsx_element(syns)
|
function! s:syn_jsx_element(syns)
|
||||||
return get(a:syns, -1) =~ 'jsxElement'
|
return get(a:syns, -1) =~? 'jsxElement'
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:syn_js_comment(syns)
|
function! s:syn_js_comment(syns)
|
||||||
return get(a:syns, -1) =~ 'Comment$'
|
return get(a:syns, -1) =~? 'Comment$'
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:syn_jsx_escapejs(syns)
|
function! s:syn_jsx_escapejs(syns)
|
||||||
return get(a:syns, -1) =~ '\(\(js\(Template\)\?\|javaScript\(Embed\)\?\|typescript\)Braces\|javascriptTemplateSB\|typescriptInterpolationDelimiter\)' &&
|
return get(a:syns, -1) =~? '\(\(js\(Template\)\?\|javaScript\(Embed\)\?\|typescript\)Braces\|javascriptTemplateSB\|typescriptInterpolationDelimiter\)' &&
|
||||||
\ (get(a:syns, -2) =~ 'jsxEscapeJs' ||
|
\ (get(a:syns, -2) =~? 'jsxEscapeJs' ||
|
||||||
\ get(a:syns, -3) =~ 'jsxEscapeJs')
|
\ get(a:syns, -3) =~? 'jsxEscapeJs')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:syn_jsx_attrib(syns)
|
function! s:syn_jsx_attrib(syns)
|
||||||
return len(filter(copy(a:syns), 'v:val =~ "jsxAttrib"'))
|
return len(filter(copy(a:syns), 'v:val =~? "jsxAttrib"'))
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
let s:start_tag = '<\s*\([-:_\.\$0-9A-Za-z]\+\|>\)'
|
let s:start_tag = '<\s*\([-:_\.\$0-9A-Za-z]\+\|>\)'
|
||||||
|
1
build
1
build
@ -272,6 +272,7 @@ PACKS="
|
|||||||
solidity:tomlion/vim-solidity
|
solidity:tomlion/vim-solidity
|
||||||
styled-components:styled-components/vim-styled-components#main
|
styled-components:styled-components/vim-styled-components#main
|
||||||
stylus:wavded/vim-stylus
|
stylus:wavded/vim-stylus
|
||||||
|
svelte:evanleck/vim-svelte
|
||||||
svg-indent:jasonshell/vim-svg-indent
|
svg-indent:jasonshell/vim-svg-indent
|
||||||
svg:vim-scripts/svg.vim
|
svg:vim-scripts/svg.vim
|
||||||
swift:keith/swift.vim
|
swift:keith/swift.vim
|
||||||
|
@ -1313,6 +1313,13 @@ autocmd BufNewFile,BufReadPost *.stylus set filetype=stylus
|
|||||||
augroup end
|
augroup end
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'svelte') == -1
|
||||||
|
augroup filetypedetect
|
||||||
|
" svelte, from svelte.vim in evanleck/vim-svelte
|
||||||
|
au BufRead,BufNewFile *.svelte setfiletype svelte
|
||||||
|
augroup end
|
||||||
|
endif
|
||||||
|
|
||||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'sxhkd') == -1
|
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'sxhkd') == -1
|
||||||
augroup filetypedetect
|
augroup filetypedetect
|
||||||
" sxhkd, from sxhkdrc.vim in baskerville/vim-sxhkdrc
|
" sxhkd, from sxhkdrc.vim in baskerville/vim-sxhkdrc
|
||||||
|
@ -38,7 +38,7 @@ if exists("g:rst_style") && g:rst_style != 0
|
|||||||
setlocal expandtab shiftwidth=3 softtabstop=3 tabstop=8
|
setlocal expandtab shiftwidth=3 softtabstop=3 tabstop=8
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if has('patch-7.3.867') " Introduced the TextChanged event.
|
if g:rst_fold_enabled != 0 && has('patch-7.3.867') " Introduced the TextChanged event.
|
||||||
setlocal foldmethod=expr
|
setlocal foldmethod=expr
|
||||||
setlocal foldexpr=RstFold#GetRstFold()
|
setlocal foldexpr=RstFold#GetRstFold()
|
||||||
setlocal foldtext=RstFold#GetRstFoldText()
|
setlocal foldtext=RstFold#GetRstFoldText()
|
||||||
|
128
indent/svelte.vim
Normal file
128
indent/svelte.vim
Normal file
@ -0,0 +1,128 @@
|
|||||||
|
if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'svelte') != -1
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Vim indent file
|
||||||
|
" Language: Svelte 3 (HTML/JavaScript)
|
||||||
|
" Author: Evan Lecklider <evan@lecklider.com>
|
||||||
|
" Maintainer: Evan Lecklide <evan@lecklider.com>
|
||||||
|
" URL: https://github.com/evanleck/vim-svelte
|
||||||
|
|
||||||
|
if exists("b:did_indent")
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
|
||||||
|
runtime! indent/html.vim
|
||||||
|
unlet! b:did_indent
|
||||||
|
|
||||||
|
let s:html_indent = &l:indentexpr
|
||||||
|
let b:did_indent = 1
|
||||||
|
|
||||||
|
setlocal indentexpr=GetSvelteIndent()
|
||||||
|
setlocal indentkeys=o,O,*<Return>,<>>,{,},0),0],!^F,;,=:else,=:then,=:catch,=/if,=/each,=/await
|
||||||
|
|
||||||
|
" Only define the function once.
|
||||||
|
if exists('*GetSvelteIndent')
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
|
||||||
|
function! GetSvelteIndent()
|
||||||
|
let current_line_number = v:lnum
|
||||||
|
|
||||||
|
if current_line_number == 0
|
||||||
|
return 0
|
||||||
|
endif
|
||||||
|
|
||||||
|
let current_line = getline(current_line_number)
|
||||||
|
|
||||||
|
" Opening script and style tags should be all the way outdented.
|
||||||
|
if current_line =~ '^\s*</\?\(script\|style\)'
|
||||||
|
return 0
|
||||||
|
endif
|
||||||
|
|
||||||
|
let previous_line_number = prevnonblank(current_line_number - 1)
|
||||||
|
let previous_line = getline(previous_line_number)
|
||||||
|
let previous_line_indent = indent(previous_line_number)
|
||||||
|
|
||||||
|
" The inside of scripts an styles should be indented.
|
||||||
|
if previous_line =~ '^<\(script\|style\)'
|
||||||
|
return shiftwidth()
|
||||||
|
endif
|
||||||
|
|
||||||
|
execute "let indent = " . s:html_indent
|
||||||
|
|
||||||
|
" For some reason, the HTML CSS indentation keeps indenting the next line over
|
||||||
|
" and over after each style declaration.
|
||||||
|
if searchpair('<style>', '', '</style>', 'bW') && previous_line =~ ';$' && current_line !~ '}'
|
||||||
|
return previous_line_indent
|
||||||
|
endif
|
||||||
|
|
||||||
|
" "#if" or "#each"
|
||||||
|
if previous_line =~ '^\s*{\s*#\(if\|each\|await\)'
|
||||||
|
return previous_line_indent + shiftwidth()
|
||||||
|
endif
|
||||||
|
|
||||||
|
" ":else" or ":then"
|
||||||
|
if previous_line =~ '^\s*{\s*:\(else\|catch\|then\)'
|
||||||
|
return previous_line_indent + shiftwidth()
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Custom element juggling for abnormal self-closing tags (<Widget />),
|
||||||
|
" capitalized component tags (<Widget></Widget>), and custom svelte tags
|
||||||
|
" (<svelte:head></svelte:head>).
|
||||||
|
if synID(previous_line_number, match(previous_line, '\S') + 1, 0) == hlID('htmlTag')
|
||||||
|
\ && synID(current_line_number, match(current_line, '\S') + 1, 0) != hlID('htmlEndTag')
|
||||||
|
let indents_match = indent == previous_line_indent
|
||||||
|
let previous_closes = previous_line =~ '/>$'
|
||||||
|
|
||||||
|
if indents_match && !previous_closes && previous_line =~ '<\(\u\|\l\+:\l\+\)'
|
||||||
|
return previous_line_indent + shiftwidth()
|
||||||
|
elseif !indents_match && previous_closes
|
||||||
|
return previous_line_indent
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
" "/await" or ":catch" or ":then"
|
||||||
|
if current_line =~ '^\s*{\s*\/await' || current_line =~ '^\s*{\s*:\(catch\|then\)'
|
||||||
|
let await_start = searchpair('{\s*#await\>', '', '{\s*\/await\>', 'bW')
|
||||||
|
|
||||||
|
if await_start
|
||||||
|
return indent(await_start)
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
" "/each"
|
||||||
|
if current_line =~ '^\s*{\s*\/each'
|
||||||
|
let each_start = searchpair('{\s*#each\>', '', '{\s*\/each\>', 'bW')
|
||||||
|
|
||||||
|
if each_start
|
||||||
|
return indent(each_start)
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
" "/if"
|
||||||
|
if current_line =~ '^\s*{\s*\/if'
|
||||||
|
let if_start = searchpair('{\s*#if\>', '', '{\s*\/if\>', 'bW')
|
||||||
|
|
||||||
|
if if_start
|
||||||
|
return indent(if_start)
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
" ":else" is tricky because it can match an opening "#each" _or_ an opening
|
||||||
|
" "#if", so we try to be smart and look for the closest of the two.
|
||||||
|
if current_line =~ '^\s*{\s*:else'
|
||||||
|
let if_start = searchpair('{\s*#if\>', '', '{\s*\/if\>', 'bW')
|
||||||
|
|
||||||
|
" If it's an "else if" then we know to look for an "#if"
|
||||||
|
if current_line =~ '^\s*{\s*:else if' && if_start
|
||||||
|
return indent(if_start)
|
||||||
|
else
|
||||||
|
" The greater line number will be closer to the cursor position because
|
||||||
|
" we're searching backward.
|
||||||
|
return indent(max([if_start, searchpair('{\s*#each\>', '', '{\s*\/each\>', 'bW')]))
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
return indent
|
||||||
|
endfunction
|
61
syntax/svelte.vim
Normal file
61
syntax/svelte.vim
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'svelte') != -1
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Vim syntax file
|
||||||
|
" Language: Svelte 3 (HTML/JavaScript)
|
||||||
|
" Author: Evan Lecklider <evan@lecklider.com>
|
||||||
|
" Maintainer: Evan Lecklide <evan@lecklider.com>
|
||||||
|
" Depends: pangloss/vim-javascript
|
||||||
|
" URL: https://github.com/evanleck/vim-svelte
|
||||||
|
"
|
||||||
|
" Like vim-jsx, this depends on the pangloss/vim-javascript syntax package (and
|
||||||
|
" is tested against it exclusively). If you're using vim-polyglot (like I am),
|
||||||
|
" then you're all set.
|
||||||
|
|
||||||
|
if exists("b:current_syntax")
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Read HTML to begin with.
|
||||||
|
runtime! syntax/html.vim
|
||||||
|
unlet! b:current_syntax
|
||||||
|
|
||||||
|
" Expand HTML tag names to include mixed case, periods, and colons.
|
||||||
|
syntax match htmlTagName contained "\<[a-zA-Z:\.]*\>"
|
||||||
|
|
||||||
|
" Special attributes that include some kind of binding e.g. "on:click",
|
||||||
|
" "bind:something", etc.
|
||||||
|
syntax match svelteKeyword "\<[a-z]\+:[a-zA-Z|]\+=" contained containedin=htmlTag
|
||||||
|
|
||||||
|
" The "slot" attribute has special meaning.
|
||||||
|
syntax keyword svelteKeyword slot contained containedin=htmlTag
|
||||||
|
|
||||||
|
" According to vim-jsx, you can let jsBlock take care of ending the region.
|
||||||
|
" https://github.com/mxw/vim-jsx/blob/master/after/syntax/jsx.vim
|
||||||
|
"
|
||||||
|
" ALLBUT,htmlSpecialTagName keeps Vim from marking CSS regions as jsBlock.
|
||||||
|
syntax region svelteExpression start="{" end="" contains=jsBlock,javascriptBlock containedin=htmlString,htmlTag,htmlArg,htmlValue,htmlH1,htmlH2,htmlH3,htmlH4,htmlH5,htmlH6,htmlHead,htmlTitle,htmlBoldItalicUnderline,htmlUnderlineBold,htmlUnderlineItalicBold,htmlUnderlineBoldItalic,htmlItalicUnderline,htmlItalicBold,htmlItalicBoldUnderline,htmlItalicUnderlineBold,htmlLink,htmlLeadingSpace,htmlBold,htmlBoldUnderline,htmlBoldItalic,htmlBoldUnderlineItalic,htmlUnderline,htmlUnderlineItalic,htmlItalic,htmlStrike,javaScript
|
||||||
|
|
||||||
|
" Block conditionals.
|
||||||
|
syntax match svelteConditional "#if" contained containedin=jsBlock,javascriptBlock
|
||||||
|
syntax match svelteConditional "/if" contained containedin=jsBlock,javascriptBlock
|
||||||
|
syntax match svelteConditional ":else if" contained containedin=jsBlock,javascriptBlock
|
||||||
|
syntax match svelteConditional ":else" contained containedin=jsBlock,javascriptBlock
|
||||||
|
|
||||||
|
" Block keywords.
|
||||||
|
syntax match svelteKeyword "#await" contained containedin=jsBlock,javascriptBlock
|
||||||
|
syntax match svelteKeyword "/await" contained containedin=jsBlock,javascriptBlock
|
||||||
|
syntax match svelteKeyword ":catch" contained containedin=jsBlock,javascriptBlock
|
||||||
|
syntax match svelteKeyword ":then" contained containedin=jsBlock,javascriptBlock
|
||||||
|
syntax match svelteKeyword "@html" contained containedin=jsBlock,javascriptBlock
|
||||||
|
|
||||||
|
" Repeat functions.
|
||||||
|
syntax match svelteRepeat "#each" contained containedin=jsBlock,javascriptBlock
|
||||||
|
syntax match svelteRepeat "/each" contained containedin=jsBlock,javascriptBlock
|
||||||
|
|
||||||
|
highlight def link svelteConditional Conditional
|
||||||
|
highlight def link svelteKeyword Keyword
|
||||||
|
highlight def link svelteRepeat Repeat
|
||||||
|
|
||||||
|
let b:current_syntax = "svelte"
|
@ -44,7 +44,7 @@ syn match zigBuiltinFn "\v\@(noInlineCall|bitOffsetOf|byteOffsetOf|OpaqueType|pa
|
|||||||
syn match zigBuiltinFn "\v\@(ptrToInt|rem|returnAddress|setCold)>"
|
syn match zigBuiltinFn "\v\@(ptrToInt|rem|returnAddress|setCold)>"
|
||||||
syn match zigBuiltinFn "\v\@(setRuntimeSafety|setEvalBranchQuota|setFloatMode)>"
|
syn match zigBuiltinFn "\v\@(setRuntimeSafety|setEvalBranchQuota|setFloatMode)>"
|
||||||
syn match zigBuiltinFn "\v\@(setGlobalLinkage|setGlobalSection|shlExact|This|hasDecl)>"
|
syn match zigBuiltinFn "\v\@(setGlobalLinkage|setGlobalSection|shlExact|This|hasDecl)>"
|
||||||
syn match zigBuiltinFn "\v\@(shlWithOverflow|shrExact|sizeOf|sqrt|bswap|subWithOverflow|intCast|floatCast|intToFloat|floatToInt|boolToInt|errSetCast)>"
|
syn match zigBuiltinFn "\v\@(shlWithOverflow|shrExact|sizeOf|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\@(truncate|typeId|typeInfo|typeName|typeOf|atomicRmw|bytesToSlice|sliceToBytes)>"
|
||||||
syn match zigBuiltinFn "\v\@(intToError|errorToInt|intToEnum|enumToInt|setAlignStack|handle|bitreverse|Vector)>"
|
syn match zigBuiltinFn "\v\@(intToError|errorToInt|intToEnum|enumToInt|setAlignStack|handle|bitreverse|Vector)>"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user