gopls on_attach does not trigger on every open buffer, need keymap for all buffers

neovim_0_5
ray-x 3 years ago
parent 2d7214d875
commit 09667c32a9

@ -75,8 +75,6 @@ M.setup = function(cfg)
-- vim.cmd("autocmd BufNewFile,BufRead *.go setlocal noexpandtab tabstop=4 shiftwidth=4")
if not _NgConfigValues.loaded then
vim.cmd([[autocmd FileType * lua require'navigator.lspclient.clients'.setup()]]) -- BufWinEnter BufNewFile,BufRead ?
-- TODO: Check this should be hooked in on_attach, but if stopping working...
vim.cmd([[autocmd FileType * lua require'navigator.lspclient.mapping'.setup()]]) -- BufWinEnter BufNewFile,BufRead ?
_NgConfigValues.loaded = true
end
end

@ -46,6 +46,10 @@ local function set_mapping(user_opts)
vim.api.nvim_buf_set_keymap(bufnr, ...)
end
local function set_keymap(...)
vim.api.nvim_set_keymap(...)
end
-- local function buf_set_option(...)
-- vim.api.nvim_buf_set_option(bufnr, ...)
-- end
@ -72,7 +76,7 @@ local function set_mapping(user_opts)
end
local k = value.key
local m = value.mode or "n"
buf_set_keymap(m, k, f, opts)
set_keymap(m, k, f, opts)
end
-- format setup
@ -102,6 +106,7 @@ local function set_mapping(user_opts)
if range_fmt then
buf_set_keymap("v", "<space>ff", "<cmd>lua vim.lsp.buf.range_formatting()<CR>", opts)
end
log("enable format ", doc_fmt, range_fmt)
end
local function autocmd(user_opts)
@ -138,7 +143,7 @@ end
local M = {}
function M.setup(user_opts)
user_opts = user_opts or _NgConfigValues
if _NgConfigValues.default_mapping == true then
set_mapping(user_opts)
end

Loading…
Cancel
Save