From ccc51564411083fcea62a3e75cc3a6d99c634cfc Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 17 Feb 2023 18:05:08 +0200 Subject: refactor(lsp)!: lua lsp renamed (#3836) Need to run `:LvimCacheReset` after this for lua ftplugin regenration * chore: bump plugins version * refactor(loader): update lazy's cache setup * chore: bump plugins version * chore(lsp): skip antlerls for html * fix(lsp): lua lsp renamed (#3841) * fix(loader): lazy's cache is now a directory * fix: LvimUpdate should bump core plugins (#3846) * chore: bump plugins version * fix(cmp): handle deprecated tree-sitter api (#3853) * fix(loader): wrap cache invocation with pcall avoid problems when lazy hasn't been updated yet * chore(lsp): skip docker-compose ls * chore: bump plugins --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: kylo252 <59826753+kylo252@users.noreply.github.com> Co-authored-by: Jieru Mei Co-authored-by: LostNeophyte --- lua/lvim/lsp/config.lua | 2 ++ lua/lvim/lsp/providers/lua_ls.lua | 63 ++++++++++++++++++++++++++++++++++ lua/lvim/lsp/providers/sumneko_lua.lua | 63 ---------------------------------- lua/lvim/plugin-loader.lua | 27 ++++++++------- 4 files changed, 79 insertions(+), 76 deletions(-) create mode 100644 lua/lvim/lsp/providers/lua_ls.lua delete mode 100644 lua/lvim/lsp/providers/sumneko_lua.lua (limited to 'lua') diff --git a/lua/lvim/lsp/config.lua b/lua/lvim/lsp/config.lua index 7128a4cc..7f4b3bd5 100644 --- a/lua/lvim/lsp/config.lua +++ b/lua/lvim/lsp/config.lua @@ -1,10 +1,12 @@ local skipped_servers = { "angularls", "ansiblels", + "antlersls", "ccls", "csharp_ls", "cssmodules_ls", "denols", + "docker_compose_language_service", "ember", "emmet_ls", "eslint", diff --git a/lua/lvim/lsp/providers/lua_ls.lua b/lua/lvim/lsp/providers/lua_ls.lua new file mode 100644 index 00000000..2d3f4932 --- /dev/null +++ b/lua/lvim/lsp/providers/lua_ls.lua @@ -0,0 +1,63 @@ +local default_workspace = { + library = { + vim.fn.expand "$VIMRUNTIME", + get_lvim_base_dir(), + require("neodev.config").types(), + "${3rd}/busted/library", + "${3rd}/luassert/library", + }, + + maxPreload = 5000, + preloadFileSize = 10000, +} + +local add_packages_to_workspace = function(packages, config) + -- config.settings.Lua = config.settings.Lua or { workspace = default_workspace } + local runtimedirs = vim.api.nvim__get_runtime({ "lua" }, true, { is_lua = true }) + local workspace = config.settings.Lua.workspace + for _, v in pairs(runtimedirs) do + for _, pack in ipairs(packages) do + if v:match(pack) and not vim.tbl_contains(workspace.library, v) then + table.insert(workspace.library, v) + end + end + end +end + +local lspconfig = require "lspconfig" + +local make_on_new_config = function(on_new_config, _) + return lspconfig.util.add_hook_before(on_new_config, function(new_config, _) + local server_name = new_config.name + + if server_name ~= "lua_ls" then + return + end + local plugins = { "plenary.nvim", "telescope.nvim", "nvim-treesitter", "LuaSnip" } + add_packages_to_workspace(plugins, new_config) + end) +end + +lspconfig.util.default_config = vim.tbl_extend("force", lspconfig.util.default_config, { + on_new_config = make_on_new_config(lspconfig.util.default_config.on_new_config), +}) + +local opts = { + settings = { + Lua = { + telemetry = { enable = false }, + runtime = { + version = "LuaJIT", + special = { + reload = "require", + }, + }, + diagnostics = { + globals = { "vim", "lvim", "reload" }, + }, + workspace = default_workspace, + }, + }, +} + +return opts diff --git a/lua/lvim/lsp/providers/sumneko_lua.lua b/lua/lvim/lsp/providers/sumneko_lua.lua deleted file mode 100644 index a73d3edc..00000000 --- a/lua/lvim/lsp/providers/sumneko_lua.lua +++ /dev/null @@ -1,63 +0,0 @@ -local default_workspace = { - library = { - vim.fn.expand "$VIMRUNTIME", - get_lvim_base_dir(), - require("neodev.config").types(), - "${3rd}/busted/library", - "${3rd}/luassert/library", - }, - - maxPreload = 5000, - preloadFileSize = 10000, -} - -local add_packages_to_workspace = function(packages, config) - -- config.settings.Lua = config.settings.Lua or { workspace = default_workspace } - local runtimedirs = vim.api.nvim__get_runtime({ "lua" }, true, { is_lua = true }) - local workspace = config.settings.Lua.workspace - for _, v in pairs(runtimedirs) do - for _, pack in ipairs(packages) do - if v:match(pack) and not vim.tbl_contains(workspace.library, v) then - table.insert(workspace.library, v) - end - end - end -end - -local lspconfig = require "lspconfig" - -local make_on_new_config = function(on_new_config, _) - return lspconfig.util.add_hook_before(on_new_config, function(new_config, _) - local server_name = new_config.name - - if server_name ~= "sumneko_lua" then - return - end - local plugins = { "plenary.nvim", "telescope.nvim", "nvim-treesitter", "LuaSnip" } - add_packages_to_workspace(plugins, new_config) - end) -end - -lspconfig.util.default_config = vim.tbl_extend("force", lspconfig.util.default_config, { - on_new_config = make_on_new_config(lspconfig.util.default_config.on_new_config), -}) - -local opts = { - settings = { - Lua = { - telemetry = { enable = false }, - runtime = { - version = "LuaJIT", - special = { - reload = "require", - }, - }, - diagnostics = { - globals = { "vim", "lvim", "reload" }, - }, - workspace = default_workspace, - }, - }, -} - -return opts diff --git a/lua/lvim/plugin-loader.lua b/lua/lvim/plugin-loader.lua index 647fab9f..5a3a94de 100644 --- a/lua/lvim/plugin-loader.lua +++ b/lua/lvim/plugin-loader.lua @@ -17,7 +17,7 @@ function plugin_loader.init(opts) local core_plugins_dir = join_paths(get_lvim_base_dir(), "plugins") if utils.is_directory(core_plugins_dir) then vim.fn.mkdir(plugins_dir, "p") - vim.loop.fs_rmdir(plugins_dir) + vim.fn.delete(plugins_dir, "rf") require("lvim.utils").fs_copy(core_plugins_dir, plugins_dir) else vim.fn.system { @@ -47,21 +47,22 @@ function plugin_loader.init(opts) vim.opt.runtimepath:append(lazy_install_dir) vim.opt.runtimepath:append(join_paths(plugins_dir, "*")) - local lazy_cache = require "lazy.core.cache" - lazy_cache.setup { - performance = { - cache = { - enabled = true, - path = join_paths(get_cache_dir(), "lazy", "cache"), - }, - }, - } - -- HACK: Don't allow lazy to call setup second time - lazy_cache.setup = function() end + pcall(function() + -- set a custom path for lazy's cache and enable it + local lazy_cache = require "lazy.core.cache" + lazy_cache.path = join_paths(get_cache_dir(), "lazy", "luac") + lazy_cache.enable() + end) end function plugin_loader.reset_cache() - os.remove(require("lazy.core.cache").config.path) + -- TODO(kylo252): is this really necessary anymore? + local lazy_cache = require "lazy.core.cache" + local cache_path = lazy_cache.path + if utils.is_directory(cache_path) then + vim.fn.delete(cache_path, "rf") + vim.fn.mkdir(cache_path, "p") + end end function plugin_loader.reload(spec) -- cgit v1.2.3