summaryrefslogtreecommitdiff
path: root/.config/nvim_old/lua/plugins/lsp.lua
diff options
context:
space:
mode:
Diffstat (limited to '.config/nvim_old/lua/plugins/lsp.lua')
-rw-r--r--.config/nvim_old/lua/plugins/lsp.lua62
1 files changed, 62 insertions, 0 deletions
diff --git a/.config/nvim_old/lua/plugins/lsp.lua b/.config/nvim_old/lua/plugins/lsp.lua
new file mode 100644
index 0000000..0314c42
--- /dev/null
+++ b/.config/nvim_old/lua/plugins/lsp.lua
@@ -0,0 +1,62 @@
+-- Language server for specified languages
+-- Hover with 'K'
+-- Goto definition with :Goto
+-- Open code action with :Codeact
+
+local servers = {
+ "lua_ls", "bashls", "clangd", "marksman", "pyright", "lemminx",
+}
+
+return {
+ {
+ "williamboman/mason.nvim",
+ config = function()
+ require("mason").setup()
+ end
+ },
+
+ {
+ "williamboman/mason-lspconfig.nvim",
+ config = function()
+ require("mason-lspconfig").setup {
+ ensure_installed = servers,
+ automatic_installation = true,
+ }
+ end
+ },
+
+ {
+ "neovim/nvim-lspconfig",
+ config = function()
+ -- Advertise autocompletion to lsp
+ local capabilities = require('cmp_nvim_lsp').default_capabilities()
+ for _, server in ipairs(servers) do
+ vim.lsp.config(server, {
+ capabilities = capabilities,
+ })
+ end
+
+ -- Key mapping
+ -- Hover for definition
+ vim.keymap.set('n', 'K', vim.lsp.buf.hover, {})
+
+ -- Move to definition
+ vim.api.nvim_create_user_command(
+ "Goto",
+ function()
+ vim.lsp.buf.definition()
+ end,
+ {}
+ )
+
+ -- Code action
+ vim.api.nvim_create_user_command(
+ "Codeact",
+ function()
+ vim.lsp.buf.code_action()
+ end,
+ {}
+ )
+ end
+ }
+}