aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJirgn <jirgn76@googlemail.com>2021-11-26 16:37:51 +0100
committerStephan Seitz <stephan.seitz@fau.de>2021-11-26 22:04:59 +0100
commit979c32493d1edabb949badf00da9d130d966aaae (patch)
tree1ecc73f323a2a72910d24714cab880acd8886d8f
parenthighlights(rust): organize keywords and literals (diff)
downloadnvim-treesitter-979c32493d1edabb949badf00da9d130d966aaae.tar
nvim-treesitter-979c32493d1edabb949badf00da9d130d966aaae.tar.gz
nvim-treesitter-979c32493d1edabb949badf00da9d130d966aaae.tar.bz2
nvim-treesitter-979c32493d1edabb949badf00da9d130d966aaae.tar.lz
nvim-treesitter-979c32493d1edabb949badf00da9d130d966aaae.tar.xz
nvim-treesitter-979c32493d1edabb949badf00da9d130d966aaae.tar.zst
nvim-treesitter-979c32493d1edabb949badf00da9d130d966aaae.zip
feat: add fusion grammar and highlights
-rw-r--r--README.md1
-rw-r--r--ftdetect/fusion.vim1
-rw-r--r--lua/nvim-treesitter/parsers.lua8
-rw-r--r--queries/fusion/highlights.scm87
-rw-r--r--queries/fusion/locals.scm3
-rw-r--r--tests/query/highlights/fusion/basic.fusion61
-rw-r--r--tests/query/highlights/fusion/expressions.fusion74
7 files changed, 235 insertions, 0 deletions
diff --git a/README.md b/README.md
index e177d21a9..be903d615 100644
--- a/README.md
+++ b/README.md
@@ -172,6 +172,7 @@ We are looking for maintainers to add more parsers and to write query files for
- [x] [fennel](https://github.com/travonted/tree-sitter-fennel) (maintained by @TravonteD)
- [x] [fish](https://github.com/ram02z/tree-sitter-fish) (maintained by @ram02z)
- [ ] [fortran](https://github.com/stadelmanma/tree-sitter-fortran)
+- [ ] [neos fusion](https://gitlab.com/jirgn/tree-sitter-fusion)(experimental, maintained by @jirgn)
- [x] [Godot (gdscript)](https://github.com/PrestonKnopp/tree-sitter-gdscript) (maintained by @Shatur95)
- [x] [Glimmer and Ember](https://github.com/alexlafroscia/tree-sitter-glimmer) (maintained by @alexlafroscia)
- [x] [glsl](https://github.com/theHamsta/tree-sitter-glsl) (maintained by @theHamsta)
diff --git a/ftdetect/fusion.vim b/ftdetect/fusion.vim
new file mode 100644
index 000000000..7a7839b23
--- /dev/null
+++ b/ftdetect/fusion.vim
@@ -0,0 +1 @@
+autocmd BufRead,BufNewFile *.fusion setfiletype fusion
diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua
index b0c51e2ef..1eb54c96a 100644
--- a/lua/nvim-treesitter/parsers.lua
+++ b/lua/nvim-treesitter/parsers.lua
@@ -131,6 +131,14 @@ list.rust = {
maintainers = { "@vigoux" },
}
+list.fusion = {
+ install_info = {
+ url = "https://gitlab.com/jirgn/tree-sitter-fusion",
+ files = { "src/parser.c"},
+ },
+ maintainers = { "@jirgn" },
+}
+
list.ledger = {
install_info = {
url = "https://github.com/cbarrete/tree-sitter-ledger",
diff --git a/queries/fusion/highlights.scm b/queries/fusion/highlights.scm
new file mode 100644
index 000000000..057671e18
--- /dev/null
+++ b/queries/fusion/highlights.scm
@@ -0,0 +1,87 @@
+(comment) @comment
+
+; identifiers eel
+
+(eel_object_path
+ (eel_path_identifier) @variable)
+
+(eel_object_pair
+ key: (eel_property_name) @property)
+
+(eel_method_name) @function
+
+(eel_parameter) @variable
+
+
+
+; identifiers fusion
+; -----------
+
+(path_part) @property
+(meta_property) @attribute
+(prototype_signature
+ "prototype" @keyword
+
+)
+(include_statement
+ "include" @include
+ ":" @punctation.delimiter
+ (source_file) @uri
+)
+
+(namespace_declaration
+ "namespace" @keyword
+ (alias_namespace) @namespace)
+
+(identifier_type
+ name: (type_name) @type)
+
+; tokens
+; ------
+
+[
+ (identifier_package)
+ (alias_namespace)
+] @namespace
+
+[
+ "="
+ "<"
+ "&&"
+ "and"
+ "||"
+ "or"
+ "*"
+ "/"
+ "%"
+ "+"
+ "-"
+ "!"
+ "not"
+ (deletion)
+] @operator
+
+(string) @string
+(number) @number
+(boolean) @boolean
+(null) @constant.builtin
+
+
+; punctation
+; ----------
+
+[
+ "("
+ ")"
+ "{"
+ "}"
+ "["
+ "]"
+] @punctation.bracket
+
+[
+ ":"
+ "."
+ "?"
+] @punctation.delimiter
+
diff --git a/queries/fusion/locals.scm b/queries/fusion/locals.scm
new file mode 100644
index 000000000..c3724f4fd
--- /dev/null
+++ b/queries/fusion/locals.scm
@@ -0,0 +1,3 @@
+(eel_arrow_function) @local.scope
+
+(eel_parameter) @local.definition
diff --git a/tests/query/highlights/fusion/basic.fusion b/tests/query/highlights/fusion/basic.fusion
new file mode 100644
index 000000000..7149956a1
--- /dev/null
+++ b/tests/query/highlights/fusion/basic.fusion
@@ -0,0 +1,61 @@
+include: SomeFile.fusion
+//<- include
+// ^punctation.delimiter
+// ^uri
+
+namespace ns = Neos.Fusion.Space
+//<- keyword
+// ^namespace
+// ^operator
+// ^namespace
+
+prototype(MyType) < prototype(ns:SuperType) {
+//<-keyword
+// ^punctation.bracket
+// ^type
+// ^punctation.bracket
+// ^operator
+// ^namespace
+// ^type
+
+ deleteProp >
+ // ^operator
+
+ string = 'value'
+ //<- property
+ // ^operator
+ // ^string
+
+ number = 10.2
+ // ^number
+
+ null = null
+ // ^constant.builtin
+
+ boolean = true
+ // ^boolean
+
+ property.inner = "value"
+ //<- property
+ // ^property
+
+ property.@meta = "value"
+ //<- property
+ // ^attribute
+
+ property.type = SomeType
+ //<- property
+ // ^type
+
+ property.aliasedType = ns:SomeType
+ //<- property
+ // ^namespace
+ // ^type
+
+ property.fullQualifiedType = SomeNamespace:SomeType
+ //<- property
+ // ^namespace
+ // ^type
+
+}
+
diff --git a/tests/query/highlights/fusion/expressions.fusion b/tests/query/highlights/fusion/expressions.fusion
new file mode 100644
index 000000000..db71a628a
--- /dev/null
+++ b/tests/query/highlights/fusion/expressions.fusion
@@ -0,0 +1,74 @@
+string = ${'foo'}
+// ^string
+
+string = ${'foo \'bar\' baz'}
+// ^string
+
+string = ${"foo"}
+// ^string
+
+string = ${"foo ${test}"}
+// ^string
+
+boolean = ${true}
+// ^boolean
+
+number = ${1}
+// ^number
+
+number = ${1.2}
+// ^number
+
+propertyPath = ${property.path}
+// ^variable
+// ^variable
+
+array = ${[]}
+// ^punctation.bracket
+
+array = ${[true, 'string', 1, [true]]}
+// ^punctation.bracket
+// ^boolean
+// ^string
+// ^number
+// ^punctation.bracket
+// ^boolean
+
+object = ${{}}
+// ^punctation.bracket
+
+object = ${{first: 'value', second: true, third: [], fourth: object.path }}
+// ^property
+// ^string
+// ^property
+// ^boolean
+// ^property
+// ^punctation.bracket
+// ^property
+// ^variable
+
+result = ${methodCall()}
+// ^function
+
+result = ${Some.methodCall(param, param)}
+// ^function
+// ^variable
+// ^variable
+
+arrowFunction = ${map(foo, (bar, buz) => bar * buz)}
+// ^function
+// ^variable
+// ^variable
+
+logic = ${!foo && !(bar || baz) and not 'string'}
+// ^operator
+// ^operator
+// ^operator
+// ^operator
+// ^operator
+
+ternary = ${ check ? true : false}
+// ^punctation.delimiter
+// ^punctation.delimiter
+
+