From f7bcac5ee5db56081981bb946a66d3fc34807988 Mon Sep 17 00:00:00 2001 From: Ariel D'Alessandro Date: Sun, 8 Jan 2023 09:58:56 +0100 Subject: feat: refactor lsp & cmp to lua folder from after --- lua/alpha/lsp/attach.lua | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 lua/alpha/lsp/attach.lua (limited to 'lua/alpha/lsp/attach.lua') 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", "vrn", vim.lsp.buf.rename, { buffer = 0 }) + vim.keymap.set("i", "", vim.lsp.buf.signature_help, { buffer = 0 }) + vim.keymap.set("n", "vo", ":LspRestart", { noremap = true }) + vim.keymap.set({ "n", "v" }, "vca", vim.lsp.buf.code_action, {}) + vim.keymap.set("n", "vf", function() + return vim.lsp.buf.format({ async = true }) + end, {}) + + telescope_mapper("gr", "lsp_references", nil, true) + telescope_mapper("pv", "find_symbol", nil, true) + telescope_mapper("pd", "lsp_document_symbols", nil, true) + telescope_mapper("", "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 -- cgit v1.2.3