nixos/home/tui/config/nvim/lua/lsp/attach.lua
Evie Litherland-Smith ed663b9674 Configure lualine
Setup lualine modules, remove some old plugins
2023-05-10 22:13:59 +01:00

25 lines
1.5 KiB
Lua

-- Use an on_attach function to only map the following keys
-- after the language server attaches to the current buffer
local on_attach = function(client, bufnr)
-- Mappings.
-- See `:help vim.lsp.*` for documentation on any of the below functions
local bufopts = { noremap = true, silent = true, buffer = bufnr }
vim.keymap.set("n", "gD", vim.lsp.buf.definition, bufopts)
vim.keymap.set("n", "gd", "<cmd>Trouble lsp_definitions<cr>", bufopts)
vim.keymap.set("n", "gR", vim.lsp.buf.references, bufopts)
vim.keymap.set("n", "gr", "<cmd>Trouble lsp_references<cr>", bufopts)
vim.keymap.set("n", "gI", vim.lsp.buf.implementation, bufopts)
vim.keymap.set("n", "gi", "<cmd>Trouble lsp_implementations<cr>", bufopts)
vim.keymap.set("n", "K", vim.lsp.buf.hover, bufopts)
vim.keymap.set("n", "<C-k>", vim.lsp.buf.signature_help, bufopts)
vim.keymap.set("n", "<leader>wa", vim.lsp.buf.add_workspace_folder, bufopts)
vim.keymap.set("n", "<leader>wr", vim.lsp.buf.remove_workspace_folder, bufopts)
vim.keymap.set("n", "<leader>wl", function() print(vim.inspect(vim.lsp.buf.list_workspace_folders())) end, bufopts)
vim.keymap.set("n", "<leader>D", vim.lsp.buf.type_definition, bufopts)
vim.keymap.set("n", "<leader>rn", vim.lsp.buf.rename, bufopts)
vim.keymap.set("n", "<leader>ca", vim.lsp.buf.code_action, bufopts)
vim.keymap.set("n", "<leader>i", require "lsp.formatting", bufopts)
if client.server_capabilities.documentSymbolProvider then require("nvim-navic").attach(client, bufnr) end
end
return on_attach