mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-13 17:00:09 -04:00
Feature: Add Surface language and integrate with Elixir (#1645)
* Add initial surface highlights & injections * Additional surface highlights * Filetype detection, fix injections * Fix Elixir function highlight when left is an identifier * Add surface parser * Fix comment highlights * Surface folds, indents, better highlights * Highlight surface components & directives * Restore comments Elixir injections
This commit is contained in:
parent
b2ce0800cf
commit
363ac62e23
9 changed files with 93 additions and 0 deletions
2
ftdetect/elixir.vim
Normal file
2
ftdetect/elixir.vim
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
au BufRead,BufNewFile *.ex,*.exs,mix.lock set filetype=elixir
|
||||||
|
au BufRead,BufNewFile *.eex,*.leex,*.heex set filetype=eelixir
|
||||||
1
ftdetect/surface.vim
Normal file
1
ftdetect/surface.vim
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
au BufRead,BufNewFile *.sface set filetype=surface
|
||||||
|
|
@ -261,6 +261,16 @@ list.elixir = {
|
||||||
maintainers = { "@nifoc" },
|
maintainers = { "@nifoc" },
|
||||||
}
|
}
|
||||||
|
|
||||||
|
list.surface = {
|
||||||
|
install_info = {
|
||||||
|
url = "https://github.com/connorlay/tree-sitter-surface",
|
||||||
|
files = { "src/parser.c" },
|
||||||
|
branch = "main",
|
||||||
|
},
|
||||||
|
filetype = "sface",
|
||||||
|
maintainers = { "@connorlay" },
|
||||||
|
}
|
||||||
|
|
||||||
list.ocaml = {
|
list.ocaml = {
|
||||||
install_info = {
|
install_info = {
|
||||||
url = "https://github.com/tree-sitter/tree-sitter-ocaml",
|
url = "https://github.com/tree-sitter/tree-sitter-ocaml",
|
||||||
|
|
|
||||||
|
|
@ -78,6 +78,10 @@
|
||||||
remote: [(atom) (module)] @type
|
remote: [(atom) (module)] @type
|
||||||
function: (function_identifier) @method)
|
function: (function_identifier) @method)
|
||||||
|
|
||||||
|
(dot_call
|
||||||
|
remote: (identifier) @variable
|
||||||
|
function: (function_identifier) @method)
|
||||||
|
|
||||||
"fn" @keyword.function
|
"fn" @keyword.function
|
||||||
|
|
||||||
; def, defp, defguard, ... everything that starts with def
|
; def, defp, defguard, ... everything that starts with def
|
||||||
|
|
|
||||||
|
|
@ -8,3 +8,8 @@
|
||||||
(sigil_start) @_start
|
(sigil_start) @_start
|
||||||
(sigil_content) @regex)
|
(sigil_content) @regex)
|
||||||
(#match? @_start "~(r|R)[/</\\\"[({|]"))
|
(#match? @_start "~(r|R)[/</\\\"[({|]"))
|
||||||
|
|
||||||
|
((sigil
|
||||||
|
(sigil_start) @_start
|
||||||
|
(sigil_content) @surface)
|
||||||
|
(#eq? @_start "~F\"\"\""))
|
||||||
|
|
|
||||||
5
queries/surface/folds.scm
Normal file
5
queries/surface/folds.scm
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
; Surface folds similar to HTML and includes blocks
|
||||||
|
[
|
||||||
|
(tag)
|
||||||
|
(block)
|
||||||
|
] @fold
|
||||||
46
queries/surface/highlights.scm
Normal file
46
queries/surface/highlights.scm
Normal file
|
|
@ -0,0 +1,46 @@
|
||||||
|
; Surface text is highlighted as such
|
||||||
|
(text) @text
|
||||||
|
|
||||||
|
; Surface has two types of comments, both are highlighted as such
|
||||||
|
(comment) @comment
|
||||||
|
|
||||||
|
; Surface attributes are highlighted as HTML attributes
|
||||||
|
(attribute_name) @tag.attribute
|
||||||
|
|
||||||
|
; Attributes are highlighted as strings
|
||||||
|
(attribute_value) @string
|
||||||
|
|
||||||
|
; Surface blocks are highlighted as keywords
|
||||||
|
[
|
||||||
|
(start_block)
|
||||||
|
(end_block)
|
||||||
|
(subblock)
|
||||||
|
] @keyword
|
||||||
|
|
||||||
|
; 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
|
||||||
|
(expression) @punctuation.special
|
||||||
|
|
||||||
|
; Expressions should be highlighted as Elixir, fallback to special strings
|
||||||
|
(expression_value) @string.special
|
||||||
|
|
||||||
|
; Surface tags are highlighted as HTML
|
||||||
|
(tag_name) @tag
|
||||||
|
|
||||||
|
; Surface components are highlighted as types (Elixir modules)
|
||||||
|
(component_name) @type
|
||||||
|
|
||||||
|
; Surface directives are highlighted as keywords
|
||||||
|
(directive_name) @keyword
|
||||||
|
|
||||||
|
; Surface operators
|
||||||
|
["="] @operator
|
||||||
12
queries/surface/indents.scm
Normal file
12
queries/surface/indents.scm
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
; Surface indents like HTML, with the addition of blocks
|
||||||
|
[
|
||||||
|
(tag)
|
||||||
|
(block)
|
||||||
|
] @indent
|
||||||
|
|
||||||
|
; Dedent at the end of each tag, as well as a subblock
|
||||||
|
[
|
||||||
|
(end_tag)
|
||||||
|
(end_block)
|
||||||
|
(subblock)
|
||||||
|
] @branch
|
||||||
8
queries/surface/injections.scm
Normal file
8
queries/surface/injections.scm
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
; Surface expressions and components are Elixir code
|
||||||
|
[
|
||||||
|
(expression_value)
|
||||||
|
(component_name)
|
||||||
|
] @elixir
|
||||||
|
|
||||||
|
; Surface comments are nvim-treesitter comments
|
||||||
|
(comment) @comment
|
||||||
Loading…
Add table
Add a link
Reference in a new issue