summaryrefslogtreecommitdiffstats
path: root/autoload/elixir
diff options
context:
space:
mode:
authorAdam Stankiewicz <sheerun@sher.pl>2020-09-27 12:05:29 +0200
committerAdam Stankiewicz <sheerun@sher.pl>2020-09-27 12:05:29 +0200
commit7ec499c19f91122724d1518887ba3ffe4a8fcb43 (patch)
tree090623fa904e05eabcffafd987cc3055b9080423 /autoload/elixir
parent33b86476b63f7fc2286336eb488a149a85cb08cb (diff)
downloadvim-polyglot-7ec499c19f91122724d1518887ba3ffe4a8fcb43.tar.gz
vim-polyglot-7ec499c19f91122724d1518887ba3ffe4a8fcb43.zip
Set indentation only locally, fixes #564v4.12.1
Diffstat (limited to 'autoload/elixir')
-rw-r--r--autoload/elixir/indent.vim16
1 files changed, 13 insertions, 3 deletions
diff --git a/autoload/elixir/indent.vim b/autoload/elixir/indent.vim
index e7c8f0ea..741ec094 100644
--- a/autoload/elixir/indent.vim
+++ b/autoload/elixir/indent.vim
@@ -276,12 +276,14 @@ function! elixir#indent#handle_inside_block(context)
" hack - handle do: better
let block_info = searchpairpos(start_pattern, '', end_pattern, 'bnW', "line('.') == " . line('.') . " || elixir#indent#searchpair_back_skip() || getline(line('.')) =~ 'do:'", max([0, a:context.lnum - g:elixir_indent_max_lookbehind]))
let block_start_lnum = block_info[0]
+ call s:debug("block_start_lnum=" . block_start_lnum)
let block_start_col = block_info[1]
if block_start_lnum != 0 || block_start_col != 0
let block_text = getline(block_start_lnum)
let block_start_char = block_text[block_start_col - 1]
+ call s:debug("block_start_char=" . block_start_char)
- let never_match = '\(a\)\@=b'
+ let never_match = ''
let config = {
\'f': {'aligned_clauses': s:keyword('end'), 'pattern_match_clauses': never_match},
\'c': {'aligned_clauses': s:keyword('end'), 'pattern_match_clauses': never_match},
@@ -293,17 +295,25 @@ function! elixir#indent#handle_inside_block(context)
\'(': {'aligned_clauses': ')', 'pattern_match_clauses': never_match}
\}
+ " if `with` clause...
if block_start_char == 'w'
call s:debug("testing s:handle_with")
return s:handle_with(block_start_lnum, block_start_col, a:context)
else
let block_config = config[block_start_char]
+ " if aligned clause (closing tag/`else` clause/etc...) then indent this
+ " at the same level as the block open tag (e.g. `if`/`case`/etc...)
if s:starts_with(a:context, block_config.aligned_clauses)
call s:debug("clause")
return indent(block_start_lnum)
else
- let clause_lnum = searchpair(block_config.pattern_match_clauses, '', '*', 'bnW', "line('.') == " . line('.') . " || elixir#indent#searchpair_back_skip()", block_start_lnum)
- let relative_lnum = max([clause_lnum, block_start_lnum])
+ if block_config.pattern_match_clauses == never_match
+ let relative_lnum = block_start_lnum
+ else
+ let clause_lnum = searchpair(block_config.pattern_match_clauses, '', '*', 'bnW', "line('.') == " . line('.') . " || elixir#indent#searchpair_back_skip()", block_start_lnum)
+ call s:debug("clause_lum=" . clause_lnum)
+ let relative_lnum = max([clause_lnum, block_start_lnum])
+ end
call s:debug("pattern matching relative to lnum " . relative_lnum)
return s:do_handle_pattern_match_block(relative_lnum, a:context)
endif