Compare commits

...

4 Commits

Author SHA1 Message Date
Adam Stankiewicz
d527002849 Update 2019-06-16 18:36:23 +02:00
Adam Stankiewicz
15727e7eb0 Add zephir support 2019-06-14 16:11:54 +02:00
Adam Stankiewicz
6b169212f8 Add svelte support, closes #410 2019-06-14 16:07:20 +02:00
Adam Stankiewicz
2edc785a5e Make typescript.tsx default filetype for tsx, fixes #409 2019-06-09 00:08:31 +02:00
13 changed files with 377 additions and 13 deletions

View File

@@ -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.
- 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-->145<!--/Package Count--> packages it consists of.
- Solid syntax and indentation support (other features skipped). Only the best language packs.
- All unnecessary files are ignored (like enormous documentation from php support).
- 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)
- [styled-components](https://github.com/styled-components/vim-styled-components#main) (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](https://github.com/vim-scripts/svg.vim) (syntax)
- [swift](https://github.com/keith/swift.vim) (syntax, indent, ftplugin)
@@ -187,6 +188,7 @@ If you need full functionality of any plugin, please use it directly with your p
- [xml](https://github.com/amadeus/vim-xml) (syntax)
- [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)
<!--/Language Packs-->

View File

@@ -182,6 +182,9 @@ function! go#config#DocUrl() abort
return godoc_url
endfunction
function! go#config#DocPopupWindow() abort
return get(g:, 'go_doc_popup_window', 0)
endfunction
function! go#config#DefReuseBuffer() abort
return get(g:, 'go_def_reuse_buffer', 0)
endfunction

View File

@@ -7,7 +7,7 @@ function! jsx_pretty#comment#update_commentstring(original)
let syn_start = s:syn_name(line('.'), 1)
let save_cursor = getcurpos()
if syn_start =~ '^jsx'
if syn_start =~? '^jsx'
let line = getline(".")
let start = len(matchstr(line, '^\s*'))
let syn_name = s:syn_name(line('.'), start + 1)
@@ -16,7 +16,7 @@ function! jsx_pretty#comment#update_commentstring(original)
let &l:commentstring = '// %s'
elseif s:syn_contains(line('.'), col('.'), 'jsxTaggedRegion')
let &l:commentstring = '<!-- %s -->'
elseif syn_name =~ '^jsxAttrib'
elseif syn_name =~? '^jsxAttrib'
let &l:commentstring = '// %s'
else
let &l:commentstring = '{/* %s */}'

View File

@@ -37,7 +37,7 @@ function! s:prev_line(lnum)
endfunction
function! s:syn_attr_jsx(synattr)
return a:synattr =~ "^jsx"
return a:synattr =~? "^jsx"
endfunction
function! s:syn_xmlish(syns)
@@ -45,21 +45,21 @@ function! s:syn_xmlish(syns)
endfunction
function! s:syn_jsx_element(syns)
return get(a:syns, -1) =~ 'jsxElement'
return get(a:syns, -1) =~? 'jsxElement'
endfunction
function! s:syn_js_comment(syns)
return get(a:syns, -1) =~ 'Comment$'
return get(a:syns, -1) =~? 'Comment$'
endfunction
function! s:syn_jsx_escapejs(syns)
return get(a:syns, -1) =~ '\(\(js\(Template\)\?\|javaScript\(Embed\)\?\|typescript\)Braces\|javascriptTemplateSB\|typescriptInterpolationDelimiter\)' &&
\ (get(a:syns, -2) =~ 'jsxEscapeJs' ||
\ get(a:syns, -3) =~ 'jsxEscapeJs')
return get(a:syns, -1) =~? '\(\(js\(Template\)\?\|javaScript\(Embed\)\?\|typescript\)Braces\|javascriptTemplateSB\|typescriptInterpolationDelimiter\)' &&
\ (get(a:syns, -2) =~? 'jsxEscapeJs' ||
\ get(a:syns, -3) =~? 'jsxEscapeJs')
endfunction
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
let s:start_tag = '<\s*\([-:_\.\$0-9A-Za-z]\+\|>\)'
@@ -124,6 +124,8 @@ function! jsx_pretty#indent#get(js_indent)
else
return prev_ind
endif
elseif prev_line =~ '^\<return'
return prev_ind
else
return prev_ind - s:sw()
endif
@@ -188,6 +190,13 @@ function! jsx_pretty#indent#get(js_indent)
else
let ind = a:js_indent()
" Issue #68
" return (<div>
" |<div>)
if prev_line =~ '^\<return' && line =~ '^<\s*' . s:end_tag
return prev_ind
endif
" If current syntax is not a jsx syntax group
if s:syn_xmlish(prev_syn_eol) && line !~ '^[)\]}]'
let sol = matchstr(line, s:opfirst)

2
build
View File

@@ -272,6 +272,7 @@ PACKS="
solidity:tomlion/vim-solidity
styled-components:styled-components/vim-styled-components#main
stylus:wavded/vim-stylus
svelte:evanleck/vim-svelte
svg-indent:jasonshell/vim-svg-indent
svg:vim-scripts/svg.vim
swift:keith/swift.vim
@@ -297,6 +298,7 @@ PACKS="
xls:vim-scripts/XSLT-syntax
yaml:stephpy/vim-yaml
yard:sheerun/vim-yardoc
zephir:xwsoul/vim-zephir
zig:ziglang/zig.vim
"

View File

@@ -91,3 +91,7 @@ augroup END
if (!exists('g:graphql_javascript_tags'))
let g:graphql_javascript_tags = ['gql', 'graphql', 'Relay.QL']
endif
augroup filetypedetect
autocmd BufNewFile,BufReadPost *.tsx setlocal filetype=typescript.tsx
augroup END

View File

@@ -91,6 +91,10 @@ augroup END
if (!exists('g:graphql_javascript_tags'))
let g:graphql_javascript_tags = ['gql', 'graphql', 'Relay.QL']
endif
augroup filetypedetect
autocmd BufNewFile,BufReadPost *.tsx setlocal filetype=typescript.tsx
augroup END
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'acpiasl') == -1
augroup filetypedetect
" acpiasl, from asl.vim in martinlroth/vim-acpi-asl
@@ -1309,6 +1313,13 @@ autocmd BufNewFile,BufReadPost *.stylus set filetype=stylus
augroup end
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
augroup filetypedetect
" sxhkd, from sxhkdrc.vim in baskerville/vim-sxhkdrc
@@ -1460,6 +1471,13 @@ autocmd BufNewFile,BufRead *.xdc setfiletype xdc
augroup end
endif
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'zephir') == -1
augroup filetypedetect
" zephir, from zephir.vim in xwsoul/vim-zephir
autocmd BufNewFile,BufReadPost *.zep set filetype=zephir
augroup end
endif
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'zig') == -1
augroup filetypedetect
" zig, from zig.vim in ziglang/zig.vim

View File

@@ -38,7 +38,7 @@ if exists("g:rst_style") && g:rst_style != 0
setlocal expandtab shiftwidth=3 softtabstop=3 tabstop=8
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 foldexpr=RstFold#GetRstFold()
setlocal foldtext=RstFold#GetRstFoldText()

128
indent/svelte.vim Normal file
View 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

View File

@@ -22,7 +22,7 @@ endif
syn include @gitcommitDiff syntax/diff.vim
syn region gitcommitDiff start=/\%(^diff --\%(git\|cc\|combined\) \)\@=/ end=/^\%(diff --\|$\|#\)\@=/ fold contains=@gitcommitDiff
syn match gitcommitSummary ".*\%<50v" contained containedin=gitcommitFirstLine nextgroup=gitcommitOverflow contains=@Spell
syn match gitcommitSummary "^.*\%<51v." contained containedin=gitcommitFirstLine nextgroup=gitcommitOverflow contains=@Spell
syn match gitcommitOverflow ".*" contained contains=@Spell
syn match gitcommitBlank "^[^#].*" contained contains=@Spell

61
syntax/svelte.vim Normal file
View 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"

137
syntax/zephir.vim Normal file
View File

@@ -0,0 +1,137 @@
if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'zephir') != -1
finish
endif
" Copyright 2009 The Go Authors. All rights reserved.
if exists("b:current_syntax")
finish
endif
syn case match
" Comments; their contents
syn keyword zepTodo contained TODO FIXME XXX
syn cluster zepCommentGroup contains=zepTodo
syn region zepComment start="/\*" end="\*/" contains=@zepCommentGroup,@Spell
syn region zepComment start="//" end="$" contains=@zepCommentGroup,@Spell
hi def link zepComment Comment
hi def link zepTodo Todo
syn keyword zepDirective namespace extends implements return
syn keyword zepDeclaration var let new const
syn keyword zepDeclType abstract class interface
syn keyword zepDeclFun function
syn keyword zepDeclMore public private protected static final
syn keyword zepExceptionOperator throw try catch
hi def link zepDirective Statement
hi def link zepDeclaration Keyword
hi def link zepDeclFun Keyword
hi def link zepDeclType Keyword
hi def link zepDeclMore Keyword
hi def link zepExceptionOperator Keyword
syn keyword zepCond if else elseif switch
syn keyword zepRepeat for in while loop
syn keyword zepLabel case default continue require this parent self
syn match zepTypeHits "\<\w+\>"me=e+1,me=e-1 contained display
hi def link zepCond Conditional
hi def link zepRepeat Repeat
hi def link zepLabel Label
syn match zepOperator "[-=+%^&|*!.~?:]" contained display
syn match zepOperator "[-+*/%^&|.]=" contained display
syn match zepOperator "/[^*/]"me=e-1 contained display
syn match zepOperator "\$" contained display
syn match zepOperator "&&\|\<and\>" contained display
syn match zepOperator "||\|\<x\=or\>" contained display
syn match zepRelation "[!=<>]=" contained display
syn match zepRelation "[<>]" contained display
syn match zepMemberSelector "->" contained display
hi def link zepOperator Operator
hi def link zepRelation Operator
hi def link zepMemberSelector Operator
syn keyword zepType array string char void void
syn keyword zepType bool[ean] true false
syn keyword zepType unsigned int uint long ulong
hi def link zepType Type
syn match zepGlobalVar "_(SERVER|POST|GET|COOKIE|SESSION)\["me=e-1 contained display
hi def link zepGlobalVar Statement
syn keyword zepSpecialOperator empty isset fetch
syn keyword zepBuildIns global_set global_get
syn keyword zepBuildIns echo count typeof range reverse
syn keyword zepBuildIns set get toString
"for string
syn keyword zepBuildIns length trim trimleft trimright index lower upper lowerfirst upperfirst format
"for array
syn keyword zepBuildIns join reverse
"for char
syn keyword zepBuildIns toHex
"for integer
syn keyword zepBuildIns abs
hi def link zepSpecialOperator Function
hi def link zepBuildIns Function
" zep escapes
syn match zepEscapeOctal display contained "\\[0-7]\{3}"
syn match zepEscapeC display contained +\\[abfnrtv\\'"]+
syn match zepEscapeX display contained "\\x\x\{2}"
syn match zepEscapeU display contained "\\u\x\{4}"
syn match zepEscapeBigU display contained "\\U\x\{8}"
syn match zepEscapeError display contained +\\[^0-7xuUabfnrtv\\'"]+
hi def link zepEscapeOctal zepSpecialString
hi def link zepEscapeC zepSpecialString
hi def link zepEscapeX zepSpecialString
hi def link zepEscapeU zepSpecialString
hi def link zepEscapeBigU zepSpecialString
hi def link zepSpecialString Special
hi def link zepEscapeError Error
" Strings and their contents
syn cluster zepStringGroup contains=zepEscapeOctal,zepEscapeC,zepEscapeX,zepEscapeU,zepEscapeBigU,zepEscapeError
syn region zepString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=@zepStringGroup
syn region zepString start=+'+ skip=+\\\\\|\\'+ end=+'+ contains=@zepStringGroup
hi def link zepString String
" Integers
syn match zepDecimalInt "\<\d\+\([Ee]\d\+\)\?\>"
syn match zepHexadecimalInt "\<0x\x\+\>"
syn match zepOctalInt "\<0\o\+\>"
syn match zepOctalError "\<0\o*[89]\d*\>"
hi def link zepDecimalInt Integer
hi def link zepHexadecimalInt Integer
hi def link zepOctalInt Integer
hi def link Integer Number
" Floating point
syn match zepFloat "\<\d\+\.\d*\([Ee][-+]\d\+\)\?\>"
syn match zepFloat "\<\.\d\+\([Ee][-+]\d\+\)\?\>"
syn match zepFloat "\<\d\+[Ee][-+]\d\+\>"
hi def link zepFloat Float
" Imaginary literals
syn match zepImaginary "\<\d\+i\>"
syn match zepImaginary "\<\d\+\.\d*\([Ee][-+]\d\+\)\?i\>"
syn match zepImaginary "\<\.\d\+\([Ee][-+]\d\+\)\?i\>"
syn match zepImaginary "\<\d\+[Ee][-+]\d\+i\>"
hi def link zepImaginary Number
syn sync minlines=500
let b:current_syntax = "zephir"
syn match zepTypeHits "<\w+>" contained display

View File

@@ -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\@(setRuntimeSafety|setEvalBranchQuota|setFloatMode)>"
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\@(intToError|errorToInt|intToEnum|enumToInt|setAlignStack|handle|bitreverse|Vector)>"