refactor(ts): notify by default

This commit is contained in:
Smirnov Oleksandr 2024-12-28 17:29:46 +02:00
parent 487013d007
commit 3dbf833a41
No known key found for this signature in database

View file

@ -43,80 +43,64 @@ end
---@param row string
---@param col string
---@param bufnr string|nil
---@param do_notify boolean|nil
---@return table|nil
function ts.get_struct_node_at_pos(row, col, bufnr, do_notify)
local notify = do_notify or true
function ts.get_struct_node_at_pos(row, col, bufnr)
local query = ts.queries.struct_block .. " " .. ts.queries.em_struct_block
local bufn = bufnr or vim.api.nvim_get_current_buf()
local ns = nodes.nodes_at_cursor(query, get_name_defaults(), bufn, row, col)
if ns == nil then
if notify then
u.deferred_notify("struct not found", vim.log.levels.WARN)
end
else
return ns[#ns]
u.deferred_notify("struct not found", vim.log.levels.WARN)
return
end
return ns[#ns]
end
---@param row string
---@param col string
---@param bufnr string|nil
---@param do_notify boolean|nil
---@return table|nil
function ts.get_func_method_node_at_pos(row, col, bufnr, do_notify)
local notify = do_notify or true
function ts.get_func_method_node_at_pos(row, col, bufnr)
local query = ts.queries.func .. " " .. ts.queries.method_name
local bufn = bufnr or vim.api.nvim_get_current_buf()
local ns = nodes.nodes_at_cursor(query, get_name_defaults(), bufn, row, col)
if ns == nil then
if notify then
u.deferred_notify("function not found", vim.log.levels.WARN)
end
else
return ns[#ns]
u.deferred_notify("function not found", vim.log.levels.WARN)
return
end
return ns[#ns]
end
---@param row string
---@param col string
---@param bufnr string|nil
---@param do_notify boolean|nil
---@return table|nil
function ts.get_package_node_at_pos(row, col, bufnr, do_notify)
local notify = do_notify or true
-- stylua: ignore
if row > 10 then return end
function ts.get_package_node_at_pos(row, col, bufnr)
if row > 10 then
return
end
local query = ts.queries.package
local bufn = bufnr or vim.api.nvim_get_current_buf()
local ns = nodes.nodes_at_cursor(query, get_name_defaults(), bufn, row, col)
if ns == nil then
if notify then
u.deferred_notify("package not found", vim.log.levels.WARN)
return nil
end
else
return ns[#ns]
u.deferred_notify("package not found", vim.log.levels.WARN)
return nil
end
return ns[#ns]
end
---@param row string
---@param col string
---@param bufnr string|nil
---@param do_notify boolean|nil
---@return table|nil
function ts.get_interface_node_at_pos(row, col, bufnr, do_notify)
local notify = do_notify or true
function ts.get_interface_node_at_pos(row, col, bufnr)
local query = ts.queries.interface
local bufn = bufnr or vim.api.nvim_get_current_buf()
local ns = nodes.nodes_at_cursor(query, get_name_defaults(), bufn, row, col)
if ns == nil then
if notify then
u.deferred_notify("interface not found", vim.log.levels.WARN)
end
else
return ns[#ns]
u.deferred_notify("interface not found", vim.log.levels.WARN)
return
end
return ns[#ns]
end
return ts