diff options
| author | Adam Stankiewicz <sheerun@sher.pl> | 2020-09-15 10:45:50 +0200 | 
|---|---|---|
| committer | Adam Stankiewicz <sheerun@sher.pl> | 2020-09-15 10:45:50 +0200 | 
| commit | d43d269bedbb6bcf725eaf5bb5b3c5a0bcfcb0c0 (patch) | |
| tree | 8e7702293cc2ced66ac83e4bbe4ae537f7312f8e /indent | |
| parent | 4314841aa4772d98b186636bdbf34fcf48c74275 (diff) | |
| download | vim-polyglot-d43d269bedbb6bcf725eaf5bb5b3c5a0bcfcb0c0.tar.gz vim-polyglot-d43d269bedbb6bcf725eaf5bb5b3c5a0bcfcb0c0.zip | |
Update
Diffstat (limited to 'indent')
| -rw-r--r-- | indent/erlang.vim | 2 | ||||
| -rw-r--r-- | indent/graphql.vim | 25 | 
2 files changed, 15 insertions, 12 deletions
| diff --git a/indent/erlang.vim b/indent/erlang.vim index ad06ef5d..2cc1cb23 100644 --- a/indent/erlang.vim +++ b/indent/erlang.vim @@ -6,7 +6,7 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'erlang') == -1  " Contributors: Edwin Fine <efine145_nospam01 at usa dot net>  "               Pawel 'kTT' Salata <rockplayer.pl@gmail.com>  "               Ricardo Catalinas Jiménez <jimenezrick@gmail.com> -" Last Update:  2017-Feb-28 +" Last Update:  2020-Jun-11  " License:      Vim license  " URL:          https://github.com/vim-erlang/vim-erlang-runtime diff --git a/indent/graphql.vim b/indent/graphql.vim index 7b601957..3a910928 100644 --- a/indent/graphql.vim +++ b/indent/graphql.vim @@ -45,6 +45,10 @@ endif  let s:cpo_save = &cpoptions  set cpoptions&vim +" searchpair() skip expression that matches in comments and strings. +let s:pair_skip_expr = +  \ 'synIDattr(synID(line("."), col("."), 0), "name") =~? "comment\\|string"' +  " Check if the character at lnum:col is inside a string.  function s:InString(lnum, col)    return synIDattr(synID(a:lnum, a:col, 1), 'name') ==# 'graphqlString' @@ -61,18 +65,18 @@ function GetGraphQLIndent()    let l:line = getline(v:lnum)    " If this line contains just a closing bracket, find its matching opening -  " bracket and indent the closing backet to match. +  " bracket and indent the closing bracket to match.    let l:col = matchend(l:line, '^\s*[]})]')    if l:col > 0 && !s:InString(v:lnum, l:col) -    let l:bracket = l:line[l:col - 1]      call cursor(v:lnum, l:col) -    if l:bracket is# '}' -      let l:matched = searchpair('{', '', '}', 'bW') -    elseif l:bracket is# ']' -      let l:matched = searchpair('\[', '', '\]', 'bW') -    elseif l:bracket is# ')' -      let l:matched = searchpair('(', '', ')', 'bW') +    let l:bracket = l:line[l:col - 1] +    if l:bracket ==# '}' +      let l:matched = searchpair('{', '', '}', 'bW', s:pair_skip_expr) +    elseif l:bracket ==# ']' +      let l:matched = searchpair('\[', '', '\]', 'bW', s:pair_skip_expr) +    elseif l:bracket ==# ')' +      let l:matched = searchpair('(', '', ')', 'bW', s:pair_skip_expr)      else        let l:matched = -1      endif @@ -85,9 +89,8 @@ function GetGraphQLIndent()      return indent(v:lnum)    endif -  " If the previous line contained an opening bracket, and we are still in it, -  " add indent depending on the bracket type. -  if getline(l:prevlnum) =~# '[[{(]\s*$' +  " If the previous line ended with an opening bracket, indent this line. +  if getline(l:prevlnum) =~# '\%(#.*\)\@<![[{(]\s*$'      return indent(l:prevlnum) + shiftwidth()    endif | 
