diff options
author | Adam Stankiewicz <sheerun@sher.pl> | 2017-02-02 21:16:29 +0100 |
---|---|---|
committer | Adam Stankiewicz <sheerun@sher.pl> | 2017-02-02 21:16:29 +0100 |
commit | e685e4b431ab017d1aec9f9668fbeeeb6e7113e6 (patch) | |
tree | 47137f448d461ebb6852d81c6f553d0843e33764 /autoload/elixir/util.vim | |
parent | e404a658b1647fad396a954776eda0bdabf8353c (diff) | |
download | vim-polyglot-e685e4b431ab017d1aec9f9668fbeeeb6e7113e6.tar.gz vim-polyglot-e685e4b431ab017d1aec9f9668fbeeeb6e7113e6.zip |
Update
Diffstat (limited to 'autoload/elixir/util.vim')
-rw-r--r-- | autoload/elixir/util.vim | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/autoload/elixir/util.vim b/autoload/elixir/util.vim index 3139d779..fbbd62aa 100644 --- a/autoload/elixir/util.vim +++ b/autoload/elixir/util.vim @@ -1,7 +1,6 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'elixir') == -1 let s:SKIP_SYNTAX = '\%(Comment\|String\)$' -let s:BLOCK_SKIP = "synIDattr(synID(line('.'),col('.'),1),'name') =~? '".s:SKIP_SYNTAX."'" function! elixir#util#is_indentable_at(line, col) if a:col == -1 " skip synID lookup for not found match @@ -20,31 +19,24 @@ function! elixir#util#is_indentable_at(line, col) \ !~ s:SKIP_SYNTAX endfunction -function! elixir#util#is_indentable_match(line, pattern) - return elixir#util#is_indentable_at(a:line.num, match(a:line.text, a:pattern)) -endfunction - function! elixir#util#count_indentable_symbol_diff(line, open, close) - if elixir#util#is_indentable_match(a:line, a:open) - \ && elixir#util#is_indentable_match(a:line, a:close) - return - \ s:match_count(a:line.text, a:open) - \ - s:match_count(a:line.text, a:close) - else - return 0 - end + return + \ s:match_count(a:line, a:open) + \ - s:match_count(a:line, a:close) endfunction -function! s:match_count(string, pattern) - let size = strlen(a:string) +function! s:match_count(line, pattern) + let size = strlen(a:line.text) let index = 0 let counter = 0 while index < size - let index = match(a:string, a:pattern, index) + let index = match(a:line.text, a:pattern, index) if index >= 0 let index += 1 - let counter +=1 + if elixir#util#is_indentable_at(a:line.num, index) + let counter +=1 + end else break end @@ -53,4 +45,8 @@ function! s:match_count(string, pattern) return counter endfunction +function elixir#util#is_blank(string) + return a:string =~ '^\s*$' +endfunction + endif |