refactor of public plugin's api (#37)
* refactor: move all plugin functionality to init.lua * fix(commands): now it uses correct module paths * refactor(config): change way how it handles options * refactor(gotests): use correct config, change way how deps required, fix some typos * fix(healthchecker): use correct config * refactor(iferr): change api * refactor(impl): change api * refactor(installer): change api * refactor(struct_tags): change way of importting deps * refactor(struct_tags): rename M to struct_tags * run stylua * refactor(dap): make it all in one file, and make some refactoring * refactor(_utils): change way how it organizes * fix: use new _utils api * refactor(_utils.health): reorganize module * refactor(_utils.ts): some renameing, moving requires lines * run stylua
This commit is contained in:
parent
94250bb08a
commit
26b41bf68c
18 changed files with 359 additions and 341 deletions
|
|
@ -1,12 +1,14 @@
|
|||
local c = require("gopher.config").commands
|
||||
local Job = require "plenary.job"
|
||||
local ts_utils = require "gopher._utils.ts"
|
||||
local u = require "gopher._utils"
|
||||
local impl = {}
|
||||
|
||||
---@return string
|
||||
local function get_struct()
|
||||
local ts_utils = require "gopher._utils.ts"
|
||||
|
||||
local ns = ts_utils.get_struct_node_at_pos(unpack(vim.api.nvim_win_get_cursor(0)))
|
||||
if ns == nil then
|
||||
u.notify("put cursor on a struct or specify a receiver", "info")
|
||||
u.deferred_notify("put cursor on a struct or specify a receiver", vim.log.levels.INFO)
|
||||
return ""
|
||||
end
|
||||
|
||||
|
|
@ -18,10 +20,7 @@ local function get_struct()
|
|||
return ns.name
|
||||
end
|
||||
|
||||
return function(...)
|
||||
local c = require("gopher.config").config.commands
|
||||
local Job = require "plenary.job"
|
||||
|
||||
function impl.impl(...)
|
||||
local args = { ... }
|
||||
local iface, recv_name = "", ""
|
||||
local recv = get_struct()
|
||||
|
|
@ -30,7 +29,7 @@ return function(...)
|
|||
iface = vim.fn.input "impl: generating method stubs for interface: "
|
||||
vim.cmd "redraw!"
|
||||
if iface == "" then
|
||||
u.notify("usage: GoImpl f *File io.Reader", "info")
|
||||
u.deferred_notify("usage: GoImpl f *File io.Reader", vim.log.levels.INFO)
|
||||
return
|
||||
end
|
||||
elseif #args == 1 then -- :GoImpl io.Reader
|
||||
|
|
@ -61,7 +60,10 @@ return function(...)
|
|||
args = cmd_args,
|
||||
on_exit = function(data, retval)
|
||||
if retval ~= 0 then
|
||||
u.notify("command 'impl " .. unpack(cmd_args) .. "' exited with code " .. retval, "error")
|
||||
u.deferred_notify(
|
||||
"command '" .. c.impl .. " " .. unpack(cmd_args) .. "' exited with code " .. retval,
|
||||
vim.log.levels.ERROR
|
||||
)
|
||||
return
|
||||
end
|
||||
|
||||
|
|
@ -73,3 +75,5 @@ return function(...)
|
|||
table.insert(res_data, 1, "")
|
||||
vim.fn.append(pos, res_data)
|
||||
end
|
||||
|
||||
return impl
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue