10 files changed,
43 insertions(+),
34 deletions(-)
Author:
Smirnov Oleksandr
ss2316544@gmail.com
Committed by:
GitHub
noreply@github.com
Committed at:
2022-12-19 11:47:43 +0200
Parent:
e8fe6c5
M
lua/gopher/_utils/commands.lua
@@ -1,11 +1,11 @@
-local Job = require "plenary.job" -local c = require("gopher.config").config.commands -local u = require "gopher._utils" - ---Run any go commands like `go generate`, `go get`, `go mod` ---@param cmd string ---@param ... string|string[] return function(cmd, ...) + local Job = require "plenary.job" + local c = require("gopher.config").config.commands + local u = require "gopher._utils" + local args = { ... } if #args == 0 then u.notify("please provice any arguments", "error")
M
lua/gopher/_utils/ts/nodes.lua
@@ -1,7 +1,3 @@
-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)@@ -57,6 +53,10 @@ ---@param bufnr integer
---@param pos_row string ---@return string function M.get_all_nodes(query, lang, _, bufnr, pos_row, _) + local ts_query = require "nvim-treesitter.query" + local parsers = require "nvim-treesitter.parsers" + local locals = require "nvim-treesitter.locals" + bufnr = bufnr or 0 pos_row = pos_row or 30000@@ -113,6 +113,8 @@ ---@param row string
---@param col string ---@return table function M.nodes_at_cursor(query, default, bufnr, row, col) + local u = require "gopher._utils" + bufnr = bufnr or vim.api.nvim_get_current_buf() local ft = vim.api.nvim_buf_get_option(bufnr, "ft") if row == nil or col == nil then
M
lua/gopher/comment.lua
@@ -1,6 +1,5 @@
-local ts_utils = require "gopher._utils.ts" - local function generate(row, col) + local ts_utils = require "gopher._utils.ts" local comment, ns = nil, nil ns = ts_utils.get_package_node_at_pos(row, col, nil, false)
M
lua/gopher/dap/init.lua
@@ -1,9 +1,10 @@
-local cfg = require "gopher.dap.config" -local u = require "gopher._utils" local M = {} ---setup nvim-dap for golang using function M.setup() + local cfg = require "gopher.dap.config" + local u = require "gopher._utils" + local dap = u.sreq "dap" dap.adapters.go = cfg.adapter dap.configurations.go = cfg.configuration
M
lua/gopher/gotests.lua
@@ -1,11 +1,11 @@
-local Job = require "plenary.job" -local ts_utils = require "gopher._utils.ts" -local c = require("gopher.config").config.commands local u = require "gopher._utils" local M = {} ---@param cmd_args table local function run(cmd_args) + local Job = require "plenary.job" + local c = require("gopher.config").config.commands + Job:new({ command = c.gotests, args = cmd_args,@@ -31,6 +31,8 @@
---generate unit test for one function ---@param parallel boolean function M.func_test(parallel) + local ts_utils = require "gopher._utils.ts" + local ns = ts_utils.get_func_method_node_at_pos(unpack(vim.api.nvim_win_get_cursor(0))) if ns == nil or ns.name == nil then u.notify("cursor on func/method and execute the command again", "info")
M
lua/gopher/health.lua
@@ -1,13 +1,11 @@
-local health = vim.health or require "health" -local utils = require "gopher._utils._health" local c = require("gopher.config").config.commands -local requried = "Gopher.nvim will not work without it!" +local requried_for_work_msg = "Gopher.nvim will not work without it!" local M = { _required = { plugins = { - { lib = "plenary", help = requried }, - { lib = "nvim-treesitter", help = requried }, + { lib = "plenary", help = requried_for_work_msg }, + { lib = "nvim-treesitter", help = requried_for_work_msg }, { lib = "dap", help = "Required for set upping debugger" }, }, binarys = {@@ -21,9 +19,12 @@ },
} function M.check() + local health = vim.health or require "health" + local u = require "gopher._utils._health" + health.report_start "Required plugins" for _, plugin in ipairs(M._required.plugins) do - if utils.lualib_is_found(plugin.lib) then + if u.lualib_is_found(plugin.lib) then health.report_ok(plugin.lib .. " installed.") else health.report_error(plugin.lib .. " not found. " .. plugin.help)@@ -32,7 +33,7 @@ end
health.report_start "Required go tools" for _, binary in ipairs(M._required.binarys) do - if utils.binary_is_found(binary.bin) then + if u.binary_is_found(binary.bin) then health.report_ok(binary.bin .. " installed") else health.report_warn(binary.bin .. " is not installed but " .. binary.help)
M
lua/gopher/iferr.lua
@@ -1,10 +1,10 @@
-local c = require("gopher.config").config.commands -local u = require "gopher._utils" - ---Add iferr declaration ---That's Lua of vimscript implementation of: ---github.com/koron/iferr return function() + local c = require("gopher.config").config.commands + local u = require "gopher._utils" + local boff = vim.fn.wordcount().cursor_bytes local cmd = (c.iferr .. " -pos " .. boff) local data = vim.fn.systemlist(cmd, vim.fn.bufnr "%")
M
lua/gopher/impl.lua
@@ -1,10 +1,9 @@
-local Job = require "plenary.job" -local ts_utils = require "gopher._utils.ts" -local c = require("gopher.config").config.commands local u = require "gopher._utils" ---@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")@@ -20,6 +19,9 @@ return ns.name
end return function(...) + local c = require("gopher.config").config.commands + local Job = require "plenary.job" + local args = { ... } local iface, recv_name = "", "" local recv = get_struct()
M
lua/gopher/installer.lua
@@ -1,5 +1,3 @@
-local Job = require "plenary.job" -local u = require "gopher._utils" local urls = { gomodifytags = "github.com/fatih/gomodifytags", impl = "github.com/josharian/impl",@@ -10,6 +8,9 @@ }
---@param pkg string local function install(pkg) + local Job = require "plenary.job" + local u = require "gopher._utils" + local url = urls[pkg] .. "@latest" Job:new({