aboutsummaryrefslogtreecommitdiffstats
path: root/lua/alpha/lsp/attach.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua/alpha/lsp/attach.lua')
-rw-r--r--lua/alpha/lsp/attach.lua29
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