register lsp mappings for buffer only

This commit is contained in:
siduck 2022-05-24 23:01:35 +05:30
parent 16d5451594
commit c7cfacd360
3 changed files with 18 additions and 7 deletions

View File

@ -18,9 +18,19 @@ win.default_opts = function(options)
return opts
end
function M.on_attach(client, _)
M.on_attach = function(client, bufnr)
client.resolved_capabilities.document_formatting = false
client.resolved_capabilities.document_range_formatting = false
local lsp_mappings = nvchad.load_config().mappings.lspconfig
local wk_exists, wk = pcall(require, "which-key")
if wk_exists then
wk.register(lsp_mappings.n, { buffer = bufnr })
else
-- todo, make use of bufnr here
-- add no whichkey func logic here
end
end
local capabilities = vim.lsp.protocol.make_client_capabilities()

View File

@ -66,17 +66,18 @@ mappings.groups = nil
-- register mappings
local function register_mappings(maps, opts)
for mode, opt in pairs(opts.mode_opts) do
for _, value in pairs(maps) do
for key, value in pairs(maps) do
if key ~= "lspconfig" then
if value[mode] then
local mode_opts = value["mode_opts"] and vim.tbl_deep_extend("force", opt, value["mode_opts"]) or opt
wk.register(value[mode], mode_opts)
end
end
end
end
end
register_mappings(mappings, options)
register_mappings(mapping_groups, options)
wk.setup(options)

View File

@ -186,7 +186,7 @@ local plugins = {
-- file managing , picker etc
["kyazdani42/nvim-tree.lua"] = {
ft = 'alpha',
ft = "alpha",
cmd = { "NvimTreeToggle", "NvimTreeFocus" },
config = function()
require "plugins.configs.nvimtree"