Add HEEx language support, add missing commentstrings

This commit is contained in:
Clay 2021-08-15 09:40:02 -07:00 committed by Stephan Seitz
parent 807c3da669
commit a9e32d0cc5
14 changed files with 87 additions and 7 deletions

View file

@ -0,0 +1 @@
setlocal commentstring=#\ %s

1
after/ftplugin/heex.vim Normal file
View file

@ -0,0 +1 @@
setlocal commentstring=<%#\ %s\ %>

View file

@ -0,0 +1 @@
setlocal commentstring={!--\ %s\ --}

View file

@ -1,2 +1,2 @@
au BufRead,BufNewFile *.ex,*.exs,mix.lock set filetype=elixir
au BufRead,BufNewFile *.eex,*.leex,*.heex set filetype=eelixir
au BufRead,BufNewFile *.eex,*.leex set filetype=eelixir

1
ftdetect/heex.vim Normal file
View file

@ -0,0 +1 @@
au BufRead,BufNewFile *.heex set filetype=heex

View file

@ -271,6 +271,16 @@ list.surface = {
maintainers = { "@connorlay" },
}
list.heex = {
install_info = {
url = "https://github.com/connorlay/tree-sitter-heex",
files = { "src/parser.c" },
branch = "main",
},
filetype = "heex",
maintainers = { "@connorlay" },
}
list.ocaml = {
install_info = {
url = "https://github.com/tree-sitter/tree-sitter-ocaml",

View file

@ -13,3 +13,8 @@
(sigil_start) @_start
(sigil_content) @surface)
(#eq? @_start "~F\"\"\""))
((sigil
(sigil_start) @_start
(sigil_content) @heex)
(#eq? @_start "~H\"\"\""))

5
queries/heex/folds.scm Normal file
View file

@ -0,0 +1,5 @@
; HEEx folds similar to HTML
[
(tag)
(component)
] @fold

View file

@ -0,0 +1,35 @@
; HEEx text is highlighted as such
(text) @text
; HEEx has two types of comments, both are highlighted as such
(comment) @comment
; HEEx attributes are highlighted as HTML attributes
(attribute_name) @tag.attribute
; Attributes are highlighted as strings
(quoted_attribute_value) @string
; HEEx supports HTML tags and are highlighted as such
[
"<"
">"
"</"
"/>"
"<%"
"<%="
"<%%="
"<%#"
"%>"
"{"
"}"
] @tag.delimiter
; HEEx tags are highlighted as HTML
(tag_name) @tag
; HEEx components are highlighted as types (Elixir modules)
(component_name) @type
; HEEx operators
["="] @operator

11
queries/heex/indents.scm Normal file
View file

@ -0,0 +1,11 @@
; HEEx indents like HTML
[
(component)
(tag)
] @indent
; Dedent at the end of each tag
[
(end_tag)
(end_component)
] @branch

View file

@ -0,0 +1,7 @@
; Directives are combined to support do blocks
(directive (expression_value) @elixir @combined)
; Expressions are not combined, as they exist separately from do blocks
(expression (expression_value) @elixir)
(comment) @comment

View file

@ -1,5 +1,6 @@
; Surface folds similar to HTML and includes blocks
[
(tag)
(component)
(block)
] @fold

View file

@ -19,12 +19,12 @@
; Surface supports HTML tags and are highlighted as such
[
(start_tag)
(end_tag)
(self_closing_tag)
(start_component)
(end_component)
(self_closing_component)
"<"
">"
"</"
"/>"
"{"
"}"
] @tag.delimiter
; Expressions are similar to string interpolation, and are highloghted as such

View file

@ -1,5 +1,6 @@
; Surface indents like HTML, with the addition of blocks
[
(component)
(tag)
(block)
] @indent
@ -7,6 +8,7 @@
; Dedent at the end of each tag, as well as a subblock
[
(end_tag)
(end_component)
(end_block)
(subblock)
] @branch