feature: go-enum. issue #260, gopls setting move to function local var

pull/274/head
ray-x 1 year ago
parent b9c8ea1d7f
commit 1f52335ea3

@ -0,0 +1,36 @@
local runner = require("go.runner")
local utils = require("go.utils")
local vfn = vim.fn
local M = {}
function M.run(args)
args = args or {}
local row, col = unpack(vim.api.nvim_win_get_cursor(0))
row, col = row - 1, col
local line = vim.api.nvim_buf_get_lines(0, row, row + 1, true)[1]
line = line:gsub("^%s+", "") -- lstrip
line = line:gsub("%s+", " ") -- combine spaces
line = vim.split(line, " ")
utils.log(line)
local fn = vfn.expand('%:p:f')
local cmd = { "go-enum", '-f', fn }
local new_name = vfn.expand('%:p:r') .. "_enum.go"
vim.list_extend(cmd, args)
local workfolder = vim.lsp.buf.list_workspace_folders()[1] or vfn.getcwd()
local opts = {
update_buffer = true,
on_exit = function()
vim.schedule(function()
-- utils.restart()
vim.cmd('e ' .. new_name)
end)
end,
}
runner.run(cmd, opts)
return cmd, opts
end
return M

@ -191,7 +191,19 @@ local get_current_gomod = function()
return mod_name
end
local setups = {
local function get_build_flags()
local get_build_tags = require('go.gotest').get_build_tags
local tags = get_build_tags()
log(vim.inspect(tags))
if tags then
return tags
else
return nil
end
end
M.setups = function()
local setups = {
capabilities = {
textDocument = {
completion = {
@ -267,20 +279,7 @@ local setups = {
buildFlags = { '-tags', 'integration' },
},
},
}
local function get_build_flags()
local get_build_tags = require('go.gotest').get_build_tags
local tags = get_build_tags()
log(vim.inspect(tags))
if tags then
return tags
else
return nil
end
end
M.setups = function()
}
local v = M.version()
if v == nil then
return

@ -147,6 +147,7 @@ local function run_test(path, args)
if next(reminder) then
path = reminder[1]
table.remove(reminder, 1)
end
local test_runner = _GO_NVIM_CFG.go
if _GO_NVIM_CFG.test_runner ~= test_runner then
@ -183,8 +184,8 @@ local function run_test(path, args)
table.insert(cmd, '-v')
end
if not empty(reminder) then
log('****', reminder)
cmd = vim.list_extend(cmd, reminder)
log('****', reminder, cmd)
end
if compile == true then

Loading…
Cancel
Save