Revert "fix: set LSP mappings only for buffers that have a configured language server (#1004)"

This reverts commit a8466ccf4c.
This commit is contained in:
siduck 2022-05-01 18:24:40 +05:30
parent 9ae7c2aff3
commit 841f839bb6
2 changed files with 19 additions and 25 deletions

View file

@ -112,79 +112,73 @@ M.comment = function()
map("v", "<leader>/", "<esc><cmd> :lua require('Comment.api').toggle_linewise_op(vim.fn.visualmode())<CR>") map("v", "<leader>/", "<esc><cmd> :lua require('Comment.api').toggle_linewise_op(vim.fn.visualmode())<CR>")
end end
M.lspconfig = function(bufnr) M.lspconfig = function()
-- See `<cmd> :help vim.lsp.*` for documentation on any of the below functions -- See `<cmd> :help vim.lsp.*` for documentation on any of the below functions
map("n", "gD", function()
local buf_map = function(...)
local key, lhs, rhs = ...
map(key, lhs, rhs, { buffer = bufnr })
end
buf_map("n", "gD", function()
vim.lsp.buf.declaration() vim.lsp.buf.declaration()
end) end)
buf_map("n", "gd", function() map("n", "gd", function()
vim.lsp.buf.definition() vim.lsp.buf.definition()
end) end)
buf_map("n", "K", function() map("n", "K", function()
vim.lsp.buf.hover() vim.lsp.buf.hover()
end) end)
buf_map("n", "gi", function() map("n", "gi", function()
vim.lsp.buf.implementation() vim.lsp.buf.implementation()
end) end)
buf_map("n", "<C-k>", function() map("n", "<C-k>", function()
vim.lsp.buf.signature_help() vim.lsp.buf.signature_help()
end) end)
buf_map("n", "<space>D", function() map("n", "<space>D", function()
vim.lsp.buf.type_definition() vim.lsp.buf.type_definition()
end) end)
buf_map("n", "<space>ra", function() map("n", "<space>ra", function()
vim.lsp.buf.rename() vim.lsp.buf.rename()
end) end)
buf_map("n", "<space>ca", function() map("n", "<space>ca", function()
vim.lsp.buf.code_action() vim.lsp.buf.code_action()
end) end)
buf_map("n", "gr", function() map("n", "gr", function()
vim.lsp.buf.references() vim.lsp.buf.references()
end) end)
buf_map("n", "<space>f", function() map("n", "<space>f", function()
vim.diagnostic.open_float() vim.diagnostic.open_float()
end) end)
buf_map("n", "[d", function() map("n", "[d", function()
vim.diagnostic.goto_prev() vim.diagnostic.goto_prev()
end) end)
buf_map("n", "d]", function() map("n", "d]", function()
vim.diagnostic.goto_next() vim.diagnostic.goto_next()
end) end)
buf_map("n", "<space>q", function() map("n", "<space>q", function()
vim.diagnostic.setloclist() vim.diagnostic.setloclist()
end) end)
buf_map("n", "<space>fm", function() map("n", "<space>fm", function()
vim.lsp.buf.formatting() vim.lsp.buf.formatting()
end) end)
buf_map("n", "<space>wa", function() map("n", "<space>wa", function()
vim.lsp.buf.add_workspace_folder() vim.lsp.buf.add_workspace_folder()
end) end)
buf_map("n", "<space>wr", function() map("n", "<space>wr", function()
vim.lsp.buf.remove_workspace_folder() vim.lsp.buf.remove_workspace_folder()
end) end)
buf_map("n", "<space>wl", function() map("n", "<space>wl", function()
print(vim.inspect(vim.lsp.buf.list_workspace_folders())) print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end) end)
end end

View file

@ -10,7 +10,7 @@ function M.on_attach(client, bufnr)
client.resolved_capabilities.document_formatting = false client.resolved_capabilities.document_formatting = false
client.resolved_capabilities.document_range_formatting = false client.resolved_capabilities.document_range_formatting = false
require("core.mappings").lspconfig(bufnr) require("core.mappings").lspconfig()
end end
local capabilities = vim.lsp.protocol.make_client_capabilities() local capabilities = vim.lsp.protocol.make_client_capabilities()