diff options
Diffstat (limited to 'indent')
| -rw-r--r-- | indent/julia.vim | 11 | ||||
| -rw-r--r-- | indent/ruby.vim | 2 | ||||
| -rw-r--r-- | indent/svelte.vim | 148 | ||||
| -rw-r--r-- | indent/typescript.vim | 2 | 
4 files changed, 13 insertions, 150 deletions
| diff --git a/indent/julia.vim b/indent/julia.vim index 59cd7d80..d95fa193 100644 --- a/indent/julia.vim +++ b/indent/julia.vim @@ -270,6 +270,12 @@ function IsInBrackets(lnum, c)    return len(stack) > 0  endfunction +function IsInDocString(lnum) +  let stack = map(synstack(a:lnum, 1), 'synIDattr(v:val, "name")') +  call filter(stack, 'v:val =~# "\\<juliaDocString\\>"') +  return len(stack) > 0 +endfunction +  " Auxiliary function to find a line which does not start in the middle of a  " multiline bracketed expression, to be used as reference for block  " indentation. @@ -290,6 +296,11 @@ function LastBlockIndent(lnum)  endfunction  function GetJuliaIndent() +  " Do not alter doctrings indentation +  if IsInDocString(v:lnum) +    return -1 +  endif +    " Find a non-blank line above the current line.    let lnum = prevnonblank(v:lnum - 1) diff --git a/indent/ruby.vim b/indent/ruby.vim index 0628a24b..8e72739e 100644 --- a/indent/ruby.vim +++ b/indent/ruby.vim @@ -28,7 +28,7 @@ endif  if !exists('g:ruby_indent_block_style')    " Possible values: "expression", "do" -  let g:ruby_indent_block_style = 'expression' +  let g:ruby_indent_block_style = 'do'  endif  setlocal nosmartindent diff --git a/indent/svelte.vim b/indent/svelte.vim deleted file mode 100644 index 8d9fbb2f..00000000 --- a/indent/svelte.vim +++ /dev/null @@ -1,148 +0,0 @@ -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 diff --git a/indent/typescript.vim b/indent/typescript.vim index f630a34c..64eca31b 100644 --- a/indent/typescript.vim +++ b/indent/typescript.vim @@ -51,7 +51,7 @@ let s:skip_expr = "synIDattr(synID(line('.'),col('.'),1),'name') =~ '".s:syng_st  let s:line_term = '\s*\%(\%(\/\/\).*\)\=$'  " Regex that defines continuation lines, not including (, {, or [. -let s:continuation_regex = '\%([\\*+/.:]\|\%(<%\)\@<![=-]\|\W[|&?]\|||\|&&\|[^=]=[^=].*,\)' . s:line_term +let s:continuation_regex = '\%([\\*+/.:]\|\%(<%\)\@<![=-]\|\W[|&?]\|||\|&&\|[^=]=[^=]\)' . s:line_term  " Regex that defines continuation lines.  " TODO: this needs to deal with if ...: and so on | 
