return { { 'williamboman/mason-lspconfig.nvim', opts = { ensure_installed = { 'lua_ls', 'gopls', 'rust_analyzer', 'pylsp' } } }, { 'L3MON4D3/LuaSnip', version = 'v2.*', build = 'make install_jsregexp', dependencies = { 'rafamadriz/friendly-snippets' }, config = function() local vscode_loader = require('luasnip.loaders.from_vscode') vscode_loader.lazy_load() vscode_loader.lazy_load({ paths = { './snippets' } }) local ls = require('luasnip') vim.keymap.set({ "i" }, "", function() ls.expand() end, { silent = true }) vim.keymap.set({ "i", "s" }, "", function() ls.jump(1) end, { silent = true }) vim.keymap.set({ "i", "s" }, "", function() ls.jump(-1) end, { silent = true }) end }, { 'hrsh7th/nvim-cmp', event = 'InsertEnter', dependencies = { 'hrsh7th/cmp-buffer', 'hrsh7th/cmp-path', 'hrsh7th/cmp-cmdline', 'hrsh7th/cmp-nvim-lsp', 'saadparwaiz1/cmp_luasnip' }, config = function() local has_words_before = function() unpack = unpack or table.unpack local line, col = unpack(vim.api.nvim_win_get_cursor(0)) return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil end local cmp = require('cmp') local luasnip = require('luasnip') cmp.setup({ snippet = { expand = function(args) luasnip.lsp_expand(args.body) end }, mapping = cmp.mapping.preset.insert({ [''] = cmp.mapping.scroll_docs(-4), [''] = cmp.mapping.scroll_docs(4), [''] = cmp.mapping.complete(), [''] = cmp.mapping.abort(), [''] = cmp.mapping.confirm({ select = true }), [""] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_next_item() elseif has_words_before() then cmp.complete() else fallback() end end, { "i", "s" }), [""] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_prev_item() elseif luasnip.jumpable(-1) then luasnip.jump(-1) else fallback() end end, { "i", "s" }), }), sources = cmp.config.sources({ { name = 'nvim_lsp' }, { name = 'luasnip' }, { name = 'buffer' }, { name = 'path' }, }) }) end }, { 'neovim/nvim-lspconfig', config = function() local lspconfig = require('lspconfig') local lsp_capabilities = require('cmp_nvim_lsp').default_capabilities() lspconfig.lua_ls.setup({ capabilities = lsp_capabilities }) lspconfig.rust_analyzer.setup({ capabilities = lsp_capabilities }) lspconfig.gopls.setup({ capabilities = lsp_capabilities }) lspconfig.typst_lsp.setup({ capabilities = lsp_capabilities }) lspconfig.clangd.setup({ capabilities = lsp_capabilities }) lspconfig.cmake.setup({ capabilities = lsp_capabilities }) end }, }