mirror of
https://github.com/stevearc/aerial.nvim
synced 2024-09-16 14:34:08 +02:00
fix: add treesitter support for JS / TS / TSX generator functions (#289)
* fix: add JS as TS generator functions * feat: add TSX generator functions
This commit is contained in:
parent
f34defe8f5
commit
9bcfbaf7a7
10 changed files with 82 additions and 1 deletions
|
@ -309,6 +309,9 @@ M.typescript = {
|
|||
postprocess = function(bufnr, item, match)
|
||||
local value_node = (utils.get_at_path(match, "var_type") or {}).node
|
||||
if value_node then
|
||||
if value_node:type() == "generator_function" then
|
||||
item.kind = "Function"
|
||||
end
|
||||
if value_node:type() == "arrow_function" then
|
||||
item.kind = "Function"
|
||||
end
|
||||
|
|
|
@ -8,6 +8,11 @@
|
|||
(#set! "kind" "Function")
|
||||
) @type
|
||||
|
||||
(generator_function_declaration
|
||||
name: (identifier) @name
|
||||
(#set! "kind" "Function")
|
||||
) @type
|
||||
|
||||
(method_definition
|
||||
name: (property_identifier) @name
|
||||
(#set! "kind" "Method")
|
||||
|
@ -23,7 +28,7 @@
|
|||
(lexical_declaration
|
||||
(variable_declarator
|
||||
name: (identifier) @name
|
||||
value: [(arrow_function) (function)] @type
|
||||
value: [(arrow_function) (function) (generator_function)] @type
|
||||
)
|
||||
(#set! "kind" "Function")
|
||||
) @start
|
||||
|
|
|
@ -8,6 +8,11 @@
|
|||
(#set! "kind" "Function")
|
||||
) @type
|
||||
|
||||
(generator_function_declaration
|
||||
name: (identifier) @name
|
||||
(#set! "kind" "Function")
|
||||
) @type
|
||||
|
||||
(interface_declaration
|
||||
name: (type_identifier) @name
|
||||
(#set! "kind" "Interface")
|
||||
|
|
|
@ -8,6 +8,11 @@
|
|||
(#set! "kind" "Function")
|
||||
) @type
|
||||
|
||||
(generator_function_declaration
|
||||
name: (identifier) @name
|
||||
(#set! "kind" "Function")
|
||||
) @type
|
||||
|
||||
(interface_declaration
|
||||
name: (type_identifier) @name
|
||||
(#set! "kind" "Interface")
|
||||
|
|
|
@ -162,6 +162,24 @@ describe("treesitter js", function()
|
|||
end_lnum = 23,
|
||||
end_col = 28,
|
||||
},
|
||||
{
|
||||
kind = "Function",
|
||||
name = "g",
|
||||
level = 0,
|
||||
lnum = 25,
|
||||
col = 0,
|
||||
end_lnum = 25,
|
||||
end_col = 16,
|
||||
},
|
||||
{
|
||||
kind = "Function",
|
||||
name = "g_1",
|
||||
level = 0,
|
||||
lnum = 26,
|
||||
col = 0,
|
||||
end_lnum = 26,
|
||||
end_col = 28,
|
||||
},
|
||||
})
|
||||
end)
|
||||
end)
|
||||
|
|
|
@ -21,3 +21,6 @@ describe("UnitTest", () => {
|
|||
|
||||
const fn_2 = () => {};
|
||||
const fn_3 = function () {};
|
||||
|
||||
function* g() {}
|
||||
const g_1 = function* () {};
|
||||
|
|
|
@ -198,6 +198,24 @@ describe("treesitter ts", function()
|
|||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
kind = "Function",
|
||||
name = "g",
|
||||
level = 0,
|
||||
lnum = 33,
|
||||
col = 0,
|
||||
end_lnum = 33,
|
||||
end_col = 16,
|
||||
},
|
||||
{
|
||||
kind = "Function",
|
||||
name = "g_1",
|
||||
level = 0,
|
||||
lnum = 34,
|
||||
col = 0,
|
||||
end_lnum = 34,
|
||||
end_col = 28,
|
||||
},
|
||||
})
|
||||
end)
|
||||
end)
|
||||
|
|
|
@ -29,3 +29,6 @@ describe("UnitTest", () => {
|
|||
test.each([])("runs multiple times", () => {});
|
||||
});
|
||||
});
|
||||
|
||||
function* g() {}
|
||||
const g_1 = function* () {};
|
||||
|
|
|
@ -198,6 +198,24 @@ describe("treesitter tsx", function()
|
|||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
kind = "Function",
|
||||
name = "g",
|
||||
level = 0,
|
||||
lnum = 35,
|
||||
col = 0,
|
||||
end_lnum = 35,
|
||||
end_col = 16,
|
||||
},
|
||||
{
|
||||
kind = "Function",
|
||||
name = "g_1",
|
||||
level = 0,
|
||||
lnum = 36,
|
||||
col = 0,
|
||||
end_lnum = 36,
|
||||
end_col = 28,
|
||||
},
|
||||
})
|
||||
end)
|
||||
end)
|
||||
|
|
|
@ -31,3 +31,6 @@ describe("UnitTest", () => {
|
|||
test.each([])("runs multiple times", () => {});
|
||||
});
|
||||
});
|
||||
|
||||
function* g() {}
|
||||
const g_1 = function* () {};
|
||||
|
|
Loading…
Reference in a new issue