Use neovim version of .vim highlighting, #578

This commit is contained in:
Adam Stankiewicz
2020-10-07 23:52:17 +02:00
parent 4bec20ec1a
commit b3763a917a
5 changed files with 146 additions and 218 deletions

View File

@@ -3,7 +3,7 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'vim') == -1
" Vim indent file
" Language: Vim script
" Maintainer: Bram Moolenaar <Bram@vim.org>
" Last Change: 2020 Sep 27
" Last Change: 2016 Jun 27
" Only load this indent file when no other was loaded.
if exists("b:did_indent")
@@ -12,8 +12,7 @@ endif
let b:did_indent = 1
setlocal indentexpr=GetVimIndent()
setlocal indentkeys+==end,=},=else,=cat,=finall,=END,0\\,0=\"\\\
setlocal indentkeys-=0#
setlocal indentkeys+==end,=else,=cat,=fina,=END,0\\,0=\"\\\
let b:undo_indent = "setl indentkeys< indentexpr<"
@@ -59,31 +58,6 @@ function GetVimIndentIntern()
" and :else. Add it three times for a line that starts with '\' or '"\ '
" after a line that doesn't (or g:vim_indent_cont if it exists).
let ind = indent(lnum)
" In heredoc indenting works completely differently.
if has('syntax_items')
let syn_here = synIDattr(synID(v:lnum, 1, 1), "name")
if syn_here =~ 'vimLetHereDocStop'
" End of heredoc: use indent of matching start line
let lnum = v:lnum - 1
while lnum > 0
if synIDattr(synID(lnum, 1, 1), "name") !~ 'vimLetHereDoc'
return indent(lnum)
endif
let lnum -= 1
endwhile
return 0
endif
if syn_here =~ 'vimLetHereDoc'
if synIDattr(synID(lnum, 1, 1), "name") !~ 'vimLetHereDoc'
" First line in heredoc: increase indent
return ind + shiftwidth()
endif
" Heredoc continues: no change in indent
return ind
endif
endif
if cur_text =~ s:lineContPat && v:lnum > 1 && prev_text !~ s:lineContPat
if exists("g:vim_indent_cont")
let ind = ind + g:vim_indent_cont
@@ -95,7 +69,7 @@ function GetVimIndentIntern()
else
" A line starting with :au does not increment/decrement indent.
if prev_text !~ '^\s*au\%[tocmd]'
let i = match(prev_text, '\(^\||\)\s*\(export\s\+\)\?\({\|\(if\|wh\%[ile]\|for\|try\|cat\%[ch]\|fina\|finall\%[y]\|fu\%[nction]\|def\|el\%[seif]\)\>\)')
let i = match(prev_text, '\(^\||\)\s*\(if\|wh\%[ile]\|for\|try\|cat\%[ch]\|fina\%[lly]\|fu\%[nction]\|el\%[seif]\)\>')
if i >= 0
let ind += shiftwidth()
if strpart(prev_text, i, 1) == '|' && has('syntax_items')
@@ -118,8 +92,8 @@ function GetVimIndentIntern()
" Subtract a 'shiftwidth' on a :endif, :endwhile, :catch, :finally, :endtry,
" :endfun, :enddef, :else and :augroup END.
if cur_text =~ '^\s*\(ene\@!\|}\|cat\|finall\|el\|aug\%[roup]\s\+[eE][nN][dD]\)'
" :endfun, :else and :augroup END.
if cur_text =~ '^\s*\(ene\@!\|cat\|fina\|el\|aug\%[roup]\s\+[eE][nN][dD]\)'
let ind = ind - shiftwidth()
endif