chore: stylua formatting
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
local config = {_data = {}}
|
local config = { _data = {} }
|
||||||
|
|
||||||
config.get = function()
|
config.get = function()
|
||||||
return config._data
|
return config._data
|
||||||
@@ -14,7 +14,7 @@ config.setup = function(default, user)
|
|||||||
end
|
end
|
||||||
rawset(langs, ft, ft_config)
|
rawset(langs, ft, ft_config)
|
||||||
return ft_config
|
return ft_config
|
||||||
end
|
end,
|
||||||
})
|
})
|
||||||
config._data = data
|
config._data = data
|
||||||
return data
|
return data
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ end
|
|||||||
return {
|
return {
|
||||||
-- Search for these nodes
|
-- Search for these nodes
|
||||||
parent = {
|
parent = {
|
||||||
func = { "function_declaration", "assignment_statement", "variable_declaration", "field"},
|
func = { "function_declaration", "assignment_statement", "variable_declaration", "field" },
|
||||||
class = { "local_variable_declaration", "variable_declaration" },
|
class = { "local_variable_declaration", "variable_declaration" },
|
||||||
type = { "local_variable_declaration", "variable_declaration" },
|
type = { "local_variable_declaration", "variable_declaration" },
|
||||||
file = { "chunk" },
|
file = { "chunk" },
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ local function get_parent_node(filetype, typ, language)
|
|||||||
|
|
||||||
language.locator = language.locator or default_locator
|
language.locator = language.locator or default_locator
|
||||||
-- Use the language locator to locate one of the required parent nodes above the cursor
|
-- Use the language locator to locate one of the required parent nodes above the cursor
|
||||||
return language.locator({root = tree, current = ts_utils.get_node_at_cursor(0)}, language.parent[typ])
|
return language.locator({ root = tree, current = ts_utils.get_node_at_cursor(0) }, language.parent[typ])
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Generates the prefix according to `template` options.
|
--- Generates the prefix according to `template` options.
|
||||||
@@ -201,7 +201,7 @@ return setmetatable({}, {
|
|||||||
table.insert(sects, line:sub(last_col + 1, s - 1))
|
table.insert(sects, line:sub(last_col + 1, s - 1))
|
||||||
if input_after_comment then
|
if input_after_comment then
|
||||||
len = len + s - last_col - 1
|
len = len + s - last_col - 1
|
||||||
table.insert(marks_pos, {row + r - 1, len - 1})
|
table.insert(marks_pos, { row + r - 1, len - 1 })
|
||||||
end
|
end
|
||||||
last_col = e
|
last_col = e
|
||||||
end
|
end
|
||||||
@@ -220,8 +220,7 @@ return setmetatable({}, {
|
|||||||
vim.cmd("startinsert")
|
vim.cmd("startinsert")
|
||||||
mark:jump()
|
mark:jump()
|
||||||
-- Add range mark after first jump
|
-- Add range mark after first jump
|
||||||
mark:add_range_mark({row, 0, row + #template_content, 1})
|
mark:add_range_mark({ row, 0, row + #template_content, 1 })
|
||||||
end
|
end
|
||||||
end
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -63,15 +63,14 @@ mark.mark_len = function(self)
|
|||||||
end
|
end
|
||||||
|
|
||||||
mark.get_range_mark = function(self)
|
mark.get_range_mark = function(self)
|
||||||
local d = api.nvim_buf_get_extmark_by_id(self.bufnr, ns, self.range_id, {details = true})
|
local d = api.nvim_buf_get_extmark_by_id(self.bufnr, ns, self.range_id, { details = true })
|
||||||
local row, col, end_row, end_col = d[1], d[2], d[3].end_row, d[3].end_col
|
local row, col, end_row, end_col = d[1], d[2], d[3].end_row, d[3].end_col
|
||||||
return row, col, end_row, end_col
|
return row, col, end_row, end_col
|
||||||
end
|
end
|
||||||
|
|
||||||
mark.add_range_mark = function(self, range)
|
mark.add_range_mark = function(self, range)
|
||||||
local row, col, end_row, end_col = unpack(range)
|
local row, col, end_row, end_col = unpack(range)
|
||||||
self.range_id = api.nvim_buf_set_extmark(self.bufnr, ns, row, col,
|
self.range_id = api.nvim_buf_set_extmark(self.bufnr, ns, row, col, { end_row = end_row, end_col = end_col })
|
||||||
{end_row = end_row, end_col = end_col})
|
|
||||||
end
|
end
|
||||||
|
|
||||||
mark.cursor_in_range = function(self, validated)
|
mark.cursor_in_range = function(self, validated)
|
||||||
@@ -80,7 +79,7 @@ mark.cursor_in_range = function(self, validated)
|
|||||||
local pos = api.nvim_win_get_cursor(self.winid)
|
local pos = api.nvim_win_get_cursor(self.winid)
|
||||||
pos[1] = pos[1] - 1
|
pos[1] = pos[1] - 1
|
||||||
local row, col, end_row, end_col = self:get_range_mark()
|
local row, col, end_row, end_col = self:get_range_mark()
|
||||||
ret = compare_pos({row, col}, pos) <= 0 and compare_pos({end_row, end_col}, pos) >= 0
|
ret = compare_pos({ row, col }, pos) <= 0 and compare_pos({ end_row, end_col }, pos) >= 0
|
||||||
end
|
end
|
||||||
return ret
|
return ret
|
||||||
end
|
end
|
||||||
@@ -124,7 +123,7 @@ mark.jump = function(self, reverse)
|
|||||||
end
|
end
|
||||||
if mark:jumpable(reverse) then
|
if mark:jumpable(reverse) then
|
||||||
local line, row = unpack(self:get_mark(self.index))
|
local line, row = unpack(self:get_mark(self.index))
|
||||||
api.nvim_win_set_cursor(self.winid, {line + 1, row})
|
api.nvim_win_set_cursor(self.winid, { line + 1, row })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -133,7 +132,7 @@ mark.jump_last_cursor = function(self, validated)
|
|||||||
local winid = self.winid
|
local winid = self.winid
|
||||||
local pos = api.nvim_buf_get_extmark_by_id(self.bufnr, ns, self.last_cursor_id, {})
|
local pos = api.nvim_buf_get_extmark_by_id(self.bufnr, ns, self.last_cursor_id, {})
|
||||||
local line, col = unpack(pos)
|
local line, col = unpack(pos)
|
||||||
api.nvim_win_set_cursor(winid, {line + 1, col})
|
api.nvim_win_set_cursor(winid, { line + 1, col })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
local config = require("neogen.config")
|
local config = require("neogen.config")
|
||||||
return {
|
return {
|
||||||
notify = function(msg, log_level)
|
notify = function(msg, log_level)
|
||||||
vim.notify(msg, log_level, {title = "Neogen"})
|
vim.notify(msg, log_level, { title = "Neogen" })
|
||||||
end,
|
end,
|
||||||
|
|
||||||
--- Generates a list of possible types in the current language
|
--- Generates a list of possible types in the current language
|
||||||
@@ -20,7 +20,6 @@ return {
|
|||||||
return vim.tbl_keys(language.parent)
|
return vim.tbl_keys(language.parent)
|
||||||
end,
|
end,
|
||||||
split = function(s, sep, plain)
|
split = function(s, sep, plain)
|
||||||
return vim.fn.has("nvim-0.6") == 1 and vim.split(s, sep, {plain = plain}) or
|
return vim.fn.has("nvim-0.6") == 1 and vim.split(s, sep, { plain = plain }) or vim.split(s, sep, plain)
|
||||||
vim.split(s, sep, plain)
|
end,
|
||||||
end
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ return {
|
|||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
|
||||||
self:recursive_find(child, node_name, {results = results})
|
self:recursive_find(child, node_name, { results = results })
|
||||||
end
|
end
|
||||||
|
|
||||||
return results
|
return results
|
||||||
@@ -63,22 +63,23 @@ return {
|
|||||||
result = result or {}
|
result = result or {}
|
||||||
|
|
||||||
for _, subtree in pairs(tree) do
|
for _, subtree in pairs(tree) do
|
||||||
assert(not subtree.retrieve or vim.tbl_contains({"all", "first"}, subtree.retrieve),
|
assert(
|
||||||
"Supported nodes matching: all|first")
|
not subtree.retrieve or vim.tbl_contains({ "all", "first" }, subtree.retrieve),
|
||||||
|
"Supported nodes matching: all|first"
|
||||||
|
)
|
||||||
|
|
||||||
-- Match all child nodes of the parent node
|
-- Match all child nodes of the parent node
|
||||||
local matched = self:matching_child_nodes(parent, subtree.node_type)
|
local matched = self:matching_child_nodes(parent, subtree.node_type)
|
||||||
|
|
||||||
-- Only keep the node with custom position
|
-- Only keep the node with custom position
|
||||||
if not subtree.retrieve then
|
if not subtree.retrieve then
|
||||||
assert(type(subtree.position) == "number",
|
assert(type(subtree.position) == "number", "please require position if retrieve is nil")
|
||||||
"please require position if retrieve is nil")
|
matched = { matched[subtree.position] }
|
||||||
matched = {matched[subtree.position]}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if subtree.recursive then
|
if subtree.recursive then
|
||||||
local first = subtree.retrieve == "first"
|
local first = subtree.retrieve == "first"
|
||||||
matched = self:recursive_find(parent, subtree.node_type, {first = first})
|
matched = self:recursive_find(parent, subtree.node_type, { first = first })
|
||||||
end
|
end
|
||||||
|
|
||||||
for _, child in pairs(matched) do
|
for _, child in pairs(matched) do
|
||||||
@@ -94,5 +95,5 @@ return {
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
return result
|
return result
|
||||||
end
|
end,
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user