diff options
Diffstat (limited to 'lua/lvim/core')
-rw-r--r-- | lua/lvim/core/alpha.lua | 20 | ||||
-rw-r--r-- | lua/lvim/core/autopairs.lua | 9 | ||||
-rw-r--r-- | lua/lvim/core/breadcrumbs.lua | 10 | ||||
-rw-r--r-- | lua/lvim/core/bufferline.lua | 10 | ||||
-rw-r--r-- | lua/lvim/core/builtins/init.lua | 91 | ||||
-rw-r--r-- | lua/lvim/core/cmp.lua | 10 | ||||
-rw-r--r-- | lua/lvim/core/comment.lua | 9 | ||||
-rw-r--r-- | lua/lvim/core/dap.lua | 10 | ||||
-rw-r--r-- | lua/lvim/core/gitsigns.lua | 9 | ||||
-rw-r--r-- | lua/lvim/core/illuminate.lua | 10 | ||||
-rw-r--r-- | lua/lvim/core/indentlines.lua | 10 | ||||
-rw-r--r-- | lua/lvim/core/lir.lua | 10 | ||||
-rw-r--r-- | lua/lvim/core/lualine/init.lua | 15 | ||||
-rw-r--r-- | lua/lvim/core/mason.lua | 4 | ||||
-rw-r--r-- | lua/lvim/core/nvimtree.lua | 10 | ||||
-rw-r--r-- | lua/lvim/core/project.lua | 13 | ||||
-rw-r--r-- | lua/lvim/core/telescope.lua | 11 | ||||
-rw-r--r-- | lua/lvim/core/terminal.lua | 10 | ||||
-rw-r--r-- | lua/lvim/core/treesitter.lua | 10 | ||||
-rw-r--r-- | lua/lvim/core/which-key.lua | 11 |
20 files changed, 130 insertions, 162 deletions
diff --git a/lua/lvim/core/alpha.lua b/lua/lvim/core/alpha.lua index 42159d70..81bff949 100644 --- a/lua/lvim/core/alpha.lua +++ b/lua/lvim/core/alpha.lua @@ -1,23 +1,21 @@ local M = {} function M.config() - local lazy_set = require("lvim.utils.modules").lazy_set - local lvim_dashboard = lazy_set("lvim.core.alpha.dashboard", "get_sections") - local lvim_startify = lazy_set("lvim.core.alpha.startify", "get_sections") - lvim.builtin.alpha = { + local config = { dashboard = { config = {}, - section = lvim_dashboard, + section = require("lvim.core.alpha.dashboard").get_sections(), opts = { autostart = true }, }, startify = { config = {}, - section = lvim_startify, + section = require("lvim.core.alpha.startify").get_sections(), opts = { autostart = true }, }, - active = true, mode = "dashboard", } + ---@cast config +LvimBuiltin + lvim.builtin.alpha = config end local function resolve_buttons(theme_name, button_section) @@ -75,14 +73,6 @@ local function configure_additional_autocmds() pattern = "alpha", command = "set showtabline=0 | autocmd BufLeave <buffer> 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 <buffer> set laststatus=" .. vim.opt.laststatus._value, - }) - end end function M.setup() diff --git a/lua/lvim/core/autopairs.lua b/lua/lvim/core/autopairs.lua index b9b66683..76032eb7 100644 --- a/lua/lvim/core/autopairs.lua +++ b/lua/lvim/core/autopairs.lua @@ -1,9 +1,7 @@ local M = {} function M.config() - lvim.builtin.autopairs = { - active = true, - on_config_done = nil, + local config = { ---@usage modifies the function or method delimiter by filetypes map_char = { all = "(", @@ -44,6 +42,8 @@ function M.config() highlight_grey = "Comment", }, } + ---@cast config +LvimBuiltin + lvim.builtin.autopairs = config end local function on_confirm_done(...) @@ -71,9 +71,6 @@ M.setup = function() fast_wrap = lvim.builtin.autopairs.fast_wrap, } - if lvim.builtin.autopairs.on_config_done then - lvim.builtin.autopairs.on_config_done(autopairs) - end pcall(function() require "nvim-autopairs.completion.cmp" require("cmp").event:off("confirm_done", on_confirm_done) diff --git a/lua/lvim/core/breadcrumbs.lua b/lua/lvim/core/breadcrumbs.lua index 0bf87a45..fe80cd95 100644 --- a/lua/lvim/core/breadcrumbs.lua +++ b/lua/lvim/core/breadcrumbs.lua @@ -5,9 +5,7 @@ local M = {} local icons = lvim.icons.kind M.config = function() - lvim.builtin.breadcrumbs = { - active = true, - on_config_done = nil, + local config = { winbar_filetype_exclude = { "help", "startify", @@ -77,6 +75,8 @@ M.config = function() depth_limit_indicator = "..", }, } + ---@cast config +LvimBuiltin + lvim.builtin.breadcrumbs = config end M.setup = function() @@ -87,10 +87,6 @@ M.setup = function() M.create_winbar() navic.setup(lvim.builtin.breadcrumbs.options) - - if lvim.builtin.breadcrumbs.on_config_done then - lvim.builtin.breadcrumbs.on_config_done() - end end M.get_filename = function() diff --git a/lua/lvim/core/bufferline.lua b/lua/lvim/core/bufferline.lua index abe16437..a65bc632 100644 --- a/lua/lvim/core/bufferline.lua +++ b/lua/lvim/core/bufferline.lua @@ -41,9 +41,7 @@ local function custom_filter(buf, buf_nums) end M.config = function() - lvim.builtin.bufferline = { - active = true, - on_config_done = nil, + local config = { keymap = { normal_mode = {}, }, @@ -142,6 +140,8 @@ M.config = function() sort_by = "id", }, } + ---@cast config +LvimBuiltin + lvim.builtin.bufferline = config end M.setup = function() @@ -158,10 +158,6 @@ M.setup = function() options = lvim.builtin.bufferline.options, highlights = lvim.builtin.bufferline.highlights, } - - if lvim.builtin.bufferline.on_config_done then - lvim.builtin.bufferline.on_config_done() - end end --stylua: ignore diff --git a/lua/lvim/core/builtins/init.lua b/lua/lvim/core/builtins/init.lua index 4764ff70..e918b033 100644 --- a/lua/lvim/core/builtins/init.lua +++ b/lua/lvim/core/builtins/init.lua @@ -1,33 +1,76 @@ local M = {} +---@class LvimBuiltin +---@field active boolean is builtin enabled +---@field setup table options passed to setup() +---@field on_config function function called to configure the builtin +---@field on_config_done function function called to configure the builtin + local builtins = { - "lvim.core.theme", - "lvim.core.which-key", - "lvim.core.gitsigns", - "lvim.core.cmp", - "lvim.core.dap", - "lvim.core.terminal", - "lvim.core.telescope", - "lvim.core.treesitter", - "lvim.core.nvimtree", - "lvim.core.lir", - "lvim.core.illuminate", - "lvim.core.indentlines", - "lvim.core.breadcrumbs", - "lvim.core.project", - "lvim.core.bufferline", - "lvim.core.autopairs", - "lvim.core.comment", - "lvim.core.lualine", - "lvim.core.alpha", - "lvim.core.mason", + "which_key", + "gitsigns", + "cmp", + "dap", + "terminal", + "telescope", + "treesitter", + "nvimtree", + "lir", + "illuminate", + "indentlines", + "breadcrumbs", + "project", + "bufferline", + "autopairs", + "comment", + "lualine", + "alpha", + "mason", } -function M.config(config) - for _, builtin_path in ipairs(builtins) do - local builtin = reload(builtin_path) +function M.init() + for _, name in ipairs(builtins) do + lvim.builtin[name] = { active = true } + end + + reload("lvim.core.theme").config() + + lvim.builtin.cmp.cmdline = { enable = false } + + lvim.builtin.luasnip = { + sources = { + friendly_snippets = true, + }, + } + + lvim.builtin.bigfile = { + active = true, + config = {}, + } +end + +function M.setup(builtin_mod_name) + local builtin_name = builtin_mod_name:gsub("-", "_") + local mod = require("lvim.core." .. builtin_mod_name) + + -- initialize config table + mod.config() + local builtin = lvim.builtin[builtin_name] + + if type(builtin.on_config) == "function" then + builtin.on_config() + + local deprecated = require "lvim.config._deprecated" + local deprecation_handler = deprecated.post_builtin[builtin_name] + if deprecation_handler then + deprecation_handler() + end + end + + mod.setup() - builtin.config(config) + if type(builtin.on_config_done) == "function" then + builtin.on_config_done() end end diff --git a/lua/lvim/core/cmp.lua b/lua/lvim/core/cmp.lua index 142d548f..2360947f 100644 --- a/lua/lvim/core/cmp.lua +++ b/lua/lvim/core/cmp.lua @@ -127,9 +127,7 @@ M.config = function() return end - lvim.builtin.cmp = { - active = true, - on_config_done = nil, + local config = { enabled = function() local buftype = vim.api.nvim_buf_get_option(0, "buftype") if buftype == "prompt" then @@ -354,6 +352,8 @@ M.config = function() }, }, } + ---@cast config +LvimBuiltin + lvim.builtin.cmp = config end function M.setup() @@ -368,10 +368,6 @@ function M.setup() }) end end - - if lvim.builtin.cmp.on_config_done then - lvim.builtin.cmp.on_config_done(cmp) - end end return M diff --git a/lua/lvim/core/comment.lua b/lua/lvim/core/comment.lua index f07929c7..c75d402c 100644 --- a/lua/lvim/core/comment.lua +++ b/lua/lvim/core/comment.lua @@ -1,9 +1,7 @@ local M = {} function M.config() - lvim.builtin.comment = { - active = true, - on_config_done = nil, + local config = { ---Add a space b/w comment and the line ---@type boolean padding = true, @@ -72,15 +70,14 @@ function M.config() ---@type function|nil post_hook = nil, } + ---@cast config +LvimBuiltin + lvim.builtin.comment = config end function M.setup() local nvim_comment = require "Comment" nvim_comment.setup(lvim.builtin.comment) - if lvim.builtin.comment.on_config_done then - lvim.builtin.comment.on_config_done(nvim_comment) - end end return M diff --git a/lua/lvim/core/dap.lua b/lua/lvim/core/dap.lua index d8de10d5..029d1d98 100644 --- a/lua/lvim/core/dap.lua +++ b/lua/lvim/core/dap.lua @@ -1,9 +1,7 @@ local M = {} M.config = function() - lvim.builtin.dap = { - active = true, - on_config_done = nil, + local config = { breakpoint = { text = lvim.icons.ui.Bug, texthl = "DiagnosticSignError", @@ -95,6 +93,8 @@ M.config = function() }, }, } + ---@cast config +LvimBuiltin + lvim.builtin.dap = config end M.setup = function() @@ -110,10 +110,6 @@ M.setup = function() end dap.set_log_level(lvim.builtin.dap.log.level) - - if lvim.builtin.dap.on_config_done then - lvim.builtin.dap.on_config_done(dap) - end end M.setup_ui = function() diff --git a/lua/lvim/core/gitsigns.lua b/lua/lvim/core/gitsigns.lua index 1c8619c8..1cf6e4ac 100644 --- a/lua/lvim/core/gitsigns.lua +++ b/lua/lvim/core/gitsigns.lua @@ -1,9 +1,7 @@ local M = {} M.config = function() - lvim.builtin.gitsigns = { - active = true, - on_config_done = nil, + local config = { opts = { signs = { add = { @@ -69,15 +67,14 @@ M.config = function() yadm = { enable = false }, }, } + ---@cast config +LvimBuiltin + lvim.builtin.gitsigns = config end M.setup = function() local gitsigns = reload "gitsigns" gitsigns.setup(lvim.builtin.gitsigns.opts) - if lvim.builtin.gitsigns.on_config_done then - lvim.builtin.gitsigns.on_config_done(gitsigns) - end end return M diff --git a/lua/lvim/core/illuminate.lua b/lua/lvim/core/illuminate.lua index 5968b4bb..3c14ecab 100644 --- a/lua/lvim/core/illuminate.lua +++ b/lua/lvim/core/illuminate.lua @@ -1,9 +1,7 @@ local M = {} M.config = function() - lvim.builtin.illuminate = { - active = true, - on_config_done = nil, + local config = { options = { -- providers: provider used to get references in the buffer, ordered by priority providers = { @@ -51,6 +49,8 @@ M.config = function() under_cursor = true, }, } + ---@cast config +LvimBuiltin + lvim.builtin.illuminate = config end M.setup = function() @@ -63,10 +63,6 @@ M.setup = function() if not config_ok then return end - - if lvim.builtin.illuminate.on_config_done then - lvim.builtin.illuminate.on_config_done() - end end return M diff --git a/lua/lvim/core/indentlines.lua b/lua/lvim/core/indentlines.lua index 3097daf8..d0716a4c 100644 --- a/lua/lvim/core/indentlines.lua +++ b/lua/lvim/core/indentlines.lua @@ -1,9 +1,7 @@ local M = {} M.config = function() - lvim.builtin.indentlines = { - active = true, - on_config_done = nil, + local config = { options = { enabled = true, buftype_exclude = { "terminal", "nofile" }, @@ -25,6 +23,8 @@ M.config = function() show_current_context = true, }, } + ---@cast config +LvimBuiltin + lvim.builtin.indentlines = config end M.setup = function() @@ -34,10 +34,6 @@ M.setup = function() end indent_blankline.setup(lvim.builtin.indentlines.options) - - if lvim.builtin.indentlines.on_config_done then - lvim.builtin.indentlines.on_config_done() - end end return M diff --git a/lua/lvim/core/lir.lua b/lua/lvim/core/lir.lua index 83f79b6f..eca156a7 100644 --- a/lua/lvim/core/lir.lua +++ b/lua/lvim/core/lir.lua @@ -5,9 +5,7 @@ M.config = function() 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, + local config = { icon = "î—¿", show_hidden_files = false, ignore = {}, -- { ".DS_Store" "node_modules" } etc. @@ -72,6 +70,8 @@ M.config = function() ) end, } + ---@cast config +LvimBuiltin + lvim.builtin.lir = config end function M.icon_setup() @@ -111,10 +111,6 @@ function M.setup() lir.setup(lvim.builtin.lir) M.icon_setup() - - if lvim.builtin.lir.on_config_done then - lvim.builtin.lir.on_config_done(lir) - end end return M diff --git a/lua/lvim/core/lualine/init.lua b/lua/lvim/core/lualine/init.lua index 0ee35c04..bb530258 100644 --- a/lua/lvim/core/lualine/init.lua +++ b/lua/lvim/core/lualine/init.lua @@ -1,14 +1,15 @@ local M = {} M.config = function() - lvim.builtin.lualine = { - active = true, + local config = { style = "lvim", options = { icons_enabled = nil, component_separators = nil, section_separators = nil, theme = nil, - disabled_filetypes = nil, + disabled_filetypes = { + statusline = { "alpha" }, + }, globalstatus = true, }, sections = { @@ -29,8 +30,9 @@ M.config = function() }, tabline = nil, extensions = nil, - on_config_done = nil, } + ---@cast config +LvimBuiltin + lvim.builtin.lualine = config end M.setup = function() @@ -47,11 +49,8 @@ M.setup = function() require("lvim.core.lualine.styles").update() + vim.opt.laststatus = 3 lualine.setup(lvim.builtin.lualine) - - if lvim.builtin.lualine.on_config_done then - lvim.builtin.lualine.on_config_done(lualine) - end end return M diff --git a/lua/lvim/core/mason.lua b/lua/lvim/core/mason.lua index 75b12229..51271045 100644 --- a/lua/lvim/core/mason.lua +++ b/lua/lvim/core/mason.lua @@ -3,7 +3,7 @@ local M = {} local join_paths = require("lvim.utils").join_paths function M.config() - lvim.builtin.mason = { + local config = { ui = { border = "rounded", keymaps = { @@ -50,6 +50,8 @@ function M.config() download_url_template = "https://github.com/%s/releases/download/%s/%s", }, } + ---@cast config +LvimBuiltin + lvim.builtin.mason = config end function M.get_prefix() diff --git a/lua/lvim/core/nvimtree.lua b/lua/lvim/core/nvimtree.lua index 6f87e30d..d3c7a2de 100644 --- a/lua/lvim/core/nvimtree.lua +++ b/lua/lvim/core/nvimtree.lua @@ -2,9 +2,7 @@ local M = {} local Log = require "lvim.core.log" function M.config() - lvim.builtin.nvimtree = { - active = true, - on_config_done = nil, + local config = { setup = { auto_reload_on_write = false, disable_netrw = false, @@ -232,6 +230,8 @@ function M.config() }, }, } + ---@cast config +LvimBuiltin + lvim.builtin.nvimtree = config end function M.setup() @@ -276,10 +276,6 @@ function M.setup() end nvim_tree.setup(lvim.builtin.nvimtree.setup) - - if lvim.builtin.nvimtree.on_config_done then - lvim.builtin.nvimtree.on_config_done(nvim_tree) - end end function M.start_telescope(telescope_mode) diff --git a/lua/lvim/core/project.lua b/lua/lvim/core/project.lua index 17473c55..f2da6c33 100644 --- a/lua/lvim/core/project.lua +++ b/lua/lvim/core/project.lua @@ -1,13 +1,7 @@ local M = {} function M.config() - lvim.builtin.project = { - ---@usage set to false to disable project.nvim. - --- This is on by default since it's currently the expected behavior. - active = true, - - on_config_done = nil, - + local config = { ---@usage set to true to disable setting the current-woriking directory --- Manual mode doesn't automatically change your root directory, so you have --- the option to manually do so using `:ProjectRoot` command. @@ -50,6 +44,8 @@ function M.config() ---@usage path to store the project history for use in telescope datapath = get_cache_dir(), } + ---@cast config +LvimBuiltin + lvim.builtin.project = config end function M.setup() @@ -59,9 +55,6 @@ function M.setup() end project.setup(lvim.builtin.project) - if lvim.builtin.project.on_config_done then - lvim.builtin.project.on_config_done(project) - end end return M diff --git a/lua/lvim/core/telescope.lua b/lua/lvim/core/telescope.lua index b701f7e4..c1b4e2ec 100644 --- a/lua/lvim/core/telescope.lua +++ b/lua/lvim/core/telescope.lua @@ -8,10 +8,7 @@ local M = {} function M.config() 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 config = { theme = "dropdown", ---@type telescope_themes defaults = { prompt_prefix = lvim.icons.ui.Telescope .. " ", @@ -107,6 +104,8 @@ function M.config() }, }, } + ---@cast config +LvimBuiltin + lvim.builtin.telescope = config end function M.setup() @@ -136,10 +135,6 @@ function M.setup() end) end - if lvim.builtin.telescope.on_config_done then - lvim.builtin.telescope.on_config_done(telescope) - end - if lvim.builtin.telescope.extensions and lvim.builtin.telescope.extensions.fzf then pcall(function() require("telescope").load_extension "fzf" diff --git a/lua/lvim/core/terminal.lua b/lua/lvim/core/terminal.lua index 663ba77a..0635b4a9 100644 --- a/lua/lvim/core/terminal.lua +++ b/lua/lvim/core/terminal.lua @@ -2,9 +2,7 @@ local M = {} local Log = require "lvim.core.log" M.config = function() - lvim.builtin["terminal"] = { - active = true, - on_config_done = nil, + local config = { -- size can be a number or function which is passed the current terminal size = 20, open_mapping = [[<c-\>]], @@ -46,6 +44,8 @@ M.config = function() { nil, "<M-3>", "Float Terminal", "float", nil }, }, } + ---@cast config +LvimBuiltin + lvim.builtin.terminal = config end --- Get current buffer size @@ -98,10 +98,6 @@ M.setup = function() M.add_exec(opts) end - - if lvim.builtin.terminal.on_config_done then - lvim.builtin.terminal.on_config_done(terminal) - end end M.add_exec = function(opts) diff --git a/lua/lvim/core/treesitter.lua b/lua/lvim/core/treesitter.lua index 456a2955..e44a39c7 100644 --- a/lua/lvim/core/treesitter.lua +++ b/lua/lvim/core/treesitter.lua @@ -2,9 +2,7 @@ local M = {} local Log = require "lvim.core.log" function M.config() - lvim.builtin.treesitter = { - on_config_done = nil, - + local config = { -- A list of parser names, or "all" ensure_installed = {}, @@ -93,6 +91,8 @@ function M.config() max_file_lines = 1000, -- Do not enable for files with more than 1000 lines, int }, } + ---@cast config +LvimBuiltin + lvim.builtin.treesitter = config end function M.setup() @@ -111,10 +111,6 @@ function M.setup() local opts = vim.deepcopy(lvim.builtin.treesitter) treesitter_configs.setup(opts) - - if lvim.builtin.treesitter.on_config_done then - lvim.builtin.treesitter.on_config_done(treesitter_configs) - end end return M diff --git a/lua/lvim/core/which-key.lua b/lua/lvim/core/which-key.lua index 8cedeabc..cfff800c 100644 --- a/lua/lvim/core/which-key.lua +++ b/lua/lvim/core/which-key.lua @@ -1,9 +1,6 @@ local M = {} M.config = function() - lvim.builtin.which_key = { - ---@usage disable which-key completely [not recommended] - active = true, - on_config_done = nil, + local config = { setup = { plugins = { marks = false, -- shows a list of your marks on ' and ` @@ -298,6 +295,8 @@ M.config = function() }, }, } + ---@cast config +LvimBuiltin + lvim.builtin.which_key = config end M.setup = function() @@ -313,10 +312,6 @@ M.setup = function() which_key.register(mappings, opts) which_key.register(vmappings, vopts) - - if lvim.builtin.which_key.on_config_done then - lvim.builtin.which_key.on_config_done(which_key) - end end return M |