From c7f6b386744a8e8e64947c040e054d424c58c0c8 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 9 Apr 2022 15:10:45 +0430 Subject: chore: bump plugins version (#2439) --- snapshots/default.json | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/snapshots/default.json b/snapshots/default.json index 10f82b6c..4615c6b8 100644 --- a/snapshots/default.json +++ b/snapshots/default.json @@ -9,13 +9,13 @@ "commit": "1bfb32e" }, "LuaSnip": { - "commit": "eb5b77e" + "commit": "69cb81c" }, "alpha-nvim": { - "commit": "534a86b" + "commit": "6655228" }, "bufferline.nvim": { - "commit": "004cd57" + "commit": "874f869" }, "cmp-buffer": { "commit": "d66c4c2" @@ -33,7 +33,7 @@ "commit": "e302658" }, "gitsigns.nvim": { - "commit": "83ab3ca" + "commit": "acdd74b" }, "lua-dev.nvim": { "commit": "a0ee777" @@ -42,37 +42,37 @@ "commit": "c8e5a69" }, "nlsp-settings.nvim": { - "commit": "995b5e6" + "commit": "2c962d6" }, "null-ls.nvim": { - "commit": "899785c" + "commit": "8d23981" }, "nvim-autopairs": { "commit": "06535b1" }, "nvim-cmp": { - "commit": "7dbe34e" + "commit": "3192a0c" }, "nvim-dap": { - "commit": "c20c78d" + "commit": "10b5781" }, "nvim-lsp-installer": { - "commit": "c7f1437" + "commit": "918ef1d" }, "nvim-lspconfig": { - "commit": "3d1baa8" + "commit": "f183d35" }, "nvim-notify": { - "commit": "da10302" + "commit": "7fed925" }, "nvim-tree.lua": { - "commit": "6368880" + "commit": "618ea25" }, "nvim-treesitter": { - "commit": "2472e47" + "commit": "9c1fb16" }, "nvim-ts-context-commentstring": { - "commit": "7810f1f" + "commit": "8834375" }, "nvim-web-devicons": { "commit": "09e6231" @@ -84,7 +84,7 @@ "commit": "4dedd3b" }, "plenary.nvim": { - "commit": "f9c65cd" + "commit": "470d0e8" }, "popup.nvim": { "commit": "b7404d3" @@ -93,7 +93,7 @@ "commit": "cef52b8" }, "schemastore.nvim": { - "commit": "d423f6c" + "commit": "597d8f6" }, "structlog.nvim": { "commit": "6f1403a" @@ -102,10 +102,10 @@ "commit": "8ec164b" }, "telescope.nvim": { - "commit": "6e7ee38" + "commit": "8af0d38" }, "toggleterm.nvim": { - "commit": "5733b24" + "commit": "e62008f" }, "which-key.nvim": { "commit": "a3c19ec" -- cgit v1.2.3 From 36361e1107d80e2eb2d8d90afebcff40f1198764 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 10 Apr 2022 23:47:23 +0430 Subject: chore: bump plugins version (#2442) * chore: bump plugins version * fix(snapshot): fix bufferline wrong commit --- snapshots/default.json | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/snapshots/default.json b/snapshots/default.json index 4615c6b8..d7a77ca0 100644 --- a/snapshots/default.json +++ b/snapshots/default.json @@ -9,13 +9,13 @@ "commit": "1bfb32e" }, "LuaSnip": { - "commit": "69cb81c" + "commit": "5d3b468" }, "alpha-nvim": { "commit": "6655228" }, "bufferline.nvim": { - "commit": "874f869" + "commit": "e62008f" }, "cmp-buffer": { "commit": "d66c4c2" @@ -33,7 +33,7 @@ "commit": "e302658" }, "gitsigns.nvim": { - "commit": "acdd74b" + "commit": "4a68d2a" }, "lua-dev.nvim": { "commit": "a0ee777" @@ -42,10 +42,10 @@ "commit": "c8e5a69" }, "nlsp-settings.nvim": { - "commit": "2c962d6" + "commit": "956c8ad" }, "null-ls.nvim": { - "commit": "8d23981" + "commit": "82be4bf" }, "nvim-autopairs": { "commit": "06535b1" @@ -57,19 +57,19 @@ "commit": "10b5781" }, "nvim-lsp-installer": { - "commit": "918ef1d" + "commit": "a6c2783" }, "nvim-lspconfig": { - "commit": "f183d35" + "commit": "fd7843a" }, "nvim-notify": { - "commit": "7fed925" + "commit": "0d02acf" }, "nvim-tree.lua": { - "commit": "618ea25" + "commit": "6e0e70b" }, "nvim-treesitter": { - "commit": "9c1fb16" + "commit": "d79b169" }, "nvim-ts-context-commentstring": { "commit": "8834375" @@ -84,7 +84,7 @@ "commit": "4dedd3b" }, "plenary.nvim": { - "commit": "470d0e8" + "commit": "13f9959" }, "popup.nvim": { "commit": "b7404d3" @@ -93,7 +93,7 @@ "commit": "cef52b8" }, "schemastore.nvim": { - "commit": "597d8f6" + "commit": "c76b696" }, "structlog.nvim": { "commit": "6f1403a" @@ -102,7 +102,7 @@ "commit": "8ec164b" }, "telescope.nvim": { - "commit": "8af0d38" + "commit": "b7ae91c" }, "toggleterm.nvim": { "commit": "e62008f" -- cgit v1.2.3 From 3de6a404c92e495baa8688aa76d98c4ea9caa8c7 Mon Sep 17 00:00:00 2001 From: Abouzar Parvan Date: Mon, 11 Apr 2022 18:17:08 +0430 Subject: fix(luasnip): make sure all snippets are loaded (#2447) Co-authored-by: danielo515 --- lua/lvim/plugins.lua | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lua/lvim/plugins.lua b/lua/lvim/plugins.lua index 519a203a..29620009 100644 --- a/lua/lvim/plugins.lua +++ b/lua/lvim/plugins.lua @@ -69,7 +69,15 @@ local core_plugins = { { "L3MON4D3/LuaSnip", config = function() - require("luasnip/loaders/from_vscode").lazy_load() + local utils = require "lvim.utils" + require("luasnip.loaders.from_lua").lazy_load() + require("luasnip.loaders.from_vscode").lazy_load { + paths = { + utils.join_paths(get_config_dir(), "snippets"), + utils.join_paths(get_runtime_dir(), "site", "pack", "packer", "start", "friendly-snippets"), + }, + } + require("luasnip.loaders.from_snipmate").lazy_load() end, }, { -- cgit v1.2.3 From 1569202d39c40d7a44de5eb1b10cf203dd33af41 Mon Sep 17 00:00:00 2001 From: kylo252 <59826753+kylo252@users.noreply.github.com> Date: Tue, 12 Apr 2022 11:18:17 +0200 Subject: fix(impatient): avoid get_options in fast handler (#2451) --- lua/lvim/core/log.lua | 6 ++-- lua/lvim/impatient.lua | 4 +++ lua/lvim/plugins.lua | 2 ++ snapshots/default.json | 18 ++++++------ tests/specs/config_loader_spec.lua | 20 ++++++++++--- tests/specs/lsp_spec.lua | 57 +++++++++++++++++++------------------- tests/specs/plugins_load_spec.lua | 6 ++++ utils/ci/run_test.sh | 12 ++++---- 8 files changed, 75 insertions(+), 50 deletions(-) diff --git a/lua/lvim/core/log.lua b/lua/lvim/core/log.lua index d0e74f18..15ccb11c 100644 --- a/lua/lvim/core/log.lua +++ b/lua/lvim/core/log.lua @@ -1,7 +1,5 @@ local Log = {} -local logfile = string.format("%s/%s.log", get_cache_dir(), "lvim") - Log.levels = { TRACE = 1, DEBUG = 2, @@ -39,7 +37,7 @@ function Log:init() { level = structlog.formatters.FormatColorizer.color_level() } ), }), - structlog.sinks.File(log_level, logfile, { + structlog.sinks.File(log_level, self:get_path(), { processors = { structlog.processors.Namer(), structlog.processors.StackWriter({ "line", "file" }, { max_parents = 3, stack_level = 2 }), @@ -155,7 +153,7 @@ end ---Retrieves the path of the logfile ---@return string path of the logfile function Log:get_path() - return logfile + return string.format("%s/%s.log", get_cache_dir(), "lvim") end ---Add a log entry at TRACE level diff --git a/lua/lvim/impatient.lua b/lua/lvim/impatient.lua index 4fdc0026..230e5195 100644 --- a/lua/lvim/impatient.lua +++ b/lua/lvim/impatient.lua @@ -203,6 +203,10 @@ function M.update_reduced_rtp() end local function load_package_with_cache_reduced_rtp(name) + if vim.in_fast_event() then + -- Can't set/get options in the fast handler + return load_package_with_cache(name, "fast") + end local orig_rtp = get_option "runtimepath" local orig_ei = get_option "eventignore" diff --git a/lua/lvim/plugins.lua b/lua/lvim/plugins.lua index 29620009..f5b9914c 100644 --- a/lua/lvim/plugins.lua +++ b/lua/lvim/plugins.lua @@ -190,6 +190,7 @@ local core_plugins = { config = function() require("lvim.core.bufferline").setup() end, + branch = "main", event = "BufWinEnter", disable = not lvim.builtin.bufferline.active, }, @@ -225,6 +226,7 @@ local core_plugins = { { "akinsho/toggleterm.nvim", event = "BufWinEnter", + branch = "main", config = function() require("lvim.core.terminal").setup() end, diff --git a/snapshots/default.json b/snapshots/default.json index d7a77ca0..22754d39 100644 --- a/snapshots/default.json +++ b/snapshots/default.json @@ -15,7 +15,7 @@ "commit": "6655228" }, "bufferline.nvim": { - "commit": "e62008f" + "commit": "bb3ac30" }, "cmp-buffer": { "commit": "d66c4c2" @@ -33,7 +33,7 @@ "commit": "e302658" }, "gitsigns.nvim": { - "commit": "4a68d2a" + "commit": "ac5ba87" }, "lua-dev.nvim": { "commit": "a0ee777" @@ -42,13 +42,13 @@ "commit": "c8e5a69" }, "nlsp-settings.nvim": { - "commit": "956c8ad" + "commit": "c4afb0f" }, "null-ls.nvim": { "commit": "82be4bf" }, "nvim-autopairs": { - "commit": "06535b1" + "commit": "6fb0479" }, "nvim-cmp": { "commit": "3192a0c" @@ -57,19 +57,19 @@ "commit": "10b5781" }, "nvim-lsp-installer": { - "commit": "a6c2783" + "commit": "88f590c" }, "nvim-lspconfig": { "commit": "fd7843a" }, "nvim-notify": { - "commit": "0d02acf" + "commit": "9655936" }, "nvim-tree.lua": { - "commit": "6e0e70b" + "commit": "9c272b9" }, "nvim-treesitter": { - "commit": "d79b169" + "commit": "d0fc684" }, "nvim-ts-context-commentstring": { "commit": "8834375" @@ -105,7 +105,7 @@ "commit": "b7ae91c" }, "toggleterm.nvim": { - "commit": "e62008f" + "commit": "1a608cc" }, "which-key.nvim": { "commit": "a3c19ec" diff --git a/tests/specs/config_loader_spec.lua b/tests/specs/config_loader_spec.lua index 1f2debc7..40eaa350 100644 --- a/tests/specs/config_loader_spec.lua +++ b/tests/specs/config_loader_spec.lua @@ -4,16 +4,28 @@ local config = require "lvim.config" a.describe("config-loader", function() local user_config_path = config:get_user_config_path() + before_each(function() + vim.cmd [[ + let v:errmsg = "" + let v:errors = [] + ]] + end) + + after_each(function() + local errmsg = vim.fn.eval "v:errmsg" + local exception = vim.fn.eval "v:exception" + local errors = vim.fn.eval "v:errors" + assert.equal("", errmsg) + assert.equal("", exception) + assert.True(vim.tbl_isempty(errors)) + end) + a.it("should be able to find user-config", function() assert.equal(user_config_path, get_config_dir() .. "/config.lua") end) a.it("should be able to load user-config without errors", function() config:load(user_config_path) - local errmsg = vim.fn.eval "v:errmsg" - local exception = vim.fn.eval "v:exception" - assert.equal("", errmsg) -- v:errmsg was not updated. - assert.equal("", exception) end) a.it("should be able to reload user-config without errors", function() diff --git a/tests/specs/lsp_spec.lua b/tests/specs/lsp_spec.lua index 2518b237..7d9a3386 100644 --- a/tests/specs/lsp_spec.lua +++ b/tests/specs/lsp_spec.lua @@ -1,12 +1,26 @@ local a = require "plenary.async_lib.tests" local utils = require "lvim.utils" local helpers = require "tests.lvim.helpers" -local temp_dir = vim.loop.os_getenv "TEMP" or "/tmp" -lvim.lsp.templates_dir = join_paths(temp_dir, "lvim", "tests", "artifacts") +local spy = require "luassert.spy" a.describe("lsp workflow", function() - local Log = require "lvim.core.log" - local logfile = Log:get_path() + before_each(function() + vim.cmd [[ + let v:errmsg = "" + let v:errors = [] + ]] + end) + + after_each(function() + local errmsg = vim.fn.eval "v:errmsg" + local exception = vim.fn.eval "v:exception" + local errors = vim.fn.eval "v:errors" + assert.equal("", errmsg) + assert.equal("", exception) + assert.True(vim.tbl_isempty(errors)) + end) + + lvim.lsp.templates_dir = join_paths(get_cache_dir(), "artifacts") a.it("should be able to delete ftplugin templates", function() if utils.is_directory(lvim.lsp.templates_dir) then @@ -19,35 +33,13 @@ a.describe("lsp workflow", function() if utils.is_directory(lvim.lsp.templates_dir) then assert.equal(vim.fn.delete(lvim.lsp.templates_dir, "rf"), 0) end - require("lvim.lsp").setup() - - -- we need to delay this check until the generation is completed - vim.schedule(function() - assert.True(utils.is_directory(lvim.lsp.templates_dir)) - end) - end) - a.it("should not attempt to re-generate ftplugin templates", function() - lvim.log.level = "debug" - - local plugins = require "lvim.plugins" - require("lvim.plugin-loader").load { plugins, lvim.plugins } - - if utils.is_file(logfile) then - assert.equal(vim.fn.delete(logfile), 0) - end - - assert.True(utils.is_directory(lvim.lsp.templates_dir)) require("lvim.lsp").setup() - -- we need to delay this check until the log gets populated - vim.schedule(function() - assert.False(helpers.log_contains "templates") - end) + assert.True(utils.is_directory(lvim.lsp.templates_dir)) end) a.it("should not include blacklisted servers in the generated templates", function() - assert.True(utils.is_directory(lvim.lsp.templates_dir)) require("lvim.lsp").setup() for _, file in ipairs(vim.fn.glob(lvim.lsp.templates_dir .. "/*.lua", 1, 1)) do @@ -59,7 +51,6 @@ a.describe("lsp workflow", function() end) a.it("should only include one server per generated template", function() - assert.True(utils.is_directory(lvim.lsp.templates_dir)) require("lvim.lsp").setup() for _, file in ipairs(vim.fn.glob(lvim.lsp.templates_dir .. "/*.lua", 1, 1)) do @@ -78,4 +69,14 @@ a.describe("lsp workflow", function() assert.equal(err_msg, "") end end) + + a.it("should not attempt to re-generate ftplugin templates", function() + local s = spy.on(require "lvim.lsp.templates", "generate_templates") + local plugins = require "lvim.plugins" + require("lvim.plugin-loader").load { plugins, lvim.plugins } + + require("lvim.lsp").setup() + assert.spy(s).was_not_called() + s:revert() + end) end) diff --git a/tests/specs/plugins_load_spec.lua b/tests/specs/plugins_load_spec.lua index d32c521d..1f11279e 100644 --- a/tests/specs/plugins_load_spec.lua +++ b/tests/specs/plugins_load_spec.lua @@ -4,6 +4,12 @@ a.describe("plugin-loader", function() local plugins = require "lvim.plugins" local loader = require "lvim.plugin-loader" + pcall(function() + lvim.log.level = "debug" + package.loaded["packer.log"] = nil + package.loaded["lvim.core.log"] = nil + end) + a.it("should be able to load default packages without errors", function() loader.load { plugins, lvim.plugins } diff --git a/utils/ci/run_test.sh b/utils/ci/run_test.sh index 5b7f81ac..b12ceb7e 100644 --- a/utils/ci/run_test.sh +++ b/utils/ci/run_test.sh @@ -6,10 +6,14 @@ export LUNARVIM_RUNTIME_DIR="${LUNARVIM_RUNTIME_DIR:-"$HOME/.local/share/lunarvi export LVIM_TEST_ENV=true # we should start with an empty configuration -TEST_BASE_DIR="$(mktemp -d)" +LUNARVIM_CONFIG_DIR="$(mktemp -d)" +LUNARVIM_CACHE_DIR="$(mktemp -d)" -export LUNARVIM_CONFIG_DIR="$TEST_BASE_DIR" -export LUNARVIM_CACHE_DIR="$TEST_BASE_DIR" +export LUNARVIM_CONFIG_DIR LUNARVIM_CACHE_DIR + +echo "cache: $LUNARVIM_CACHE_DIR + +config: $LUNARVIM_CONFIG_DIR" lvim() { nvim -u "$LUNARVIM_RUNTIME_DIR/lvim/tests/minimal_init.lua" --cmd "set runtimepath+=$LUNARVIM_RUNTIME_DIR/lvim" "$@" @@ -20,5 +24,3 @@ if [ -n "$1" ]; then else lvim --headless -c "PlenaryBustedDirectory tests/specs { minimal_init = './tests/minimal_init.lua' }" fi - -rm -rf "$TEST_BASE_DIR" -- cgit v1.2.3 From 0fa5a5db499dbfe34e5e3582168fe3d1e6e896dc Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 13 Apr 2022 14:33:21 +0430 Subject: chore: bump plugins version (#2448) --- snapshots/default.json | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/snapshots/default.json b/snapshots/default.json index 22754d39..99584487 100644 --- a/snapshots/default.json +++ b/snapshots/default.json @@ -33,16 +33,16 @@ "commit": "e302658" }, "gitsigns.nvim": { - "commit": "ac5ba87" + "commit": "f2e9e30" }, "lua-dev.nvim": { "commit": "a0ee777" }, "lualine.nvim": { - "commit": "c8e5a69" + "commit": "385580e" }, "nlsp-settings.nvim": { - "commit": "c4afb0f" + "commit": "21a00be" }, "null-ls.nvim": { "commit": "82be4bf" @@ -57,7 +57,7 @@ "commit": "10b5781" }, "nvim-lsp-installer": { - "commit": "88f590c" + "commit": "39f84cd" }, "nvim-lspconfig": { "commit": "fd7843a" @@ -66,10 +66,10 @@ "commit": "9655936" }, "nvim-tree.lua": { - "commit": "9c272b9" + "commit": "477536c" }, "nvim-treesitter": { - "commit": "d0fc684" + "commit": "05ba924" }, "nvim-ts-context-commentstring": { "commit": "8834375" @@ -93,7 +93,7 @@ "commit": "cef52b8" }, "schemastore.nvim": { - "commit": "c76b696" + "commit": "71a0a25" }, "structlog.nvim": { "commit": "6f1403a" -- cgit v1.2.3 From b4d5f093a5607d3f14cbf90aebfb25036c3ee272 Mon Sep 17 00:00:00 2001 From: FADHsquared <77851256+FADHsquared@users.noreply.github.com> Date: Thu, 14 Apr 2022 17:15:54 +0700 Subject: docs(windows): use alpha in config_win.example.lua (#2452) --- utils/installer/config_win.example.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/utils/installer/config_win.example.lua b/utils/installer/config_win.example.lua index ecfbd1e4..ffb51c9f 100644 --- a/utils/installer/config_win.example.lua +++ b/utils/installer/config_win.example.lua @@ -70,7 +70,8 @@ lvim.keys.normal_mode[""] = ":w" -- } -- After changing plugin config exit and reopen LunarVim, Run :PackerInstall :PackerCompile -lvim.builtin.dashboard.active = true +lvim.builtin.alpha.active = true +lvim.builtin.alpha.mode = "dashboard" lvim.builtin.notify.active = true lvim.builtin.terminal.active = false -- lvim.builtin.terminal.shell = "pwsh.exe -NoLogo" -- cgit v1.2.3 From 332e974b53d8053a7102f669141cdc054d3f20d5 Mon Sep 17 00:00:00 2001 From: Abouzar Parvan Date: Thu, 14 Apr 2022 23:17:06 +0430 Subject: feat(cmp): documentation is deprecated in favor of window.documentation (#2461) --- lua/lvim/core/cmp.lua | 5 +++-- snapshots/default.json | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lua/lvim/core/cmp.lua b/lua/lvim/core/cmp.lua index 621e2b6d..8fb18c5f 100644 --- a/lua/lvim/core/cmp.lua +++ b/lua/lvim/core/cmp.lua @@ -232,8 +232,9 @@ M.config = function() require("luasnip").lsp_expand(args.body) end, }, - documentation = { - border = { "╭", "─", "╮", "│", "╯", "─", "╰", "│" }, + window = { + completion = cmp.config.window.bordered(), + documentation = cmp.config.window.bordered(), }, sources = { { name = "nvim_lsp" }, diff --git a/snapshots/default.json b/snapshots/default.json index 99584487..eb242de0 100644 --- a/snapshots/default.json +++ b/snapshots/default.json @@ -51,7 +51,7 @@ "commit": "6fb0479" }, "nvim-cmp": { - "commit": "3192a0c" + "commit": "dbc7229" }, "nvim-dap": { "commit": "10b5781" -- cgit v1.2.3 From 198577aa756acdbbacc81e3953bc7e790277a8e6 Mon Sep 17 00:00:00 2001 From: kylo252 <59826753+kylo252@users.noreply.github.com> Date: Thu, 14 Apr 2022 20:47:22 +0200 Subject: refactor(lsp): cleanup servers' override configuration (#2243) * refactor(lsp): cleanup override settings - rename lsp.override to lsp.automatic_configuration.ignored_servers - add lsp.automatic_configuration.ignored_filetypes * chore(info): update override section * refactor(lsp): rename ignored to skipped * fix: better deprecation handling * docs(lsp): add example for (un-)skipping servers * refactor(lsp): allow installing overridden servers * docs(lsp): update config_win.example.lua as well * chore(lsp): update skipped_servers list * fix(logger): less noise from client_is_configured --- lua/lvim/config/init.lua | 29 ++++++----- lua/lvim/core/info.lua | 30 +++++++----- lua/lvim/lsp/config.lua | 89 ++++++++++++++++++---------------- lua/lvim/lsp/manager.lua | 6 +-- lua/lvim/lsp/templates.lua | 12 +++-- utils/installer/config.example.lua | 16 +++--- utils/installer/config_win.example.lua | 16 +++--- 7 files changed, 115 insertions(+), 83 deletions(-) diff --git a/lua/lvim/config/init.lua b/lua/lvim/config/init.lua index 6927d52a..505029a2 100644 --- a/lua/lvim/config/init.lua +++ b/lua/lvim/config/init.lua @@ -56,19 +56,19 @@ function M:init() end local function handle_deprecated_settings() - local function deprecation_notice(setting, msg) + local function deprecation_notice(setting, new_setting) local in_headless = #vim.api.nvim_list_uis() == 0 if in_headless then return end - msg = msg - or string.format( - "Deprecation notice: [%s] setting is no longer supported. See https://github.com/LunarVim/LunarVim#breaking-changes", - setting - ) + local msg = string.format( + "Deprecation notice: [%s] setting is no longer supported. %s", + setting, + new_setting or "See https://github.com/LunarVim/LunarVim#breaking-changes" + ) vim.schedule(function() - Log:warn(msg) + vim.notify_once(msg, vim.log.levels.WARN) end) end @@ -80,6 +80,16 @@ local function handle_deprecated_settings() end end + -- lvim.lsp.override + if lvim.lsp.override and not vim.tbl_isempty(lvim.lsp.override) then + deprecation_notice("lvim.lsp.override", "Use `lvim.lsp.automatic_configuration.skipped_servers` instead") + vim.tbl_map(function(c) + if not vim.tbl_contains(lvim.lsp.automatic_configuration.skipped_servers, c) then + table.insert(lvim.lsp.automatic_configuration.skipped_servers, c) + end + end, lvim.lsp.override) + end + -- lvim.lsp.popup_border if vim.tbl_contains(vim.tbl_keys(lvim.lsp), "popup_border") then deprecation_notice "lvim.lsp.popup_border" @@ -87,10 +97,7 @@ local function handle_deprecated_settings() -- dashboard.nvim if lvim.builtin.dashboard.active then - deprecation_notice( - "dashboard", - "Deprecation notice: `lvim.builtin.dashboard` has been replaced with `lvim.builtin.alpha`. See LunarVim#1906" - ) + deprecation_notice("lvim.builtin.dashboard", "Use `lvim.builtin.alpha` instead. See LunarVim#1906") end end diff --git a/lua/lvim/core/info.lua b/lua/lvim/core/info.lua index 9c9652da..00a7e85a 100644 --- a/lua/lvim/core/info.lua +++ b/lua/lvim/core/info.lua @@ -100,21 +100,26 @@ local function make_client_info(client) return client_info end -local function make_override_info(ft) +local function make_auto_lsp_info(ft) + local skipped_filetypes = lvim.lsp.automatic_configuration.skipped_filetypes + local skipped_servers = lvim.lsp.automatic_configuration.skipped_servers + local info_lines = { "Automatic LSP info" } + + if vim.tbl_contains(skipped_filetypes, ft) then + vim.list_extend(info_lines, { "* Status: disabled for " .. ft }) + return info_lines + end + local available = lsp_utils.get_supported_servers_per_filetype(ft) - local overridden = vim.tbl_filter(function(name) + local skipped = vim.tbl_filter(function(name) return vim.tbl_contains(available, name) - end, lvim.lsp.override) + end, skipped_servers) - local info_lines = { "" } - if #overridden == 0 then - return info_lines + if #skipped == 0 then + return { "" } end - info_lines = { - fmt("Overridden %s server(s)", ft), - fmt("* list: %s", str_list(overridden)), - } + vim.list_extend(info_lines, { fmt("* Skipped servers: %s", str_list(skipped)) }) return info_lines end @@ -150,7 +155,7 @@ function M.toggle_popup(ft) table.insert(client_names, client.name) end - local override_info = make_override_info(ft) + local auto_lsp_info = make_auto_lsp_info(ft) local formatters_info = make_formatters_info(ft) @@ -169,7 +174,7 @@ function M.toggle_popup(ft) { "" }, lsp_info, { "" }, - override_info, + auto_lsp_info, { "" }, formatters_info, { "" }, @@ -192,6 +197,7 @@ function M.toggle_popup(ft) vim.fn.matchadd("LvimInfoHeader", "Formatters info") vim.fn.matchadd("LvimInfoHeader", "Linters info") vim.fn.matchadd("LvimInfoHeader", "Code actions info") + vim.fn.matchadd("LvimInfoHeader", "Automatic LSP info") vim.fn.matchadd("LvimInfoIdentifier", " " .. ft .. "$") vim.fn.matchadd("string", "true") vim.fn.matchadd("string", "active") diff --git a/lua/lvim/lsp/config.lua b/lua/lvim/lsp/config.lua index 986cb500..182f8fbf 100644 --- a/lua/lvim/lsp/config.lua +++ b/lua/lvim/lsp/config.lua @@ -1,3 +1,43 @@ +local skipped_servers = { + "angularls", + "ansiblels", + "ccls", + "csharp_ls", + "cssmodules_ls", + "denols", + "ember", + "emmet_ls", + "eslint", + "eslintls", + "golangci_lint_ls", + "graphql", + "jedi_language_server", + "ltex", + "ocamlls", + "phpactor", + "psalm", + "pylsp", + "quick_lint_js", + "rome", + "reason_ls", + "scry", + "solang", + "solidity_ls", + "sorbet", + "sourcekit", + "sourcery", + "spectral", + "sqlls", + "sqls", + "stylelint_lsp", + "tailwindcss", + "tflint", + "verible", + "vuels", +} + +local skipped_filetypes = { "markdown", "rst", "plaintext" } + return { templates_dir = join_paths(get_runtime_dir(), "site", "after", "ftplugin"), diagnostics = { @@ -41,6 +81,12 @@ return { on_attach_callback = nil, on_init_callback = nil, automatic_servers_installation = true, + automatic_configuration = { + ---@usage list of servers that the automatic installer will skip + skipped_servers = skipped_servers, + ---@usage list of filetypes that the automatic installer will skip + skipped_filetypes = skipped_filetypes, + }, buffer_mappings = { normal_mode = { ["K"] = { "lua vim.lsp.buf.hover()", "Show hover" }, @@ -62,45 +108,6 @@ return { setup = {}, config = {}, }, - override = { - "angularls", - "ansiblels", - "ccls", - "csharp_ls", - "cssmodules_ls", - "denols", - "ember", - "emmet_ls", - "eslint", - "eslintls", - "golangci_lint_ls", - "grammarly", - "graphql", - "jedi_language_server", - "ltex", - "ocamlls", - "phpactor", - "psalm", - "pylsp", - "quick_lint_js", - "reason_ls", - "remark_ls", - "rome", - "scry", - "solang", - "solidity_ls", - "sorbet", - "sourcekit", - "sourcery", - "spectral", - "sqlls", - "sqls", - "stylelint_lsp", - "tailwindcss", - "tflint", - "verible", - "vuels", - "zeta_note", - "zk", - }, + ---@deprecated use automatic_configuration.skipped_servers instead + override = {}, } diff --git a/lua/lvim/lsp/manager.lua b/lua/lvim/lsp/manager.lua index 6c748020..09369d48 100644 --- a/lua/lvim/lsp/manager.lua +++ b/lua/lvim/lsp/manager.lua @@ -55,6 +55,7 @@ local function client_is_configured(server_name, ft) local active_autocmds = vim.split(vim.fn.execute("autocmd FileType " .. ft), "\n") for _, result in ipairs(active_autocmds) do if result:match(server_name) then + Log:debug(string.format("[%q] is already configured", server_name)) return true end end @@ -68,7 +69,6 @@ function M.setup(server_name, user_config) vim.validate { name = { server_name, "string" } } if lvim_lsp_utils.is_client_active(server_name) or client_is_configured(server_name) then - Log:debug(string.format("[%q] is already configured. Ignoring repeated setup call.", server_name)) return end @@ -77,9 +77,7 @@ function M.setup(server_name, user_config) local servers = require "nvim-lsp-installer.servers" local server_available, requested_server = servers.get_server(server_name) - local is_overridden = vim.tbl_contains(lvim.lsp.override, server_name) - - if not server_available or is_overridden then + if not server_available then pcall(function() require("lspconfig")[server_name].setup(config) buf_try_add(server_name) diff --git a/lua/lvim/lsp/templates.lua b/lua/lvim/lsp/templates.lua index eb05615e..38e68fb6 100644 --- a/lua/lvim/lsp/templates.lua +++ b/lua/lvim/lsp/templates.lua @@ -15,16 +15,22 @@ function M.remove_template_files() end end +local skipped_filetypes = lvim.lsp.automatic_configuration.skipped_filetypes +local skipped_servers = lvim.lsp.automatic_configuration.skipped_servers + ---Generates an ftplugin file based on the server_name in the selected directory ---@param server_name string name of a valid language server, e.g. pyright, gopls, tsserver, etc. ---@param dir string the full path to the desired directory function M.generate_ftplugin(server_name, dir) - if vim.tbl_contains(lvim.lsp.override, server_name) then + if vim.tbl_contains(skipped_servers, server_name) then return end - -- we need to go through lspconfig to get the corresponding filetypes currently - local filetypes = lvim_lsp_utils.get_supported_filetypes(server_name) or {} + -- get the supported filetypes and remove any ignored ones + local filetypes = vim.tbl_filter(function(ft) + return not vim.tbl_contains(skipped_filetypes, ft) + end, lvim_lsp_utils.get_supported_filetypes(server_name) or {}) + if not filetypes then return end diff --git a/utils/installer/config.example.lua b/utils/installer/config.example.lua index 409235a5..61c2f915 100644 --- a/utils/installer/config.example.lua +++ b/utils/installer/config.example.lua @@ -85,13 +85,17 @@ lvim.builtin.treesitter.highlight.enabled = true -- ---@usage disable automatic installation of servers -- lvim.lsp.automatic_servers_installation = false --- ---@usage Select which servers should be configured manually. Requires `:LvimCacheReset` to take effect. --- See the full default list `:lua print(vim.inspect(lvim.lsp.override))` --- vim.list_extend(lvim.lsp.override, { "pyright" }) - --- ---@usage setup a server -- see: https://www.lunarvim.org/languages/#overriding-the-default-configuration +-- ---configure a server manually. !!Requires `:LvimCacheReset` to take effect!! +-- ---see the full default list `:lua print(vim.inspect(lvim.lsp.automatic_configuration.skipped_servers))` +-- vim.list_extend(lvim.lsp.automatic_configuration.skipped_servers, { "pyright" }) -- local opts = {} -- check the lspconfig documentation for a list of all possible options --- require("lvim.lsp.manager").setup("pylsp", opts) +-- require("lvim.lsp.manager").setup("pyright", opts) + +-- ---remove a server from the skipped list, e.g. eslint, or emmet_ls. !!Requires `:LvimCacheReset` to take effect!! +-- ---`:LvimInfo` lists which server(s) are skiipped for the current filetype +-- vim.tbl_map(function(server) +-- return server ~= "emmet_ls" +-- end, lvim.lsp.automatic_configuration.skipped_servers) -- -- you can set a custom on_attach function that will be used for all the language servers -- -- See diff --git a/utils/installer/config_win.example.lua b/utils/installer/config_win.example.lua index ffb51c9f..c6bf470e 100644 --- a/utils/installer/config_win.example.lua +++ b/utils/installer/config_win.example.lua @@ -100,13 +100,17 @@ lvim.builtin.treesitter.highlight.enabled = true -- ---@usage disable automatic installation of servers -- lvim.lsp.automatic_servers_installation = false --- ---@usage Select which servers should be configured manually. Requires `:LvimCacheRest` to take effect. --- See the full default list `:lua print(vim.inspect(lvim.lsp.override))` --- vim.list_extend(lvim.lsp.override, { "pyright" }) - --- ---@usage setup a server -- see: https://www.lunarvim.org/languages/#overriding-the-default-configuration +-- ---configure a server manually. !!Requires `:LvimCacheReset` to take effect!! +-- ---see the full default list `:lua print(vim.inspect(lvim.lsp.automatic_configuration.skipped_servers))` +-- vim.list_extend(lvim.lsp.automatic_configuration.skipped_servers, { "pyright" }) -- local opts = {} -- check the lspconfig documentation for a list of all possible options --- require("lvim.lsp.manager").setup("pylsp", opts) +-- require("lvim.lsp.manager").setup("pyright", opts) + +-- ---remove a server from the skipped list, e.g. eslint, or emmet_ls. !!Requires `:LvimCacheReset` to take effect!! +-- ---`:LvimInfo` lists which server(s) are skiipped for the current filetype +-- vim.tbl_map(function(server) +-- return server ~= "emmet_ls" +-- end, lvim.lsp.automatic_configuration.skipped_servers) -- -- you can set a custom on_attach function that will be used for all the language servers -- -- See -- cgit v1.2.3 From 09684eff642eb455bffda3100f29ef182f734a82 Mon Sep 17 00:00:00 2001 From: Abouzar Parvan Date: Thu, 14 Apr 2022 23:19:43 +0430 Subject: fix(readme): update lsp server ignore syntax --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7d6a4a45..41a011ac 100644 --- a/README.md +++ b/README.md @@ -91,7 +91,7 @@ lvim.lsp.diagnostics.virtual_text = false -- Select which servers should be configured manually. Requires `:LvimCacheReset` to take effect. -- See the full default list `:lua print(vim.inspect(lvim.lsp.override))` -vim.list_extend(lvim.lsp.override, { "pyright" }) +vim.list_extend(lvim.lsp.automatic_configuration.skipped_servers, { "pyright" }) -- set a formatter, this will override the language server formatting capabilities (if it exists) local formatters = require "lvim.lsp.null-ls.formatters" -- cgit v1.2.3