refactor(_utils): notify by vim.notify in _utils
This commit is contained in:
parent
096bc8e7ee
commit
2adbb49064
2 changed files with 6 additions and 4 deletions
|
|
@ -1,4 +1,5 @@
|
||||||
local nodes = require "gopher._utils.ts.nodes"
|
local nodes = require "gopher._utils.ts.nodes"
|
||||||
|
local u = require "gopher._utils"
|
||||||
local M = {
|
local M = {
|
||||||
querys = {
|
querys = {
|
||||||
struct_block = [[((type_declaration (type_spec name:(type_identifier) @struct.name type: (struct_type)))@struct.declaration)]],
|
struct_block = [[((type_declaration (type_spec name:(type_identifier) @struct.name type: (struct_type)))@struct.declaration)]],
|
||||||
|
|
@ -27,7 +28,7 @@ function M.get_struct_node_at_pos(row, col, bufnr)
|
||||||
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
|
||||||
print "struct not found"
|
u.notify("struct not found", "warn")
|
||||||
else
|
else
|
||||||
return ns[#ns]
|
return ns[#ns]
|
||||||
end
|
end
|
||||||
|
|
@ -42,7 +43,7 @@ function M.get_func_method_node_at_pos(row, col, bufnr)
|
||||||
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
|
||||||
print "func not found"
|
u.notify("function not found", "warn")
|
||||||
else
|
else
|
||||||
return ns[#ns]
|
return ns[#ns]
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
local ts_query = require "nvim-treesitter.query"
|
local ts_query = require "nvim-treesitter.query"
|
||||||
local parsers = require "nvim-treesitter.parsers"
|
local parsers = require "nvim-treesitter.parsers"
|
||||||
local locals = require "nvim-treesitter.locals"
|
local locals = require "nvim-treesitter.locals"
|
||||||
|
local u = require "gopher._utils"
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
local function intersects(row, col, sRow, sCol, eRow, eCol)
|
local function intersects(row, col, sRow, sCol, eRow, eCol)
|
||||||
|
|
@ -120,13 +121,13 @@ function M.nodes_at_cursor(query, default, bufnr, row, col)
|
||||||
|
|
||||||
local nodes = M.get_all_nodes(query, ft, default, bufnr, row, col)
|
local nodes = M.get_all_nodes(query, ft, default, bufnr, row, col)
|
||||||
if nodes == nil then
|
if nodes == nil then
|
||||||
print "Unable to find any nodes. place your cursor on a go symbol and try again"
|
u.notify("Unable to find any nodes. Place your cursor on a go symbol and try again", "debug")
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
nodes = M.sort_nodes(M.intersect_nodes(nodes, row, col))
|
nodes = M.sort_nodes(M.intersect_nodes(nodes, row, col))
|
||||||
if nodes == nil or #nodes == 0 then
|
if nodes == nil or #nodes == 0 then
|
||||||
print("Unable to find any nodes at pos. " .. tostring(row) .. ":" .. tostring(col))
|
u.notify("Unable to find any nodes at pos. " .. tostring(row) .. ":" .. tostring(col), "debug")
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue