2021-12-16 22:59:47 +00:00
|
|
|
local utils = require("go.utils")
|
|
|
|
local log = utils.log
|
|
|
|
|
|
|
|
-- ONLY SUPPORT GOPLS
|
|
|
|
|
|
|
|
local M = {}
|
|
|
|
|
|
|
|
function M.run_action()
|
|
|
|
local guihua = utils.load_plugin("guihua.lua", "guihua.gui")
|
|
|
|
|
|
|
|
local original_select = vim.ui.select
|
2022-06-16 04:10:49 +00:00
|
|
|
local original_input = vim.ui.input
|
2021-12-16 22:59:47 +00:00
|
|
|
if guihua then
|
|
|
|
vim.ui.select = require("guihua.gui").select
|
2022-06-16 04:10:49 +00:00
|
|
|
vim.ui.input = require("guihua.input").input
|
2021-12-16 22:59:47 +00:00
|
|
|
end
|
|
|
|
log("codeaction")
|
|
|
|
|
2022-06-16 04:10:49 +00:00
|
|
|
if vim.api.nvim_get_mode().mode ~= "v" then
|
|
|
|
vim.lsp.buf.code_action()
|
|
|
|
else
|
|
|
|
vim.lsp.buf.range_code_action()
|
|
|
|
end
|
2021-12-16 22:59:47 +00:00
|
|
|
|
|
|
|
vim.defer_fn(function()
|
|
|
|
vim.ui.select = original_select
|
|
|
|
end, 1000)
|
2022-06-16 04:10:49 +00:00
|
|
|
|
|
|
|
vim.defer_fn(function()
|
|
|
|
vim.ui.input = original_input
|
|
|
|
end, 10000)
|
2021-12-16 22:59:47 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
return M
|