diff --git a/init.lua b/init.lua index 754528432a..3fdf2a4e0a 100644 --- a/init.lua +++ b/init.lua @@ -23,5 +23,3 @@ Log:debug "Starting LunarVim" local commands = require "lvim.core.commands" commands.load(commands.defaults) - -require("lvim.lsp").setup() diff --git a/lua/lvim/config/settings.lua b/lua/lvim/config/settings.lua index 0f3629bd53..42281ca14f 100644 --- a/lua/lvim/config/settings.lua +++ b/lua/lvim/config/settings.lua @@ -26,7 +26,6 @@ M.load_default_options = function() mouse = "a", -- allow the mouse to be used in neovim pumheight = 10, -- pop up menu height showmode = false, -- we don't need to see things like -- INSERT -- anymore - showtabline = 2, -- always show tabs smartcase = true, -- smart case splitbelow = true, -- force all horizontal splits to go below current window splitright = true, -- force all vertical splits to go to the right of current window diff --git a/lua/lvim/core/alpha.lua b/lua/lvim/core/alpha.lua index 3fded29f9a..13642c29be 100644 --- a/lua/lvim/core/alpha.lua +++ b/lua/lvim/core/alpha.lua @@ -66,24 +66,6 @@ local function resolve_config(theme_name) return selected_theme.config end -local function configure_additional_autocmds() - local group = "_dashboard_settings" - vim.api.nvim_create_augroup(group, {}) - vim.api.nvim_create_autocmd("FileType", { - group = group, - pattern = "alpha", - command = "set showtabline=0 | autocmd BufLeave set showtabline=" .. vim.opt.showtabline._value, - }) - if not lvim.builtin.lualine.options.globalstatus then - -- https://github.com/goolord/alpha-nvim/issues/42 - vim.api.nvim_create_autocmd("FileType", { - group = group, - pattern = "alpha", - command = "set laststatus=0 | autocmd BufUnload set laststatus=" .. vim.opt.laststatus._value, - }) - end -end - function M.setup() local status_ok, alpha = pcall(require, "alpha") if not status_ok then @@ -98,7 +80,6 @@ function M.setup() end alpha.setup(config) - configure_additional_autocmds() end return M diff --git a/lua/lvim/core/autocmds.lua b/lua/lvim/core/autocmds.lua index f8da317e31..a9f7115a59 100644 --- a/lua/lvim/core/autocmds.lua +++ b/lua/lvim/core/autocmds.lua @@ -119,6 +119,35 @@ function M.load_defaults() end, }, }, + { -- taken from AstroNvim + "BufEnter", + { + group = "_dir_opened", + once = true, + callback = function(args) + local bufname = vim.api.nvim_buf_get_name(args.buf) + if require("lvim.utils").is_directory(bufname) then + vim.api.nvim_del_augroup_by_name "_dir_opened" + vim.cmd "do User DirOpened" + vim.api.nvim_exec_autocmds("BufEnter", {}) + end + end, + }, + }, + { -- taken from AstroNvim + { "BufRead", "BufWinEnter", "BufNewFile" }, + { + group = "_file_opened", + once = true, + callback = function(args) + local buftype = vim.api.nvim_get_option_value("buftype", { buf = args.buf }) + if not (vim.fn.expand "%" == "" or buftype == "nofile") then + vim.cmd "do User FileOpened" + require("lvim.lsp").setup() + end + end, + }, + }, } M.define_autocmds(definitions) diff --git a/lua/lvim/core/bufferline.lua b/lua/lvim/core/bufferline.lua index 1344eb9a88..27318a1846 100644 --- a/lua/lvim/core/bufferline.lua +++ b/lua/lvim/core/bufferline.lua @@ -152,6 +152,9 @@ M.setup = function() return end + -- can't be set in settings.lua because default tabline would flash before bufferline is loaded + vim.opt.showtabline = 2 + bufferline.setup { options = lvim.builtin.bufferline.options, highlights = lvim.builtin.bufferline.highlights, diff --git a/lua/lvim/core/cmp.lua b/lua/lvim/core/cmp.lua index 142d548f67..c116f12281 100644 --- a/lua/lvim/core/cmp.lua +++ b/lua/lvim/core/cmp.lua @@ -118,14 +118,17 @@ end M.methods.jumpable = jumpable M.config = function() - local status_cmp_ok, cmp = pcall(require, "cmp") + local status_cmp_ok, cmp_types = pcall(require, "cmp.types.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 + local ConfirmBehavior = cmp_types.ConfirmBehavior + local SelectBehavior = cmp_types.SelectBehavior + + local cmp = require("lvim.utils.modules").require_on_index "cmp" + local luasnip = require("lvim.utils.modules").require_on_index "luasnip" + local cmp_window = require "cmp.config.window" + local cmp_mapping = require "cmp.config.mapping" lvim.builtin.cmp = { active = true, @@ -138,7 +141,7 @@ M.config = function() return lvim.builtin.cmp.active end, confirm_opts = { - behavior = cmp.ConfirmBehavior.Replace, + behavior = ConfirmBehavior.Replace, select = false, }, completion = { @@ -214,12 +217,12 @@ M.config = function() }, snippet = { expand = function(args) - require("luasnip").lsp_expand(args.body) + luasnip.lsp_expand(args.body) end, }, window = { - completion = cmp.config.window.bordered(), - documentation = cmp.config.window.bordered(), + completion = cmp_window.bordered(), + documentation = cmp_window.bordered(), }, sources = { { @@ -255,7 +258,7 @@ M.config = function() { name = "nvim_lsp", entry_filter = function(entry, ctx) - local kind = require("cmp.types").lsp.CompletionItemKind[entry:get_kind()] + local kind = require("cmp.types.lsp").CompletionItemKind[entry:get_kind()] if kind == "Snippet" and ctx.prev_context.filetype == "java" then return false end @@ -277,24 +280,24 @@ M.config = function() { name = "crates" }, { name = "tmux" }, }, - mapping = cmp.mapping.preset.insert { - [""] = cmp.mapping(cmp.mapping.select_prev_item(), { "i", "c" }), - [""] = cmp.mapping(cmp.mapping.select_next_item(), { "i", "c" }), - [""] = 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 }, + mapping = cmp_mapping.preset.insert { + [""] = cmp_mapping(cmp_mapping.select_prev_item(), { "i", "c" }), + [""] = cmp_mapping(cmp_mapping.select_next_item(), { "i", "c" }), + [""] = cmp_mapping(cmp_mapping.select_next_item { behavior = SelectBehavior.Select }, { "i" }), + [""] = cmp_mapping(cmp_mapping.select_prev_item { behavior = SelectBehavior.Select }, { "i" }), + [""] = cmp_mapping.scroll_docs(-4), + [""] = cmp_mapping.scroll_docs(4), + [""] = cmp_mapping { + i = cmp_mapping.confirm { behavior = ConfirmBehavior.Replace, select = false }, c = function(fallback) if cmp.visible() then - cmp.confirm { behavior = cmp.ConfirmBehavior.Replace, select = false } + cmp.confirm { behavior = ConfirmBehavior.Replace, select = false } else fallback() end end, }, - [""] = cmp.mapping(function(fallback) + [""] = cmp_mapping(function(fallback) if cmp.visible() then cmp.select_next_item() elseif luasnip.expand_or_locally_jumpable() then @@ -308,7 +311,7 @@ M.config = function() fallback() end end, { "i", "s" }), - [""] = cmp.mapping(function(fallback) + [""] = cmp_mapping(function(fallback) if cmp.visible() then cmp.select_prev_item() elseif luasnip.jumpable(-1) then @@ -317,16 +320,16 @@ M.config = function() fallback() end end, { "i", "s" }), - [""] = cmp.mapping.complete(), - [""] = cmp.mapping.abort(), - [""] = cmp.mapping(function(fallback) + [""] = cmp_mapping.complete(), + [""] = cmp_mapping.abort(), + [""] = cmp_mapping(function(fallback) if cmp.visible() then local confirm_opts = vim.deepcopy(lvim.builtin.cmp.confirm_opts) -- avoid mutating the original opts below 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 + confirm_opts.behavior = ConfirmBehavior.Insert end if cmp.confirm(confirm_opts) then return -- success, exit early diff --git a/lua/lvim/core/comment.lua b/lua/lvim/core/comment.lua index 501d01b6ce..f07929c7bf 100644 --- a/lua/lvim/core/comment.lua +++ b/lua/lvim/core/comment.lua @@ -1,11 +1,6 @@ local M = {} function M.config() - local pre_hook - local loaded, ts_comment = pcall(require, "ts_context_commentstring.integrations.comment_nvim") - if loaded and ts_comment then - pre_hook = ts_comment.create_pre_hook() - end lvim.builtin.comment = { active = true, on_config_done = nil, @@ -66,7 +61,12 @@ function M.config() ---Pre-hook, called before commenting the line ---@type function|nil - pre_hook = pre_hook, + pre_hook = function(...) + local loaded, ts_comment = pcall(require, "ts_context_commentstring.integrations.comment_nvim") + if loaded and ts_comment then + return ts_comment.create_pre_hook()(...) + end + end, ---Post-hook, called after commenting is done ---@type function|nil diff --git a/lua/lvim/core/lir.lua b/lua/lvim/core/lir.lua index 9f915ed281..83f79b6f09 100644 --- a/lua/lvim/core/lir.lua +++ b/lua/lvim/core/lir.lua @@ -1,22 +1,14 @@ local M = {} M.config = function() + local utils = require "lvim.utils.modules" + local actions = utils.require_on_exported_call "lir.actions" + local clipboard_actions = utils.require_on_exported_call "lir.clipboard.actions" + lvim.builtin.lir = { active = true, on_config_done = nil, icon = "", - } - - local status_ok, _ = pcall(require, "lir") - if not status_ok then - return - end - - local actions = require "lir.actions" - local mark_actions = require "lir.mark.actions" - local clipboard_actions = require "lir.clipboard.actions" - - lvim.builtin.lir = vim.tbl_extend("force", lvim.builtin.lir, { show_hidden_files = false, ignore = {}, -- { ".DS_Store" "node_modules" } etc. devicons = { @@ -42,7 +34,7 @@ M.config = function() ["d"] = actions.delete, ["J"] = function() - mark_actions.toggle_mark() + require("lir.mark.actions").toggle_mark() vim.cmd "normal! j" end, ["c"] = clipboard_actions.copy, @@ -79,7 +71,7 @@ M.config = function() { noremap = true, silent = true } ) end, - }) + } end function M.icon_setup() @@ -118,6 +110,7 @@ function M.setup() end lir.setup(lvim.builtin.lir) + M.icon_setup() if lvim.builtin.lir.on_config_done then lvim.builtin.lir.on_config_done(lir) diff --git a/lua/lvim/core/lualine/init.lua b/lua/lvim/core/lualine/init.lua index 0ee35c04c9..fa4cf8218c 100644 --- a/lua/lvim/core/lualine/init.lua +++ b/lua/lvim/core/lualine/init.lua @@ -8,7 +8,7 @@ M.config = function() component_separators = nil, section_separators = nil, theme = nil, - disabled_filetypes = nil, + disabled_filetypes = { statusline = { "alpha" } }, globalstatus = true, }, sections = { diff --git a/lua/lvim/core/nvimtree.lua b/lua/lvim/core/nvimtree.lua index 6f87e30d31..26bd6d7021 100644 --- a/lua/lvim/core/nvimtree.lua +++ b/lua/lvim/core/nvimtree.lua @@ -12,8 +12,6 @@ function M.config() hijack_netrw = true, hijack_unnamed_buffer_when_opening = false, ignore_buffer_on_setup = false, - open_on_setup = false, - open_on_setup_file = false, sort_by = "name", root_dirs = {}, prefer_startup_root = false, @@ -117,11 +115,6 @@ function M.config() update_root = true, ignore_list = {}, }, - ignore_ft_on_setup = { - "startify", - "dashboard", - "alpha", - }, diagnostics = { enable = lvim.use_icons, show_on_dirs = false, diff --git a/lua/lvim/core/telescope.lua b/lua/lvim/core/telescope.lua index a1b17e040d..b701f7e407 100644 --- a/lua/lvim/core/telescope.lua +++ b/lua/lvim/core/telescope.lua @@ -7,21 +7,11 @@ local M = {} ---| "center" # retain the default telescope theme function M.config() - -- Define this minimal config so that it's available if telescope is not yet available. - + local actions = require("lvim.utils.modules").require_on_exported_call "telescope.actions" lvim.builtin.telescope = { ---@usage disable telescope completely [not recommended] active = true, on_config_done = nil, - } - - local ok, actions = pcall(require, "telescope.actions") - if not ok then - return - end - lvim.builtin.telescope = { - active = true, - on_config_done = nil, theme = "dropdown", ---@type telescope_themes defaults = { prompt_prefix = lvim.icons.ui.Telescope .. " ", @@ -51,13 +41,19 @@ function M.config() [""] = actions.close, [""] = actions.cycle_history_next, [""] = actions.cycle_history_prev, - [""] = actions.smart_send_to_qflist + actions.open_qflist, + [""] = function(...) + actions.smart_send_to_qflist(...) + actions.open_qflist(...) + end, [""] = actions.select_default, }, n = { [""] = actions.move_selection_next, [""] = actions.move_selection_previous, - [""] = actions.smart_send_to_qflist + actions.open_qflist, + [""] = function(...) + actions.smart_send_to_qflist(...) + actions.open_qflist(...) + end, }, }, file_ignore_patterns = {}, diff --git a/lua/lvim/core/terminal.lua b/lua/lvim/core/terminal.lua index 663ba77a97..454953223f 100644 --- a/lua/lvim/core/terminal.lua +++ b/lua/lvim/core/terminal.lua @@ -77,10 +77,7 @@ local function get_dynamic_terminal_size(direction, size) end end -M.setup = function() - local terminal = require "toggleterm" - terminal.setup(lvim.builtin.terminal) - +M.init = function() for i, exec in pairs(lvim.builtin.terminal.execs) do local direction = exec[4] or lvim.builtin.terminal.direction @@ -98,7 +95,11 @@ M.setup = function() M.add_exec(opts) end +end +M.setup = function() + local terminal = require "toggleterm" + terminal.setup(lvim.builtin.terminal) if lvim.builtin.terminal.on_config_done then lvim.builtin.terminal.on_config_done(terminal) end diff --git a/lua/lvim/core/theme.lua b/lua/lvim/core/theme.lua index 6bf67906aa..5a39f04609 100644 --- a/lua/lvim/core/theme.lua +++ b/lua/lvim/core/theme.lua @@ -85,8 +85,12 @@ M.setup = function() vim.g.colors_name = lvim.colorscheme vim.cmd("colorscheme " .. lvim.colorscheme) - require("lvim.core.lualine").setup() - require("lvim.core.lir").icon_setup() + if package.loaded.lualine then + require("lvim.core.lualine").setup() + end + if package.loaded.lir then + require("lvim.core.lir").icon_setup() + end end return M diff --git a/lua/lvim/core/which-key.lua b/lua/lvim/core/which-key.lua index 8cedeabced..0e67178278 100644 --- a/lua/lvim/core/which-key.lua +++ b/lua/lvim/core/which-key.lua @@ -205,20 +205,20 @@ M.config = function() a = { "lua vim.lsp.buf.code_action()", "Code Action" }, d = { "Telescope diagnostics bufnr=0 theme=get_ivy", "Buffer Diagnostics" }, w = { "Telescope diagnostics", "Diagnostics" }, - f = { require("lvim.lsp.utils").format, "Format" }, + f = { "lua require('lvim.lsp.utils').format()", "Format" }, i = { "LspInfo", "Info" }, I = { "Mason", "Mason Info" }, j = { - vim.diagnostic.goto_next, + "lua vim.diagnostic.goto_next()", "Next Diagnostic", }, k = { - vim.diagnostic.goto_prev, + "lua vim.diagnostic.goto_prev()", "Prev Diagnostic", }, - l = { vim.lsp.codelens.run, "CodeLens Action" }, - q = { vim.diagnostic.setloclist, "Quickfix" }, - r = { vim.lsp.buf.rename, "Rename" }, + l = { "lua vim.lsp.codelens.run()", "CodeLens Action" }, + q = { "lua vim.diagnostic.setloclist()", "Quickfix" }, + r = { "lua vim.lsp.buf.rename()", "Rename" }, s = { "Telescope lsp_document_symbols", "Document Symbols" }, S = { "Telescope lsp_dynamic_workspace_symbols", @@ -287,6 +287,7 @@ M.config = function() t = { "Telescope live_grep", "Text" }, k = { "Telescope keymaps", "Keymaps" }, C = { "Telescope commands", "Commands" }, + l = { "Telescope resume", "Resume last search" }, p = { "lua require('telescope.builtin').colorscheme({enable_preview = true})", "Colorscheme with Preview", diff --git a/lua/lvim/lsp/config.lua b/lua/lvim/lsp/config.lua index 6eecbf856b..7128a4ccb5 100644 --- a/lua/lvim/lsp/config.lua +++ b/lua/lvim/lsp/config.lua @@ -20,6 +20,7 @@ local skipped_servers = { "phpactor", "psalm", "pylsp", + "pyre", "quick_lint_js", "reason_ls", "rnix", @@ -39,7 +40,9 @@ local skipped_servers = { "stylelint_lsp", "svlangserver", "tflint", + "unocss", "verible", + "vtsls", "vuels", } @@ -96,12 +99,12 @@ return { }, buffer_mappings = { normal_mode = { - ["K"] = { vim.lsp.buf.hover, "Show hover" }, - ["gd"] = { vim.lsp.buf.definition, "Goto Definition" }, - ["gD"] = { vim.lsp.buf.declaration, "Goto declaration" }, - ["gr"] = { vim.lsp.buf.references, "Goto references" }, - ["gI"] = { vim.lsp.buf.implementation, "Goto Implementation" }, - ["gs"] = { vim.lsp.buf.signature_help, "show signature help" }, + ["K"] = { "lua vim.lsp.buf.hover()", "Show hover" }, + ["gd"] = { "lua vim.lsp.buf.definition()", "Goto Definition" }, + ["gD"] = { "lua vim.lsp.buf.declaration()", "Goto declaration" }, + ["gr"] = { "lua vim.lsp.buf.references()", "Goto references" }, + ["gI"] = { "lua vim.lsp.buf.implementation()", "Goto Implementation" }, + ["gs"] = { "lua vim.lsp.buf.signature_help()", "show signature help" }, ["gl"] = { function() local config = lvim.lsp.diagnostics.float diff --git a/lua/lvim/lsp/init.lua b/lua/lvim/lsp/init.lua index b997b17100..0fea876a07 100644 --- a/lua/lvim/lsp/init.lua +++ b/lua/lvim/lsp/init.lua @@ -110,14 +110,6 @@ function M.setup() require("nlspsettings").setup(lvim.lsp.nlsp_settings.setup) end) - pcall(function() - require("mason-lspconfig").setup(lvim.lsp.installer.setup) - - -- automatic_installation is handled by lsp-manager - local settings = require "mason-lspconfig.settings" - settings.current.automatic_installation = false - end) - require("lvim.lsp.null-ls").setup() autocmds.configure_format_on_save() diff --git a/lua/lvim/lsp/templates.lua b/lua/lvim/lsp/templates.lua index dc2e5b11cf..7df19a71b3 100644 --- a/lua/lvim/lsp/templates.lua +++ b/lua/lvim/lsp/templates.lua @@ -44,6 +44,7 @@ function M.generate_ftplugin(server_name, dir) end for _, filetype in ipairs(filetypes) do + filetype = filetype:match "%.([^.]*)$" or filetype local filename = join_paths(dir, filetype .. ".lua") local setup_cmd = string.format([[require("lvim.lsp.manager").setup(%q)]], server_name) -- print("using setup_cmd: " .. setup_cmd) diff --git a/lua/lvim/plugin-loader.lua b/lua/lvim/plugin-loader.lua index c2118edf40..647fab9f16 100644 --- a/lua/lvim/plugin-loader.lua +++ b/lua/lvim/plugin-loader.lua @@ -23,7 +23,6 @@ function plugin_loader.init(opts) vim.fn.system { "git", "clone", - "--filter=blob:none", "--branch=stable", "https://github.com/folke/lazy.nvim.git", lazy_install_dir, @@ -39,6 +38,10 @@ function plugin_loader.init(opts) snapshot["lazy.nvim"].commit, } end + + vim.schedule(function() + require("lvim.lsp").setup() + end) end vim.opt.runtimepath:append(lazy_install_dir) @@ -118,6 +121,10 @@ function plugin_loader.load(configurations) reset = false, }, }, + defaults = { + lazy = false, + version = nil, + }, readme = { root = join_paths(get_runtime_dir(), "lazy", "readme"), }, diff --git a/lua/lvim/plugins.lua b/lua/lvim/plugins.lua index e13413986e..61aeb22111 100644 --- a/lua/lvim/plugins.lua +++ b/lua/lvim/plugins.lua @@ -6,25 +6,41 @@ local core_plugins = { lazy = true, dependencies = { "mason-lspconfig.nvim", "nlsp-settings.nvim" }, }, - { "williamboman/mason-lspconfig.nvim", lazy = true }, - { "tamago324/nlsp-settings.nvim", lazy = true }, + { + "williamboman/mason-lspconfig.nvim", + cmd = { "LspInstall", "LspUninstall" }, + config = function() + require("mason-lspconfig").setup(lvim.lsp.installer.setup) + + -- automatic_installation is handled by lsp-manager + local settings = require "mason-lspconfig.settings" + settings.current.automatic_installation = false + end, + lazy = true, + dependencies = "mason.nvim", + }, + { "tamago324/nlsp-settings.nvim", cmd = "LspSettings", lazy = true }, { "jose-elias-alvarez/null-ls.nvim", lazy = true }, { "williamboman/mason.nvim", config = function() require("lvim.core.mason").setup() end, + cmd = { "Mason", "MasonInstall", "MasonUninstall", "MasonUninstallAll", "MasonLog" }, + lazy = true, }, { "folke/tokyonight.nvim", + lazy = not vim.startswith(lvim.colorscheme, "tokyonight"), }, { "lunarvim/lunar.nvim", + lazy = lvim.colorscheme ~= "lunar", }, - { "Tastyep/structlog.nvim" }, + { "Tastyep/structlog.nvim", lazy = true }, - { "nvim-lua/popup.nvim" }, - { "nvim-lua/plenary.nvim" }, + { "nvim-lua/popup.nvim", lazy = true }, + { "nvim-lua/plenary.nvim", cmd = { "PlenaryBustedFile", "PlenaryBustedDirectory" }, lazy = true }, -- Telescope { "nvim-telescope/telescope.nvim", @@ -113,21 +129,32 @@ local core_plugins = { vim.opt.rtp:prepend(path) -- treesitter needs to be before nvim's runtime in rtp require("lvim.core.treesitter").setup() end, + cmd = { + "TSInstall", + "TSUninstall", + "TSUpdate", + "TSUpdateSync", + "TSInstallInfo", + "TSInstallSync", + "TSInstallFromGrammar", + }, + event = "User FileOpened", }, { + -- Lazy loaded by Comment.nvim pre_hook "JoosepAlviste/nvim-ts-context-commentstring", - event = "VeryLazy", + lazy = true, }, -- NvimTree { "kyazdani42/nvim-tree.lua", - -- event = "BufWinOpen", - -- cmd = "NvimTreeToggle", config = function() require("lvim.core.nvimtree").setup() end, enabled = lvim.builtin.nvimtree.active, + cmd = { "NvimTreeToggle", "NvimTreeOpen", "NvimTreeFocus", "NvimTreeFindFileToggle" }, + event = "User DirOpened", }, -- Lir { @@ -136,13 +163,15 @@ local core_plugins = { require("lvim.core.lir").setup() end, enabled = lvim.builtin.lir.active, + event = "User DirOpened", }, { "lewis6991/gitsigns.nvim", config = function() require("lvim.core.gitsigns").setup() end, - event = "BufRead", + event = "User FileOpened", + cmd = "Gitsigns", enabled = lvim.builtin.gitsigns.active, }, @@ -152,6 +181,7 @@ local core_plugins = { config = function() require("lvim.core.which-key").setup() end, + cmd = "WhichKey", event = "VeryLazy", enabled = lvim.builtin.which_key.active, }, @@ -159,10 +189,11 @@ local core_plugins = { -- Comments { "numToStr/Comment.nvim", - event = "BufRead", config = function() require("lvim.core.comment").setup() end, + keys = { { "gc", mode = { "n", "v" } }, { "gb", mode = { "n", "v" } } }, + event = "User FileOpened", enabled = lvim.builtin.comment.active, }, @@ -173,12 +204,15 @@ local core_plugins = { require("lvim.core.project").setup() end, enabled = lvim.builtin.project.active, + event = "VimEnter", + cmd = "Telescope projects", }, -- Icons { "nvim-tree/nvim-web-devicons", enabled = lvim.use_icons, + lazy = true, }, -- Status Line and Bufferline @@ -189,6 +223,7 @@ local core_plugins = { config = function() require("lvim.core.lualine").setup() end, + event = "VimEnter", enabled = lvim.builtin.lualine.active, }, @@ -198,6 +233,7 @@ local core_plugins = { config = function() require("lvim.core.breadcrumbs").setup() end, + event = "User FileOpened", enabled = lvim.builtin.breadcrumbs.active, }, @@ -207,16 +243,17 @@ local core_plugins = { require("lvim.core.bufferline").setup() end, branch = "main", + event = "User FileOpened", enabled = lvim.builtin.bufferline.active, }, -- Debugging { "mfussenegger/nvim-dap", - -- event = "BufWinEnter", config = function() require("lvim.core.dap").setup() end, + lazy = true, enabled = lvim.builtin.dap.active, }, @@ -226,6 +263,7 @@ local core_plugins = { config = function() require("lvim.core.dap").setup_ui() end, + lazy = true, enabled = lvim.builtin.dap.active, }, @@ -236,16 +274,28 @@ local core_plugins = { require("lvim.core.alpha").setup() end, enabled = lvim.builtin.alpha.active, + event = "VimEnter", }, -- Terminal { "akinsho/toggleterm.nvim", - event = "VeryLazy", branch = "main", + init = function() + require("lvim.core.terminal").init() + end, config = function() require("lvim.core.terminal").setup() end, + cmd = { + "ToggleTerm", + "TermExec", + "ToggleTermToggleAll", + "ToggleTermSendCurrentLine", + "ToggleTermSendVisualLines", + "ToggleTermSendVisualSelection", + }, + keys = lvim.builtin.terminal.open_mapping, enabled = lvim.builtin.terminal.active, }, @@ -260,7 +310,7 @@ local core_plugins = { config = function() require("lvim.core.illuminate").setup() end, - event = "VeryLazy", + event = "User FileOpened", enabled = lvim.builtin.illuminate.active, }, @@ -269,6 +319,7 @@ local core_plugins = { config = function() require("lvim.core.indentlines").setup() end, + event = "User FileOpened", enabled = lvim.builtin.indentlines.active, }, @@ -283,7 +334,7 @@ local core_plugins = { end end) end, - enabled = lvim.colorscheme == "onedarker", + lazy = lvim.colorscheme ~= "onedarker", }, { @@ -294,6 +345,7 @@ local core_plugins = { end) end, enabled = lvim.builtin.bigfile.active, + event = { "FileReadPre", "BufReadPre", "User FileOpened" }, }, } diff --git a/lua/lvim/utils/modules.lua b/lua/lvim/utils/modules.lua index d567448361..45cacfa39a 100644 --- a/lua/lvim/utils/modules.lua +++ b/lua/lvim/utils/modules.lua @@ -95,4 +95,28 @@ M.reload = function(mod) return old end +-- code from +function M.require_on_index(require_path) + return setmetatable({}, { + __index = function(_, key) + return require(require_path)[key] + end, + + __newindex = function(_, key, value) + require(require_path)[key] = value + end, + }) +end + +-- code from +function M.require_on_exported_call(require_path) + return setmetatable({}, { + __index = function(_, k) + return function(...) + return require(require_path)[k](...) + end + end, + }) +end + return M diff --git a/snapshots/default.json b/snapshots/default.json index 3e694b035d..7052ab33a5 100644 --- a/snapshots/default.json +++ b/snapshots/default.json @@ -3,7 +3,7 @@ "commit": "eab2c83" }, "LuaSnip": { - "commit": "af60ac1" + "commit": "d404ec3" }, "alpha-nvim": { "commit": "21a0f25" @@ -21,7 +21,7 @@ "commit": "23c51b2" }, "cmp-nvim-lsp": { - "commit": "5922477" + "commit": "0e6b2ed" }, "cmp-path": { "commit": "91ff86c" @@ -30,19 +30,19 @@ "commit": "1809552" }, "friendly-snippets": { - "commit": "046e4d3" + "commit": "a6f7a16" }, "gitsigns.nvim": { - "commit": "addd6e1" + "commit": "ec4742a" }, "indent-blankline.nvim": { - "commit": "c4c203c" + "commit": "8299fe7" }, "lazy.nvim": { - "commit": "4f60fac" + "commit": "9b20869" }, "lir.nvim": { - "commit": "937e882" + "commit": "3aa6c20" }, "lualine.nvim": { "commit": "0050b30" @@ -51,55 +51,55 @@ "commit": "29eedf7" }, "mason-lspconfig.nvim": { - "commit": "5b388c0" + "commit": "53f3a8b" }, "mason.nvim": { - "commit": "41d6a88" + "commit": "357ef66" }, "neodev.nvim": { - "commit": "e905fb7" + "commit": "b3b22cf" }, "nlsp-settings.nvim": { - "commit": "0681602" + "commit": "d0b7caa" }, "null-ls.nvim": { - "commit": "ef3d4a4" + "commit": "60b4a71" }, "nvim-autopairs": { - "commit": "f00eb3b" + "commit": "28f57e6" }, "nvim-cmp": { - "commit": "11a9579" + "commit": "cfafe0a" }, "nvim-dap": { - "commit": "c64a662" + "commit": "0e376f0" }, "nvim-dap-ui": { - "commit": "b80227e" + "commit": "6f18751" }, "nvim-lspconfig": { - "commit": "d228bcf" + "commit": "d3c82d2" }, "nvim-navic": { - "commit": "7a2b823" + "commit": "7e9d2b2" }, "nvim-tree.lua": { - "commit": "e8a89db" + "commit": "02fdc26" }, "nvim-treesitter": { - "commit": "c961595" + "commit": "df6f322" }, "nvim-ts-context-commentstring": { "commit": "a0f8956" }, "nvim-web-devicons": { - "commit": "6c38926" + "commit": "ade34ca" }, "onedarker.nvim": { "commit": "b00dd21" }, "plenary.nvim": { - "commit": "1c7e3e6" + "commit": "9a0d3bf" }, "popup.nvim": { "commit": "b7404d3" @@ -108,27 +108,27 @@ "commit": "685bc8e" }, "schemastore.nvim": { - "commit": "8ec6e1b" + "commit": "fd5ddd8" }, "structlog.nvim": { "commit": "45b26a2" }, "telescope-fzf-native.nvim": { - "commit": "fab3e22" + "commit": "580b6c4" }, "telescope.nvim": { - "commit": "c1a2af0" + "commit": "a1bd686" }, "toggleterm.nvim": { - "commit": "a54e6c4" + "commit": "19aad0f" }, "tokyonight.nvim": { - "commit": "4071f7f" + "commit": "affb21a" }, "vim-illuminate": { - "commit": "da80f38" + "commit": "d6ca7f7" }, "which-key.nvim": { - "commit": "e4fa445" + "commit": "684e96c" } } diff --git a/utils/installer/config.example.lua b/utils/installer/config.example.lua index a1b2c9c951..52c99b8b2f 100644 --- a/utils/installer/config.example.lua +++ b/utils/installer/config.example.lua @@ -44,6 +44,9 @@ lvim.builtin.treesitter.auto_install = true -- lvim.builtin.treesitter.ignore_install = { "haskell" } +-- -- always installed on startup, useful for parsers without a strict filetype +-- lvim.builtin.treesitter.ensure_installed = { "comment", "markdown_inline", "regex" } + -- -- generic LSP settings -- --- disable automatic installation of servers diff --git a/utils/installer/config_win.example.lua b/utils/installer/config_win.example.lua index 3467c86e31..f8d3e8562c 100644 --- a/utils/installer/config_win.example.lua +++ b/utils/installer/config_win.example.lua @@ -66,6 +66,9 @@ lvim.builtin.treesitter.auto_install = true -- lvim.builtin.treesitter.ignore_install = { "haskell" } +-- -- ensure these parsers are always installed, useful for those without a strict filetype +-- lvim.builtin.treesitter.ensure_installed = { "comment", "markdown_inline", "regex" } + -- -- generic LSP settings -- --- disable automatic installation of servers