mirror of
https://github.com/stevearc/aerial.nvim
synced 2024-09-16 14:34:08 +02:00
fix: enforce treesitter backend uses LSP SymbolKind values (#219)
This commit is contained in:
parent
1bdb9ca19b
commit
06c6b4c8eb
9 changed files with 41 additions and 35 deletions
|
@ -1,12 +1,11 @@
|
|||
local backends = require("aerial.backends")
|
||||
local config = require("aerial.config")
|
||||
local data = require("aerial.data")
|
||||
local protocol = require("vim.lsp.protocol")
|
||||
|
||||
local M = {}
|
||||
|
||||
local function get_symbol_kind_name(kind_number)
|
||||
return protocol.SymbolKind[kind_number] or "Unknown"
|
||||
return vim.lsp.protocol.SymbolKind[kind_number] or "Unknown"
|
||||
end
|
||||
|
||||
local function convert_range(range)
|
||||
|
|
|
@ -73,7 +73,14 @@ M.fetch_symbols_sync = function(bufnr)
|
|||
end
|
||||
local kind = match.kind
|
||||
if not kind then
|
||||
vim.api.nvim_err_writeln(string.format("Missing 'kind' metadata in query file."))
|
||||
vim.api.nvim_err_writeln(
|
||||
string.format("Missing 'kind' metadata in query file for language %s", lang)
|
||||
)
|
||||
break
|
||||
elseif not vim.lsp.protocol.SymbolKind[kind] then
|
||||
vim.api.nvim_err_writeln(
|
||||
string.format("Invalid 'kind' metadata '%s' in query file for language %s", kind, lang)
|
||||
)
|
||||
break
|
||||
end
|
||||
local row, col = start_node:start()
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
(start_tag (tag_name) @name)
|
||||
(self_closing_tag (tag_name) @name)
|
||||
]
|
||||
(#set! "kind" "Snippet")
|
||||
(#set! "kind" "Struct")
|
||||
) @type
|
||||
|
||||
(attribute (attribute_name) @name
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
(type_alias_declaration
|
||||
name: (type_identifier) @name
|
||||
(#set! "kind" "Type")
|
||||
(#set! "kind" "Variable")
|
||||
) @type
|
||||
|
||||
(lexical_declaration
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
(type_alias_declaration
|
||||
name: (type_identifier) @name
|
||||
(#set! "kind" "Type")
|
||||
(#set! "kind" "Variable")
|
||||
) @type
|
||||
|
||||
(lexical_declaration
|
||||
|
|
|
@ -40,7 +40,7 @@ describe("treesitter html", function()
|
|||
col = 4,
|
||||
end_col = 28,
|
||||
end_lnum = 5,
|
||||
kind = "Snippet",
|
||||
kind = "Struct",
|
||||
level = 2,
|
||||
lnum = 5,
|
||||
name = "meta",
|
||||
|
@ -69,7 +69,7 @@ describe("treesitter html", function()
|
|||
col = 4,
|
||||
end_col = 58,
|
||||
end_lnum = 6,
|
||||
kind = "Snippet",
|
||||
kind = "Struct",
|
||||
level = 2,
|
||||
lnum = 6,
|
||||
name = "meta",
|
||||
|
@ -78,7 +78,7 @@ describe("treesitter html", function()
|
|||
col = 4,
|
||||
end_col = 29,
|
||||
end_lnum = 7,
|
||||
kind = "Snippet",
|
||||
kind = "Struct",
|
||||
level = 2,
|
||||
lnum = 7,
|
||||
name = "title",
|
||||
|
@ -107,7 +107,7 @@ describe("treesitter html", function()
|
|||
col = 4,
|
||||
end_col = 44,
|
||||
end_lnum = 8,
|
||||
kind = "Snippet",
|
||||
kind = "Struct",
|
||||
level = 2,
|
||||
lnum = 8,
|
||||
name = "link",
|
||||
|
@ -116,7 +116,7 @@ describe("treesitter html", function()
|
|||
col = 4,
|
||||
end_col = 12,
|
||||
end_lnum = 13,
|
||||
kind = "Snippet",
|
||||
kind = "Struct",
|
||||
level = 2,
|
||||
lnum = 9,
|
||||
name = "style",
|
||||
|
@ -125,7 +125,7 @@ describe("treesitter html", function()
|
|||
col = 2,
|
||||
end_col = 9,
|
||||
end_lnum = 14,
|
||||
kind = "Snippet",
|
||||
kind = "Struct",
|
||||
level = 1,
|
||||
lnum = 4,
|
||||
name = "head",
|
||||
|
@ -158,7 +158,7 @@ describe("treesitter html", function()
|
|||
col = 6,
|
||||
end_col = 41,
|
||||
end_lnum = 17,
|
||||
kind = "Snippet",
|
||||
kind = "Struct",
|
||||
level = 3,
|
||||
lnum = 17,
|
||||
name = "h1",
|
||||
|
@ -167,7 +167,7 @@ describe("treesitter html", function()
|
|||
col = 6,
|
||||
end_col = 27,
|
||||
end_lnum = 18,
|
||||
kind = "Snippet",
|
||||
kind = "Struct",
|
||||
level = 3,
|
||||
lnum = 18,
|
||||
name = "p",
|
||||
|
@ -176,7 +176,7 @@ describe("treesitter html", function()
|
|||
col = 6,
|
||||
end_col = 12,
|
||||
end_lnum = 20,
|
||||
kind = "Snippet",
|
||||
kind = "Struct",
|
||||
level = 3,
|
||||
lnum = 20,
|
||||
name = "hr",
|
||||
|
@ -191,7 +191,7 @@ describe("treesitter html", function()
|
|||
col = 14,
|
||||
end_col = 27,
|
||||
end_lnum = 24,
|
||||
kind = "Snippet",
|
||||
kind = "Struct",
|
||||
level = 6,
|
||||
lnum = 24,
|
||||
name = "th",
|
||||
|
@ -200,7 +200,7 @@ describe("treesitter html", function()
|
|||
col = 27,
|
||||
end_col = 44,
|
||||
end_lnum = 24,
|
||||
kind = "Snippet",
|
||||
kind = "Struct",
|
||||
level = 6,
|
||||
lnum = 24,
|
||||
name = "th",
|
||||
|
@ -209,7 +209,7 @@ describe("treesitter html", function()
|
|||
col = 10,
|
||||
end_col = 49,
|
||||
end_lnum = 24,
|
||||
kind = "Snippet",
|
||||
kind = "Struct",
|
||||
level = 5,
|
||||
lnum = 24,
|
||||
name = "tr",
|
||||
|
@ -218,7 +218,7 @@ describe("treesitter html", function()
|
|||
col = 8,
|
||||
end_col = 16,
|
||||
end_lnum = 25,
|
||||
kind = "Snippet",
|
||||
kind = "Struct",
|
||||
level = 4,
|
||||
lnum = 23,
|
||||
name = "thead",
|
||||
|
@ -231,7 +231,7 @@ describe("treesitter html", function()
|
|||
col = 14,
|
||||
end_col = 29,
|
||||
end_lnum = 27,
|
||||
kind = "Snippet",
|
||||
kind = "Struct",
|
||||
level = 6,
|
||||
lnum = 27,
|
||||
name = "td",
|
||||
|
@ -240,7 +240,7 @@ describe("treesitter html", function()
|
|||
col = 29,
|
||||
end_col = 39,
|
||||
end_lnum = 27,
|
||||
kind = "Snippet",
|
||||
kind = "Struct",
|
||||
level = 6,
|
||||
lnum = 27,
|
||||
name = "td",
|
||||
|
@ -249,7 +249,7 @@ describe("treesitter html", function()
|
|||
col = 10,
|
||||
end_col = 44,
|
||||
end_lnum = 27,
|
||||
kind = "Snippet",
|
||||
kind = "Struct",
|
||||
level = 5,
|
||||
lnum = 27,
|
||||
name = "tr",
|
||||
|
@ -260,7 +260,7 @@ describe("treesitter html", function()
|
|||
col = 14,
|
||||
end_col = 30,
|
||||
end_lnum = 28,
|
||||
kind = "Snippet",
|
||||
kind = "Struct",
|
||||
level = 6,
|
||||
lnum = 28,
|
||||
name = "td",
|
||||
|
@ -269,7 +269,7 @@ describe("treesitter html", function()
|
|||
col = 30,
|
||||
end_col = 40,
|
||||
end_lnum = 28,
|
||||
kind = "Snippet",
|
||||
kind = "Struct",
|
||||
level = 6,
|
||||
lnum = 28,
|
||||
name = "td",
|
||||
|
@ -278,7 +278,7 @@ describe("treesitter html", function()
|
|||
col = 10,
|
||||
end_col = 45,
|
||||
end_lnum = 28,
|
||||
kind = "Snippet",
|
||||
kind = "Struct",
|
||||
level = 5,
|
||||
lnum = 28,
|
||||
name = "tr",
|
||||
|
@ -287,7 +287,7 @@ describe("treesitter html", function()
|
|||
col = 8,
|
||||
end_col = 16,
|
||||
end_lnum = 29,
|
||||
kind = "Snippet",
|
||||
kind = "Struct",
|
||||
level = 4,
|
||||
lnum = 26,
|
||||
name = "tbody",
|
||||
|
@ -296,7 +296,7 @@ describe("treesitter html", function()
|
|||
col = 6,
|
||||
end_col = 14,
|
||||
end_lnum = 30,
|
||||
kind = "Snippet",
|
||||
kind = "Struct",
|
||||
level = 3,
|
||||
lnum = 22,
|
||||
name = "table",
|
||||
|
@ -305,7 +305,7 @@ describe("treesitter html", function()
|
|||
col = 4,
|
||||
end_col = 10,
|
||||
end_lnum = 31,
|
||||
kind = "Snippet",
|
||||
kind = "Struct",
|
||||
level = 2,
|
||||
lnum = 16,
|
||||
name = "div",
|
||||
|
@ -314,7 +314,7 @@ describe("treesitter html", function()
|
|||
col = 4,
|
||||
end_col = 13,
|
||||
end_lnum = 35,
|
||||
kind = "Snippet",
|
||||
kind = "Struct",
|
||||
level = 2,
|
||||
lnum = 33,
|
||||
name = "script",
|
||||
|
@ -323,7 +323,7 @@ describe("treesitter html", function()
|
|||
col = 2,
|
||||
end_col = 9,
|
||||
end_lnum = 36,
|
||||
kind = "Snippet",
|
||||
kind = "Struct",
|
||||
level = 1,
|
||||
lnum = 15,
|
||||
name = "body",
|
||||
|
@ -332,7 +332,7 @@ describe("treesitter html", function()
|
|||
col = 0,
|
||||
end_col = 7,
|
||||
end_lnum = 37,
|
||||
kind = "Snippet",
|
||||
kind = "Struct",
|
||||
level = 0,
|
||||
lnum = 3,
|
||||
name = "html",
|
||||
|
|
|
@ -51,7 +51,7 @@ describe("treesitter ts", function()
|
|||
},
|
||||
},
|
||||
{
|
||||
kind = "Type",
|
||||
kind = "Variable",
|
||||
name = "Type1",
|
||||
level = 0,
|
||||
lnum = 11,
|
||||
|
|
|
@ -12,8 +12,8 @@ type Type1 = {};
|
|||
|
||||
const fn_3 = () => {};
|
||||
|
||||
const const_var = 'value';
|
||||
let let_var = 'value';
|
||||
const const_var = "value";
|
||||
let let_var = "value";
|
||||
|
||||
describe("UnitTest", () => {
|
||||
afterAll(() => {});
|
||||
|
|
|
@ -51,7 +51,7 @@ describe("treesitter tsx", function()
|
|||
},
|
||||
},
|
||||
{
|
||||
kind = "Type",
|
||||
kind = "Variable",
|
||||
name = "Type1",
|
||||
level = 0,
|
||||
lnum = 13,
|
||||
|
|
Loading…
Reference in a new issue