Skip to content

Commit

Permalink
Merge pull request elixir-editors#544 from lucassperez/syntax-char-lists
Browse files Browse the repository at this point in the history
Added char lists syntax highlighting
  • Loading branch information
jbodah authored Jun 15, 2021
2 parents 6dc61ad + 5bc5702 commit e7caa59
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion autoload/elixir/indent.vim
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ 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 s:syntax_name(a:line, a:col) =~ '\%(String\|Comment\)'
return s:syntax_name(a:line, a:col) =~ '\%(String\|Comment\|CharList\)'
endfunction

function! s:syntax_name(line, col)
Expand Down
8 changes: 8 additions & 0 deletions spec/indent/basic_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -558,4 +558,12 @@ def hi do
:send
end
EOF

i <<~EOF
defmodule Hi do
def hello_world do
"end"
'end'
end
EOF
end
6 changes: 4 additions & 2 deletions syntax/elixir.vim
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ syn region elixirStruct matchgroup=elixirStructDelimiter start="%\(\w\+{\)\@=" e

syn region elixirMap matchgroup=elixirMapDelimiter start="%{" end="}" contains=ALLBUT,@elixirNotTop fold

syn region elixirString matchgroup=elixirStringDelimiter start=+\z('\)+ end=+\z1+ skip=+\\\\\|\\\z1+ contains=@Spell,@elixirStringContained
syn region elixirCharList matchgroup=elixirCharListDelimiter start=+\z('\)+ end=+\z1+ skip=+\\\\\|\\\z1+ contains=@Spell,@elixirStringContained
syn region elixirString matchgroup=elixirStringDelimiter start=+\z("\)+ end=+\z1+ skip=+\\\\\|\\\z1+ contains=@Spell,@elixirStringContained
syn region elixirString matchgroup=elixirStringDelimiter start=+\z('''\)+ end=+^\s*\z1+ contains=@Spell,@elixirStringContained
syn region elixirString matchgroup=elixirStringDelimiter start=+\z("""\)+ end=+^\s*\z1+ contains=@Spell,@elixirStringContained
Expand All @@ -88,7 +88,7 @@ syn match elixirString "\(\w\)\@<!?\%(\\\(x\d{1,2}\|\h{1,2}\h\@!\>\|
syn region elixirBlock matchgroup=elixirBlockDefinition start="\<do\>:\@!" end="\<end\>" contains=ALLBUT,@elixirNotTop fold
syn region elixirAnonymousFunction matchgroup=elixirBlockDefinition start="\<fn\>" end="\<end\>" contains=ALLBUT,@elixirNotTop fold

syn region elixirArguments start="(" end=")" contained contains=elixirOperator,elixirAtom,elixirPseudoVariable,elixirAlias,elixirBoolean,elixirVariable,elixirUnusedVariable,elixirNumber,elixirDocString,elixirAtomInterpolated,elixirRegex,elixirString,elixirStringDelimiter,elixirRegexDelimiter,elixirInterpolationDelimiter,elixirSigil,elixirAnonymousFunction,elixirComment
syn region elixirArguments start="(" end=")" contained contains=elixirOperator,elixirAtom,elixirPseudoVariable,elixirAlias,elixirBoolean,elixirVariable,elixirUnusedVariable,elixirNumber,elixirDocString,elixirAtomInterpolated,elixirRegex,elixirString,elixirStringDelimiter,elixirRegexDelimiter,elixirInterpolationDelimiter,elixirSigil,elixirAnonymousFunction,elixirComment,elixirCharList,elixirCharListDelimiter

syn match elixirDelimEscape "\\[(<{\[)>}\]/\"'|]" transparent display contained contains=NONE

Expand Down Expand Up @@ -230,10 +230,12 @@ hi def link elixirRegexCharClass elixirSpecial
hi def link elixirRegexQuantifier elixirSpecial
hi def link elixirSpecial Special
hi def link elixirString String
hi def link elixirCharList String
hi def link elixirSigil String
hi def link elixirDocStringDelimiter elixirStringDelimiter
hi def link elixirDocSigilDelimiter elixirSigilDelimiter
hi def link elixirStringDelimiter Delimiter
hi def link elixirCharListDelimiter Delimiter
hi def link elixirRegexDelimiter Delimiter
hi def link elixirInterpolationDelimiter Delimiter
hi def link elixirSigilDelimiter Delimiter
Expand Down

0 comments on commit e7caa59

Please sign in to comment.