refactor(_utils): notify by vim.notify in _utils

This commit is contained in:
Smirnov Oleksandr 2022-06-25 12:00:58 +03:00
parent 096bc8e7ee
commit 2adbb49064
2 changed files with 6 additions and 4 deletions

View file

@ -1,4 +1,5 @@
local nodes = require "gopher._utils.ts.nodes"
local u = require "gopher._utils"
local M = {
querys = {
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 ns = nodes.nodes_at_cursor(query, get_name_defaults(), bufn, row, col)
if ns == nil then
print "struct not found"
u.notify("struct not found", "warn")
else
return ns[#ns]
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 ns = nodes.nodes_at_cursor(query, get_name_defaults(), bufn, row, col)
if ns == nil then
print "func not found"
u.notify("function not found", "warn")
else
return ns[#ns]
end

View file

@ -1,6 +1,7 @@
local ts_query = require "nvim-treesitter.query"
local parsers = require "nvim-treesitter.parsers"
local locals = require "nvim-treesitter.locals"
local u = require "gopher._utils"
local M = {}
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)
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
end
nodes = M.sort_nodes(M.intersect_nodes(nodes, row, col))
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
end