mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-01 11:06:54 -04:00
Added USD as a language + some queries
Added USD highlight unittests Added USD indentation Added USD indents.scm file Added USD indent rules Simplified USD highlight groups Added explicit highlight groups Added newline Removed after/ftdetect/usda.lua usd/indents.scm - Added inline comments explaining the nodes Fixed USD highlight group unittests Added indentation unittests Simplified USD `@identifier` highlighting Added USD documentation highlight group tests Simplified USD highlight groups Moved USD `@identifier` and `@namespace` highlights into one place Removed and simplified tests/query/highlights/usd Simplified tests/query/highlights/usd more Removed trailing newline Combined USD test files Added `set filetype=usd` to minimal_init.lua
This commit is contained in:
parent
3b0c133c31
commit
4c35c0b75d
12 changed files with 399 additions and 0 deletions
|
|
@ -345,6 +345,7 @@ We are looking for maintainers to add more parsers and to write query files for
|
|||
- [x] [twig](https://github.com/gbprod/tree-sitter-twig) (maintained by @gbprod)
|
||||
- [x] [typescript](https://github.com/tree-sitter/tree-sitter-typescript) (maintained by @steelsojka)
|
||||
- [x] [ungrammar](https://github.com/Philipp-M/tree-sitter-ungrammar) (maintained by @Philipp-M, @amaanq)
|
||||
- [x] [usd](https://github.com/ColinKennedy/tree-sitter-usd) (maintained by @ColinKennedy)
|
||||
- [x] [uxn tal](https://github.com/amaanq/tree-sitter-uxntal) (maintained by @amaanq)
|
||||
- [x] [v](https://github.com/vlang/vls) (maintained by @kkharji)
|
||||
- [x] [vala](https://github.com/vala-lang/tree-sitter-vala) (maintained by @Prince781)
|
||||
|
|
|
|||
|
|
@ -1522,6 +1522,14 @@ list.ungrammar = {
|
|||
maintainers = { "@Philipp-M", "@amaanq" },
|
||||
}
|
||||
|
||||
list.usd = {
|
||||
install_info = {
|
||||
url = "https://github.com/ColinKennedy/tree-sitter-usd",
|
||||
files = { "src/parser.c" },
|
||||
},
|
||||
maintainers = { "@ColinKennedy" },
|
||||
}
|
||||
|
||||
list.uxntal = {
|
||||
install_info = {
|
||||
url = "https://github.com/amaanq/tree-sitter-uxntal",
|
||||
|
|
|
|||
3
queries/usd/folds.scm
Normal file
3
queries/usd/folds.scm
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
[
|
||||
(block)
|
||||
] @fold
|
||||
181
queries/usd/highlights.scm
Normal file
181
queries/usd/highlights.scm
Normal file
|
|
@ -0,0 +1,181 @@
|
|||
(None) @constant.builtin
|
||||
(asset_path) @text.uri
|
||||
(attribute_property) @property
|
||||
(bool) @boolean
|
||||
(comment) @comment @spell
|
||||
(custom) @function.builtin
|
||||
(float) @float
|
||||
(integer) @number
|
||||
(orderer) @function.call
|
||||
(prim_path) @string.special
|
||||
(relationship_type) @type
|
||||
(string) @string
|
||||
(uniform) @function.builtin
|
||||
(variant_set_definition) @keyword
|
||||
|
||||
;; Prefer namespace highlighting, if any.
|
||||
;;
|
||||
;; e.g. `rel fizz` - `fizz` uses `@identifier`
|
||||
;; e.g. `rel foo:bar:fizz` - `foo` and `bar` use `@namespace` and `fizz` uses `@identifier`
|
||||
;;
|
||||
(identifier) @variable
|
||||
(namespace_identifier) @namespace
|
||||
(namespace_identifier
|
||||
(identifier) @namespace
|
||||
)
|
||||
|
||||
[
|
||||
"class"
|
||||
"def"
|
||||
"over"
|
||||
] @keyword.function
|
||||
|
||||
["(" ")" "[" "]" "{" "}"] @punctuation.bracket
|
||||
[":" ";" "."] @punctuation.delimiter
|
||||
|
||||
[
|
||||
"="
|
||||
] @operator
|
||||
|
||||
(attribute_type) @type
|
||||
(
|
||||
;; Reference: https://openusd.org/release/api/sdf_page_front.html
|
||||
(attribute_type) @type.builtin
|
||||
(#any-of? @type.builtin
|
||||
;; Scalar types
|
||||
"asset" "asset[]"
|
||||
"bool" "bool[]"
|
||||
"double" "double[]"
|
||||
"float" "float[]"
|
||||
"half" "half[]"
|
||||
"int" "int[]"
|
||||
"int64" "int64[]"
|
||||
"string" "string[]"
|
||||
"timecode" "timecode[]"
|
||||
"token" "token[]"
|
||||
"uchar" "uchar[]"
|
||||
"uint" "uint[]"
|
||||
"uint64" "uint64[]"
|
||||
|
||||
;; Dimensioned Types
|
||||
"double2" "double2[]"
|
||||
"double3" "double3[]"
|
||||
"double4" "double4[]"
|
||||
"float2" "float2[]"
|
||||
"float3" "float3[]"
|
||||
"float4" "float4[]"
|
||||
"half2" "half2[]"
|
||||
"half3" "half3[]"
|
||||
"half4" "half4[]"
|
||||
"int2" "int2[]"
|
||||
"int3" "int3[]"
|
||||
"int4" "int4[]"
|
||||
"matrix2d" "matrix2d[]"
|
||||
"matrix3d" "matrix3d[]"
|
||||
"matrix4d" "matrix4d[]"
|
||||
"quatd" "quatd[]"
|
||||
"quatf" "quatf[]"
|
||||
"quath" "quath[]"
|
||||
|
||||
;; Extra Types
|
||||
"color3f" "color3f[]"
|
||||
"normal3f" "normal3f[]"
|
||||
"point3f" "point3f[]"
|
||||
"texCoord2f" "texCoord2f[]"
|
||||
"vector3d" "vector3d[]"
|
||||
"vector3f" "vector3f[]"
|
||||
"vector3h" "vector3h[]"
|
||||
|
||||
"dictionary"
|
||||
|
||||
;; Deprecated Types
|
||||
"EdgeIndex" "EdgeIndex[]"
|
||||
"FaceIndex" "FaceIndex[]"
|
||||
"Matrix4d" "Matrix4d[]"
|
||||
"PointIndex" "PointIndex[]"
|
||||
"PointFloat" "PointFloat[]"
|
||||
"Transform" "Transform[]"
|
||||
"Vec3f" "Vec3f[]"
|
||||
)
|
||||
)
|
||||
|
||||
(
|
||||
(identifier) @keyword
|
||||
(#any-of? @keyword
|
||||
|
||||
;; Reference: https://openusd.org/release/api/sdf_page_front.html
|
||||
;; LIVRPS names
|
||||
"inherits"
|
||||
"payload"
|
||||
"references"
|
||||
"specializes"
|
||||
"variantSets"
|
||||
"variants"
|
||||
|
||||
; assetInfo names
|
||||
"assetInfo"
|
||||
"identifier"
|
||||
"name"
|
||||
"payloadAssetDependencies"
|
||||
"version"
|
||||
|
||||
;; clips names
|
||||
"clips"
|
||||
|
||||
"active"
|
||||
"assetPaths"
|
||||
"manifestAssetPath"
|
||||
"primPath"
|
||||
"templateAssetPath"
|
||||
"templateEndTime"
|
||||
"templateStartTime"
|
||||
"templateStride"
|
||||
"times"
|
||||
|
||||
;; customData names
|
||||
"customData"
|
||||
|
||||
"apiSchemaAutoApplyTo"
|
||||
"apiSchemaOverridePropertyNames"
|
||||
"className"
|
||||
"extraPlugInfo"
|
||||
"isUsdShadeContainer"
|
||||
"libraryName"
|
||||
"providesUsdShadeConnectableAPIBehavior"
|
||||
"requiresUsdShadeEncapsulation"
|
||||
"skipCodeGeneration"
|
||||
|
||||
;; Layer metadata names
|
||||
"colorConfiguration"
|
||||
"colorManagementSystem"
|
||||
"customLayerData"
|
||||
"defaultPrim"
|
||||
"doc"
|
||||
"endTimeCode"
|
||||
"framesPerSecond"
|
||||
"owner"
|
||||
"startTimeCode"
|
||||
"subLayers"
|
||||
|
||||
;; Prim metadata
|
||||
"instanceable"
|
||||
)
|
||||
)
|
||||
|
||||
;; Common attribute metadata
|
||||
(
|
||||
(layer_offset
|
||||
(identifier) @keyword
|
||||
(#any-of? @keyword
|
||||
|
||||
"offset"
|
||||
"scale"
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
;; Docstrings in USD
|
||||
(metadata
|
||||
(comment)*
|
||||
(string) @comment.documentation
|
||||
)
|
||||
26
queries/usd/indents.scm
Normal file
26
queries/usd/indents.scm
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
[
|
||||
(block) ; The {}s in `def "foo" { ... Attributes / Prims here ... }`
|
||||
(dictionary) ; The {}s in `dictionary foo = { string "foo" = "bar" }`
|
||||
(list)
|
||||
(list_proxy) ; [@foo.usda@, @bar.usda@]
|
||||
(metadata) ; ( anything = "goes-here" )
|
||||
(prim_paths) ; [</foo>, <../bar>]
|
||||
(timeSamples) ; The {}s in `int value.timeSamples = { 0: 1, -10: 10, ... }`
|
||||
(tuple)
|
||||
(variant_set_definition) ; The {}s in `variantSet "foo" = { "vr1" { ... } "vr2" { ... } }`
|
||||
] @indent.begin
|
||||
|
||||
(block "}" @indent.end)
|
||||
(dictionary "}" @indent.end)
|
||||
(list "]" @indent.end)
|
||||
(list_proxy "]" @indent.end)
|
||||
(metadata ")" @indent.end)
|
||||
(timeSamples "}" @indent.end)
|
||||
(tuple ")" @indent.end)
|
||||
(variant_set_definition "}" @indent.end)
|
||||
|
||||
[
|
||||
")"
|
||||
"]"
|
||||
"}"
|
||||
] @indent.branch
|
||||
4
queries/usd/locals.scm
Normal file
4
queries/usd/locals.scm
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
[
|
||||
(block)
|
||||
(metadata)
|
||||
] @scope
|
||||
|
|
@ -5,6 +5,7 @@ vim.cmd [[runtime! plugin/nvim-treesitter.lua]]
|
|||
vim.cmd [[au BufRead,BufNewFile *.conf set filetype=hocon]]
|
||||
vim.cmd [[au BufRead,BufNewFile *.gleam set filetype=gleam]]
|
||||
vim.cmd [[au BufRead,BufNewFile *.ncl set filetype=nickel]]
|
||||
vim.cmd [[au BufRead,BufNewFile *.usd,*.usda set filetype=usd]]
|
||||
|
||||
vim.o.swapfile = false
|
||||
vim.bo.swapfile = false
|
||||
|
|
|
|||
6
tests/indent/usd/prim.usd
Normal file
6
tests/indent/usd/prim.usd
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
#usda 1.0
|
||||
|
||||
def "foo" (
|
||||
)
|
||||
{
|
||||
}
|
||||
21
tests/indent/usd_spec.lua
Normal file
21
tests/indent/usd_spec.lua
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
local Runner = require("tests.indent.common").Runner
|
||||
|
||||
local run = Runner:new(it, "tests/indent/usd", {
|
||||
tabstop = 4,
|
||||
shiftwidth = 4,
|
||||
softtabstop = 4,
|
||||
expandtab = true,
|
||||
})
|
||||
|
||||
describe("indent USD:", function()
|
||||
describe("whole file:", function()
|
||||
run:whole_file(".", {
|
||||
expected_failures = {},
|
||||
})
|
||||
end)
|
||||
|
||||
describe("new line:", function()
|
||||
run:new_line("prim.usd", { on_line = 3, text = "active = false", indent = 4 })
|
||||
run:new_line("prim.usd", { on_line = 5, text = "custom int foo = 10", indent = 4 })
|
||||
end)
|
||||
end)
|
||||
118
tests/query/highlights/usd/prims.usda
Normal file
118
tests/query/highlights/usd/prims.usda
Normal file
|
|
@ -0,0 +1,118 @@
|
|||
def Xform "cube" (
|
||||
assetInfo = {
|
||||
# <- keyword
|
||||
asset[] payloadAssetDependencies = [@fizz.usd@, @buzz.usd@]
|
||||
# <- type
|
||||
# ^ keyword
|
||||
# ^ text.uri
|
||||
# ^ text.uri
|
||||
}
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
def "root" (
|
||||
add references = @foo.usda@</Model> (offset = 1; scale = 2.0)
|
||||
# <- text.uri
|
||||
# ^ string.special
|
||||
# ^ keyword
|
||||
# ^ number
|
||||
# ^ punctuation.delimiter
|
||||
# ^ keyword
|
||||
# ^ float
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
def "World"
|
||||
{
|
||||
over "points" (
|
||||
clips = {
|
||||
# <- keyword
|
||||
dictionary default = {
|
||||
# <- type
|
||||
# ^ variable
|
||||
double2[] times = [(101, 101), (102, 102)]
|
||||
# <- type
|
||||
# ^ keyword
|
||||
# ^ number
|
||||
}
|
||||
}
|
||||
)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
def Xform "torch_2" (
|
||||
payload = @./torch.usda@
|
||||
kind = "model"
|
||||
)
|
||||
{
|
||||
// Pre-published light list
|
||||
# <- comment
|
||||
rel lightList = [ <light> ] # inline comment
|
||||
# ^ comment
|
||||
token lightList:cacheBehavior = "consumeAndContinue"
|
||||
|
||||
double3 xformOp:translate = (1, 0, 0.5)
|
||||
uniform token[] xformOpOrder = ["xformOp:translate"]
|
||||
}
|
||||
|
||||
def "foo" (
|
||||
"some comment"
|
||||
# <- comment.documentation
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
def "foo" (
|
||||
# inline comment
|
||||
"actual in-description comment"
|
||||
# <- comment.documentation
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
def "foo" (
|
||||
add references = @foo.usda@
|
||||
# <- function.call
|
||||
append references = @foo.usda@
|
||||
# <- function.call
|
||||
delete references = @foo.usda@
|
||||
# <- function.call
|
||||
reorder references = [@foo.usda@]
|
||||
# <- function.call
|
||||
|
||||
references = [@foo.usda@] # explicit
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
over "Parent" (
|
||||
prepend references = [</InternalRef>, @./ref.usda@</RefParent>]
|
||||
# <- function.call
|
||||
# ^ keyword
|
||||
# ^ string.special
|
||||
# ^ text.uri
|
||||
# ^ string.special
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
def "foo"
|
||||
{
|
||||
float value.timeSamples = {
|
||||
# <- type
|
||||
# ^ variable
|
||||
# ^ property
|
||||
-414: 14.4
|
||||
# <- number
|
||||
# ^ float
|
||||
10: 201.0,
|
||||
# <- number
|
||||
# ^ float
|
||||
10.123: 201.0123,
|
||||
# <- float
|
||||
# ^ float
|
||||
}
|
||||
}
|
||||
21
tests/query/highlights/usd/properties.usda
Normal file
21
tests/query/highlights/usd/properties.usda
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
dictionary foo = {}
|
||||
# <- type
|
||||
half[] foo = [2, 1, 2]
|
||||
# <- type
|
||||
string foo = "something"
|
||||
# <- type
|
||||
timecode time = 1.0
|
||||
# <- type
|
||||
token[] purpose = ["default", "render"]
|
||||
# <- type
|
||||
|
||||
rel material:binding:collection:Erasers = None
|
||||
# <- type
|
||||
# ^ namespace
|
||||
# ^ punctuation.delimiter
|
||||
# ^ namespace
|
||||
# ^ punctuation.delimiter
|
||||
# ^ namespace
|
||||
# ^ punctuation.delimiter
|
||||
# ^ variable
|
||||
# ^ constant.builtin
|
||||
9
tests/query/highlights/usd/subLayers.usda
Normal file
9
tests/query/highlights/usd/subLayers.usda
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
#usda 1.0
|
||||
(
|
||||
subLayers = [
|
||||
# <- keyword
|
||||
@./model_sub.usda@ (offset = 1)
|
||||
# <- text.uri
|
||||
# ^ keyword
|
||||
]
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue