diff options
| author | Cryxtalix <fgx8p9t@protonmail.com> | 2024-11-08 21:58:55 +0800 |
|---|---|---|
| committer | Cryxtalix <fgx8p9t@protonmail.com> | 2024-11-08 21:58:55 +0800 |
| commit | dc839e971ad6a724bc99bccc6dfaa11ee8a1eaa9 (patch) | |
| tree | 79e1ee75429a5ef500f716d3675aeec6c52dcda1 /.config/nvim/lua/plugins/lsp.lua | |
Init gnu stow
Diffstat (limited to '.config/nvim/lua/plugins/lsp.lua')
| -rw-r--r-- | .config/nvim/lua/plugins/lsp.lua | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/.config/nvim/lua/plugins/lsp.lua b/.config/nvim/lua/plugins/lsp.lua new file mode 100644 index 0000000..ad6f420 --- /dev/null +++ b/.config/nvim/lua/plugins/lsp.lua @@ -0,0 +1,60 @@ +return { + { + "williamboman/mason.nvim", + config = function() + require("mason").setup() + end + }, + + { + "williamboman/mason-lspconfig.nvim", + config = function() + require("mason-lspconfig").setup({ + -- Add languages + ensure_installed = { + "bashls", + "clangd", + "lua_ls", + "marksman", + "pyright", + "rust_analyzer", + } + }) + end + }, + + { + "neovim/nvim-lspconfig", + config = function() + local lspconfig = require("lspconfig") + lspconfig.bashls.setup({}) + lspconfig.lua_ls.setup({}) + lspconfig.clangd.setup({}) + lspconfig.marksman.setup({}) + lspconfig.pyright.setup({}) + lspconfig.rust_analyzer.setup({}) + + -- 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 + } +} |
