refactor(ts): notify by default
This commit is contained in:
parent
487013d007
commit
3dbf833a41
1 changed files with 19 additions and 35 deletions
|
|
@ -43,80 +43,64 @@ end
|
||||||
---@param row string
|
---@param row string
|
||||||
---@param col string
|
---@param col string
|
||||||
---@param bufnr string|nil
|
---@param bufnr string|nil
|
||||||
---@param do_notify boolean|nil
|
|
||||||
---@return table|nil
|
---@return table|nil
|
||||||
function ts.get_struct_node_at_pos(row, col, bufnr, do_notify)
|
function ts.get_struct_node_at_pos(row, col, bufnr)
|
||||||
local notify = do_notify or true
|
|
||||||
local query = ts.queries.struct_block .. " " .. ts.queries.em_struct_block
|
local query = ts.queries.struct_block .. " " .. ts.queries.em_struct_block
|
||||||
local bufn = bufnr or vim.api.nvim_get_current_buf()
|
local bufn = bufnr or vim.api.nvim_get_current_buf()
|
||||||
local ns = nodes.nodes_at_cursor(query, get_name_defaults(), bufn, row, col)
|
local ns = nodes.nodes_at_cursor(query, get_name_defaults(), bufn, row, col)
|
||||||
if ns == nil then
|
if ns == nil then
|
||||||
if notify then
|
|
||||||
u.deferred_notify("struct not found", vim.log.levels.WARN)
|
u.deferred_notify("struct not found", vim.log.levels.WARN)
|
||||||
|
return
|
||||||
end
|
end
|
||||||
else
|
|
||||||
return ns[#ns]
|
return ns[#ns]
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param row string
|
---@param row string
|
||||||
---@param col string
|
---@param col string
|
||||||
---@param bufnr string|nil
|
---@param bufnr string|nil
|
||||||
---@param do_notify boolean|nil
|
|
||||||
---@return table|nil
|
---@return table|nil
|
||||||
function ts.get_func_method_node_at_pos(row, col, bufnr, do_notify)
|
function ts.get_func_method_node_at_pos(row, col, bufnr)
|
||||||
local notify = do_notify or true
|
|
||||||
local query = ts.queries.func .. " " .. ts.queries.method_name
|
local query = ts.queries.func .. " " .. ts.queries.method_name
|
||||||
local bufn = bufnr or vim.api.nvim_get_current_buf()
|
local bufn = bufnr or vim.api.nvim_get_current_buf()
|
||||||
local ns = nodes.nodes_at_cursor(query, get_name_defaults(), bufn, row, col)
|
local ns = nodes.nodes_at_cursor(query, get_name_defaults(), bufn, row, col)
|
||||||
if ns == nil then
|
if ns == nil then
|
||||||
if notify then
|
|
||||||
u.deferred_notify("function not found", vim.log.levels.WARN)
|
u.deferred_notify("function not found", vim.log.levels.WARN)
|
||||||
|
return
|
||||||
end
|
end
|
||||||
else
|
|
||||||
return ns[#ns]
|
return ns[#ns]
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param row string
|
---@param row string
|
||||||
---@param col string
|
---@param col string
|
||||||
---@param bufnr string|nil
|
---@param bufnr string|nil
|
||||||
---@param do_notify boolean|nil
|
|
||||||
---@return table|nil
|
---@return table|nil
|
||||||
function ts.get_package_node_at_pos(row, col, bufnr, do_notify)
|
function ts.get_package_node_at_pos(row, col, bufnr)
|
||||||
local notify = do_notify or true
|
if row > 10 then
|
||||||
-- stylua: ignore
|
return
|
||||||
if row > 10 then return end
|
end
|
||||||
local query = ts.queries.package
|
local query = ts.queries.package
|
||||||
local bufn = bufnr or vim.api.nvim_get_current_buf()
|
local bufn = bufnr or vim.api.nvim_get_current_buf()
|
||||||
local ns = nodes.nodes_at_cursor(query, get_name_defaults(), bufn, row, col)
|
local ns = nodes.nodes_at_cursor(query, get_name_defaults(), bufn, row, col)
|
||||||
if ns == nil then
|
if ns == nil then
|
||||||
if notify then
|
|
||||||
u.deferred_notify("package not found", vim.log.levels.WARN)
|
u.deferred_notify("package not found", vim.log.levels.WARN)
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
else
|
|
||||||
return ns[#ns]
|
return ns[#ns]
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param row string
|
---@param row string
|
||||||
---@param col string
|
---@param col string
|
||||||
---@param bufnr string|nil
|
---@param bufnr string|nil
|
||||||
---@param do_notify boolean|nil
|
|
||||||
---@return table|nil
|
---@return table|nil
|
||||||
function ts.get_interface_node_at_pos(row, col, bufnr, do_notify)
|
function ts.get_interface_node_at_pos(row, col, bufnr)
|
||||||
local notify = do_notify or true
|
|
||||||
local query = ts.queries.interface
|
local query = ts.queries.interface
|
||||||
local bufn = bufnr or vim.api.nvim_get_current_buf()
|
local bufn = bufnr or vim.api.nvim_get_current_buf()
|
||||||
local ns = nodes.nodes_at_cursor(query, get_name_defaults(), bufn, row, col)
|
local ns = nodes.nodes_at_cursor(query, get_name_defaults(), bufn, row, col)
|
||||||
if ns == nil then
|
if ns == nil then
|
||||||
if notify then
|
|
||||||
u.deferred_notify("interface not found", vim.log.levels.WARN)
|
u.deferred_notify("interface not found", vim.log.levels.WARN)
|
||||||
|
return
|
||||||
end
|
end
|
||||||
else
|
|
||||||
return ns[#ns]
|
return ns[#ns]
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return ts
|
return ts
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue