diff options
| author | Ariel D'Alessandro <dalessandro.ariel@gmail.com> | 2023-01-08 09:58:56 +0100 |
|---|---|---|
| committer | Ariel D'Alessandro <dalessandro.ariel@gmail.com> | 2023-01-08 09:58:56 +0100 |
| commit | f7bcac5ee5db56081981bb946a66d3fc34807988 (patch) | |
| tree | 2cfc8d60054508d5297cd392d6df1e540057bcc7 /lua/alpha/lsp/attach.lua | |
| parent | fb9196e7766f53115009c081f0b4308ca6c081b4 (diff) | |
| download | nvim-conf-f7bcac5ee5db56081981bb946a66d3fc34807988.tar.gz nvim-conf-f7bcac5ee5db56081981bb946a66d3fc34807988.zip | |
feat: refactor lsp & cmp to lua folder from after
Diffstat (limited to 'lua/alpha/lsp/attach.lua')
| -rw-r--r-- | lua/alpha/lsp/attach.lua | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/lua/alpha/lsp/attach.lua b/lua/alpha/lsp/attach.lua new file mode 100644 index 0000000..ce63e02 --- /dev/null +++ b/lua/alpha/lsp/attach.lua @@ -0,0 +1,29 @@ +local telescope_mapper = require("alpha.telescope.mappings") + +local filetype_attach = setmetatable({}, { + __index = function() + return function() end + end, +}) +return function (client, bufnr) + local filetype = vim.api.nvim_buf_get_option(0, "filetype") + -- keymaps for lsp + vim.keymap.set("n", "K", vim.lsp.buf.hover, { buffer = 0 }) + vim.keymap.set("n", "<leader>vrn", vim.lsp.buf.rename, { buffer = 0 }) + vim.keymap.set("i", "<c-h>", vim.lsp.buf.signature_help, { buffer = 0 }) + vim.keymap.set("n", "<leader>vo", ":LspRestart<cr>", { noremap = true }) + vim.keymap.set({ "n", "v" }, "<leader>vca", vim.lsp.buf.code_action, {}) + vim.keymap.set("n", "<leader>vf", function() + return vim.lsp.buf.format({ async = true }) + end, {}) + + telescope_mapper("gr", "lsp_references", nil, true) + telescope_mapper("<leader>pv", "find_symbol", nil, true) + telescope_mapper("<leader>pd", "lsp_document_symbols", nil, true) + telescope_mapper("<c-]>", "lsp_definitions", nil, true) + + vim.bo.omnifunc = "v:lua.vim.lsp.omnifunc" + + -- Attach any filetype specific options to the client + filetype_attach[filetype](client, bufnr) +end |