diff options
| author | Clay <connorlay@pm.me> | 2021-08-15 09:40:02 -0700 |
|---|---|---|
| committer | Thomas Vigouroux <tomvig38@gmail.com> | 2021-08-18 14:07:59 +0200 |
| commit | 57c2081e3fde09ad1d87e04ecc7b85caa42df1bf (patch) | |
| tree | c6fb6e091621bd04778a6ee8af976e6f24b1b37d | |
| parent | Update lockfile.json (diff) | |
| download | nvim-treesitter-57c2081e3fde09ad1d87e04ecc7b85caa42df1bf.tar nvim-treesitter-57c2081e3fde09ad1d87e04ecc7b85caa42df1bf.tar.gz nvim-treesitter-57c2081e3fde09ad1d87e04ecc7b85caa42df1bf.tar.bz2 nvim-treesitter-57c2081e3fde09ad1d87e04ecc7b85caa42df1bf.tar.lz nvim-treesitter-57c2081e3fde09ad1d87e04ecc7b85caa42df1bf.tar.xz nvim-treesitter-57c2081e3fde09ad1d87e04ecc7b85caa42df1bf.tar.zst nvim-treesitter-57c2081e3fde09ad1d87e04ecc7b85caa42df1bf.zip | |
Add HEEx language support, add missing commentstrings
| -rw-r--r-- | after/ftplugin/elixir.vim | 1 | ||||
| -rw-r--r-- | after/ftplugin/heex.vim | 1 | ||||
| -rw-r--r-- | after/ftplugin/surface.vim | 1 | ||||
| -rw-r--r-- | ftdetect/elixir.vim | 2 | ||||
| -rw-r--r-- | ftdetect/heex.vim | 1 | ||||
| -rw-r--r-- | lua/nvim-treesitter/parsers.lua | 10 | ||||
| -rw-r--r-- | queries/elixir/injections.scm | 5 | ||||
| -rw-r--r-- | queries/heex/folds.scm | 5 | ||||
| -rw-r--r-- | queries/heex/highlights.scm | 35 | ||||
| -rw-r--r-- | queries/heex/indents.scm | 11 | ||||
| -rw-r--r-- | queries/heex/injections.scm | 7 | ||||
| -rw-r--r-- | queries/surface/folds.scm | 1 | ||||
| -rw-r--r-- | queries/surface/highlights.scm | 12 | ||||
| -rw-r--r-- | queries/surface/indents.scm | 2 |
14 files changed, 87 insertions, 7 deletions
diff --git a/after/ftplugin/elixir.vim b/after/ftplugin/elixir.vim new file mode 100644 index 000000000..463eea989 --- /dev/null +++ b/after/ftplugin/elixir.vim @@ -0,0 +1 @@ +setlocal commentstring=#\ %s diff --git a/after/ftplugin/heex.vim b/after/ftplugin/heex.vim new file mode 100644 index 000000000..1ec0d53e9 --- /dev/null +++ b/after/ftplugin/heex.vim @@ -0,0 +1 @@ +setlocal commentstring=<%#\ %s\ %> diff --git a/after/ftplugin/surface.vim b/after/ftplugin/surface.vim new file mode 100644 index 000000000..7bbb073f5 --- /dev/null +++ b/after/ftplugin/surface.vim @@ -0,0 +1 @@ +setlocal commentstring={!--\ %s\ --} diff --git a/ftdetect/elixir.vim b/ftdetect/elixir.vim index b06597ce2..60231a565 100644 --- a/ftdetect/elixir.vim +++ b/ftdetect/elixir.vim @@ -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 diff --git a/ftdetect/heex.vim b/ftdetect/heex.vim new file mode 100644 index 000000000..6c7658877 --- /dev/null +++ b/ftdetect/heex.vim @@ -0,0 +1 @@ +au BufRead,BufNewFile *.heex set filetype=heex diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua index 9803f241e..89b448942 100644 --- a/lua/nvim-treesitter/parsers.lua +++ b/lua/nvim-treesitter/parsers.lua @@ -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", diff --git a/queries/elixir/injections.scm b/queries/elixir/injections.scm index 02709add0..29fc58426 100644 --- a/queries/elixir/injections.scm +++ b/queries/elixir/injections.scm @@ -13,3 +13,8 @@ (sigil_start) @_start (sigil_content) @surface) (#eq? @_start "~F\"\"\"")) + +((sigil + (sigil_start) @_start + (sigil_content) @heex) + (#eq? @_start "~H\"\"\"")) diff --git a/queries/heex/folds.scm b/queries/heex/folds.scm new file mode 100644 index 000000000..414890e91 --- /dev/null +++ b/queries/heex/folds.scm @@ -0,0 +1,5 @@ +; HEEx folds similar to HTML +[ + (tag) + (component) +] @fold diff --git a/queries/heex/highlights.scm b/queries/heex/highlights.scm new file mode 100644 index 000000000..d9d0b0c66 --- /dev/null +++ b/queries/heex/highlights.scm @@ -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 diff --git a/queries/heex/indents.scm b/queries/heex/indents.scm new file mode 100644 index 000000000..02771b016 --- /dev/null +++ b/queries/heex/indents.scm @@ -0,0 +1,11 @@ +; HEEx indents like HTML +[ + (component) + (tag) +] @indent + +; Dedent at the end of each tag +[ + (end_tag) + (end_component) +] @branch diff --git a/queries/heex/injections.scm b/queries/heex/injections.scm new file mode 100644 index 000000000..de3b4202d --- /dev/null +++ b/queries/heex/injections.scm @@ -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 diff --git a/queries/surface/folds.scm b/queries/surface/folds.scm index 57763a6e2..994f12e1e 100644 --- a/queries/surface/folds.scm +++ b/queries/surface/folds.scm @@ -1,5 +1,6 @@ ; Surface folds similar to HTML and includes blocks [ (tag) + (component) (block) ] @fold diff --git a/queries/surface/highlights.scm b/queries/surface/highlights.scm index 77b88c052..5cdaa977c 100644 --- a/queries/surface/highlights.scm +++ b/queries/surface/highlights.scm @@ -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 diff --git a/queries/surface/indents.scm b/queries/surface/indents.scm index ad6835752..dceea9c7e 100644 --- a/queries/surface/indents.scm +++ b/queries/surface/indents.scm @@ -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 |
