mirror of
https://github.com/stevearc/aerial.nvim
synced 2024-09-16 14:34:08 +02:00
Add Treesitter Protobuf support
This commit is contained in:
parent
82c84bbf60
commit
1ce27f20b8
5 changed files with 65 additions and 0 deletions
|
@ -135,6 +135,7 @@ automatically fetch symbols from treesitter.
|
|||
- norg
|
||||
- org
|
||||
- php
|
||||
- proto
|
||||
- python
|
||||
- rst
|
||||
- ruby
|
||||
|
|
|
@ -90,6 +90,10 @@ return {
|
|||
method_declaration = "Method",
|
||||
trait_declaration = "Class",
|
||||
},
|
||||
proto = {
|
||||
message = "Class",
|
||||
enum = "Enum",
|
||||
},
|
||||
python = {
|
||||
function_definition = "Function",
|
||||
class_definition = "Class",
|
||||
|
|
7
queries/proto/aerial.scm
Normal file
7
queries/proto/aerial.scm
Normal file
|
@ -0,0 +1,7 @@
|
|||
(message
|
||||
(message_name) @name
|
||||
) @type
|
||||
|
||||
(enum
|
||||
(enum_name) @name
|
||||
) @type
|
37
tests/treesitter/proto_spec.lua
Normal file
37
tests/treesitter/proto_spec.lua
Normal file
|
@ -0,0 +1,37 @@
|
|||
local util = require("tests.test_util")
|
||||
|
||||
describe("treesitter proto", function()
|
||||
it("parses all symbols correctly", function()
|
||||
util.test_file_symbols("treesitter", "./tests/treesitter/proto_test.proto", {
|
||||
{
|
||||
kind = "Class",
|
||||
name = "MessageA",
|
||||
level = 0,
|
||||
lnum = 3,
|
||||
col = 0,
|
||||
end_lnum = 11,
|
||||
end_col = 1,
|
||||
children = {
|
||||
{
|
||||
kind = "Enum",
|
||||
name = "Number",
|
||||
level = 1,
|
||||
lnum = 7,
|
||||
col = 2,
|
||||
end_lnum = 10,
|
||||
end_col = 3,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
kind = "Class",
|
||||
name = "MessageB",
|
||||
level = 0,
|
||||
lnum = 13,
|
||||
col = 0,
|
||||
end_lnum = 16,
|
||||
end_col = 1,
|
||||
},
|
||||
})
|
||||
end)
|
||||
end)
|
16
tests/treesitter/proto_test.proto
Normal file
16
tests/treesitter/proto_test.proto
Normal file
|
@ -0,0 +1,16 @@
|
|||
syntax = "proto3";
|
||||
|
||||
message MessageA {
|
||||
string foo = 1;
|
||||
Number bar = 2;
|
||||
|
||||
enum Number {
|
||||
ONE = 1;
|
||||
TWO = 2;
|
||||
}
|
||||
}
|
||||
|
||||
message MessageB {
|
||||
string foo = 1;
|
||||
int32 bar = 2;
|
||||
}
|
Loading…
Reference in a new issue