Fix svelte branch name, closes #522

This commit is contained in:
Adam Stankiewicz
2020-08-14 19:15:07 +02:00
parent 34e01b8b62
commit a3bdbcdb3c
13 changed files with 346 additions and 15 deletions

View File

@@ -166,7 +166,7 @@ If you need full functionality of any plugin, please use it directly with your p
- [smt2](https://github.com/bohlender/vim-smt2) (syntax, autoload, ftplugin)
- [solidity](https://github.com/tomlion/vim-solidity) (syntax, indent, ftplugin)
- [stylus](https://github.com/wavded/vim-stylus) (syntax, indent, ftplugin)
- [svelte](https://github.com/evanleck/vim-svelte) ()
- [svelte](https://github.com/evanleck/vim-svelte#main) (syntax, indent, ftplugin)
- [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, compiler, ftplugin, ctags)

View File

@@ -117,7 +117,7 @@ lockvar g:crystal#indent#end_start_regex
" Regex that defines the middle-match for the 'end' keyword.
let g:crystal#indent#end_middle_regex =
\ g:crystal#indent#sol .
\ '\<\%(else\|elsif\|when\|rescue\|ensure\)\>'
\ '\<\%(else\|elsif\|when\|in\|rescue\|ensure\)\>'
lockvar g:crystal#indent#end_middle_regex
" Regex that defines the end-match for the 'end' keyword.

2
build
View File

@@ -258,7 +258,7 @@ PACKS="
smt2:bohlender/vim-smt2
solidity:tomlion/vim-solidity
stylus:wavded/vim-stylus
svelte:evanleck/vim-svelte
svelte:evanleck/vim-svelte#main
svg-indent:jasonshell/vim-svg-indent
svg:vim-scripts/svg.vim
swift:keith/swift.vim

View File

@@ -60,7 +60,7 @@ if exists('g:loaded_matchit') && !exists('b:match_words')
let b:match_words =
\ '\<\%(if\|unless\|case\|while\|until\|for\|do\|class\|module\|struct\|lib\|macro\|ifdef\|def\|begin\|enum\|annotation\)\>=\@!' .
\ ':' .
\ '\<\%(else\|elsif\|ensure\|when\|rescue\|break\|next\)\>' .
\ '\<\%(else\|elsif\|ensure\|when\|in\|rescue\|break\|next\)\>' .
\ ':' .
\ '\<end\>' .
\ ',{:},\[:\],(:)'

47
ftplugin/svelte.vim Normal file
View File

@@ -0,0 +1,47 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'svelte') == -1
" Vim filetype plugin
" 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_ftplugin'))
finish
endif
let b:did_ftplugin = 1
" Matchit support
if exists('loaded_matchit') && !exists('b:match_words')
let b:match_ignorecase = 0
" In order:
"
" 1. Svelte control flow keywords.
" 2. Parens.
" 3-5. HTML tags pulled from Vim itself.
"
" https://github.com/vim/vim/blob/5259275347667a90fb88d8ea74331f88ad68edfc/runtime/ftplugin/html.vim#L29-L35
let b:match_words =
\ '#\%(if\|await\|each\)\>:\:\%(else\|catch\|then\)\>:\/\%(if\|await\|each\)\>,' .
\ '{:},' .
\ '<\@<=[ou]l\>[^>]*\%(>\|$\):<\@<=li\>:<\@<=/[ou]l>,' .
\ '<\@<=dl\>[^>]*\%(>\|$\):<\@<=d[td]\>:<\@<=/dl>,' .
\ '<\@<=\([^/][^ \t>]*\)[^>]*\%(>\|$\):<\@<=/\1>'
endif
" ALE fixing and linting.
if exists('g:loaded_ale')
if !exists('b:ale_fixers')
let b:ale_fixers = ['eslint', 'prettier', 'prettier_standard']
endif
if !exists('b:ale_linter_aliases')
let b:ale_linter_aliases = ['css', 'javascript']
endif
if !exists('b:ale_linters')
let b:ale_linters = ['stylelint', 'eslint']
endif
endif
endif

View File

@@ -15,7 +15,7 @@ setlocal nosmartindent
" Now, set up our indentation expression and keys that trigger it.
setlocal indentexpr=GetCrystalIndent(v:lnum)
setlocal indentkeys=0{,0},0),0],!^F,o,O,e,.
setlocal indentkeys+==end,=else,=elsif,=when,=ensure,=rescue
setlocal indentkeys+==end,=else,=elsif,=when,=in,=ensure,=rescue
" Only define the function once.
if exists('*GetCrystalIndent')

View File

@@ -52,7 +52,7 @@ if b:ecrystal_indent_multiline
endif
setlocal indentexpr=GetEcrystalIndent()
setlocal indentkeys+=<>>,=end,=else,=elsif,=rescue,=ensure,=when
setlocal indentkeys+=<>>,=end,=else,=elsif,=rescue,=ensure,=when,=in
let b:did_indent = 1
@@ -71,10 +71,10 @@ let s:ecr_control_open = '<%%\@!-\=[=#]\@!'
let s:ecr_comment_open = '<%%\@!-\=#'
let s:ecr_indent_regex =
\ '\<\%(if\|unless\|else\|elsif\|case\|when\|while\|until\|begin\|do\|rescue\|ensure\|\)\>'
\ '\<\%(if\|unless\|else\|elsif\|case\|when\|in\|while\|until\|begin\|do\|rescue\|ensure\|\)\>'
let s:ecr_dedent_regex =
\ '\<\%(end\|else\|elsif\|when\|rescue\|ensure\)\>'
\ '\<\%(end\|else\|elsif\|when\|in\|rescue\|ensure\)\>'
" Return the value of a single shift-width
if exists('*shiftwidth')

148
indent/svelte.vim Normal file
View File

@@ -0,0 +1,148 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'svelte') == -1
" 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
if !exists('g:svelte_indent_script')
let g:svelte_indent_script = 1
endif
if !exists('g:svelte_indent_style')
let g:svelte_indent_style = 1
endif
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 unless disabled.
if previous_line =~ '^\s*<script'
if g:svelte_indent_script
return previous_line_indent + shiftwidth()
else
return previous_line_indent
endif
endif
if previous_line =~ '^\s*<style'
if g:svelte_indent_style
return previous_line_indent + shiftwidth()
else
return previous_line_indent
endif
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
" "/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
" "#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
return indent
endfunction
endif

View File

@@ -49,6 +49,16 @@ function! TerraformIndent(lnum)
let thisindent -= &shiftwidth
endif
" If the previous line starts a block comment /*, increase by one
if prevline =~# '/\*'
let thisindent += 1
endif
" If the previous line ends a block comment */, decrease by one
if prevline =~# '\*/'
let thisindent -= 1
endif
return thisindent
endfunction

View File

@@ -183,7 +183,7 @@ syn match crystalPredefinedConstant "\%(\%(\.\@1<!\.\)\@2<!\|::\)\_s*\zs\%(STDER
syn match crystalPredefinedConstant "\%(\%(\.\@1<!\.\)\@2<!\|::\)\_s*\zs\%(crystal_\%(VERSION\|RELEASE_DATE\|PLATFORM\|PATCHLEVEL\|REVISION\|DESCRIPTION\|COPYRIGHT\|ENGINE\)\)\>\%(\s*(\)\@!"
" Normal Regular Expression
SynFold '/' syn region crystalRegexp matchgroup=crystalRegexpDelimiter start="\%(\%(^\|\<\%(and\|or\|while\|until\|unless\|if\|elsif\|ifdef\|when\|not\|then\|else\)\|[;\~=!|&(,[<>?:*+-]\)\s*\)\@<=/" end="/[imx]*" skip="\\\\\|\\/" contains=@crystalRegexpSpecial
SynFold '/' syn region crystalRegexp matchgroup=crystalRegexpDelimiter start="\%(\%(^\|\<\%(and\|or\|while\|until\|unless\|if\|elsif\|ifdef\|when\|in\|not\|then\|else\)\|[;\~=!|&(,[<>?:*+-]\)\s*\)\@<=/" end="/[imx]*" skip="\\\\\|\\/" contains=@crystalRegexpSpecial
SynFold '/' syn region crystalRegexp matchgroup=crystalRegexpDelimiter start="\%(\h\k*\s\+\)\@<=/[ \t=/]\@!" end="/[imx]*" skip="\\\\\|\\/" contains=@crystalRegexpSpecial
" Generalized Regular Expression
@@ -315,7 +315,7 @@ if !exists('b:crystal_no_expensive') && !exists('g:crystal_no_expensive')
SynFold 'select' syn region crystalSelectExpression matchgroup=crystalConditional start="\<select\>" end="\<end\>" contains=TOP
SynFold 'if' syn region crystalConditionalExpression matchgroup=crystalConditional start="\%(\%(^\|\.\.\.\=\|[{:,;([<>~\*/%&^|+=-]\|\%(\<[_[:lower:]][_[:alnum:]]*\)\@<![?!]\)\s*\)\@<=\%(if\|ifdef\|unless\)\>" end="\%(\%(\%(\.\@1<!\.\)\|::\)\s*\)\@<!\<end\>" contains=TOP
syn match crystalConditional "\<\%(then\|else\|when\)\>[?!]\@!" contained containedin=crystalCaseExpression
syn match crystalConditional "\<\%(then\|else\|when\|in\)\>[?!]\@!" contained containedin=crystalCaseExpression
syn match crystalConditional "\<\%(when\|else\)\>[?!]\@!" contained containedin=crystalSelectExpression
syn match crystalConditional "\<\%(then\|else\|elsif\)\>[?!]\@!" contained containedin=crystalConditionalExpression
@@ -339,7 +339,7 @@ else
syn match crystalControl "\<macro\>[?!]\@!" nextgroup=crystalMacroDeclaration skipwhite skipnl
syn match crystalControl "\<enum\>[?!]\@!" nextgroup=crystalEnumDeclaration skipwhite skipnl
syn match crystalControl "\<annotation\>[?!]\@!" nextgroup=crystalAnnotationDeclaration skipwhite skipnl
syn match crystalControl "\<\%(case\|begin\|do\|if\|ifdef\|unless\|while\|until\|else\|elsif\|ensure\|then\|when\|end\)\>[?!]\@!"
syn match crystalControl "\<\%(case\|begin\|do\|if\|ifdef\|unless\|while\|until\|else\|elsif\|ensure\|then\|when\|in\|end\)\>[?!]\@!"
syn match crystalKeyword "\<\%(alias\|undef\)\>[?!]\@!"
endif
@@ -402,7 +402,7 @@ SynFold '#' syn region crystalMultilineComment start="\%(\%(^\s*#.*\n\)\@<!\%(^\
syn match crystalKeywordAsMethod "\%(\%(\.\@1<!\.\)\|::\)\_s*\%(alias\|begin\|break\|case\|class\|def\|defined\|do\|else\|select\)\>" transparent contains=NONE
syn match crystalKeywordAsMethod "\%(\%(\.\@1<!\.\)\|::\)\_s*\%(elsif\|end\|ensure\|false\|for\|if\|ifdef\|in\|module\|next\|nil\)\>" transparent contains=NONE
syn match crystalKeywordAsMethod "\%(\%(\.\@1<!\.\)\|::\)\_s*\%(rescue\|return\|self\|super\|previous_def\|then\|true\)\>" transparent contains=NONE
syn match crystalKeywordAsMethod "\%(\%(\.\@1<!\.\)\|::\)\_s*\%(undef\|unless\|until\|when\|while\|yield\|with\|__FILE__\|__LINE__\)\>" transparent contains=NONE
syn match crystalKeywordAsMethod "\%(\%(\.\@1<!\.\)\|::\)\_s*\%(undef\|unless\|until\|when\|in\|while\|yield\|with\|__FILE__\|__LINE__\)\>" transparent contains=NONE
syn match crystalKeywordAsMethod "\<\%(alias\|begin\|case\|class\|def\|do\|end\)[?!]" transparent contains=NONE
syn match crystalKeywordAsMethod "\<\%(if\|ifdef\|module\|undef\|unless\|until\|while\)[?!]" transparent contains=NONE

126
syntax/svelte.vim Normal file
View File

@@ -0,0 +1,126 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'svelte') == -1
" 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, 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
" Mixed-case attributes are likely props.
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
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
syntax region svelteSurroundingTag contained start=+<\(script\|style\|template\)+ end=+>+ fold contains=htmlTagN,htmlString,htmlArg,htmlValue,htmlTagError,htmlEvent
" 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
" Inline keywords.
syntax match svelteKeyword "@html" contained containedin=jsBlock,javascriptBlock
syntax match svelteKeyword "@debug" 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
" Preprocessed languages that aren't supported out of the box by Svelte require
" additional syntax files to be pulled in and can slow Vim down a bit. For that
" reason, preprocessed languages must be enabled manually. Note that some may
" require additional plugins that contain the actual syntax definitions.
"
" Heavily cribbed from https://github.com/posva/vim-vue and largely completed by
" @davidroeca (thank you!).
" A syntax should be registered if there's a valid syntax definition known to
" Vim and it is enabled for the Svelte plugin.
function! s:enabled(language)
" Check whether a syntax file for {language} exists
if empty(globpath(&runtimepath, 'syntax/' . a:language . '.vim'))
return 0
endif
" If g:svelte_preprocessors is set, check for it there, otherwise return 0.
if exists('g:svelte_preprocessors') && type(g:svelte_preprocessors) == v:t_list
return index(g:svelte_preprocessors, a:language) != -1
else
return 0
endif
endfunction
" Default tag definitions.
let s:languages = [
\ { 'name': 'less', 'tag': 'style' },
\ { 'name': 'scss', 'tag': 'style' },
\ { 'name': 'sass', 'tag': 'style' },
\ { 'name': 'stylus', 'tag': 'style' },
\ { 'name': 'typescript', 'tag': 'script' },
\ ]
" Add global tag definitions to our defaults.
if exists('g:svelte_preprocessor_tags') && type('g:svelte_preprocessor_tags') == v:t_list
let s:languages += g:svelte_preprocessor_tags
endif
for s:language in s:languages
let s:attr = '\(lang\|type\)=\("\|''\)[^\2]*' . s:language.name . '[^\2]*\2'
let s:start = '<' . s:language.tag . '\>\_[^>]*' . s:attr . '\_[^>]*>'
if s:enabled(s:language.name)
execute 'syntax include @' . s:language.name . ' syntax/' . get(s:language, 'as', s:language.name) . '.vim'
unlet! b:current_syntax
execute 'syntax region svelte_' . s:language.name
\ 'keepend'
\ 'start=/' . s:start . '/'
\ 'end="</' . s:language.tag . '>"me=s-1'
\ 'contains=@' . s:language.name . ',svelteSurroundingTag'
\ 'fold'
endif
endfor
" Cybernetically enhanced web apps.
let b:current_syntax = "svelte"
" Sync from start because of the wacky nesting.
syntax sync fromstart
endif

View File

@@ -248,7 +248,7 @@ 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 sdServiceType contained nextgroup=sdErr simple exec 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

View File

@@ -2,7 +2,7 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'vifm') == -1
" vifm syntax file
" Maintainer: xaizek <xaizek@posteo.net>
" Last Change: July 27, 2020
" Last Change: August 8, 2020
" Inspired By: Vim syntax file by Dr. Charles E. Campbell, Jr.
if exists('b:current_syntax')
@@ -89,7 +89,7 @@ syntax case ignore
syntax keyword vifmHiGroups contained WildMenu Border Win CmdLine CurrLine
\ OtherLine Directory Link Socket Device Executable Selected BrokenLink
\ TopLine TopLineSel StatusLine JobLine SuggestBox Fifo ErrorMsg CmpMismatch
\ AuxWin OtherWin TabLine TabLineSel TabNr HardLink LineNr OddLine
\ AuxWin OtherWin TabLine TabLineSel TabNr TabNrSel HardLink LineNr OddLine
\ User1 User2 User3 User4 User5 User6 User7 User8 User9
syntax keyword vifmHiStyles contained
\ bold underline reverse inverse standout italic none