@@ -1,4 +1,3 @@
|
|||||||
local ts_utils = require("nvim-treesitter.ts_utils")
|
|
||||||
local nodes_utils = require("neogen.utilities.nodes")
|
local nodes_utils = require("neogen.utilities.nodes")
|
||||||
local extractors = require("neogen.utilities.extractors")
|
local extractors = require("neogen.utilities.extractors")
|
||||||
local locator = require("neogen.locators.default")
|
local locator = require("neogen.locators.default")
|
||||||
@@ -110,7 +109,7 @@ return {
|
|||||||
-- Check if function is a static method. If so, will not remove the first parameter
|
-- Check if function is a static method. If so, will not remove the first parameter
|
||||||
if node:parent():type() == "decorated_definition" then
|
if node:parent():type() == "decorated_definition" then
|
||||||
local decorator = nodes_utils:matching_child_nodes(node:parent(), "decorator")
|
local decorator = nodes_utils:matching_child_nodes(node:parent(), "decorator")
|
||||||
decorator = ts_utils.get_node_text(decorator[1])[1]
|
decorator = vim.treesitter.query.get_node_text(decorator[1], 0)
|
||||||
if decorator == "@staticmethod" then
|
if decorator == "@staticmethod" then
|
||||||
remove_identifier = false
|
remove_identifier = false
|
||||||
end
|
end
|
||||||
@@ -185,7 +184,7 @@ return {
|
|||||||
for _, assignment in pairs(nodes["assignment"]) do
|
for _, assignment in pairs(nodes["assignment"]) do
|
||||||
local left_side = assignment:field("left")[1]
|
local left_side = assignment:field("left")[1]
|
||||||
local left_attribute = left_side:field("attribute")[1]
|
local left_attribute = left_side:field("attribute")[1]
|
||||||
left_attribute = ts_utils.get_node_text(left_attribute)[1]
|
left_attribute = vim.treesitter.query.get_node_text(left_attribute, 0)
|
||||||
if left_attribute and not vim.startswith(left_attribute, "_") then
|
if left_attribute and not vim.startswith(left_attribute, "_") then
|
||||||
table.insert(results[i.ClassAttribute], left_attribute)
|
table.insert(results[i.ClassAttribute], left_attribute)
|
||||||
end
|
end
|
||||||
@@ -233,7 +232,7 @@ return {
|
|||||||
if child:type() == "comment" then
|
if child:type() == "comment" then
|
||||||
local start_row = child:start()
|
local start_row = child:start()
|
||||||
if start_row == 0 then
|
if start_row == 0 then
|
||||||
if vim.startswith(ts_utils.get_node_text(node, 0)[1], "#!") then
|
if vim.startswith(vim.treesitter.query.get_node_text(node, 0), "#!") then
|
||||||
return 1, 0
|
return 1, 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
local ts_utils = require("nvim-treesitter.ts_utils")
|
|
||||||
local helpers = require("neogen.utilities.helpers")
|
local helpers = require("neogen.utilities.helpers")
|
||||||
|
|
||||||
--- Tries to use the configuration to find all required content nodes from the parent node
|
--- Tries to use the configuration to find all required content nodes from the parent node
|
||||||
@@ -27,14 +26,13 @@ return function(parent_node, node_data)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if not data.match or child_node:type() == data.match then
|
if not data.match or child_node:type() == data.match then
|
||||||
if type(data.extract) == "function" then
|
if not type(data.extract) == "function" then
|
||||||
-- Extract content from it { [type] = { data } }
|
return
|
||||||
for type, extracted_data in pairs(data.extract(child_node)) do
|
end
|
||||||
result[type] = extracted_data
|
|
||||||
end
|
-- Extract content from it { [type] = { data } }
|
||||||
else
|
for type, extracted_data in pairs(data.extract(child_node)) do
|
||||||
-- if not extract function, get the text from the node (required: data.type)
|
result[type] = extracted_data
|
||||||
result[data.type] = ts_utils.get_node_text(child_node)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
local ts_utils = require("nvim-treesitter.ts_utils")
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
--- Extract the content from each node from data
|
--- Extract the content from each node from data
|
||||||
--- @param _ any self
|
--- @param _ any self
|
||||||
@@ -14,7 +12,7 @@ return {
|
|||||||
return node:type()
|
return node:type()
|
||||||
end
|
end
|
||||||
local get_text = function(node)
|
local get_text = function(node)
|
||||||
return ts_utils.get_node_text(node)[1]
|
return vim.treesitter.query.get_node_text(node, 0)
|
||||||
end
|
end
|
||||||
if opts.type then
|
if opts.type then
|
||||||
result[k] = vim.tbl_map(get_type, v)
|
result[k] = vim.tbl_map(get_type, v)
|
||||||
|
|||||||
Reference in New Issue
Block a user