diff options
| author | Blake Romero <blake@blkrom.com> | 2025-01-24 15:54:19 +0000 |
|---|---|---|
| committer | Blake Romero <blake@blkrom.com> | 2025-01-24 15:54:19 +0000 |
| commit | 34038f9a25fee77e3a64235676b3e83f39f74b68 (patch) | |
| tree | 7ba660cc6b8bd4afe4dfd3667d5a0d069482986a | |
| parent | d3b36fad967d8cf52356042aff0423cd22cc8767 (diff) | |
Add completions & enable lsp config auto-install
| -rw-r--r-- | lua/plugins/complete.lua | 44 | ||||
| -rw-r--r-- | lua/plugins/mason.lua | 9 |
2 files changed, 50 insertions, 3 deletions
diff --git a/lua/plugins/complete.lua b/lua/plugins/complete.lua new file mode 100644 index 0000000..72e741c --- /dev/null +++ b/lua/plugins/complete.lua @@ -0,0 +1,44 @@ +return { + { + "hrsh7th/cmp-nvim-lsp", + }, + { + "L3MON4D3/LuaSnip", + dependencies = { + "saadparwaiz1/cmp_luasnip", + "rafamadriz/friendly-snippets", + }, + }, + { + "hrsh7th/nvim-cmp", + config = function() + local cmp = require("cmp") + require("luasnip.loaders.from_vscode").lazy_load() + cmp.setup({ + snippet = { + -- REQUIRED - you must specify a snippet engine + expand = function(args) + require("luasnip").lsp_expand(args.body) + end, + }, + window = { + completion = cmp.config.window.bordered(), + documentation = cmp.config.window.bordered(), + }, + mapping = cmp.mapping.preset.insert({ + ["<C-b>"] = cmp.mapping.scroll_docs(-4), + ["<C-f>"] = cmp.mapping.scroll_docs(4), + ["<C-Space>"] = cmp.mapping.complete(), + ["<C-e>"] = cmp.mapping.abort(), + ["<CR>"] = cmp.mapping.confirm({ select = true }), + }), + sources = cmp.config.sources({ + { name = 'nvim_lsp' }, + { name = "luasnip" }, + }, { + { name = "buffer" }, + }), + }) + end, + }, +} diff --git a/lua/plugins/mason.lua b/lua/plugins/mason.lua index f600a1a..32895ee 100644 --- a/lua/plugins/mason.lua +++ b/lua/plugins/mason.lua @@ -5,16 +5,19 @@ return { }, { "williamboman/mason-lspconfig.nvim", - config = true, + lazy = false, opts = { - ensure_installed = { "lua_ls" } + auto_install = true, } }, { "neovim/nvim-lspconfig", config = function() local lspconfig = require("lspconfig") - lspconfig.lua_ls.setup({}) + local capabilities = require('cmp_nvim_lsp').default_capabilities() + + lspconfig.lua_ls.setup({ capabilities = capabilities }) + lspconfig.clangd.setup({ capabilities = capabilities }) vim.keymap.set('n', 'K', vim.lsp.buf.hover, {}) vim.keymap.set('n', 'gd', vim.lsp.buf.definition, {}) |
