diff --git a/README.md b/README.md index 414942fc..3dac7da0 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Features: * Syntax highlighting for Elixir and EEx files -* Filetype detection for `.ex`, `.exs` and `.eex` files +* Filetype detection for `.ex`, `.exs`, `.eex` and `.leex` files * Automatic indentation ## Installation diff --git a/ftplugin/eelixir.vim b/ftplugin/eelixir.vim index c115429f..83601e15 100644 --- a/ftplugin/eelixir.vim +++ b/ftplugin/eelixir.vim @@ -20,7 +20,10 @@ if !exists("b:eelixir_subtype") let b:eelixir_subtype = matchstr(&filetype,'^eex\.\zs\w\+') endif if b:eelixir_subtype == '' - let b:eelixir_subtype = matchstr(substitute(expand("%:t"),'\c\%(\.eex\|\.eelixir\)\+$','',''),'\.\zs\w\+$') + let b:eelixir_subtype = matchstr(&filetype,'^leex\.\zs\w\+') + endif + if b:eelixir_subtype == '' + let b:eelixir_subtype = matchstr(substitute(expand("%:t"),'\c\%(\.eex\|\.leex\|\.eelixir\)\+$','',''),'\.\zs\w\+$') endif if b:eelixir_subtype == 'ex' let b:eelixir_subtype = 'elixir' diff --git a/ftplugin/elixir.vim b/ftplugin/elixir.vim index 95858894..c36d8bee 100644 --- a/ftplugin/elixir.vim +++ b/ftplugin/elixir.vim @@ -28,7 +28,7 @@ let &l:path = \ &g:path \ ], ',') setlocal includeexpr=elixir#util#get_filename(v:fname) -setlocal suffixesadd=.ex,.exs,.eex,.erl,.xrl,.yrl,.hrl +setlocal suffixesadd=.ex,.exs,.eex,.leex,.erl,.xrl,.yrl,.hrl let &l:define = 'def\(macro\|guard\|delegate\)\=p\=' diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index ad4c49d4..aad0220f 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -122,6 +122,12 @@ def self.new end end +module EexBuffer + def self.new + Buffer.new(VIM, :leex) + end +end + RSpec::Matchers.define :be_typed_with_right_indent do |syntax| buffer = Buffer.new(VIM, syntax || :ex) @@ -144,7 +150,8 @@ def self.new { be_elixir_indentation: :ex, - be_eelixir_indentation: :eex + be_eelixir_indentation: :eex, + be_leelixir_indentation: :leex }.each do |matcher, type| RSpec::Matchers.define matcher do buffer = Buffer.new(VIM, type) @@ -169,7 +176,8 @@ def self.new { include_elixir_syntax: :ex, - include_eelixir_syntax: :eex + include_eelixir_syntax: :eex, + include_leelixir_syntax: :leex }.each do |matcher, type| RSpec::Matchers.define matcher do |syntax, pattern| buffer = Buffer.new(VIM, type) diff --git a/spec/syntax/sigil_spec.rb b/spec/syntax/sigil_spec.rb index 6ef7f9da..380b0fb0 100644 --- a/spec/syntax/sigil_spec.rb +++ b/spec/syntax/sigil_spec.rb @@ -87,6 +87,10 @@ it 'without escaped parenthesis' do expect('~S(\( )').not_to include_elixir_syntax('elixirRegexEscapePunctuation', '( ') end + + it 'Live EEx' do + expect('~L"""liveview template"""').to include_elixir_syntax('elixirSigilDelimiter', '"""') + end end describe 'lower case' do diff --git a/syntax/eelixir.vim b/syntax/eelixir.vim index 18c98635..1ec0ac66 100644 --- a/syntax/eelixir.vim +++ b/syntax/eelixir.vim @@ -20,7 +20,10 @@ if !exists("b:eelixir_subtype") let b:eelixir_subtype = matchstr(&filetype,'^eex\.\zs\w\+') endif if b:eelixir_subtype == '' - let b:eelixir_subtype = matchstr(substitute(expand("%:t"),'\c\%(\.eex\|\.eelixir\)\+$','',''),'\.\zs\w\+$') + let b:eelixir_subtype = matchstr(&filetype,'^leex\.\zs\w\+') + endif + if b:eelixir_subtype == '' + let b:eelixir_subtype = matchstr(substitute(expand("%:t"),'\c\%(\.eex\|\.leex\|\.eelixir\)\+$','',''),'\.\zs\w\+$') endif if b:eelixir_subtype == 'ex' let b:eelixir_subtype = 'elixir' diff --git a/syntax/elixir.vim b/syntax/elixir.vim index 41c1a3b6..40e796dd 100644 --- a/syntax/elixir.vim +++ b/syntax/elixir.vim @@ -105,6 +105,12 @@ syn region elixirSigil matchgroup=elixirSigilDelimiter start="\~\l\/" syn region elixirSigil matchgroup=elixirSigilDelimiter start=+\~\a\z("""\)+ end=+^\s*\z1+ skip=+\\"+ fold syn region elixirSigil matchgroup=elixirSigilDelimiter start=+\~\a\z('''\)+ end=+^\s*\z1+ skip=+\\'+ fold + +" LiveView Sigils surrounded with ~L""" +syntax include @HTML syntax/html.vim +syntax region elixirLiveViewSigil matchgroup=elixirSigilDelimiter keepend start=+\~L\z("""\)+ end=+^\s*\z1+ skip=+\\"+ contains=@HTML fold + + " Documentation if exists('g:elixir_use_markdown_for_docs') && g:elixir_use_markdown_for_docs syn include @markdown syntax/markdown.vim