From a5095db20d5bd4e8ce946ef7d1ea18e15b86bd23 Mon Sep 17 00:00:00 2001 From: Benedikt Schnatterbeck Date: Mon, 1 Aug 2022 20:13:48 +0100 Subject: feat(whichkey): add default keybindings to cycle to next buffer (#2873) --- lua/lvim/core/which-key.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/lvim/core/which-key.lua b/lua/lvim/core/which-key.lua index 3015781b..8f0f964f 100644 --- a/lua/lvim/core/which-key.lua +++ b/lua/lvim/core/which-key.lua @@ -1,5 +1,4 @@ local M = {} - M.config = function() lvim.builtin.which_key = { ---@usage disable which-key completely [not recommended] @@ -92,6 +91,7 @@ M.config = function() j = { "BufferLinePick", "Jump" }, f = { "Telescope buffers", "Find" }, b = { "BufferLineCyclePrev", "Previous" }, + n = { "BufferLineCycleNext", "Next" }, -- w = { "BufferWipeout", "Wipeout" }, -- TODO: implement this for bufferline e = { "BufferLinePickClose", -- cgit v1.2.3 From eefde00ae80f91ecf88a93e869e346fdd04c7ba4 Mon Sep 17 00:00:00 2001 From: kylo252 <59826753+kylo252@users.noreply.github.com> Date: Tue, 9 Aug 2022 10:41:17 +0200 Subject: refactor!: migrate to mason.nvim (#2880) --- lua/lvim/config/init.lua | 7 +++++ lua/lvim/core/builtins/init.lua | 1 + lua/lvim/core/info.lua | 4 +-- lua/lvim/core/mason.lua | 41 +++++++++++++++++++++++++ lua/lvim/core/which-key.lua | 2 +- lua/lvim/lsp/config.lua | 13 +++----- lua/lvim/lsp/init.lua | 5 ++- lua/lvim/lsp/manager.lua | 67 ++++++++++++++++++++++++++++++----------- lua/lvim/lsp/templates.lua | 11 +------ lua/lvim/lsp/utils.lua | 29 ++++++++---------- lua/lvim/plugins.lua | 6 +++- snapshots/default.json | 9 ++++-- tests/minimal_lsp.lua | 59 +++++++++++++++++------------------- tests/specs/lsp_spec.lua | 6 +++- 14 files changed, 168 insertions(+), 92 deletions(-) create mode 100644 lua/lvim/core/mason.lua diff --git a/lua/lvim/config/init.lua b/lua/lvim/config/init.lua index 4343ace9..c6765f56 100644 --- a/lua/lvim/config/init.lua +++ b/lua/lvim/config/init.lua @@ -99,6 +99,13 @@ local function handle_deprecated_settings() "Use vim.api.nvim_create_autocmd instead or check LunarVim#2592 to learn about the new syntax" ) end + + if lvim.lsp.automatic_servers_installation then + deprecation_notice( + "lvim.lsp.automatic_servers_installation", + "Use `lvim.lsp.installer.setup.automatic_installation` instead" + ) + end end --- Override the configuration with a user provided one diff --git a/lua/lvim/core/builtins/init.lua b/lua/lvim/core/builtins/init.lua index e219d45e..5cad2a00 100644 --- a/lua/lvim/core/builtins/init.lua +++ b/lua/lvim/core/builtins/init.lua @@ -16,6 +16,7 @@ local builtins = { "lvim.core.notify", "lvim.core.lualine", "lvim.core.alpha", + "lvim.core.mason", } function M.config(config) diff --git a/lua/lvim/core/info.lua b/lua/lvim/core/info.lua index ac7d690a..da9ddbe6 100644 --- a/lua/lvim/core/info.lua +++ b/lua/lvim/core/info.lua @@ -111,9 +111,9 @@ local function make_auto_lsp_info(ft) return info_lines end - local available = lsp_utils.get_supported_servers_per_filetype(ft) + local supported = lsp_utils.get_supported_servers(ft) local skipped = vim.tbl_filter(function(name) - return vim.tbl_contains(available, name) + return vim.tbl_contains(supported, name) end, skipped_servers) if #skipped == 0 then diff --git a/lua/lvim/core/mason.lua b/lua/lvim/core/mason.lua new file mode 100644 index 00000000..39be4f42 --- /dev/null +++ b/lua/lvim/core/mason.lua @@ -0,0 +1,41 @@ +local M = {} + +function M.config() + lvim.builtin.mason = { + ui = { + keymaps = { + toggle_package_expand = "", + install_package = "i", + update_package = "u", + check_package_version = "c", + update_all_packages = "U", + check_outdated_packages = "C", + uninstall_package = "X", + cancel_installation = "", + apply_language_filter = "", + }, + }, + log_level = vim.log.levels.INFO, + max_concurrent_installers = 4, + + github = { + -- The template URL to use when downloading assets from GitHub. + -- The placeholders are the following (in order): + -- 1. The repository (e.g. "rust-lang/rust-analyzer") + -- 2. The release version (e.g. "v0.3.0") + -- 3. The asset name (e.g. "rust-analyzer-v0.3.0-x86_64-unknown-linux-gnu.tar.gz") + download_url_template = "https://github.com/%s/releases/download/%s/%s", + }, + } +end + +function M.setup() + local status_ok, mason = pcall(require, "mason") + if not status_ok then + return + end + + mason.setup(lvim.builtin.mason) +end + +return M diff --git a/lua/lvim/core/which-key.lua b/lua/lvim/core/which-key.lua index 8f0f964f..6d0dc9fc 100644 --- a/lua/lvim/core/which-key.lua +++ b/lua/lvim/core/which-key.lua @@ -160,7 +160,7 @@ M.config = function() w = { "Telescope diagnostics", "Diagnostics" }, f = { require("lvim.lsp.utils").format, "Format" }, i = { "LspInfo", "Info" }, - I = { "LspInstallInfo", "Installer Info" }, + I = { "Mason", "Mason Info" }, j = { vim.diagnostic.goto_next, "Next Diagnostic", diff --git a/lua/lvim/lsp/config.lua b/lua/lvim/lsp/config.lua index e3cd503b..41290787 100644 --- a/lua/lvim/lsp/config.lua +++ b/lua/lvim/lsp/config.lua @@ -88,7 +88,6 @@ 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, @@ -131,12 +130,8 @@ return { installer = { setup = { ensure_installed = {}, - ui = { - icons = { - server_installed = "✓", - server_pending = "", - server_uninstalled = "✗", - }, + automatic_installation = { + exclude = {}, }, }, }, @@ -153,6 +148,8 @@ return { setup = {}, config = {}, }, - ---@deprecated use automatic_configuration.skipped_servers instead + ---@deprecated use lvim.lsp.automatic_configuration.skipped_servers instead override = {}, + ---@deprecated use lvim.lsp.installer.setup.automatic_installation instead + automatic_servers_installation = nil, } diff --git a/lua/lvim/lsp/init.lua b/lua/lvim/lsp/init.lua index 53b4f248..0b361972 100644 --- a/lua/lvim/lsp/init.lua +++ b/lua/lvim/lsp/init.lua @@ -110,7 +110,10 @@ function M.setup() end) pcall(function() - require("nvim-lsp-installer").setup(lvim.lsp.installer.setup) + require("mason-lspconfig").setup(lvim.lsp.installer.setup) + local util = require "lspconfig.util" + -- automatic_installation is handled by lsp-manager + util.on_setup = nil end) require("lvim.lsp.null-ls").setup() diff --git a/lua/lvim/lsp/manager.lua b/lua/lvim/lsp/manager.lua index 00643815..aa76af6c 100644 --- a/lua/lvim/lsp/manager.lua +++ b/lua/lvim/lsp/manager.lua @@ -1,7 +1,30 @@ local M = {} local Log = require "lvim.core.log" +local fmt = string.format local lvim_lsp_utils = require "lvim.lsp.utils" +local is_windows = vim.loop.os_uname().version:match "Windows" + +local function resolve_mason_config(server_name) + local found, mason_config = pcall(require, "mason-lspconfig.server_configurations." .. server_name) + if not found then + Log:debug(fmt("mason configuration not found for %s", server_name)) + return {} + end + local server_mapping = require "mason-lspconfig.mappings.server" + local path = require "mason-core.path" + local pkg_name = server_mapping.lspconfig_to_package[server_name] + local install_dir = path.package_prefix(pkg_name) + local conf = mason_config(install_dir) + if is_windows and conf.cmd and conf.cmd[1] then + local exepath = vim.fn.exepath(conf.cmd[1]) + if exepath ~= "" then + conf.cmd[1] = exepath + end + end + Log:debug(fmt("resolved mason configuration for %s, got %s", server_name, vim.inspect(mason_config))) + return mason_config or {} +end ---Resolve the configuration for a server by merging with the default config ---@param server_name string @@ -65,35 +88,45 @@ function M.setup(server_name, user_config) return end - local servers = require "nvim-lsp-installer.servers" - local server_available, server = servers.get_server(server_name) + local server_mapping = require "mason-lspconfig.mappings.server" + local registry = require "mason-registry" - if not server_available then + local pkg_name = server_mapping.lspconfig_to_package[server_name] + if not pkg_name then local config = resolve_config(server_name, user_config) launch_server(server_name, config) return end - local install_in_progress = false + local should_auto_install = function() + local installer_settings = lvim.lsp.installer.setup + return installer_settings.automatic_installation + and not vim.tbl_contains(installer_settings.automatic_installation.exclude, server_name) + end - if not server:is_installed() then - if lvim.lsp.automatic_servers_installation then + if not registry.is_installed(pkg_name) then + if should_auto_install(server_name) then Log:debug "Automatic server installation detected" - server:install() - install_in_progress = true + vim.notify_once(string.format("Installation in progoress for [%s] server", server_name), vim.log.levels.INFO) + local pkg = registry.get_package(pkg_name) + pkg:install():once("closed", function() + if pkg:is_installed() then + vim.schedule(function() + vim.notify_once(string.format("Installation complete for [%s] server", server_name), vim.log.levels.INFO) + -- mason config is only available once the server has been installed + local config = resolve_config(server_name, resolve_mason_config(server_name), user_config) + launch_server(server_name, config) + end) + end + end) + return else - Log:debug(server.name .. " is not managed by the automatic installer") + Log:debug(server_name .. " is not managed by the automatic installer") end end - server:on_ready(function() - if install_in_progress then - vim.notify(string.format("Installation complete for [%s] server", server.name), vim.log.levels.INFO) - end - install_in_progress = false - local config = resolve_config(server_name, server:get_default_options(), user_config) - launch_server(server_name, config) - end) + local config = resolve_config(server_name, resolve_mason_config(server_name), user_config) + launch_server(server_name, config) end return M diff --git a/lua/lvim/lsp/templates.lua b/lua/lvim/lsp/templates.lua index 578362a7..dc2e5b11 100644 --- a/lua/lvim/lsp/templates.lua +++ b/lua/lvim/lsp/templates.lua @@ -56,21 +56,12 @@ end ---The files are generated to a runtimepath: "$LUNARVIM_RUNTIME_DIR/site/after/ftplugin/template.lua" ---@param servers_names? table list of servers to be enabled. Will add all by default function M.generate_templates(servers_names) - servers_names = servers_names or {} + servers_names = servers_names or lvim_lsp_utils.get_supported_servers() Log:debug "Templates installation in progress" M.remove_template_files() - if vim.tbl_isempty(servers_names) then - local available_servers = require("nvim-lsp-installer.servers").get_available_servers() - - for _, server in pairs(available_servers) do - table.insert(servers_names, server.name) - table.sort(servers_names) - end - end - -- create the directory if it didn't exist if not utils.is_directory(lvim.lsp.templates_dir) then vim.fn.mkdir(ftplugin_dir, "p") diff --git a/lua/lvim/lsp/utils.lua b/lua/lvim/lsp/utils.lua index fa1ac6d9..b92ef11c 100644 --- a/lua/lvim/lsp/utils.lua +++ b/lua/lvim/lsp/utils.lua @@ -51,37 +51,34 @@ end ---Get supported filetypes per server ---@param server_name string can be any server supported by nvim-lsp-installer ----@return table supported filestypes as a list of strings +---@return string[] supported filestypes as a list of strings function M.get_supported_filetypes(server_name) - local status_ok, lsp_installer_servers = pcall(require, "nvim-lsp-installer.servers") + local status_ok, config = pcall(require, ("lspconfig.server_configurations.%s"):format(server_name)) if not status_ok then return {} end - local server_available, requested_server = lsp_installer_servers.get_server(server_name) - if not server_available then - return {} - end - - return requested_server:get_supported_filetypes() + return config.default_config.filetypes or {} end ---Get supported servers per filetype ----@param filetype string ----@return table list of names of supported servers -function M.get_supported_servers_per_filetype(filetype) - local filetype_server_map = require "nvim-lsp-installer._generated.filetype_map" - return filetype_server_map[filetype] +---@param filter { filetype: string | string[] }?: (optional) Used to filter the list of server names. +---@return string[] list of names of supported servers +function M.get_supported_servers(filter) + local _, supported_servers = pcall(function() + return require("mason-lspconfig").get_available_servers(filter) + end) + return supported_servers or {} end ---Get all supported filetypes by nvim-lsp-installer ----@return table supported filestypes as a list of strings +---@return string[] supported filestypes as a list of strings function M.get_all_supported_filetypes() - local status_ok, lsp_installer_filetypes = pcall(require, "nvim-lsp-installer._generated.filetype_map") + local status_ok, filetype_server_map = pcall(require, "mason-lspconfig.mappings.filetype") if not status_ok then return {} end - return vim.tbl_keys(lsp_installer_filetypes or {}) + return vim.tbl_keys(filetype_server_map or {}) end function M.setup_document_highlight(client, bufnr) diff --git a/lua/lvim/plugins.lua b/lua/lvim/plugins.lua index fec91bc9..24f71204 100644 --- a/lua/lvim/plugins.lua +++ b/lua/lvim/plugins.lua @@ -7,8 +7,12 @@ local core_plugins = { "jose-elias-alvarez/null-ls.nvim", }, { "antoinemadec/FixCursorHold.nvim" }, -- Needed while issue https://github.com/neovim/neovim/issues/12587 is still open + { "williamboman/mason-lspconfig.nvim" }, { - "williamboman/nvim-lsp-installer", + "williamboman/mason.nvim", + config = function() + require("lvim.core.mason").setup() + end, }, { "lunarvim/onedarker.nvim", diff --git a/snapshots/default.json b/snapshots/default.json index 564e26b3..9bb8e9e7 100644 --- a/snapshots/default.json +++ b/snapshots/default.json @@ -41,6 +41,12 @@ "lualine.nvim": { "commit": "8d956c1" }, + "mason-lspconfig.nvim": { + "commit": "e48a41e" + }, + "mason.nvim": { + "commit": "6fa15d7" + }, "nlsp-settings.nvim": { "commit": "6c4e1a4" }, @@ -56,9 +62,6 @@ "nvim-dap": { "commit": "c0f43f4" }, - "nvim-lsp-installer": { - "commit": "45571e1" - }, "nvim-lspconfig": { "commit": "3479473" }, diff --git a/tests/minimal_lsp.lua b/tests/minimal_lsp.lua index a610fd7f..09224f94 100644 --- a/tests/minimal_lsp.lua +++ b/tests/minimal_lsp.lua @@ -16,7 +16,7 @@ local package_root = join_paths(temp_dir, "nvim", "site", "pack") local install_path = join_paths(package_root, "packer", "start", "packer.nvim") local compile_path = join_paths(install_path, "plugin", "packer_compiled.lua") --- Choose whether to use the executable that's managed by lsp-installer +-- Choose whether to use the executable that's managed by mason local use_lsp_installer = true local function load_plugins() @@ -24,7 +24,8 @@ local function load_plugins() { "wbthomason/packer.nvim", "neovim/nvim-lspconfig", - { "williamboman/nvim-lsp-installer", disable = not use_lsp_installer }, + "williamboman/mason-lspconfig.nvim", + "williamboman/mason.nvim", }, config = { package_root = package_root, @@ -44,9 +45,6 @@ _G.load_config = function() require("vim.lsp.log").set_format_func(vim.inspect) local nvim_lsp = require "lspconfig" local on_attach = function(_, bufnr) - local function buf_set_keymap(...) - vim.api.nvim_buf_set_keymap(bufnr, ...) - end local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end @@ -54,24 +52,26 @@ _G.load_config = function() buf_set_option("omnifunc", "v:lua.vim.lsp.omnifunc") -- Mappings. - local opts = { noremap = true, silent = true } - buf_set_keymap("n", "gD", "lua vim.lsp.buf.declaration()", opts) - buf_set_keymap("n", "gd", "lua vim.lsp.buf.definition()", opts) - buf_set_keymap("n", "K", "lua vim.lsp.buf.hover()", opts) - buf_set_keymap("n", "gi", "lua vim.lsp.buf.implementation()", opts) - buf_set_keymap("n", "", "lua vim.lsp.buf.signature_help()", opts) - buf_set_keymap("n", "wa", "lua vim.lsp.buf.add_workspace_folder()", opts) - buf_set_keymap("n", "wr", "lua vim.lsp.buf.remove_workspace_folder()", opts) - buf_set_keymap("n", "wl", "lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))", opts) - buf_set_keymap("n", "lD", "lua vim.lsp.buf.type_definition()", opts) - buf_set_keymap("n", "lr", "lua vim.lsp.buf.rename()", opts) - buf_set_keymap("n", "gr", "lua vim.lsp.buf.references()", opts) - buf_set_keymap("n", "gl", "lua vim.diagnostic.open_float(0,{scope='line'})", opts) - buf_set_keymap("n", "lk", "lua vim.diagnostic.goto_prev()", opts) - buf_set_keymap("n", "lj", "lua vim.diagnostic.goto_next()", opts) - buf_set_keymap("n", "lq", "lua vim.diagnostic.setloclist()", opts) - buf_set_keymap("n", "li", "LspInfo", opts) - buf_set_keymap("n", "lI", "LspInstallInfo", opts) + local opts = { buffer = bufnr, noremap = true, silent = true } + vim.keymap.set("n", "gD", vim.lsp.buf.declaration, opts) + vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts) + vim.keymap.set("n", "K", vim.lsp.buf.hover, opts) + vim.keymap.set("n", "gi", vim.lsp.buf.implementation, opts) + vim.keymap.set("n", "", vim.lsp.buf.signature_help, opts) + vim.keymap.set("n", "wa", vim.lsp.buf.add_workspace_folder, opts) + vim.keymap.set("n", "wr", vim.lsp.buf.remove_workspace_folder, opts) + vim.keymap.set("n", "wl", function() + print(vim.inspect(vim.lsp.buf.list_workspace_folders())) + end, opts) + vim.keymap.set("n", "lD", vim.lsp.buf.type_definition, opts) + vim.keymap.set("n", "lr", vim.lsp.buf.rename, opts) + vim.keymap.set("n", "gr", vim.lsp.buf.references, opts) + vim.keymap.set("n", "gl", vim.diagnostic.open_float, opts) + vim.keymap.set("n", "[d", vim.diagnostic.goto_prev, opts) + vim.keymap.set("n", "]d", vim.diagnostic.goto_next, opts) + vim.keymap.set("n", "q", vim.diagnostic.setloclist, opts) + vim.keymap.set("n", "li", "LspInfo", opts) + vim.keymap.set("n", "lI", "MasonCR>", opts) end -- Add the server that troubles you here, e.g. "clangd", "pyright", "tsserver" @@ -81,15 +81,6 @@ _G.load_config = function() on_attach = on_attach, } - if use_lsp_installer then - local server_available, server = require("nvim-lsp-installer.servers").get_server(name) - if not server_available then - server:install() - end - local default_opts = server:get_default_options() - setup_opts = vim.tbl_deep_extend("force", setup_opts, default_opts) - end - if not name then print "You have not defined a server name, please edit minimal_init.lua" end @@ -99,6 +90,10 @@ _G.load_config = function() end nvim_lsp[name].setup(setup_opts) + if use_lsp_installer then + require("mason-lspconfig").setup { automatic_installation = true } + end + print [[You can find your log at $HOME/.cache/nvim/lsp.log. Please paste in a github issue under a details tag as described in the issue template.]] end diff --git a/tests/specs/lsp_spec.lua b/tests/specs/lsp_spec.lua index 7d9a3386..01e5e1d3 100644 --- a/tests/specs/lsp_spec.lua +++ b/tests/specs/lsp_spec.lua @@ -53,10 +53,14 @@ a.describe("lsp workflow", function() a.it("should only include one server per generated template", function() require("lvim.lsp").setup() + local allowed_dupes = { "tailwindcss" } for _, file in ipairs(vim.fn.glob(lvim.lsp.templates_dir .. "/*.lua", 1, 1)) do local content = {} for entry in io.lines(file) do - table.insert(content, entry) + local server_name = entry:match [[.*setup%("(.*)"%)]] + if not vim.tbl_contains(allowed_dupes, server_name) then + table.insert(content, server_name) + end end local err_msg = "" if #content > 1 then -- cgit v1.2.3 From 5f9a0a5b203fa16acf433296f11a3fb93725785e Mon Sep 17 00:00:00 2001 From: Dlani Date: Tue, 9 Aug 2022 08:15:20 -0300 Subject: fix: handle deprecated telescope.builtin.internal (#2885) --- lua/lvim/core/which-key.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/lvim/core/which-key.lua b/lua/lvim/core/which-key.lua index 6d0dc9fc..b1cfdc03 100644 --- a/lua/lvim/core/which-key.lua +++ b/lua/lvim/core/which-key.lua @@ -252,7 +252,7 @@ M.config = function() k = { "Telescope keymaps", "Keymaps" }, C = { "Telescope commands", "Commands" }, p = { - "lua require('telescope.builtin.internal').colorscheme({enable_preview = true})", + "lua require('telescope.builtin').colorscheme({enable_preview = true})", "Colorscheme with Preview", }, }, -- cgit v1.2.3 From 67366cdf89e98c285eef57a9282fc61c06aeb789 Mon Sep 17 00:00:00 2001 From: lvimuser <109605931+lvimuser@users.noreply.github.com> Date: Tue, 9 Aug 2022 08:27:47 -0300 Subject: feat(lvim/lsp): enable tailwindcss by default (#2870) --- lua/lvim/lsp/config.lua | 1 - lua/lvim/lsp/providers/tailwindcss.lua | 8 ++++++++ 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 lua/lvim/lsp/providers/tailwindcss.lua diff --git a/lua/lvim/lsp/config.lua b/lua/lvim/lsp/config.lua index 41290787..2cd1bc6e 100644 --- a/lua/lvim/lsp/config.lua +++ b/lua/lvim/lsp/config.lua @@ -30,7 +30,6 @@ local skipped_servers = { "sqlls", "sqls", "stylelint_lsp", - "tailwindcss", "tflint", "svlangserver", "verible", diff --git a/lua/lvim/lsp/providers/tailwindcss.lua b/lua/lvim/lsp/providers/tailwindcss.lua new file mode 100644 index 00000000..063cf89f --- /dev/null +++ b/lua/lvim/lsp/providers/tailwindcss.lua @@ -0,0 +1,8 @@ +local opts = { + root_dir = function(fname) + local util = require "lspconfig/util" + return util.root_pattern("tailwind.config.js", "tailwind.config.cjs", "tailwind.js", "tailwind.cjs")(fname) + end, +} + +return opts -- cgit v1.2.3 From 3bc52f9988a58e3e1a2a48ee2299383d967a1573 Mon Sep 17 00:00:00 2001 From: Myles Mo <54089360+emxxjnm@users.noreply.github.com> Date: Tue, 9 Aug 2022 19:32:35 +0800 Subject: fix(lualine): set icon color according to the status of treesitter (#2754) Co-authored-by: emxxjnm --- lua/lvim/core/lualine/components.lua | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lua/lvim/core/lualine/components.lua b/lua/lvim/core/lualine/components.lua index 49a8ff81..5095cfb4 100644 --- a/lua/lvim/core/lualine/components.lua +++ b/lua/lvim/core/lualine/components.lua @@ -70,13 +70,13 @@ return { }, treesitter = { function() - local b = vim.api.nvim_get_current_buf() - if next(vim.treesitter.highlighter.active[b]) then - return "" - end - return "" + return "" + end, + color = function() + local buf = vim.api.nvim_get_current_buf() + local ts = vim.treesitter.highlighter.active[buf] + return { fg = ts and not vim.tbl_isempty(ts) and colors.green or colors.red } end, - color = { fg = colors.green }, cond = conditions.hide_in_width, }, lsp = { -- cgit v1.2.3 From 7fc0d0f72b9fbe7bc94cc2a9a30dd9c22b9d8ce9 Mon Sep 17 00:00:00 2001 From: Philipp Bokatius Date: Tue, 9 Aug 2022 13:54:25 +0200 Subject: fix(installer): create profile.ps1 if nonexistent (#2810) --- utils/installer/install.ps1 | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/utils/installer/install.ps1 b/utils/installer/install.ps1 index dcfa47f4..320e377c 100644 --- a/utils/installer/install.ps1 +++ b/utils/installer/install.ps1 @@ -264,6 +264,13 @@ function create_alias { return } + try { + Get-Content $PROFILE -ErrorAction Stop + } + catch { + New-Item -Path $PROFILE -ItemType "file" -Force + } + Add-Content -Path $PROFILE -Value $("`r`nSet-Alias lvim $lvim_bin") Write-Host 'To use the new alias in this window reload your profile with: `. $PROFILE`' -ForegroundColor Green -- cgit v1.2.3 From 63696c1425fb264c649cf202bc02f8edb34e0445 Mon Sep 17 00:00:00 2001 From: Gabriel Kwong Date: Tue, 9 Aug 2022 05:02:38 -0700 Subject: docs(windows): update example config for nvim-tree (#2766) --- utils/installer/config_win.example.lua | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/utils/installer/config_win.example.lua b/utils/installer/config_win.example.lua index cb110664..c48335b0 100644 --- a/utils/installer/config_win.example.lua +++ b/utils/installer/config_win.example.lua @@ -79,14 +79,14 @@ lvim.builtin.terminal.active = false -- lvim.builtin.terminal.shell = "pwsh.exe -NoLogo" -- nvim-tree has some performance issues on windows, see kyazdani42/nvim-tree.lua#549 -lvim.builtin.nvimtree.setup.diagnostics.enable = false -lvim.builtin.nvimtree.setup.filters.custom = false -lvim.builtin.nvimtree.setup.git.enable = false -lvim.builtin.nvimtree.setup.update_cwd = false -lvim.builtin.nvimtree.setup.update_focused_file.update_cwd = false +lvim.builtin.nvimtree.setup.diagnostics.enable = nil +lvim.builtin.nvimtree.setup.filters.custom = nil +lvim.builtin.nvimtree.setup.git.enable = nil +lvim.builtin.nvimtree.setup.update_cwd = nil +lvim.builtin.nvimtree.setup.update_focused_file.update_cwd = nil lvim.builtin.nvimtree.setup.view.side = "left" -lvim.builtin.nvimtree.setup.renderer.highlight_git = false -lvim.builtin.nvimtree.setup.renderer.icons.show.git = false +lvim.builtin.nvimtree.setup.renderer.highlight_git = nil +lvim.builtin.nvimtree.setup.renderer.icons.show.git = nil -- if you don't want all the parsers change this to a table of the ones you want lvim.builtin.treesitter.ensure_installed = { -- cgit v1.2.3 From 2e4620cb4f3ffea328f8b0e57daa42d8f54024e8 Mon Sep 17 00:00:00 2001 From: kylo252 <59826753+kylo252@users.noreply.github.com> Date: Tue, 9 Aug 2022 16:11:45 +0200 Subject: fix(lsp): return the actual resolved mason-config (#2889) --- lua/lvim/lsp/manager.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lua/lvim/lsp/manager.lua b/lua/lvim/lsp/manager.lua index aa76af6c..258a4983 100644 --- a/lua/lvim/lsp/manager.lua +++ b/lua/lvim/lsp/manager.lua @@ -22,8 +22,8 @@ local function resolve_mason_config(server_name) conf.cmd[1] = exepath end end - Log:debug(fmt("resolved mason configuration for %s, got %s", server_name, vim.inspect(mason_config))) - return mason_config or {} + Log:debug(fmt("resolved mason configuration for %s, got %s", server_name, vim.inspect(conf))) + return conf or {} end ---Resolve the configuration for a server by merging with the default config @@ -107,12 +107,12 @@ function M.setup(server_name, user_config) if not registry.is_installed(pkg_name) then if should_auto_install(server_name) then Log:debug "Automatic server installation detected" - vim.notify_once(string.format("Installation in progoress for [%s] server", server_name), vim.log.levels.INFO) + vim.notify_once(string.format("Installation in progress for [%s]", server_name), vim.log.levels.INFO) local pkg = registry.get_package(pkg_name) pkg:install():once("closed", function() if pkg:is_installed() then vim.schedule(function() - vim.notify_once(string.format("Installation complete for [%s] server", server_name), vim.log.levels.INFO) + vim.notify_once(string.format("Installation complete for [%s]", server_name), vim.log.levels.INFO) -- mason config is only available once the server has been installed local config = resolve_config(server_name, resolve_mason_config(server_name), user_config) launch_server(server_name, config) -- cgit v1.2.3 From 9caa457810a26369f848d4f90f6e0ec84e0048e0 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 10 Aug 2022 11:30:18 +0200 Subject: chore: bump plugins version (#2893) --- snapshots/default.json | 54 +++++++++++++++++++++++++------------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/snapshots/default.json b/snapshots/default.json index 9bb8e9e7..e5bc50a7 100644 --- a/snapshots/default.json +++ b/snapshots/default.json @@ -1,27 +1,27 @@ { "Comment.nvim": { - "commit": "2e0572c" + "commit": "fe9bbdb" }, "FixCursorHold.nvim": { "commit": "5aa5ff1" }, "LuaSnip": { - "commit": "be3083b" + "commit": "c599c56" }, "alpha-nvim": { - "commit": "14974c3" + "commit": "d688f46" }, "bufferline.nvim": { - "commit": "d7b775a" + "commit": "2e5d92e" }, "cmp-buffer": { - "commit": "62fc67a" + "commit": "3022dbc" }, "cmp-nvim-lsp": { "commit": "affe808" }, "cmp-path": { - "commit": "981baf9" + "commit": "447c87c" }, "cmp_luasnip": { "commit": "a9de941" @@ -30,52 +30,52 @@ "commit": "bbda2b0" }, "friendly-snippets": { - "commit": "40c306b" + "commit": "7339def" }, "gitsigns.nvim": { - "commit": "bb6c3bf" + "commit": "9c3ca02" }, "lua-dev.nvim": { "commit": "54149d1" }, "lualine.nvim": { - "commit": "8d956c1" + "commit": "c0510dd" }, "mason-lspconfig.nvim": { - "commit": "e48a41e" + "commit": "3cbd87f" }, "mason.nvim": { - "commit": "6fa15d7" + "commit": "3458edb" }, "nlsp-settings.nvim": { - "commit": "6c4e1a4" + "commit": "e5c11a6" }, "null-ls.nvim": { - "commit": "9c396ab" + "commit": "5b745e5" }, "nvim-autopairs": { - "commit": "972a797" + "commit": "ca89ab9" }, "nvim-cmp": { - "commit": "c4dcb12" + "commit": "706371f" }, "nvim-dap": { - "commit": "c0f43f4" + "commit": "66d33b7" }, "nvim-lspconfig": { - "commit": "3479473" + "commit": "da7461b" }, "nvim-notify": { - "commit": "74ba257" + "commit": "60bb6bf" }, "nvim-tree.lua": { - "commit": "08ab346" + "commit": "261a5c3" }, "nvim-treesitter": { - "commit": "07b7221" + "commit": "e7b5e92" }, "nvim-ts-context-commentstring": { - "commit": "8834375" + "commit": "4befb89" }, "nvim-web-devicons": { "commit": "2d02a56" @@ -84,19 +84,19 @@ "commit": "b00dd21" }, "packer.nvim": { - "commit": "494fd59" + "commit": "afab895" }, "plenary.nvim": { - "commit": "986ad71" + "commit": "31807ee" }, "popup.nvim": { "commit": "b7404d3" }, "project.nvim": { - "commit": "541115e" + "commit": "090bb11" }, "schemastore.nvim": { - "commit": "fbc7c71" + "commit": "cba478d" }, "structlog.nvim": { "commit": "232a8e2" @@ -105,10 +105,10 @@ "commit": "6a33ece" }, "telescope.nvim": { - "commit": "273ccff" + "commit": "8f80e82" }, "toggleterm.nvim": { - "commit": "9db6f98" + "commit": "6236642" }, "which-key.nvim": { "commit": "f03a259" -- cgit v1.2.3 From 45f9825d1e666890ed37baf15a14707ae40e5cff Mon Sep 17 00:00:00 2001 From: Benedikt Schnatterbeck <48836135+benediktms@users.noreply.github.com> Date: Fri, 12 Aug 2022 17:01:11 +0100 Subject: refactor(keymaps)!: don't hijack H/L by default (#2874) --- lua/lvim/keymappings.lua | 4 ---- utils/installer/config.example.lua | 2 ++ 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/lua/lvim/keymappings.lua b/lua/lvim/keymappings.lua index 8c91b761..63835f75 100644 --- a/lua/lvim/keymappings.lua +++ b/lua/lvim/keymappings.lua @@ -61,10 +61,6 @@ local defaults = { [""] = ":vertical resize -2", [""] = ":vertical resize +2", - -- Tab switch buffer - [""] = ":BufferLineCycleNext", - [""] = ":BufferLineCyclePrev", - -- Move current line / block with Alt-j/k a la vscode. [""] = ":m .+1==", [""] = ":m .-2==", diff --git a/utils/installer/config.example.lua b/utils/installer/config.example.lua index 036b8ec2..5f950cb5 100644 --- a/utils/installer/config.example.lua +++ b/utils/installer/config.example.lua @@ -19,6 +19,8 @@ lvim.colorscheme = "onedarker" lvim.leader = "space" -- add your own keymapping lvim.keys.normal_mode[""] = ":w" +-- lvim.keys.normal_mode[""] = ":BufferLineCycleNext" +-- lvim.keys.normal_mode[""] = ":BufferLineCyclePrev" -- unmap a default keymapping -- vim.keymap.del("n", "") -- override a default keymapping -- cgit v1.2.3 From 9d9d497e077f51933ff5264519bb33cc3c7efbbd Mon Sep 17 00:00:00 2001 From: Opa Kholis Majid Date: Fri, 19 Aug 2022 16:48:01 +0700 Subject: docs(windows): update example config (#2919) --- utils/installer/config.example.lua | 2 +- utils/installer/config_win.example.lua | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/utils/installer/config.example.lua b/utils/installer/config.example.lua index 5f950cb5..d99e868d 100644 --- a/utils/installer/config.example.lua +++ b/utils/installer/config.example.lua @@ -53,7 +53,7 @@ lvim.keys.normal_mode[""] = ":w" -- d = { "Trouble document_diagnostics", "Diagnostics" }, -- q = { "Trouble quickfix", "QuickFix" }, -- l = { "Trouble loclist", "LocationList" }, --- w = { "Trouble workspace_diagnostics", "Wordspace Diagnostics" }, +-- w = { "Trouble workspace_diagnostics", "Workspace Diagnostics" }, -- } -- TODO: User Config for predefined plugins diff --git a/utils/installer/config_win.example.lua b/utils/installer/config_win.example.lua index c48335b0..7353724a 100644 --- a/utils/installer/config_win.example.lua +++ b/utils/installer/config_win.example.lua @@ -36,6 +36,8 @@ lvim.colorscheme = "onedarker" lvim.leader = "space" -- add your own keymapping lvim.keys.normal_mode[""] = ":w" +-- lvim.keys.normal_mode[""] = ":BufferLineCycleNext" +-- lvim.keys.normal_mode[""] = ":BufferLineCyclePrev" -- unmap a default keymapping -- vim.keymap.del("n", "") -- override a default keymapping -- cgit v1.2.3 From d259efd40b2ebab57ff364da565e280981fec410 Mon Sep 17 00:00:00 2001 From: Akihiro Okuno Date: Fri, 19 Aug 2022 18:50:52 +0900 Subject: fix(statusline): display null-ls linters properly (#2921) --- lua/lvim/lsp/null-ls/linters.lua | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lua/lvim/lsp/null-ls/linters.lua b/lua/lvim/lsp/null-ls/linters.lua index 07c8094b..ba7670d3 100644 --- a/lua/lvim/lsp/null-ls/linters.lua +++ b/lua/lvim/lsp/null-ls/linters.lua @@ -6,9 +6,19 @@ local null_ls = require "null-ls" local services = require "lvim.lsp.null-ls.services" local method = null_ls.methods.DIAGNOSTICS +local alternative_methods = { + null_ls.methods.DIAGNOSTICS, + null_ls.methods.DIAGNOSTICS_ON_OPEN, + null_ls.methods.DIAGNOSTICS_ON_SAVE, +} + function M.list_registered(filetype) local registered_providers = services.list_registered_providers_names(filetype) - return registered_providers[method] or {} + local providers_for_methods = vim.tbl_flatten(vim.tbl_map(function(m) + return registered_providers[m] or {} + end, alternative_methods)) + + return providers_for_methods end function M.list_supported(filetype) -- cgit v1.2.3 From e13c465d5178cf3d20530c70261b1e5f6f10e4e4 Mon Sep 17 00:00:00 2001 From: Liam <101684827+SkiingIsFun123@users.noreply.github.com> Date: Fri, 19 Aug 2022 02:53:38 -0700 Subject: docs: fix some typos and enhance readability (#2917) --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index ec4f1c55..8b8a9cdc 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ bash <(curl -s https://raw.githubusercontent.com/lunarvim/lunarvim/master/utils/ To run the install script without any interaction you can pass the `-y` flag to automatically install all dependencies and have no prompts. This is particularly useful in automated installations. -The same way, you can use `--no-install-dependencies` to skip the dependency installation. +In the same way, you can use `--no-install-dependencies` to skip the dependency installation. ### Windows (Powershell 7+): @@ -51,7 +51,7 @@ Invoke-WebRequest https://raw.githubusercontent.com/LunarVim/LunarVim/master/uti ## Automatic LSP support -By default, most supported language servers will get automatically installed once you open the supported file-type, e.g, opening a Python file for the first time will install `Pyright` and configure it automatically for you. +By default, most supported language servers will get automatically installed once you open the supported file type, e.g, opening a Python file for the first time will install `Pyright` and configure it automatically for you. ## Configuration file @@ -99,7 +99,7 @@ formatters.setup { { command = "black" }, { command = "prettier", - ---@usage specify which filetypes to enable. By default a providers will attach to all the filetypes it supports. + ---@usage specify which filetypes to enable. By default, providers will attach to all the filetypes it supports. filetypes = { "typescript", "typescriptreact" }, }, } @@ -109,7 +109,7 @@ local linters = require "lvim.lsp.null-ls.linters" linters.setup { { command = "eslint_d", - ---@usage specify which filetypes to enable. By default a providers will attach to all the filetypes it supports. + ---@usage specify which filetypes to enable. By default, providers will attach to all the filetypes it supports. filetypes = { "javascript", "javascriptreact" }, }, } -- cgit v1.2.3 From 7df4773b0bc293d50fe9979505db8db246a61607 Mon Sep 17 00:00:00 2001 From: Ian C Date: Fri, 19 Aug 2022 06:01:19 -0400 Subject: docs: fix automatic_servers_installation example (#2918) --- utils/installer/config.example.lua | 2 +- utils/installer/config_win.example.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/utils/installer/config.example.lua b/utils/installer/config.example.lua index d99e868d..65662794 100644 --- a/utils/installer/config.example.lua +++ b/utils/installer/config.example.lua @@ -101,7 +101,7 @@ lvim.builtin.treesitter.highlight.enabled = true -- } -- ---@usage disable automatic installation of servers --- lvim.lsp.automatic_servers_installation = false +-- lvim.lsp.installer.setup.automatic_installation = false -- ---configure a server manually. !!Requires `:LvimCacheReset` to take effect!! -- ---see the full default list `:lua print(vim.inspect(lvim.lsp.automatic_configuration.skipped_servers))` diff --git a/utils/installer/config_win.example.lua b/utils/installer/config_win.example.lua index 7353724a..6e9a1ba0 100644 --- a/utils/installer/config_win.example.lua +++ b/utils/installer/config_win.example.lua @@ -116,7 +116,7 @@ lvim.builtin.treesitter.highlight.enabled = true -- } -- ---@usage disable automatic installation of servers --- lvim.lsp.automatic_servers_installation = false +-- lvim.lsp.installer.setup.automatic_installation = false -- ---configure a server manually. !!Requires `:LvimCacheReset` to take effect!! -- ---see the full default list `:lua print(vim.inspect(lvim.lsp.automatic_configuration.skipped_servers))` -- cgit v1.2.3 From 08b5e99f53fc5170d35de3f474c7df5ae1fac62f Mon Sep 17 00:00:00 2001 From: kylo252 <59826753+kylo252@users.noreply.github.com> Date: Fri, 19 Aug 2022 12:02:15 +0200 Subject: feat(installer): handle INSTALL_PREFIX not on PATH (#2912) --- utils/installer/install.sh | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/utils/installer/install.sh b/utils/installer/install.sh index dc342d12..620d46f5 100755 --- a/utils/installer/install.sh +++ b/utils/installer/install.sh @@ -26,6 +26,7 @@ declare ARGS_LOCAL=0 declare ARGS_OVERWRITE=0 declare ARGS_INSTALL_DEPENDENCIES=1 declare INTERACTIVE_MODE=1 +declare ADDITIONAL_WARNINGS="" declare -a __lvim_dirs=( "$LUNARVIM_CONFIG_DIR" @@ -148,6 +149,7 @@ function main() { setup_lvim + msg "$ADDITIONAL_WARNINGS" msg "Thank you for installing LunarVim!!" echo "You can start it by running: $INSTALL_PREFIX/bin/lvim" echo "Do not forget to use a font with glyphs (icons) support [https://github.com/ryanoasis/nerd-fonts]" @@ -226,7 +228,25 @@ function validate_lunarvim_files() { fi } +function validate_install_prefix() { + local prefix="$1" + case $PATH in + *"$prefix/bin"*) + return + ;; + esac + local profile="$HOME/.profile" + test -z "$ZSH_VERSION" && profile="$HOME/.zshenv" + ADDITIONAL_WARNINGS="[WARN] the folder $prefix/bin is not on PATH, consider adding 'export PATH=$prefix/bin:\$PATH' to your $profile" + + # avoid problems when calling any verify_* function + export PATH="$prefix/bin:$PATH" +} + function check_system_deps() { + + validate_install_prefix "$INSTALL_PREFIX" + if ! command -v git &>/dev/null; then print_missing_dep_msg "git" exit 1 @@ -279,7 +299,6 @@ function __validate_node_installation() { fi if [ ! -d "$manager_home" ] || [ ! -w "$manager_home" ]; then - echo "[ERROR] Unable to install using [$pkg_manager] without administrative privileges." return 1 fi @@ -294,21 +313,21 @@ function install_nodejs_deps() { return fi done - print_missing_dep_msg "${pkg_managers[@]}" - exit 1 + echo "[WARN]: skipping installing optional nodejs dependencies due to insufficient permissions." + echo "check how to solve it: https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally" } function install_python_deps() { echo "Verifying that pip is available.." - if ! python3 -m ensurepip &>/dev/null; then + if ! python3 -m ensurepip >/dev/null; then if ! python3 -m pip --version &>/dev/null; then - print_missing_dep_msg "pip" - exit 1 + echo "[WARN]: skipping installing optional python dependencies" + return 1 fi fi echo "Installing with pip.." for dep in "${__pip_deps[@]}"; do - python3 -m pip install --user "$dep" + python3 -m pip install --user "$dep" || return 1 done echo "All Python dependencies are successfully installed" } -- cgit v1.2.3 From 0fc1e423097485035bd6c1f19d64ce8424387ca9 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 20 Aug 2022 11:06:34 +0200 Subject: chore: bump plugins version (#2895) --- lua/lvim/core/bufferline.lua | 4 ++-- snapshots/default.json | 42 +++++++++++++++++++------------------- utils/ci/generate_new_lockfile.lua | 3 ++- 3 files changed, 25 insertions(+), 24 deletions(-) diff --git a/lua/lvim/core/bufferline.lua b/lua/lvim/core/bufferline.lua index 28e0f06d..7e8f1376 100644 --- a/lua/lvim/core/bufferline.lua +++ b/lua/lvim/core/bufferline.lua @@ -45,10 +45,10 @@ M.config = function() }, highlights = { background = { - gui = "italic", + italic = true, }, buffer_selected = { - gui = "bold", + bold = true, }, }, options = { diff --git a/snapshots/default.json b/snapshots/default.json index e5bc50a7..3ab142c0 100644 --- a/snapshots/default.json +++ b/snapshots/default.json @@ -1,18 +1,18 @@ { "Comment.nvim": { - "commit": "fe9bbdb" + "commit": "350bf0c" }, "FixCursorHold.nvim": { "commit": "5aa5ff1" }, "LuaSnip": { - "commit": "c599c56" + "commit": "faa5257" }, "alpha-nvim": { "commit": "d688f46" }, "bufferline.nvim": { - "commit": "2e5d92e" + "commit": "13a532e" }, "cmp-buffer": { "commit": "3022dbc" @@ -27,13 +27,13 @@ "commit": "a9de941" }, "dap-buddy.nvim": { - "commit": "bbda2b0" + "commit": "3679132" }, "friendly-snippets": { - "commit": "7339def" + "commit": "6227548" }, "gitsigns.nvim": { - "commit": "9c3ca02" + "commit": "79c55eb" }, "lua-dev.nvim": { "commit": "54149d1" @@ -42,25 +42,25 @@ "commit": "c0510dd" }, "mason-lspconfig.nvim": { - "commit": "3cbd87f" + "commit": "d9365e7" }, "mason.nvim": { - "commit": "3458edb" + "commit": "5dbb22a" }, "nlsp-settings.nvim": { - "commit": "e5c11a6" + "commit": "48d02d1" }, "null-ls.nvim": { - "commit": "5b745e5" + "commit": "9d1f8dc" }, "nvim-autopairs": { - "commit": "ca89ab9" + "commit": "0a18e10" }, "nvim-cmp": { - "commit": "706371f" + "commit": "b1ebdb0" }, "nvim-dap": { - "commit": "66d33b7" + "commit": "ad8b0de" }, "nvim-lspconfig": { "commit": "da7461b" @@ -69,13 +69,13 @@ "commit": "60bb6bf" }, "nvim-tree.lua": { - "commit": "261a5c3" + "commit": "81eb718" }, "nvim-treesitter": { - "commit": "e7b5e92" + "commit": "2bb9bb7" }, "nvim-ts-context-commentstring": { - "commit": "4befb89" + "commit": "37a97a0" }, "nvim-web-devicons": { "commit": "2d02a56" @@ -84,7 +84,7 @@ "commit": "b00dd21" }, "packer.nvim": { - "commit": "afab895" + "commit": "90b323b" }, "plenary.nvim": { "commit": "31807ee" @@ -96,19 +96,19 @@ "commit": "090bb11" }, "schemastore.nvim": { - "commit": "cba478d" + "commit": "539a2d3" }, "structlog.nvim": { "commit": "232a8e2" }, "telescope-fzf-native.nvim": { - "commit": "6a33ece" + "commit": "6791f74" }, "telescope.nvim": { - "commit": "8f80e82" + "commit": "5103387" }, "toggleterm.nvim": { - "commit": "6236642" + "commit": "62683d9" }, "which-key.nvim": { "commit": "f03a259" diff --git a/utils/ci/generate_new_lockfile.lua b/utils/ci/generate_new_lockfile.lua index fd10775c..8eef5184 100644 --- a/utils/ci/generate_new_lockfile.lua +++ b/utils/ci/generate_new_lockfile.lua @@ -70,6 +70,7 @@ local function write_lockfile(verbose) name = name, url = url, commit = commit, + branch = plugin.branch or "HEAD", }) end @@ -90,7 +91,7 @@ local function write_lockfile(verbose) } end - local handle = call_proc("git", { args = { "ls-remote", entry.url, "HEAD" } }, on_done) + local handle = call_proc("git", { args = { "ls-remote", entry.url, entry.branch } }, on_done) assert(handle) table.insert(active_jobs, handle) end -- cgit v1.2.3 From 06fa62e6e9ea9b362d3c2340f4f4f843eb3cbc14 Mon Sep 17 00:00:00 2001 From: "Ed (Wright) Rosewright" Date: Mon, 22 Aug 2022 22:24:38 +0900 Subject: fix: update key bindings for comment.nvim to use new api (#2926) --- lua/lvim/core/which-key.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/lvim/core/which-key.lua b/lua/lvim/core/which-key.lua index b1cfdc03..2301943f 100644 --- a/lua/lvim/core/which-key.lua +++ b/lua/lvim/core/which-key.lua @@ -76,13 +76,13 @@ M.config = function() -- NOTE: Prefer using : over as the latter avoids going back in normal-mode. -- see https://neovim.io/doc/user/map.html#:map-cmd vmappings = { - ["/"] = { "lua require('Comment.api').toggle_linewise_op(vim.fn.visualmode())", "Comment" }, + ["/"] = { "(comment_toggle_linewise_visual)", "Comment toggle linewise (visual)" }, }, mappings = { [";"] = { "Alpha", "Dashboard" }, ["w"] = { "w!", "Save" }, ["q"] = { "lua require('lvim.utils.functions').smart_quit()", "Quit" }, - ["/"] = { "lua require('Comment.api').toggle_current_linewise()", "Comment" }, + ["/"] = { "(comment_toggle_linewise_current)", "Comment toggle current line" }, ["c"] = { "BufferKill", "Close Buffer" }, ["f"] = { require("lvim.core.telescope.custom-finders").find_project_files, "Find File" }, ["h"] = { "nohlsearch", "No Highlight" }, -- cgit v1.2.3 From 9fcb6bbd8116caa498433f6ecb47e7acccfd0dcd Mon Sep 17 00:00:00 2001 From: kylo252 <59826753+kylo252@users.noreply.github.com> Date: Mon, 29 Aug 2022 13:53:58 +0200 Subject: refactor(cmp)!: adapt new recommendations (#2913) --- lua/lvim/core/autopairs.lua | 4 ++ lua/lvim/core/cmp.lua | 101 +++++++++++++++++++++----------------------- snapshots/default.json | 4 +- 3 files changed, 55 insertions(+), 54 deletions(-) diff --git a/lua/lvim/core/autopairs.lua b/lua/lvim/core/autopairs.lua index 4d9f33f4..469a38a4 100644 --- a/lua/lvim/core/autopairs.lua +++ b/lua/lvim/core/autopairs.lua @@ -79,6 +79,10 @@ M.setup = function() if lvim.builtin.autopairs.on_config_done then lvim.builtin.autopairs.on_config_done(autopairs) end + pcall(function() + local cmp_autopairs = require "nvim-autopairs.completion.cmp" + require("cmp").event:on("confirm_done", cmp_autopairs.on_confirm_done()) + end) end return M diff --git a/lua/lvim/core/cmp.lua b/lua/lvim/core/cmp.lua index 942a72f6..10cf56be 100644 --- a/lua/lvim/core/cmp.lua +++ b/lua/lvim/core/cmp.lua @@ -1,24 +1,23 @@ local M = {} M.methods = {} ----checks if the character preceding the cursor is a space character ----@return boolean true if it is a space character, false otherwise -local check_backspace = function() - local col = vim.fn.col "." - 1 - return col == 0 or vim.fn.getline("."):sub(col, col):match "%s" +local has_words_before = function() + 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 -M.methods.check_backspace = check_backspace +M.methods.has_words_before = has_words_before -local function T(str) +---@deprecated use M.methods.has_words_before instead +M.methods.check_backspace = function() + return not has_words_before() +end + +local T = function(str) return vim.api.nvim_replace_termcodes(str, true, true, true) end ----wraps vim.fn.feedkeys while replacing key codes with escape codes ----Ex: feedkeys("", "n") becomes feedkeys("^M", "n") ----@param key string ----@param mode string local function feedkeys(key, mode) - vim.fn.feedkeys(T(key), mode) + vim.api.nvim_feedkeys(T(key), mode, true) end M.methods.feedkeys = feedkeys @@ -28,39 +27,21 @@ M.methods.feedkeys = feedkeys local function jumpable(dir) local luasnip_ok, luasnip = pcall(require, "luasnip") if not luasnip_ok then - return + return false end local win_get_cursor = vim.api.nvim_win_get_cursor local get_current_buf = vim.api.nvim_get_current_buf - local function inside_snippet() - -- for outdated versions of luasnip - if not luasnip.session.current_nodes then - return false - end - - local node = luasnip.session.current_nodes[get_current_buf()] - if not node then - return false - end - - local snip_begin_pos, snip_end_pos = node.parent.snippet.mark:pos_begin_end() - local pos = win_get_cursor(0) - pos[1] = pos[1] - 1 -- LuaSnip is 0-based not 1-based like nvim for rows - return pos[1] >= snip_begin_pos[1] and pos[1] <= snip_end_pos[1] - end - ---sets the current buffer's luasnip to the one nearest the cursor ---@return boolean true if a node is found, false otherwise local function seek_luasnip_cursor_node() + -- TODO(kylo252): upstream this -- for outdated versions of luasnip if not luasnip.session.current_nodes then return false end - local pos = win_get_cursor(0) - pos[1] = pos[1] - 1 local node = luasnip.session.current_nodes[get_current_buf()] if not node then return false @@ -69,6 +50,9 @@ local function jumpable(dir) local snippet = node.parent.snippet local exit_node = snippet.insert_nodes[0] + local pos = win_get_cursor(0) + pos[1] = pos[1] - 1 + -- exit early if we're past the exit node if exit_node then local exit_pos_end = exit_node.mark:pos_end() @@ -124,9 +108,9 @@ local function jumpable(dir) end if dir == -1 then - return inside_snippet() and luasnip.jumpable(-1) + return luasnip.in_snippet() and luasnip.jumpable(-1) else - return inside_snippet() and seek_luasnip_cursor_node() and luasnip.jumpable() + return luasnip.in_snippet() and seek_luasnip_cursor_node() and luasnip.jumpable(1) end end M.methods.jumpable = jumpable @@ -241,48 +225,61 @@ M.config = function() mapping = cmp.mapping.preset.insert { [""] = cmp.mapping.select_prev_item(), [""] = cmp.mapping.select_next_item(), + [""] = cmp.mapping(cmp.mapping.select_next_item { behavior = cmp.SelectBehavior.Select }, { "i" }), + [""] = cmp.mapping(cmp.mapping.select_prev_item { behavior = cmp.SelectBehavior.Select }, { "i" }), [""] = cmp.mapping.scroll_docs(-4), [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping { + i = cmp.mapping.confirm { behavior = cmp.ConfirmBehavior.Replace, select = false }, + c = function(fallback) + if cmp.visible() then + cmp.confirm { behavior = cmp.ConfirmBehavior.Replace, select = false } + else + fallback() + end + end, + }, [""] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_next_item() - elseif luasnip.expandable() then - luasnip.expand() - elseif jumpable() then + elseif luasnip.expand_or_locally_jumpable() then + luasnip.expand_or_jump() + elseif jumpable(1) then luasnip.jump(1) - elseif check_backspace() then - fallback() + elseif has_words_before() then + cmp.complete() else fallback() end - end, { - "i", - "s", - }), + end, { "i", "s" }), [""] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_prev_item() - elseif jumpable(-1) then + elseif luasnip.jumpable(-1) then luasnip.jump(-1) else fallback() end - end, { - "i", - "s", - }), - + end, { "i", "s" }), [""] = cmp.mapping.complete(), [""] = cmp.mapping.abort(), [""] = cmp.mapping(function(fallback) - if cmp.visible() and cmp.confirm(lvim.builtin.cmp.confirm_opts) then - if jumpable() then + if cmp.visible() then + local confirm_opts = lvim.builtin.cmp.confirm_opts + local is_insert_mode = function() + return vim.api.nvim_get_mode().mode:sub(1, 1) == "i" + end + if is_insert_mode() then -- prevent overwriting brackets + confirm_opts.behavior = cmp.ConfirmBehavior.Insert + end + cmp.confirm(confirm_opts) + if jumpable(1) then luasnip.jump(1) end return end - if jumpable() then + if jumpable(1) then if not luasnip.jump(1) then fallback() end diff --git a/snapshots/default.json b/snapshots/default.json index 3ab142c0..4b1d68a7 100644 --- a/snapshots/default.json +++ b/snapshots/default.json @@ -6,7 +6,7 @@ "commit": "5aa5ff1" }, "LuaSnip": { - "commit": "faa5257" + "commit": "9f454cc" }, "alpha-nvim": { "commit": "d688f46" @@ -57,7 +57,7 @@ "commit": "0a18e10" }, "nvim-cmp": { - "commit": "b1ebdb0" + "commit": "058100d" }, "nvim-dap": { "commit": "ad8b0de" -- cgit v1.2.3 From 537a192179c1123618489b2faaf58204d899f3a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Rodr=C3=ADguez=20Rivero?= Date: Mon, 29 Aug 2022 14:04:46 +0200 Subject: fix(lsp): pass name arg to should_auto_install (#2958) --- lua/lvim/lsp/manager.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/lvim/lsp/manager.lua b/lua/lvim/lsp/manager.lua index 258a4983..1323ace7 100644 --- a/lua/lvim/lsp/manager.lua +++ b/lua/lvim/lsp/manager.lua @@ -98,10 +98,10 @@ function M.setup(server_name, user_config) return end - local should_auto_install = function() + local should_auto_install = function(name) local installer_settings = lvim.lsp.installer.setup return installer_settings.automatic_installation - and not vim.tbl_contains(installer_settings.automatic_installation.exclude, server_name) + and not vim.tbl_contains(installer_settings.automatic_installation.exclude, name) end if not registry.is_installed(pkg_name) then -- cgit v1.2.3 From 68e8132b909dab6a748340f81c4b3a6ef452079d Mon Sep 17 00:00:00 2001 From: zenVentzi <11378653+zenVentzi@users.noreply.github.com> Date: Mon, 29 Aug 2022 15:13:57 +0300 Subject: fix(ts_context_commentstring): block comment match new api (#2948) --- lua/lvim/core/comment.lua | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/lua/lvim/core/comment.lua b/lua/lvim/core/comment.lua index 86a2091a..d07739c6 100644 --- a/lua/lvim/core/comment.lua +++ b/lua/lvim/core/comment.lua @@ -3,8 +3,24 @@ local M = {} function M.config() local pre_hook = nil if lvim.builtin.treesitter.context_commentstring.enable then - pre_hook = function(_ctx) - return require("ts_context_commentstring.internal").calculate_commentstring() + pre_hook = function(ctx) + local U = require "Comment.utils" + + -- Determine whether to use linewise or blockwise commentstring + local type = ctx.ctype == U.ctype.linewise and "__default" or "__multiline" + + -- Determine the location where to calculate commentstring from + local location = nil + if ctx.ctype == U.ctype.blockwise then + location = require("ts_context_commentstring.utils").get_cursor_location() + elseif ctx.cmotion == U.cmotion.v or ctx.cmotion == U.cmotion.V then + location = require("ts_context_commentstring.utils").get_visual_start_location() + end + + return require("ts_context_commentstring.internal").calculate_commentstring { + key = type, + location = location, + } end end lvim.builtin.comment = { -- cgit v1.2.3 From df84e4ecce5a7c8838fd21d5de939128f3214ef4 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 29 Aug 2022 14:34:43 +0200 Subject: chore: bump plugins version (#2925) --- snapshots/default.json | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/snapshots/default.json b/snapshots/default.json index 4b1d68a7..84990838 100644 --- a/snapshots/default.json +++ b/snapshots/default.json @@ -1,6 +1,6 @@ { "Comment.nvim": { - "commit": "350bf0c" + "commit": "80e7746" }, "FixCursorHold.nvim": { "commit": "5aa5ff1" @@ -9,7 +9,7 @@ "commit": "9f454cc" }, "alpha-nvim": { - "commit": "d688f46" + "commit": "f457f7f" }, "bufferline.nvim": { "commit": "13a532e" @@ -30,28 +30,28 @@ "commit": "3679132" }, "friendly-snippets": { - "commit": "6227548" + "commit": "e5a16f9" }, "gitsigns.nvim": { - "commit": "79c55eb" + "commit": "1e107c9" }, "lua-dev.nvim": { "commit": "54149d1" }, "lualine.nvim": { - "commit": "c0510dd" + "commit": "3cf4540" }, "mason-lspconfig.nvim": { - "commit": "d9365e7" + "commit": "74c45b3" }, "mason.nvim": { - "commit": "5dbb22a" + "commit": "9249238" }, "nlsp-settings.nvim": { - "commit": "48d02d1" + "commit": "1ffdeff" }, "null-ls.nvim": { - "commit": "9d1f8dc" + "commit": "753ad51" }, "nvim-autopairs": { "commit": "0a18e10" @@ -60,22 +60,22 @@ "commit": "058100d" }, "nvim-dap": { - "commit": "ad8b0de" + "commit": "57003a0" }, "nvim-lspconfig": { - "commit": "da7461b" + "commit": "636ce36" }, "nvim-notify": { - "commit": "60bb6bf" + "commit": "cf5dc4f" }, "nvim-tree.lua": { - "commit": "81eb718" + "commit": "4a725c0" }, "nvim-treesitter": { - "commit": "2bb9bb7" + "commit": "f3c53d2" }, "nvim-ts-context-commentstring": { - "commit": "37a97a0" + "commit": "4d3a68c" }, "nvim-web-devicons": { "commit": "2d02a56" @@ -84,10 +84,10 @@ "commit": "b00dd21" }, "packer.nvim": { - "commit": "90b323b" + "commit": "3a9f980" }, "plenary.nvim": { - "commit": "31807ee" + "commit": "a3dafaa" }, "popup.nvim": { "commit": "b7404d3" @@ -96,7 +96,7 @@ "commit": "090bb11" }, "schemastore.nvim": { - "commit": "539a2d3" + "commit": "8f3a6e8" }, "structlog.nvim": { "commit": "232a8e2" @@ -105,10 +105,10 @@ "commit": "6791f74" }, "telescope.nvim": { - "commit": "5103387" + "commit": "8dce937" }, "toggleterm.nvim": { - "commit": "62683d9" + "commit": "f494c61" }, "which-key.nvim": { "commit": "f03a259" -- cgit v1.2.3