diff options
Diffstat (limited to 'lua/lvim')
-rw-r--r-- | lua/lvim/bootstrap.lua | 5 | ||||
-rw-r--r-- | lua/lvim/core/autopairs.lua | 16 | ||||
-rw-r--r-- | lua/lvim/core/cmp.lua | 2 | ||||
-rw-r--r-- | lua/lvim/plugin-loader.lua | 14 | ||||
-rw-r--r-- | lua/lvim/utils/hooks.lua | 18 |
5 files changed, 36 insertions, 19 deletions
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", "<CR>", "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 |