From 0e0a9645733b8cae6aa999a3d1eaee8c24c9ea27 Mon Sep 17 00:00:00 2001 From: Guillaume Cauchon Date: Wed, 25 Aug 2021 15:32:27 -0400 Subject: [PATCH] Support the new .heex extension --- README.md | 2 +- doc/elixir.txt | 2 +- ftdetect/elixir.vim | 2 +- ftplugin/eelixir.vim | 5 ++++- ftplugin/elixir.vim | 2 +- spec/spec_helper.rb | 8 ++++++++ syntax/eelixir.vim | 5 ++++- 7 files changed, 20 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 7383b8f..c964692 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Features: * Syntax highlighting for Elixir and EEx files -* Filetype detection for `.ex`, `.exs`, `.eex`, `.leex`, and `.sface` files +* Filetype detection for `.ex`, `.exs`, `.eex`, `.heex`, `.leex`, and `.sface` files * Automatic indentation * Integration between Ecto projects and [vim-dadbod][] for running SQL queries on defined Ecto repositories diff --git a/doc/elixir.txt b/doc/elixir.txt index 43fc942..273b494 100644 --- a/doc/elixir.txt +++ b/doc/elixir.txt @@ -19,7 +19,7 @@ INTRODUCTION *elixir-introduction* *elixir* provides Vim configuration files for Elixir http://elixir-lang.org/ * Syntax highlighting for Elixir and EEx files -* Filetype detection for `.ex`, `.exs`, `.eex`, `.leex`, and `.sface` files +* Filetype detection for `.ex`, `.exs`, `.eex`, `.heex`, `.leex`, and `.sface` files * Automatic indentation * Integration between Ecto projects and |vim-dadbod| for running SQL queries on defined Ecto repositories diff --git a/ftdetect/elixir.vim b/ftdetect/elixir.vim index 85df27a..389c7d1 100644 --- a/ftdetect/elixir.vim +++ b/ftdetect/elixir.vim @@ -1,5 +1,5 @@ au BufRead,BufNewFile *.ex,*.exs set filetype=elixir -au BufRead,BufNewFile *.eex,*.leex,*.sface set filetype=eelixir +au BufRead,BufNewFile *.eex,*.heex,*.leex,*.sface set filetype=eelixir au BufRead,BufNewFile mix.lock set filetype=elixir au BufRead,BufNewFile * call s:DetectElixir() diff --git a/ftplugin/eelixir.vim b/ftplugin/eelixir.vim index a9b8dfe..eebfb69 100644 --- a/ftplugin/eelixir.vim +++ b/ftplugin/eelixir.vim @@ -19,6 +19,9 @@ if !exists("b:eelixir_subtype") if b:eelixir_subtype == '' let b:eelixir_subtype = matchstr(&filetype,'^eex\.\zs\w\+') endif + if b:eelixir_subtype == '' + let b:eelixir_subtype = matchstr(&filetype,'^heex\.\zs\w\+') + endif if b:eelixir_subtype == '' let b:eelixir_subtype = matchstr(&filetype,'^leex\.\zs\w\+') endif @@ -26,7 +29,7 @@ if !exists("b:eelixir_subtype") let b:eelixir_subtype = matchstr(&filetype,'^sface\.\zs\w\+') endif if b:eelixir_subtype == '' - let b:eelixir_subtype = matchstr(substitute(expand("%:t"),'\c\%(\.eex\|\.sface\|\.leex\|\.eelixir\)\+$','',''),'\.\zs\w\+$') + let b:eelixir_subtype = matchstr(substitute(expand("%:t"),'\c\%(\.eex\|\.heex\|\.leex\|\.sface\|\.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 675b92b..1b95811 100644 --- a/ftplugin/elixir.vim +++ b/ftplugin/elixir.vim @@ -29,7 +29,7 @@ let &l:path = \ &g:path \ ], ',') setlocal includeexpr=elixir#util#get_filename(v:fname) -setlocal suffixesadd=.ex,.exs,.eex,.leex,.sface,.erl,.xrl,.yrl,.hrl +setlocal suffixesadd=.ex,.exs,.eex,.heex,.leex,.sface,.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 c9ea61a..d84e822 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -125,6 +125,12 @@ def self.new end end +module HeexBuffer + def self.new + Buffer.new(VIM, :heex) + end +end + module LeexBuffer def self.new Buffer.new(VIM, :leex) @@ -162,6 +168,7 @@ def self.new { be_elixir_indentation: :ex, be_eelixir_indentation: :eex, + be_heelixir_indentation: :heex, be_leelixir_indentation: :leex, be_surface_indentation: :sface }.each do |matcher, type| @@ -191,6 +198,7 @@ def self.new { include_elixir_syntax: :ex, include_eelixir_syntax: :eex, + include_heelixir_syntax: :heex, include_leelixir_syntax: :leex, include_surface_syntax: :sface }.each do |matcher, type| diff --git a/syntax/eelixir.vim b/syntax/eelixir.vim index 381ab81..19bc252 100644 --- a/syntax/eelixir.vim +++ b/syntax/eelixir.vim @@ -19,6 +19,9 @@ if !exists("b:eelixir_subtype") if b:eelixir_subtype == '' let b:eelixir_subtype = matchstr(&filetype,'^eex\.\zs\w\+') endif + if b:eelixir_subtype == '' + let b:eelixir_subtype = matchstr(&filetype,'^heex\.\zs\w\+') + endif if b:eelixir_subtype == '' let b:eelixir_subtype = matchstr(&filetype,'^leex\.\zs\w\+') endif @@ -26,7 +29,7 @@ if !exists("b:eelixir_subtype") let b:eelixir_subtype = matchstr(&filetype,'^sface\.\zs\w\+') endif if b:eelixir_subtype == '' - let b:eelixir_subtype = matchstr(substitute(expand("%:t"),'\c\%(\.eex\|\.sface\|\.leex\|\.eelixir\)\+$','',''),'\.\zs\w\+$') + let b:eelixir_subtype = matchstr(substitute(expand("%:t"),'\c\%(\.eex\|\.heex\|\.leex\|\.sface\|\.eelixir\)\+$','',''),'\.\zs\w\+$') endif if b:eelixir_subtype == 'ex' let b:eelixir_subtype = 'elixir'