Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
sheerun committed Sep 6, 2019
1 parent ae18284 commit 66b7693
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 16 deletions.
24 changes: 21 additions & 3 deletions autoload/elixir/indent.vim
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ function! elixir#indent#indent(lnum)

let handlers = [
\'top_of_file',
\'starts_with_string_continuation',
\'following_trailing_binary_operator',
\'starts_with_pipe',
\'starts_with_binary_operator',
Expand All @@ -35,9 +36,14 @@ function! elixir#indent#indent(lnum)
\]
for handler in handlers
call s:debug('testing handler elixir#indent#handle_'.handler)
let context = {'lnum': lnum, 'text': text, 'prev_nb_lnum': prev_nb_lnum, 'prev_nb_text': prev_nb_text}
let context = {'lnum': lnum, 'text': text, 'first_nb_char_idx': match(text, '\w'), 'prev_nb_lnum': prev_nb_lnum, 'prev_nb_text': prev_nb_text}
let indent = function('elixir#indent#handle_'.handler)(context)
if indent != -1
if indent == -2
" Keep indent the same
call s:debug('line '.lnum.': elixir#indent#handle_'.handler.' returned -2; returning indent of -1')
call cursor(curs_lnum, curs_col)
return -1
elseif indent != -1
call s:debug('line '.lnum.': elixir#indent#handle_'.handler.' returned '.indent)
call cursor(curs_lnum, curs_col)
return indent
Expand Down Expand Up @@ -102,7 +108,11 @@ endfunction
" Returns 0 or 1 based on whether or not the given line number and column
" number pair is a string or comment
function! s:is_string_or_comment(line, col)
return synIDattr(synID(a:line, a:col, 1), "name") =~ '\%(String\|Comment\)'
return s:syntax_name(a:line, a:col) =~ '\%(String\|Comment\)'
endfunction

function! s:syntax_name(line, col)
return synIDattr(synID(a:line, a:col, 1), "name")
endfunction

" Skip expression for searchpair. Returns 0 or 1 based on whether the value
Expand Down Expand Up @@ -158,6 +168,14 @@ function! elixir#indent#handle_top_of_file(context)
end
endfunction

function! elixir#indent#handle_starts_with_string_continuation(context)
if s:syntax_name(a:context.lnum, a:context.first_nb_char_idx) =~ '\(String\|Comment\)$'
return -2
else
return -1
end
endfunction

function! elixir#indent#handle_follow_prev_nb(context)
return s:get_base_indent(a:context.prev_nb_lnum, a:context.prev_nb_text)
endfunction
Expand Down
5 changes: 5 additions & 0 deletions ftdetect/polyglot.vim
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
" Enable jsx syntax by default
if !exists('g:jsx_ext_required')
let g:jsx_ext_required = 0
endif

" Make csv loading faster
if !exists('g:csv_start')
let g:csv_start = 1
Expand Down
2 changes: 1 addition & 1 deletion ftplugin/ruby.vim
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ endfunction

function! s:build_path(path) abort
let path = join(map(copy(a:path), 'v:val ==# "." ? "" : v:val'), ',')
if &g:path !~# '\v^\.%(,/%(usr|emx)/include)=,,$'
if &g:path !~# '\v^%(\.,)=%(/%(usr|emx)/include,)=,$'
let path = substitute(&g:path,',,$',',','') . ',' . path
endif
return path
Expand Down
18 changes: 9 additions & 9 deletions syntax/elixir.vim
Original file line number Diff line number Diff line change
Expand Up @@ -129,15 +129,15 @@ else
syn region elixirDocTest start="^\s*\%(iex\|\.\.\.\)\%((\d*)\)\?>\s" end="^\s*$" contained
endif

syn region elixirDocString matchgroup=elixirDocSigilDelimiter start="\%(@\w*doc\s\+\)\@<=\~[Ss]\z(/\|\"\|'\||\)" end="\z1" skip="\\\\\|\\\z1" contains=@elixirDocStringContained fold keepend
syn region elixirDocString matchgroup=elixirDocSigilDelimiter start="\%(@\w*doc\s\+\)\@<=\~[Ss]{" end="}" skip="\\\\\|\\}" contains=@elixirDocStringContained fold keepend
syn region elixirDocString matchgroup=elixirDocSigilDelimiter start="\%(@\w*doc\s\+\)\@<=\~[Ss]<" end=">" skip="\\\\\|\\>" contains=@elixirDocStringContained fold keepend
syn region elixirDocString matchgroup=elixirDocSigilDelimiter start="\%(@\w*doc\s\+\)\@<=\~[Ss]\[" end="\]" skip="\\\\\|\\\]" contains=@elixirDocStringContained fold keepend
syn region elixirDocString matchgroup=elixirDocSigilDelimiter start="\%(@\w*doc\s\+\)\@<=\~[Ss](" end=")" skip="\\\\\|\\)" contains=@elixirDocStringContained fold keepend
syn region elixirDocString matchgroup=elixirDocStringDelimiter start=+\%(@\w*doc\s\+\)\@<=\z("\)+ end=+\z1+ skip=+\\\\\|\\\z1+ contains=@elixirDocStringContained keepend
syn region elixirDocString matchgroup=elixirDocStringDelimiter start=+\%(@\w*doc\s\+\)\@<=\z("""\)+ end=+^\s*\z1+ contains=@elixirDocStringContained fold keepend
syn region elixirDocString matchgroup=elixirDocSigilDelimiter start=+\%(@\w*doc\s\+\)\@<=\~[Ss]\z('''\)+ end=+^\s*\z1+ contains=@elixirDocStringContained fold keepend
syn region elixirDocString matchgroup=elixirDocSigilDelimiter start=+\%(@\w*doc\s\+\)\@<=\~[Ss]\z("""\)+ end=+^\s*\z1+ contains=@elixirDocStringContained fold keepend
syn region elixirDocString matchgroup=elixirDocSigilDelimiter start="\%(@\w*doc\(\s\|(\)\+\)\@<=\~[Ss]\z(/\|\"\|'\||\)" end="\z1" skip="\\\\\|\\\z1" contains=@elixirDocStringContained fold keepend
syn region elixirDocString matchgroup=elixirDocSigilDelimiter start="\%(@\w*doc\(\s\|(\)\+\)\@<=\~[Ss]{" end="}" skip="\\\\\|\\}" contains=@elixirDocStringContained fold keepend
syn region elixirDocString matchgroup=elixirDocSigilDelimiter start="\%(@\w*doc\(\s\|(\)\+\)\@<=\~[Ss]<" end=">" skip="\\\\\|\\>" contains=@elixirDocStringContained fold keepend
syn region elixirDocString matchgroup=elixirDocSigilDelimiter start="\%(@\w*doc\(\s\|(\)\+\)\@<=\~[Ss]\[" end="\]" skip="\\\\\|\\\]" contains=@elixirDocStringContained fold keepend
syn region elixirDocString matchgroup=elixirDocSigilDelimiter start="\%(@\w*doc\(\s\|(\)\+\)\@<=\~[Ss](" end=")" skip="\\\\\|\\)" contains=@elixirDocStringContained fold keepend
syn region elixirDocString matchgroup=elixirDocStringDelimiter start=+\%(@\w*doc\(\s\|(\)\+\)\@<=\z("\)+ end=+\z1+ skip=+\\\\\|\\\z1+ contains=@elixirDocStringContained keepend
syn region elixirDocString matchgroup=elixirDocStringDelimiter start=+\%(@\w*doc\(\s\|(\)\+\)\@<=\z("""\)+ end=+^\s*\z1+ contains=@elixirDocStringContained fold keepend
syn region elixirDocString matchgroup=elixirDocSigilDelimiter start=+\%(@\w*doc\(\s\|(\)\+\)\@<=\~[Ss]\z('''\)+ end=+^\s*\z1+ contains=@elixirDocStringContained fold keepend
syn region elixirDocString matchgroup=elixirDocSigilDelimiter start=+\%(@\w*doc\(\s\|(\)\+\)\@<=\~[Ss]\z("""\)+ end=+^\s*\z1+ contains=@elixirDocStringContained fold keepend

" Defines
syn match elixirDefine '\<def\>\(:\)\@!' nextgroup=elixirFunctionDeclaration skipwhite skipnl
Expand Down
6 changes: 3 additions & 3 deletions syntax/zig.vim
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ if exists("b:current_syntax")
endif
let b:current_syntax = "zig"

syn keyword zigStorage const var extern packed export pub noalias inline comptime nakedcc stdcallcc volatile allowzero align linksection threadlocal
syn keyword zigStorage const var extern packed export pub noalias inline noinline comptime nakedcc stdcallcc volatile allowzero align linksection threadlocal
syn keyword zigStructure struct enum union error
syn keyword zigStatement break return continue asm defer errdefer unreachable try catch async await suspend resume
syn keyword zigStatement break return continue asm defer errdefer unreachable try catch async noasync await suspend resume
syn keyword zigConditional if else switch and or orelse
syn keyword zigRepeat while for

Expand All @@ -41,7 +41,7 @@ syn match zigBuiltinFn "\v\@(frameAddress|import|inlineCall|newStackCall|asyncCa
syn match zigBuiltinFn "\v\@(maxValue|memberCount|memberName|memberType)>"
syn match zigBuiltinFn "\v\@(memcpy|memset|minValue|mod|mulWithOverflow)>"
syn match zigBuiltinFn "\v\@(noInlineCall|bitOffsetOf|byteOffsetOf|OpaqueType|panic|ptrCast)>"
syn match zigBuiltinFn "\v\@(ptrToInt|rem|returnAddress|setCold)>"
syn match zigBuiltinFn "\v\@(ptrToInt|rem|returnAddress|setCold|Type)>"
syn match zigBuiltinFn "\v\@(setRuntimeSafety|setEvalBranchQuota|setFloatMode)>"
syn match zigBuiltinFn "\v\@(setGlobalLinkage|setGlobalSection|shlExact|This|hasDecl|hasField)>"
syn match zigBuiltinFn "\v\@(shlWithOverflow|shrExact|sizeOf|sqrt|byteSwap|subWithOverflow|intCast|floatCast|intToFloat|floatToInt|boolToInt|errSetCast)>"
Expand Down

0 comments on commit 66b7693

Please sign in to comment.