diff options
author | Adam Stankiewicz <sheerun@sher.pl> | 2020-12-29 19:44:40 +0100 |
---|---|---|
committer | Adam Stankiewicz <sheerun@sher.pl> | 2020-12-29 19:44:40 +0100 |
commit | 95d82fdb668b746ac100a8b7d2aca38038150707 (patch) | |
tree | 19f2e80acbab5efe1d35630faafb5e24d7230fd8 /indent | |
parent | 73c518717741fb3ebb6822645d38f37ffae7c19b (diff) | |
download | vim-polyglot-95d82fdb668b746ac100a8b7d2aca38038150707.tar.gz vim-polyglot-95d82fdb668b746ac100a8b7d2aca38038150707.zip |
Update
Diffstat (limited to 'indent')
-rw-r--r-- | indent/crystal.vim | 10 | ||||
-rw-r--r-- | indent/html.vim | 4 | ||||
-rw-r--r-- | indent/typescript.vim | 2 | ||||
-rw-r--r-- | indent/typescriptreact.vim | 42 |
4 files changed, 37 insertions, 21 deletions
diff --git a/indent/crystal.vim b/indent/crystal.vim index 4a0cdb00..724f9611 100644 --- a/indent/crystal.vim +++ b/indent/crystal.vim @@ -12,6 +12,16 @@ endif let b:did_indent = 1 +if !exists('g:crystal_indent_assignment_style') + " Possible values: 'variable', 'hanging' + let g:crystal_indent_assignment_style = 'hanging' +endif + +if !exists('g:crystal_indent_block_style') + " Possible values: 'expression', 'do' + let g:crystal_indent_block_style = 'expression' +endif + setlocal nosmartindent " Now, set up our indentation expression and keys that trigger it. diff --git a/indent/html.vim b/indent/html.vim index 82cd7074..25e306f3 100644 --- a/indent/html.vim +++ b/indent/html.vim @@ -5,7 +5,7 @@ endif " Vim indent script for HTML " Maintainer: Bram Moolenaar " Original Author: Andy Wokula <anwoku@yahoo.de> -" Last Change: 2020 Jul 06 +" Last Change: 2020 Dec 11 " Version: 1.0 "{{{ " Description: HTML indent script with cached state for faster indenting on a " range of lines. @@ -819,7 +819,7 @@ func! s:Alien5() let idx = match(prevtext, '^\s*\zs<!--') if idx >= 0 " just below comment start, add a shiftwidth - return idx + shiftwidth() + return indent(prevlnum) + shiftwidth() endif " Some files add 4 spaces just below a TODO line. It's difficult to detect diff --git a/indent/typescript.vim b/indent/typescript.vim index 0bc143c3..d372f992 100644 --- a/indent/typescript.vim +++ b/indent/typescript.vim @@ -355,7 +355,7 @@ function GetTypescriptIndent() " If the line is empty and the previous nonblank line was a multi-line " comment, use that comment's indent. Deduct one char to account for the " space in ' */'. - if line =~ '^\s*$' && s:IsInMultilineComment(prevline, 1) + if line =~ '^\s*$' && yats#IsInMultilineComment(prevline, 1) return indent(prevline) - 1 endif diff --git a/indent/typescriptreact.vim b/indent/typescriptreact.vim index fe9a2c32..9a640523 100644 --- a/indent/typescriptreact.vim +++ b/indent/typescriptreact.vim @@ -2,7 +2,8 @@ if has_key(g:polyglot_is_disabled, 'typescript') finish endif -exe 'runtime! indent/typescript.vim' +runtime! indent/typescript.vim + " Save the current JavaScript indentexpr. let b:tsx_ts_indentexpr = &indentexpr @@ -11,7 +12,7 @@ if exists('b:did_indent') let s:did_indent=b:did_indent unlet b:did_indent endif -exe 'runtime! indent/xml.vim' +runtime! indent/xml.vim if exists('s:did_indent') let b:did_indent=s:did_indent endif @@ -23,47 +24,52 @@ setlocal indentkeys=0{,0},0),0],0\,,!^F,o,O,e " XML indentkeys setlocal indentkeys+=*<Return>,<>>,<<>,/ +" Only define the function once. +if exists("*GetTsxIndent") + finish +endif + " Multiline end tag regex (line beginning with '>' or '/>') let s:endtag = '^\s*\/\?>\s*;\=' let s:startexp = '[\{\(]\s*$' " Get all syntax types at the beginning of a given line. -fu! SynSOL(lnum) +fu! s:SynSOL(lnum) return map(synstack(a:lnum, 1), 'synIDattr(v:val, "name")') endfu " Get all syntax types at the end of a given line. -fu! SynEOL(lnum) +fu! s:SynEOL(lnum) let lnum = prevnonblank(a:lnum) let col = strlen(getline(lnum)) return map(synstack(lnum, col), 'synIDattr(v:val, "name")') endfu " Check if a syntax attribute is XMLish. -fu! SynAttrXMLish(synattr) +fu! s:SynAttrXMLish(synattr) return a:synattr =~ "^xml" || a:synattr =~ "^tsx" endfu " Check if a synstack is XMLish (i.e., has an XMLish last attribute). -fu! SynXMLish(syns) - return SynAttrXMLish(get(a:syns, -1)) +fu! s:SynXMLish(syns) + return s:SynAttrXMLish(get(a:syns, -1)) endfu " Check if a synstack denotes the end of a TSX block. -fu! SynTSXBlockEnd(syns) +fu! s:SynTSXBlockEnd(syns) return get(a:syns, -1) =~ '\%(ts\|typescript\)Braces' && - \ SynAttrXMLish(get(a:syns, -2)) + \ s:SynAttrXMLish(get(a:syns, -2)) endfu " Determine how many tsxRegions deep a synstack is. -fu! SynTSXDepth(syns) +fu! s:SynTSXDepth(syns) return len(filter(copy(a:syns), 'v:val ==# "tsxRegion"')) endfu " Check whether `cursyn' continues the same tsxRegion as `prevsyn'. -fu! SynTSXContinues(cursyn, prevsyn) - let curdepth = SynTSXDepth(a:cursyn) - let prevdepth = SynTSXDepth(a:prevsyn) +fu! s:SynTSXContinues(cursyn, prevsyn) + let curdepth = s:SynTSXDepth(a:cursyn) + let prevdepth = s:SynTSXDepth(a:prevsyn) " In most places, we expect the nesting depths to be the same between any " two consecutive positions within a tsxRegion (e.g., between a parent and @@ -78,15 +84,15 @@ endfu " Cleverly mix JS and XML indentation. fu! GetTsxIndent() - let cursyn = SynSOL(v:lnum) - let prevsyn = SynEOL(v:lnum - 1) + let cursyn = s:SynSOL(v:lnum) + let prevsyn = s:SynEOL(v:lnum - 1) " Use XML indenting iff: " - the syntax at the end of the previous line was either TSX or was the " closing brace of a jsBlock whose parent syntax was TSX; and " - the current line continues the same tsxRegion as the previous line. - if (SynXMLish(prevsyn) || SynTSXBlockEnd(prevsyn)) && - \ SynTSXContinues(cursyn, prevsyn) + if (s:SynXMLish(prevsyn) || s:SynTSXBlockEnd(prevsyn)) && + \ s:SynTSXContinues(cursyn, prevsyn) let ind = XmlIndentGet(v:lnum, 0) let l:line = getline(v:lnum) let l:pline = getline(v:lnum - 1) @@ -112,4 +118,4 @@ fu! GetTsxIndent() endif return ind -endfu
\ No newline at end of file +endfu |