refactor(struct_tags): use new ts_util
This commit is contained in:
parent
1277e7b74f
commit
99f13e699d
1 changed files with 5 additions and 15 deletions
|
|
@ -33,23 +33,11 @@ local struct_tags = {}
|
||||||
|
|
||||||
local function modify(...)
|
local function modify(...)
|
||||||
local fpath = vim.fn.expand "%" ---@diagnostic disable-line: missing-parameter
|
local fpath = vim.fn.expand "%" ---@diagnostic disable-line: missing-parameter
|
||||||
local ns = ts_utils.get_struct_node_at_pos(unpack(vim.api.nvim_win_get_cursor(0)))
|
local bufnr = vim.api.nvim_get_current_buf()
|
||||||
if ns == nil then
|
local struct = ts_utils.get_struct_node_at_pos(bufnr)
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
-- by struct name of line pos
|
|
||||||
local cmd_args = {}
|
|
||||||
if ns.name == nil then
|
|
||||||
local _, csrow, _, _ = unpack(vim.fn.getpos ".")
|
|
||||||
table.insert(cmd_args, "-line")
|
|
||||||
table.insert(cmd_args, csrow)
|
|
||||||
else
|
|
||||||
table.insert(cmd_args, "-struct")
|
|
||||||
table.insert(cmd_args, ns.name)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- set user args for cmd
|
-- set user args for cmd
|
||||||
|
local cmd_args = {}
|
||||||
local arg = { ... }
|
local arg = { ... }
|
||||||
for _, v in ipairs(arg) do
|
for _, v in ipairs(arg) do
|
||||||
table.insert(cmd_args, v)
|
table.insert(cmd_args, v)
|
||||||
|
|
@ -61,6 +49,8 @@ local function modify(...)
|
||||||
c.gotag.transform,
|
c.gotag.transform,
|
||||||
"-format",
|
"-format",
|
||||||
"json",
|
"json",
|
||||||
|
"-struct",
|
||||||
|
struct.name,
|
||||||
"-w",
|
"-w",
|
||||||
"-file",
|
"-file",
|
||||||
fpath,
|
fpath,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue