From f59af32e115d567a60b045c7e197199f1aa96fc6 Mon Sep 17 00:00:00 2001 From: Abouzar Parvan Date: Sun, 24 Oct 2021 12:09:11 +0330 Subject: feat: add transparent endofbuffer --- lua/lvim/config/settings.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'lua') diff --git a/lua/lvim/config/settings.lua b/lua/lvim/config/settings.lua index b86e1a18..8db43904 100644 --- a/lua/lvim/config/settings.lua +++ b/lua/lvim/config/settings.lua @@ -69,6 +69,7 @@ M.load_commands = function() cmd "au ColorScheme * hi MsgArea ctermbg=none guibg=none" cmd "au ColorScheme * hi TelescopeBorder ctermbg=none guibg=none" cmd "au ColorScheme * hi NvimTreeNormal ctermbg=none guibg=none" + cmd "au ColorScheme * hi EndOfBuffer ctermbg=none guibg=none" cmd "let &fcs='eob: '" end end -- cgit v1.2.3 From 674588a375ce354e77dc6ced858e7c5efcbf67d9 Mon Sep 17 00:00:00 2001 From: Abouzar Parvan Date: Sun, 24 Oct 2021 12:23:10 +0330 Subject: feat: make listchars visible Fixes #1812 --- lua/onedarker/highlights.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lua') diff --git a/lua/onedarker/highlights.lua b/lua/onedarker/highlights.lua index 2869977c..f035635b 100644 --- a/lua/onedarker/highlights.lua +++ b/lua/onedarker/highlights.lua @@ -18,7 +18,7 @@ local highlights = { FoldColumn = { fg = C.accent, bg = C.alt_bg }, LineNr = { fg = C.context }, FloatBorder = { fg = C.gray, bg = C.alt_bg }, - Whitespace = { fg = C.bg }, + Whitespace = { fg = C.gray }, VertSplit = { fg = C.bg, bg = C.fg }, CursorLine = { bg = C.dark }, CursorColumn = { bg = C.dark }, -- cgit v1.2.3 From 27ffaab737ae27a10a05eb11473f51ac35b21701 Mon Sep 17 00:00:00 2001 From: kylo252 <59826753+kylo252@users.noreply.github.com> Date: Sun, 24 Oct 2021 14:22:39 +0200 Subject: feat: make cmp keyword_length easier to configure (#1840) --- lua/lvim/core/cmp.lua | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'lua') diff --git a/lua/lvim/core/cmp.lua b/lua/lvim/core/cmp.lua index b1cb1431..f35ead9a 100644 --- a/lua/lvim/core/cmp.lua +++ b/lua/lvim/core/cmp.lua @@ -126,6 +126,12 @@ M.config = function() behavior = cmp.ConfirmBehavior.Replace, select = false, }, + completion = { + ---@usage vim's `completeopt` setting. Warning: Be careful when changing this value. + completeopt = "menu,menuone,noinsert", + ---@usage The minimum length of a word to complete on. + keyword_length = 1, + }, experimental = { ghost_text = true, native_menu = false, @@ -241,7 +247,7 @@ M.config = function() }), [""] = cmp.mapping.complete(), - [""] = cmp.mapping.close(), + [""] = cmp.mapping.abort(), [""] = cmp.mapping(function(fallback) if cmp.visible() and cmp.confirm(lvim.builtin.cmp.confirm_opts) then return -- cgit v1.2.3 From 620beb5c94dc4efd165fda80dfa1bbe27871b7cd Mon Sep 17 00:00:00 2001 From: kylo252 <59826753+kylo252@users.noreply.github.com> Date: Sun, 24 Oct 2021 14:34:00 +0200 Subject: fix(lsp): disable eslint server by default (#1842) --- lua/lvim/lsp/config.lua | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lua') diff --git a/lua/lvim/lsp/config.lua b/lua/lvim/lsp/config.lua index 96430631..2d9104ea 100644 --- a/lua/lvim/lsp/config.lua +++ b/lua/lvim/lsp/config.lua @@ -46,6 +46,8 @@ return { "ansiblels", "denols", "ember", + "eslint", + "eslintls", "jedi_language_server", "pylsp", "rome", -- cgit v1.2.3 From 177916d63d7e1c748c48436ef93b30f0019eacac Mon Sep 17 00:00:00 2001 From: Chase Colman <5411+chase@users.noreply.github.com> Date: Tue, 26 Oct 2021 00:54:27 +0800 Subject: feat(cmp): expose lunarvim's cmp helper methods (#1844) Co-authored-by: xeluxee <88047141+xeluxee@users.noreply.github.com> --- lua/lvim/core/cmp.lua | 60 ++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 47 insertions(+), 13 deletions(-) (limited to 'lua') diff --git a/lua/lvim/core/cmp.lua b/lua/lvim/core/cmp.lua index f35ead9a..57fb70c4 100644 --- a/lua/lvim/core/cmp.lua +++ b/lua/lvim/core/cmp.lua @@ -1,14 +1,29 @@ 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" end +M.methods.check_backspace = check_backspace local function T(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) +end +M.methods.feedkeys = feedkeys + +---checks if emmet_ls is available and active in the buffer +---@return boolean true if available, false otherwise local is_emmet_active = function() local clients = vim.lsp.buf_get_clients() @@ -19,16 +34,17 @@ local is_emmet_active = function() end return false end +M.methods.is_emmet_active = is_emmet_active -M.config = function() - local status_cmp_ok, cmp = pcall(require, "cmp") - if not status_cmp_ok then - return - end - local status_luasnip_ok, luasnip = pcall(require, "luasnip") - if not status_luasnip_ok then +---when inside a snippet, seeks to the nearest luasnip field if possible, and checks if it is jumpable +---@param dir number 1 for forward, -1 for backward; defaults to 1 +---@return boolean true if a jumpable luasnip field is found while inside a snippet +local function jumpable(dir) + local luasnip_ok, luasnip = pcall(require, "luasnip") + if not luasnip_ok then return end + local win_get_cursor = vim.api.nvim_win_get_cursor local get_current_buf = vim.api.nvim_get_current_buf @@ -121,6 +137,24 @@ M.config = function() return false end + if dir == -1 then + return inside_snippet() and luasnip.jumpable(-1) + else + return inside_snippet() and seek_luasnip_cursor_node() and luasnip.jumpable() + end +end +M.methods.jumpable = jumpable + +M.config = function() + local status_cmp_ok, cmp = pcall(require, "cmp") + if not status_cmp_ok then + return + end + local status_luasnip_ok, luasnip = pcall(require, "luasnip") + if not status_luasnip_ok then + return + end + lvim.builtin.cmp = { confirm_opts = { behavior = cmp.ConfirmBehavior.Replace, @@ -215,19 +249,19 @@ M.config = function() [""] = cmp.mapping.scroll_docs(-4), [""] = cmp.mapping.scroll_docs(4), -- TODO: potentially fix emmet nonsense - [""] = cmp.mapping(function() + [""] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_next_item() elseif luasnip.expandable() then luasnip.expand() - elseif inside_snippet() and seek_luasnip_cursor_node() and luasnip.jumpable() then + elseif jumpable() then luasnip.jump(1) elseif check_backspace() then - vim.fn.feedkeys(T "", "n") + fallback() elseif is_emmet_active() then return vim.fn["cmp#complete"]() else - vim.fn.feedkeys(T "", "n") + fallback() end end, { "i", @@ -236,7 +270,7 @@ M.config = function() [""] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_prev_item() - elseif inside_snippet() and luasnip.jumpable(-1) then + elseif jumpable(-1) then luasnip.jump(-1) else fallback() @@ -253,7 +287,7 @@ M.config = function() return end - if inside_snippet() and seek_luasnip_cursor_node() and luasnip.jumpable() then + if jumpable() then if not luasnip.jump(1) then fallback() end -- cgit v1.2.3 From 6b8ef55e3de47224cd40de1d67831901484d3d5a Mon Sep 17 00:00:00 2001 From: Chase Colman Date: Thu, 28 Oct 2021 21:15:49 +0800 Subject: fix(lsp): install templates and configure overrides for custom providers --- lua/lvim/lsp/manager.lua | 10 +++++++--- lua/lvim/lsp/templates.lua | 3 ++- 2 files changed, 9 insertions(+), 4 deletions(-) (limited to 'lua') diff --git a/lua/lvim/lsp/manager.lua b/lua/lvim/lsp/manager.lua index 0b11c175..a8544803 100644 --- a/lua/lvim/lsp/manager.lua +++ b/lua/lvim/lsp/manager.lua @@ -26,8 +26,8 @@ local function resolve_config(name, user_config) capabilities = require("lvim.lsp").common_capabilities(), } - local status_ok, custom_config = pcall(require, "lvim.lsp/providers/" .. name) - if status_ok then + local has_custom_provider, custom_config = pcall(require, "lvim/lsp/providers/" .. name) + if has_custom_provider then Log:debug("Using custom configuration for requested server: " .. name) config = vim.tbl_deep_extend("force", config, custom_config) end @@ -70,7 +70,11 @@ function M.setup(server_name, user_config) if server_available and ensure_installed(requested_server) then requested_server:setup(config) else - require("lspconfig")[server_name].setup(config) + -- since it may not be installed, don't attempt to configure the LSP unless there is a custom provider + local has_custom_provider, _ = pcall(require, "lvim/lsp/providers/" .. server_name) + if has_custom_provider then + require("lspconfig")[server_name].setup(config) + end end end diff --git a/lua/lvim/lsp/templates.lua b/lua/lvim/lsp/templates.lua index 3478f4fb..33c75a6e 100644 --- a/lua/lvim/lsp/templates.lua +++ b/lua/lvim/lsp/templates.lua @@ -19,7 +19,8 @@ end ---@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 + local has_custom_provider, _ = pcall(require, "lvim/lsp/providers/" .. server_name) + if vim.tbl_contains(lvim.lsp.override, server_name) and not has_custom_provider then return end -- cgit v1.2.3 From 05337a9cf363ce24d1b65d51da4d674bab506651 Mon Sep 17 00:00:00 2001 From: Xavier Young <45989017+younger-1@users.noreply.github.com> Date: Sat, 30 Oct 2021 01:13:42 +0800 Subject: fix(whick-key): add missing space (only windows cause problem) (#1866) --- lua/lvim/core/which-key.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lua') diff --git a/lua/lvim/core/which-key.lua b/lua/lvim/core/which-key.lua index fcaeacf5..42e37456 100644 --- a/lua/lvim/core/which-key.lua +++ b/lua/lvim/core/which-key.lua @@ -177,7 +177,7 @@ M.config = function() L = { name = "+LunarVim", c = { - "edit" .. get_config_dir() .. "/config.lua", + "edit " .. get_config_dir() .. "/config.lua", "Edit config.lua", }, f = { -- cgit v1.2.3 From ffd1d5e16522f7c03603c183eec237d529dbe1e3 Mon Sep 17 00:00:00 2001 From: Antonio Hickey <64357439+antonio-hickey@users.noreply.github.com> Date: Fri, 29 Oct 2021 13:32:13 -0400 Subject: feat: new file cmd for dashboard + icon update (#1849) --- lua/lvim/core/dashboard.lua | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'lua') diff --git a/lua/lvim/core/dashboard.lua b/lua/lvim/core/dashboard.lua index 108ed0d2..11053796 100644 --- a/lua/lvim/core/dashboard.lua +++ b/lua/lvim/core/dashboard.lua @@ -31,22 +31,26 @@ M.config = function(config) custom_section = { a = { - description = { " Find File " }, + description = { " Find File " }, command = "Telescope find_files", }, b = { + description = { " New File " }, + command = ":ene!", + }, + c = { description = { " Recent Projects " }, command = "Telescope projects", }, - c = { + d = { description = { " Recently Used Files" }, command = "Telescope oldfiles", }, - d = { + e = { description = { " Find Word " }, command = "Telescope live_grep", }, - e = { + f = { description = { " Configuration " }, command = ":e " .. config.user_config_file, }, -- cgit v1.2.3 From 377cab434c79aa537820ba21bbcc44261304ed09 Mon Sep 17 00:00:00 2001 From: kylo252 <59826753+kylo252@users.noreply.github.com> Date: Fri, 29 Oct 2021 19:33:00 +0200 Subject: feat: update now syncs the core plugins (#1865) --- lua/lvim/bootstrap.lua | 5 ++--- lua/lvim/core/autopairs.lua | 16 ++++++---------- lua/lvim/core/cmp.lua | 2 -- lua/lvim/plugin-loader.lua | 14 ++++++++++++++ lua/lvim/utils/hooks.lua | 18 ++++++++++++++---- 5 files changed, 36 insertions(+), 19 deletions(-) (limited to 'lua') diff --git a/lua/lvim/bootstrap.lua b/lua/lvim/bootstrap.lua index fbb362ce..e17c79db 100644 --- a/lua/lvim/bootstrap.lua +++ b/lua/lvim/bootstrap.lua @@ -1,8 +1,5 @@ local M = {} -package.loaded["lvim.utils.hooks"] = nil -local _, hooks = pcall(require, "lvim.utils.hooks") - local uv = vim.loop local path_sep = uv.os_uname().version:match "Windows" and "\\" or "/" @@ -101,6 +98,8 @@ end ---Update LunarVim ---pulls the latest changes from github and, resets the startup cache function M:update() + package.loaded["lvim.utils.hooks"] = nil + local _, hooks = pcall(require, "lvim.utils.hooks") hooks.run_pre_update() M:update_repo() hooks.run_post_update() diff --git a/lua/lvim/core/autopairs.lua b/lua/lvim/core/autopairs.lua index eb080fb1..51649790 100644 --- a/lua/lvim/core/autopairs.lua +++ b/lua/lvim/core/autopairs.lua @@ -4,8 +4,6 @@ function M.config() lvim.builtin.autopairs = { active = true, on_config_done = nil, - ---@usage auto insert after select function or method item - map_complete = true, ---@usage -- modifies the function or method delimiter by filetypes map_char = { all = "(", @@ -52,14 +50,12 @@ M.setup = function() end), } - if package.loaded["cmp"] then - require("nvim-autopairs.completion.cmp").setup { - map_cr = false, - map_complete = lvim.builtin.autopairs.map_complete, - map_char = lvim.builtin.autopairs.map_char, - } - -- we map CR explicitly in cmp.lua but we still need to setup the autopairs CR keymap - vim.api.nvim_set_keymap("i", "", "v:lua.MPairs.autopairs_cr()", { expr = true, noremap = true }) + local cmp_status_ok, cmp = pcall(require, "cmp") + if cmp_status_ok then + -- If you want insert `(` after select function or method item + local cmp_autopairs = require "nvim-autopairs.completion.cmp" + local map_char = lvim.builtin.autopairs.map_char + cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done { map_char = map_char }) end require("nvim-treesitter.configs").setup { autopairs = { enable = true } } diff --git a/lua/lvim/core/cmp.lua b/lua/lvim/core/cmp.lua index 57fb70c4..68c695cb 100644 --- a/lua/lvim/core/cmp.lua +++ b/lua/lvim/core/cmp.lua @@ -161,8 +161,6 @@ M.config = function() select = false, }, completion = { - ---@usage vim's `completeopt` setting. Warning: Be careful when changing this value. - completeopt = "menu,menuone,noinsert", ---@usage The minimum length of a word to complete on. keyword_length = 1, }, diff --git a/lua/lvim/plugin-loader.lua b/lua/lvim/plugin-loader.lua index feef7ea7..e1ede7bc 100644 --- a/lua/lvim/plugin-loader.lua +++ b/lua/lvim/plugin-loader.lua @@ -60,4 +60,18 @@ function plugin_loader:load(configurations) end) end +function plugin_loader:get_core_plugins() + local list = {} + local plugins = require "lvim.plugins" + for _, item in pairs(plugins) do + table.insert(list, item[1]:match "/(%S*)") + end + return list +end + +function plugin_loader:sync_core_plugins() + local core_plugins = plugin_loader.get_core_plugins() + vim.cmd("PackerSync " .. unpack(core_plugins)) +end + return plugin_loader diff --git a/lua/lvim/utils/hooks.lua b/lua/lvim/utils/hooks.lua index d536bc76..cc884523 100644 --- a/lua/lvim/utils/hooks.lua +++ b/lua/lvim/utils/hooks.lua @@ -1,11 +1,13 @@ local M = {} +local plugin_loader = require "lvim.plugin-loader" local Log = require "lvim.core.log" local in_headless = #vim.api.nvim_list_uis() == 0 function M.run_pre_update() Log:debug "Starting pre-update hook" _G.__luacache.clear_cache() + vim.cmd "LspStop" end ---Reset any startup cache files used by Packer and Impatient @@ -13,21 +15,29 @@ end ---Tip: Useful for clearing any outdated settings function M.reset_cache() _G.__luacache.clear_cache() - require("lvim.plugin-loader"):cache_reset() + + plugin_loader:cache_reset() package.loaded["lvim.lsp.templates"] = nil + + Log:debug "Re-generatring ftplugin template files" require("lvim.lsp.templates").generate_templates() end function M.run_post_update() Log:debug "Starting post-update hook" - M.reset_cache() + + Log:debug "Re-generatring ftplugin template files" + package.loaded["lvim.lsp.templates"] = nil + require("lvim.lsp.templates").generate_templates() + + Log:debug "Updating core plugins" + plugin_loader:sync_core_plugins() if not in_headless then vim.schedule(function() - require("packer").install() -- TODO: add a changelog vim.notify("Update complete", vim.log.levels.INFO) - vim.cmd "LspStart" + vim.cmd "LspRestart" end) end end -- cgit v1.2.3 From c4a85b32752e1ca41c6d9a2613b9d2e75dbf463d Mon Sep 17 00:00:00 2001 From: kylo252 <59826753+kylo252@users.noreply.github.com> Date: Sat, 30 Oct 2021 14:20:53 +0200 Subject: fix: pin nvim-tree (#1874) --- lua/lvim/plugins.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lua') diff --git a/lua/lvim/plugins.lua b/lua/lvim/plugins.lua index 976e5141..4c3a0f67 100644 --- a/lua/lvim/plugins.lua +++ b/lua/lvim/plugins.lua @@ -81,7 +81,7 @@ return { "kyazdani42/nvim-tree.lua", -- event = "BufWinOpen", -- cmd = "NvimTreeToggle", - -- commit = "fd7f60e242205ea9efc9649101c81a07d5f458bb", + commit = "f92b7e7627c5a36f4af6814c408211539882c4f3", config = function() require("lvim.core.nvimtree").setup() end, -- cgit v1.2.3