Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions indent/ls.vim
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ endif

" Keywords to indent after
let s:INDENT_AFTER_KEYWORD = '^\%(if\|unless\|else\|for\|while\|until\|'
\ . 'loop\|case\|default\|try\|catch\|finally\|'
\ . 'loop\|case\||\|default\|try\|catch\|finally\|'
\ . 'class\|do\|new\|let\|with\|function\)\>'

" Operators to indent after
Expand Down Expand Up @@ -115,7 +115,7 @@ function! s:ShouldSkip(startlinenum, linenum, col)
endif

" Check for a single-line statement that isn't adjacent.
if s:SmartSearch(a:linenum, '\<then\>') && a:startlinenum - a:linenum > 1
if s:SmartSearch(a:linenum, '\<then\>\|=>') && a:startlinenum - a:linenum > 1
return 1
endif

Expand Down Expand Up @@ -162,7 +162,7 @@ function! s:GetMatch(curline)
elseif firstchar == ']'
return s:SearchPair('\[', '\]')
elseif a:curline =~ '^else\>'
return s:SearchPair('\<\%(if\|unless\|case\|when\)\>', '\<else\>')
return s:SearchPair('\<\%(if\|unless\|case\||\|when\)\>', '\<else\>')
elseif a:curline =~ '^catch\>'
return s:SearchPair('\<try\>', '\<catch\>')
elseif a:curline =~ '^finally\>'
Expand Down Expand Up @@ -231,7 +231,7 @@ function! s:GetLiveScriptIndent(curlinenum)
" Indent after these keywords and compound assignments if they aren't a
" single-line statement.
if prevline =~ s:INDENT_AFTER_KEYWORD || prevline =~ s:COMPOUND_ASSIGNMENT
if !s:SmartSearch(prevlinenum, '\<then\>') && prevline !~ s:SINGLE_LINE_ELSE
if !s:SmartSearch(prevlinenum, '\<then\>\|=>') && prevline !~ s:SINGLE_LINE_ELSE
return previndent + &shiftwidth
endif
endif
Expand All @@ -245,7 +245,7 @@ function! s:GetLiveScriptIndent(curlinenum)
" aren't a single-line statement.
if prevline =~ s:OUTDENT_AFTER
if !s:SmartSearch(prevlinenum, s:POSTFIX_CONDITION) ||
\ s:SmartSearch(prevlinenum, '\<then\>')
\ s:SmartSearch(prevlinenum, '\<then\>\|=>')
return previndent - &shiftwidth
endif
endif
Expand Down
7 changes: 5 additions & 2 deletions syntax/ls.vim
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,16 @@ highlight default link lsStatement Statement
syntax match lsRepeat /\<\%(for\%( own\| ever\)\?\|while\|until\)\>/
highlight default link lsRepeat Repeat

syntax match lsConditional /\<\%(if\|else\|unless\|switch\|case\|when\|default\|match\)\>/
syntax match lsConditional /\<\%(if\|then\|else\|unless\|switch\|match\)\>\|=>/
highlight default link lsConditional Conditional

syntax match lsLabel /\<\%(when\|case\|default\)\>\||\|^\s\+:[$A-Za-z_]\k*\%(-[a-zA-Z]\+\)*/
highlight default link lsLabel Label

syntax match lsException /\<\%(try\|catch\|finally\)\>/
highlight default link lsException Exception

syntax match lsKeyword /\<\%(new\|in\%(stanceof\)\?\|typeof\|delete\|and\|o[fr]\|not\|xor\|is\|isnt\|imp\%(ort\%( all\)\?\|lements\)\|extends\|loop\|from\|to\|til\|by\|do\|then\|function\|class\|let\|with\|export\|const\|var\|eval\|super\|fallthrough\|debugger\|where\|yield\)\>/
syntax match lsKeyword /\<\%(new\|in\%(stanceof\)\?\|typeof\|delete\|and\|o[fr]\|not\|xor\|is\|isnt\|imp\%(ort\%( all\)\?\|lements\)\|extends\|loop\|from\|to\|til\|by\|do\|function\|class\|let\|with\|export\|const\|var\|eval\|super\|fallthrough\|debugger\|where\|yield\)\>/
highlight default link lsKeyword Keyword

syntax match lsBoolean /\<\%(true\|false\|yes\|no\|on\|off\|null\|void\)\>/
Expand Down