diff options
author | ben <ben@nagy.contact> | 2025-01-08 15:45:00 -0800 |
---|---|---|
committer | ben <ben@nagy.contact> | 2025-01-08 15:45:00 -0800 |
commit | bb2e30b412c23b76ae876e792398f4926467d962 (patch) | |
tree | 4f50f94b7bf50103a61ddbab8a0a30f753918b21 /nvim/lua/plugins/lsp.lua | |
parent | ec2cc455fed8933a98a8b13bea015dd9c4b6e99a (diff) |
added current config
Diffstat (limited to 'nvim/lua/plugins/lsp.lua')
-rw-r--r-- | nvim/lua/plugins/lsp.lua | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/nvim/lua/plugins/lsp.lua b/nvim/lua/plugins/lsp.lua new file mode 100644 index 0000000..e33925e --- /dev/null +++ b/nvim/lua/plugins/lsp.lua @@ -0,0 +1,100 @@ +return +{ + 'VonHeikemen/lsp-zero.nvim', + branch = 'v3.x', + dependencies = { + -- LSP Support + {'neovim/nvim-lspconfig'}, + {'williamboman/mason.nvim'}, + {'williamboman/mason-lspconfig.nvim'}, + {'folke/todo-comments.nvim'}, -- doesn't load for some reason + + -- Autocompletion + {'hrsh7th/nvim-cmp'}, + {'hrsh7th/cmp-nvim-lsp'}, + {'hrsh7th/cmp-buffer'}, + {'hrsh7th/cmp-path'}, + {'saadparwaiz1/cmp_luasnip'}, + {'hrsh7th/cmp-nvim-lua'}, + + -- Snippets + {'L3MON4D3/LuaSnip'}, + {'rafamadriz/friendly-snippets'}, + }, + + config = function() + local lsp_zero = require('lsp-zero') + + lsp_zero.on_attach(function(client, bufnr) + -- see :help lsp-zero-keybindings + -- to learn the available actions + lsp_zero.default_keymaps({buffer = bufnr}) + + vim.keymap.set('n', 'K', '<cmd>lua vim.lsp.buf.hover()<cr>', opts) + vim.keymap.set('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<cr>', opts) + vim.keymap.set('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<cr>', opts) + vim.keymap.set('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<cr>', opts) + vim.keymap.set('n', 'go', '<cmd>lua vim.lsp.buf.type_definition()<cr>', opts) + vim.keymap.set('n', 'gr', '<cmd>lua vim.lsp.buf.references()<cr>', opts) + vim.keymap.set('n', 'gs', '<cmd>lua vim.lsp.buf.signature_help()<cr>', opts) + end) + + -- to learn how to use mason.nvim with lsp-zero + -- read this: https://github.com/VonHeikemen/lsp-zero.nvim/blob/v3.x/doc/md/guides/integrate-with-mason-nvim.md + require('mason').setup({}) + require('mason-lspconfig').setup({ + ensure_installed = { + 'lua_ls', + 'clangd', + 'texlab', + }, + handlers = { + lsp_zero.default_setup, + }, + }) + + -- Setup completion + local cmp = require('cmp') + local cmp_action = lsp_zero.cmp_action() + + cmp.setup({ + mapping = cmp.mapping.preset.insert({ + ['<CR>'] = cmp.mapping.confirm({select = false}), + ['<C-Space>'] = cmp.mapping.complete(), + ['<C-f>'] = cmp_action.luasnip_jump_forward(), + ['<C-b>'] = cmp_action.luasnip_jump_backward(), + ['<C-u>'] = cmp.mapping.scroll_docs(-4), + ['<C-d>'] = cmp.mapping.scroll_docs(4), + }), + snippet = { + expand = function(args) + -- You need Neovim v0.10 to use vim.snippet + vim.snippet.expand(args.body) + end, + }, + }) + + require('lspconfig').lua_ls.setup({ + capabilities = lsp_capabilities, + settings = { + Lua = { + runtime = { + version = 'LuaJIT' + }, + diagnostics = { + globals = {'vim'}, + disable = { 'unused-function' }, + }, + workspace = { + library = { + vim.env.VIMRUNTIME, + } + } + } + } + }) + + + end + +} |