diff --git a/.luarc.json b/.luarc.json new file mode 100644 index 0000000..03e738a --- /dev/null +++ b/.luarc.json @@ -0,0 +1,15 @@ +{ + "runtime.version": "LuaJIT", + "runtime.path": [ + "lua/?.lua", + "lua/?/init.lua" + ], + "diagnostics.globals": [ + "vim" + ], + "workspace.checkThirdParty": false, + "workspace.library": [ + "$VIMRUNTIME", + "./lua" + ] +} diff --git a/after/plugin/lsp.lua b/after/plugin/lsp.lua index 0f07cb9..992c3b2 100644 --- a/after/plugin/lsp.lua +++ b/after/plugin/lsp.lua @@ -2,27 +2,30 @@ local lsp = require("lsp-zero") lsp.preset("recommended") -lsp.ensure_installed({ - 'lua_ls', -}) - --- Fix Undefined global 'vim' -lsp.nvim_workspace() - +lsp.extend_cmp() local cmp = require('cmp') local cmp_select = { behavior = cmp.SelectBehavior.Select } -local cmp_mappings = lsp.defaults.cmp_mappings({ - [''] = cmp.mapping.select_prev_item(cmp_select), - [''] = cmp.mapping.select_next_item(cmp_select), - [''] = cmp.mapping.confirm({ select = true }), - [""] = cmp.mapping.complete(), -}) -cmp_mappings[''] = nil -cmp_mappings[''] = nil - -lsp.setup_nvim_cmp({ - mapping = cmp_mappings +cmp.setup({ + window = { + completion = cmp.config.window.bordered(), + documentation = cmp.config.window.bordered(), + }, + mapping = cmp.mapping.preset.insert({ + [''] = cmp.mapping.select_prev_item(cmp_select), + [''] = cmp.mapping.select_next_item(cmp_select), + [''] = cmp.mapping.confirm({ select = true }), + [""] = cmp.mapping.complete(), + [''] = nil, + [''] = nil, + }), + sources = { + { name = 'nvim_lsp' }, + { name = 'buffer' }, + { name = 'path' }, + { name = 'nvim_lua' }, + { name = 'luasnip' }, + } }) lsp.set_preferences({ @@ -35,6 +38,8 @@ lsp.set_preferences({ } }) +lsp.extend_lspconfig() + lsp.on_attach(function(client, bufnr) local opts = { buffer = bufnr, remap = false } @@ -55,3 +60,11 @@ lsp.setup() vim.diagnostic.config({ virtual_text = true }) + +require("mason").setup({}) +require("mason-lspconfig").setup({ + ensure_installed = { 'lua_ls' }, + handlers = { + lsp.default_setup, + } +}) diff --git a/lua/crony/lazy.lua b/lua/crony/lazy.lua index 19cb47a..47525a8 100644 --- a/lua/crony/lazy.lua +++ b/lua/crony/lazy.lua @@ -19,7 +19,7 @@ require('lazy').setup({ { 'VonHeikemen/lsp-zero.nvim', - branch = 'v1.x', + branch = 'v3.x', dependencies = { -- LSP Support { 'neovim/nvim-lspconfig' },