|
|
|
@ -37,11 +37,10 @@ local on_attach = function(client, bufnr)
|
|
|
|
|
buf_set_keymap('n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
|
|
|
|
|
buf_set_keymap('n', '<space>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts)
|
|
|
|
|
buf_set_keymap('n', '<space>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts)
|
|
|
|
|
buf_set_keymap('n', '<space>wl',
|
|
|
|
|
'<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts)
|
|
|
|
|
buf_set_keymap('n', '<space>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts)
|
|
|
|
|
buf_set_keymap('n', '<space>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
|
|
|
|
|
buf_set_keymap('n', '<space>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
|
|
|
|
|
buf_set_keymap('n', '<space>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
|
|
|
|
|
buf_set_keymap('n', '<space>ca', '<cmd>lua require"go.lsp".telescope_code_actions()<CR>', opts)
|
|
|
|
|
buf_set_keymap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
|
|
|
|
|
buf_set_keymap('n', '<space>e', '<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>', opts)
|
|
|
|
|
buf_set_keymap('n', '[d', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>', opts)
|
|
|
|
@ -61,7 +60,13 @@ local gopls = {
|
|
|
|
|
"gopls", -- share the gopls instance if there is one already
|
|
|
|
|
"-remote.debug=:0"
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
root_dir = function(fname)
|
|
|
|
|
local has_lsp, lspconfig = pcall(require, "lspconfig")
|
|
|
|
|
if has_lsp then
|
|
|
|
|
local util = lspconfig.util
|
|
|
|
|
return util.root_pattern("go.mod", ".git")(fname) or util.path.dirname(fname)
|
|
|
|
|
end
|
|
|
|
|
end,
|
|
|
|
|
flags = {allow_incremental_sync = true, debounce_text_changes = 500},
|
|
|
|
|
settings = {
|
|
|
|
|
gopls = {
|
|
|
|
@ -184,4 +189,19 @@ M.codeaction = function(action, only, wait_ms)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function M.telescope_code_actions()
|
|
|
|
|
local ok, _ = utils.load_plugin('telescope', "builtin")
|
|
|
|
|
if ok then
|
|
|
|
|
local themes = require('telescope.themes')
|
|
|
|
|
local opts = themes.get_dropdown {
|
|
|
|
|
winblend = 10,
|
|
|
|
|
border = true,
|
|
|
|
|
previewer = false,
|
|
|
|
|
shorten_path = false
|
|
|
|
|
}
|
|
|
|
|
require('telescope.builtin').lsp_code_actions(opts)
|
|
|
|
|
else
|
|
|
|
|
vim.lsp.buf.code_action()
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
return M
|
|
|
|
|