diff options
-rw-r--r-- | lua/lvim/config/_deprecated.lua | 23 | ||||
-rw-r--r-- | lua/lvim/core/alpha.lua | 26 | ||||
-rw-r--r-- | lua/lvim/core/autopairs.lua | 74 | ||||
-rw-r--r-- | lua/lvim/core/breadcrumbs.lua | 138 | ||||
-rw-r--r-- | lua/lvim/core/bufferline.lua | 186 | ||||
-rw-r--r-- | lua/lvim/core/builtins/init.lua | 19 | ||||
-rw-r--r-- | lua/lvim/core/cmp.lua | 416 | ||||
-rw-r--r-- | lua/lvim/core/comment.lua | 126 | ||||
-rw-r--r-- | lua/lvim/core/dap.lua | 164 | ||||
-rw-r--r-- | lua/lvim/core/gitsigns.lua | 122 | ||||
-rw-r--r-- | lua/lvim/core/illuminate.lua | 94 | ||||
-rw-r--r-- | lua/lvim/core/indentlines.lua | 42 | ||||
-rw-r--r-- | lua/lvim/core/lir.lua | 120 | ||||
-rw-r--r-- | lua/lvim/core/lualine/init.lua | 8 | ||||
-rw-r--r-- | lua/lvim/core/lualine/styles.lua | 6 | ||||
-rw-r--r-- | lua/lvim/core/mason.lua | 82 | ||||
-rw-r--r-- | lua/lvim/core/nvimtree.lua | 412 | ||||
-rw-r--r-- | lua/lvim/core/project.lua | 88 | ||||
-rw-r--r-- | lua/lvim/core/telescope.lua | 174 | ||||
-rw-r--r-- | lua/lvim/core/terminal.lua | 84 | ||||
-rw-r--r-- | lua/lvim/core/treesitter.lua | 156 | ||||
-rw-r--r-- | lua/lvim/core/which-key.lua | 543 |
22 files changed, 1523 insertions, 1580 deletions
diff --git a/lua/lvim/config/_deprecated.lua b/lua/lvim/config/_deprecated.lua index 5ce851c2..d2a86e9f 100644 --- a/lua/lvim/config/_deprecated.lua +++ b/lua/lvim/config/_deprecated.lua @@ -134,9 +134,26 @@ end M.post_builtin = { -- example: - -- which_key = function () - -- - -- end + cmp = function() + local builtin = "cmp" + local table = lvim.builtin[builtin] + local allowed_keys = { active = true, on_config = true, on_config_done = true, opts = true } + for key, value in pairs(table) do + if not allowed_keys[key] then + vim.schedule(function() + vim.notify( + string.format( + "`lvim.builtin.%s.%s` is deprecated, use `lvim.builtin.%s.opts.%s` instead", + builtin, + key, + builtin, + key + ) + ) + end) + end + end + end, } return M diff --git a/lua/lvim/core/alpha.lua b/lua/lvim/core/alpha.lua index d49a4d0f..259f97c2 100644 --- a/lua/lvim/core/alpha.lua +++ b/lua/lvim/core/alpha.lua @@ -1,22 +1,18 @@ local M = {} function M.config() - local config = { - dashboard = { - config = {}, - section = require("lvim.core.alpha.dashboard").get_sections(), - opts = { autostart = true }, - }, - startify = { - config = {}, - section = require("lvim.core.alpha.startify").get_sections(), - opts = { autostart = true }, - }, - mode = "dashboard", + lvim.builtin.alpha.dashboard = { + config = {}, + section = require("lvim.core.alpha.dashboard").get_sections(), + opts = { autostart = true }, } - ---@cast config +LvimBuiltin - require("lvim.core.builtins").extend_defaults(config) - lvim.builtin.alpha = config + lvim.builtin.alpha.startify = { + config = {}, + section = require("lvim.core.alpha.startify").get_sections(), + opts = { autostart = true }, + } + lvim.builtin.alpha.mode = "dashboard" + lvim.builtin.alpha = require("lvim.core.builtins").add_completion "alpha" end local function resolve_buttons(theme_name, button_section) diff --git a/lua/lvim/core/autopairs.lua b/lua/lvim/core/autopairs.lua index c7033d2b..263c8126 100644 --- a/lua/lvim/core/autopairs.lua +++ b/lua/lvim/core/autopairs.lua @@ -1,47 +1,43 @@ local M = {} function M.config() - local config = { - opts = { - ---@usage check bracket in same line - enable_check_bracket_line = false, - ---@usage check treesitter - check_ts = true, - ts_config = { - lua = { "string", "source" }, - javascript = { "string", "template_string" }, - java = false, - }, - disable_filetype = { "TelescopePrompt", "spectre_panel" }, - ignored_next_char = string.gsub([[ [%w%%%'%[%"%.] ]], "%s+", ""), - enable_moveright = true, - ---@usage disable when recording or executing a macro - disable_in_macro = false, - ---@usage add bracket pairs after quote - enable_afterquote = true, - ---@usage map the <BS> key - map_bs = true, - ---@usage map <c-w> to delete a pair if possible - map_c_w = false, - ---@usage disable when insert after visual block mode - disable_in_visualblock = false, - ---@usage change default fast_wrap - fast_wrap = { - map = "<M-e>", - chars = { "{", "[", "(", '"', "'" }, - pattern = string.gsub([[ [%'%"%)%>%]%)%}%,] ]], "%s+", ""), - offset = 0, -- Offset from pattern match - end_key = "$", - keys = "qwertyuiopzxcvbnmasdfghjkl", - check_comma = true, - highlight = "Search", - highlight_grey = "Comment", - }, + lvim.builtin.autopairs.opts = { + ---@usage check bracket in same line + enable_check_bracket_line = false, + ---@usage check treesitter + check_ts = true, + ts_config = { + lua = { "string", "source" }, + javascript = { "string", "template_string" }, + java = false, + }, + disable_filetype = { "TelescopePrompt", "spectre_panel" }, + ignored_next_char = string.gsub([[ [%w%%%'%[%"%.] ]], "%s+", ""), + enable_moveright = true, + ---@usage disable when recording or executing a macro + disable_in_macro = false, + ---@usage add bracket pairs after quote + enable_afterquote = true, + ---@usage map the <BS> key + map_bs = true, + ---@usage map <c-w> to delete a pair if possible + map_c_w = false, + ---@usage disable when insert after visual block mode + disable_in_visualblock = false, + ---@usage change default fast_wrap + fast_wrap = { + map = "<M-e>", + chars = { "{", "[", "(", '"', "'" }, + pattern = string.gsub([[ [%'%"%)%>%]%)%}%,] ]], "%s+", ""), + offset = 0, -- Offset from pattern match + end_key = "$", + keys = "qwertyuiopzxcvbnmasdfghjkl", + check_comma = true, + highlight = "Search", + highlight_grey = "Comment", }, } - ---@cast config +LvimBuiltin - require("lvim.core.builtins").extend_defaults(config) - lvim.builtin.autopairs = config + lvim.builtin.autopairs = require("lvim.core.builtins").add_completion "autopairs" end local function on_confirm_done(...) diff --git a/lua/lvim/core/breadcrumbs.lua b/lua/lvim/core/breadcrumbs.lua index 7ebf5259..1fa90f55 100644 --- a/lua/lvim/core/breadcrumbs.lua +++ b/lua/lvim/core/breadcrumbs.lua @@ -5,79 +5,75 @@ local M = {} local icons = lvim.icons.kind M.config = function() - local config = { - winbar_filetype_exclude = { - "help", - "startify", - "dashboard", - "lazy", - "neo-tree", - "neogitstatus", - "NvimTree", - "Trouble", - "alpha", - "lir", - "Outline", - "spectre_panel", - "toggleterm", - "DressingSelect", - "Jaq", - "harpoon", - "dap-repl", - "dap-terminal", - "dapui_console", - "dapui_hover", - "lab", - "notify", - "noice", - "", - }, - opts = { - icons = { - Array = icons.Array .. " ", - Boolean = icons.Boolean, - Class = icons.Class .. " ", - Color = icons.Color .. " ", - Constant = icons.Constant .. " ", - Constructor = icons.Constructor .. " ", - Enum = icons.Enum .. " ", - EnumMember = icons.EnumMember .. " ", - Event = icons.Event .. " ", - Field = icons.Field .. " ", - File = icons.File .. " ", - Folder = icons.Folder .. " ", - Function = icons.Function .. " ", - Interface = icons.Interface .. " ", - Key = icons.Key .. " ", - Keyword = icons.Keyword .. " ", - Method = icons.Method .. " ", - Module = icons.Module .. " ", - Namespace = icons.Namespace .. " ", - Null = icons.Null .. " ", - Number = icons.Number .. " ", - Object = icons.Object .. " ", - Operator = icons.Operator .. " ", - Package = icons.Package .. " ", - Property = icons.Property .. " ", - Reference = icons.Reference .. " ", - Snippet = icons.Snippet .. " ", - String = icons.String .. " ", - Struct = icons.Struct .. " ", - Text = icons.Text .. " ", - TypeParameter = icons.TypeParameter .. " ", - Unit = icons.Unit .. " ", - Value = icons.Value .. " ", - Variable = icons.Variable .. " ", - }, - highlight = true, - separator = " " .. lvim.icons.ui.ChevronRight .. " ", - depth_limit = 0, - depth_limit_indicator = "..", + lvim.builtin.breadcrumbs.winbar_filetype_exclude = { + "help", + "startify", + "dashboard", + "lazy", + "neo-tree", + "neogitstatus", + "NvimTree", + "Trouble", + "alpha", + "lir", + "Outline", + "spectre_panel", + "toggleterm", + "DressingSelect", + "Jaq", + "harpoon", + "dap-repl", + "dap-terminal", + "dapui_console", + "dapui_hover", + "lab", + "notify", + "noice", + "", + } + lvim.builtin.breadcrumbs.opts = { + icons = { + Array = icons.Array .. " ", + Boolean = icons.Boolean, + Class = icons.Class .. " ", + Color = icons.Color .. " ", + Constant = icons.Constant .. " ", + Constructor = icons.Constructor .. " ", + Enum = icons.Enum .. " ", + EnumMember = icons.EnumMember .. " ", + Event = icons.Event .. " ", + Field = icons.Field .. " ", + File = icons.File .. " ", + Folder = icons.Folder .. " ", + Function = icons.Function .. " ", + Interface = icons.Interface .. " ", + Key = icons.Key .. " ", + Keyword = icons.Keyword .. " ", + Method = icons.Method .. " ", + Module = icons.Module .. " ", + Namespace = icons.Namespace .. " ", + Null = icons.Null .. " ", + Number = icons.Number .. " ", + Object = icons.Object .. " ", + Operator = icons.Operator .. " ", + Package = icons.Package .. " ", + Property = icons.Property .. " ", + Reference = icons.Reference .. " ", + Snippet = icons.Snippet .. " ", + String = icons.String .. " ", + Struct = icons.Struct .. " ", + Text = icons.Text .. " ", + TypeParameter = icons.TypeParameter .. " ", + Unit = icons.Unit .. " ", + Value = icons.Value .. " ", + Variable = icons.Variable .. " ", }, + highlight = true, + separator = " " .. lvim.icons.ui.ChevronRight .. " ", + depth_limit = 0, + depth_limit_indicator = "..", } - ---@cast config +LvimBuiltin - require("lvim.core.builtins").extend_defaults(config) - lvim.builtin.breadcrumbs = config + lvim.builtin.breadcrumbs = require("lvim.core.builtins").add_completion "breadcrumbs" end M.setup = function() diff --git a/lua/lvim/core/bufferline.lua b/lua/lvim/core/bufferline.lua index a48bffb9..605eca85 100644 --- a/lua/lvim/core/bufferline.lua +++ b/lua/lvim/core/bufferline.lua @@ -41,110 +41,106 @@ local function custom_filter(buf, buf_nums) end M.config = function() - local config = { - keymap = { - normal_mode = {}, + lvim.builtin.bufferline.keymap = { + normal_mode = {}, + } + lvim.builtin.bufferline.opts = { + highlights = { + background = { + italic = true, + }, + buffer_selected = { + bold = true, + }, }, - opts = { - highlights = { - background = { - italic = true, + options = { + mode = "buffers", -- set to "tabs" to only show tabpages instead + numbers = "none", -- can be "none" | "ordinal" | "buffer_id" | "both" | function + close_command = function(bufnr) -- can be a string | function, see "Mouse actions" + M.buf_kill("bd", bufnr, false) + end, + right_mouse_command = "vert sbuffer %d", -- can be a string | function, see "Mouse actions" + left_mouse_command = "buffer %d", -- can be a string | function, see "Mouse actions" + middle_mouse_command = nil, -- can be a string | function, see "Mouse actions" + indicator = { + icon = lvim.icons.ui.BoldLineLeft, -- this should be omitted if indicator style is not 'icon' + style = "icon", -- can also be 'underline'|'none', + }, + buffer_close_icon = lvim.icons.ui.Close, + modified_icon = lvim.icons.ui.Circle, + close_icon = lvim.icons.ui.BoldClose, + left_trunc_marker = lvim.icons.ui.ArrowCircleLeft, + right_trunc_marker = lvim.icons.ui.ArrowCircleRight, + --- name_formatter can be used to change the buffer's label in the bufferline. + --- Please note some names can/will break the + --- bufferline so use this at your discretion knowing that it has + --- some limitations that will *NOT* be fixed. + name_formatter = function(buf) -- buf contains a "name", "path" and "bufnr" + -- remove extension from markdown files for example + if buf.name:match "%.md" then + return vim.fn.fnamemodify(buf.name, ":t:r") + end + end, + max_name_length = 18, + max_prefix_length = 15, -- prefix used when a buffer is de-duplicated + truncate_names = true, -- whether or not tab names should be truncated + tab_size = 18, + diagnostics = "nvim_lsp", + diagnostics_update_in_insert = false, + diagnostics_indicator = diagnostics_indicator, + -- NOTE: this will be called a lot so don't do any heavy processing here + custom_filter = custom_filter, + offsets = { + { + filetype = "undotree", + text = "Undotree", + highlight = "PanelHeading", + padding = 1, }, - buffer_selected = { - bold = true, + { + filetype = "NvimTree", + text = "Explorer", + highlight = "PanelHeading", + padding = 1, }, - }, - options = { - mode = "buffers", -- set to "tabs" to only show tabpages instead - numbers = "none", -- can be "none" | "ordinal" | "buffer_id" | "both" | function - close_command = function(bufnr) -- can be a string | function, see "Mouse actions" - M.buf_kill("bd", bufnr, false) - end, - right_mouse_command = "vert sbuffer %d", -- can be a string | function, see "Mouse actions" - left_mouse_command = "buffer %d", -- can be a string | function, see "Mouse actions" - middle_mouse_command = nil, -- can be a string | function, see "Mouse actions" - indicator = { - icon = lvim.icons.ui.BoldLineLeft, -- this should be omitted if indicator style is not 'icon' - style = "icon", -- can also be 'underline'|'none', + { + filetype = "DiffviewFiles", + text = "Diff View", + highlight = "PanelHeading", + padding = 1, }, - buffer_close_icon = lvim.icons.ui.Close, - modified_icon = lvim.icons.ui.Circle, - close_icon = lvim.icons.ui.BoldClose, - left_trunc_marker = lvim.icons.ui.ArrowCircleLeft, - right_trunc_marker = lvim.icons.ui.ArrowCircleRight, - --- name_formatter can be used to change the buffer's label in the bufferline. - --- Please note some names can/will break the - --- bufferline so use this at your discretion knowing that it has - --- some limitations that will *NOT* be fixed. - name_formatter = function(buf) -- buf contains a "name", "path" and "bufnr" - -- remove extension from markdown files for example - if buf.name:match "%.md" then - return vim.fn.fnamemodify(buf.name, ":t:r") - end - end, - max_name_length = 18, - max_prefix_length = 15, -- prefix used when a buffer is de-duplicated - truncate_names = true, -- whether or not tab names should be truncated - tab_size = 18, - diagnostics = "nvim_lsp", - diagnostics_update_in_insert = false, - diagnostics_indicator = diagnostics_indicator, - -- NOTE: this will be called a lot so don't do any heavy processing here - custom_filter = custom_filter, - offsets = { - { - filetype = "undotree", - text = "Undotree", - highlight = "PanelHeading", - padding = 1, - }, - { - filetype = "NvimTree", - text = "Explorer", - highlight = "PanelHeading", - padding = 1, - }, - { - filetype = "DiffviewFiles", - text = "Diff View", - highlight = "PanelHeading", - padding = 1, - }, - { - filetype = "flutterToolsOutline", - text = "Flutter Outline", - highlight = "PanelHeading", - }, - { - filetype = "lazy", - text = "Lazy", - highlight = "PanelHeading", - padding = 1, - }, + { + filetype = "flutterToolsOutline", + text = "Flutter Outline", + highlight = "PanelHeading", }, - color_icons = true, -- whether or not to add the filetype icon highlights - show_buffer_icons = lvim.use_icons, -- disable filetype icons for buffers - show_buffer_close_icons = lvim.use_icons, - show_close_icon = false, - show_tab_indicators = true, - persist_buffer_sort = true, -- whether or not custom sorted buffers should persist - -- can also be a table containing 2 custom separators - -- [focused and unfocused]. eg: { '|', '|' } - separator_style = "thin", - enforce_regular_tabs = false, - always_show_bufferline = false, - hover = { - enabled = false, -- requires nvim 0.8+ - delay = 200, - reveal = { "close" }, + { + filetype = "lazy", + text = "Lazy", + highlight = "PanelHeading", + padding = 1, }, - sort_by = "id", }, + color_icons = true, -- whether or not to add the filetype icon highlights + show_buffer_icons = lvim.use_icons, -- disable filetype icons for buffers + show_buffer_close_icons = lvim.use_icons, + show_close_icon = false, + show_tab_indicators = true, + persist_buffer_sort = true, -- whether or not custom sorted buffers should persist + -- can also be a table containing 2 custom separators + -- [focused and unfocused]. eg: { '|', '|' } + separator_style = "thin", + enforce_regular_tabs = false, + always_show_bufferline = false, + hover = { + enabled = false, -- requires nvim 0.8+ + delay = 200, + reveal = { "close" }, + }, + sort_by = "id", }, } - ---@cast config +LvimBuiltin - require("lvim.core.builtins").extend_defaults(config) - lvim.builtin.bufferline = config + lvim.builtin.bufferline = require("lvim.core.builtins").add_completion "bufferline" end M.setup = function() diff --git a/lua/lvim/core/builtins/init.lua b/lua/lvim/core/builtins/init.lua index 17fcd892..865b498f 100644 --- a/lua/lvim/core/builtins/init.lua +++ b/lua/lvim/core/builtins/init.lua @@ -22,20 +22,21 @@ local builtins = { "mason", } -function M.extend_defaults(config) - ---@class LvimBuiltin - ---@field active boolean is builtin enabled - ---@field opts 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 +---@class LvimBuiltin +---@field active boolean is builtin enabled +---@field opts 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 - config.active = true +function M.add_completion(builtin) + local table = lvim.builtin[builtin] + ---@cast table +LvimBuiltin + return table end function M.init() for _, name in ipairs(builtins) do - lvim.builtin[name] = {} - M.extend_defaults(lvim.builtin[name]) + lvim.builtin[name] = { active = true } end reload("lvim.core.theme").config() diff --git a/lua/lvim/core/cmp.lua b/lua/lvim/core/cmp.lua index fc855e34..da5067e1 100644 --- a/lua/lvim/core/cmp.lua +++ b/lua/lvim/core/cmp.lua @@ -127,236 +127,232 @@ M.config = function() return end - local config = { - opts = { - enabled = function() - local buftype = vim.api.nvim_buf_get_option(0, "buftype") - if buftype == "prompt" then - return false - end - return lvim.builtin.cmp.active - end, - confirm_opts = { - behavior = cmp.ConfirmBehavior.Replace, - select = false, - }, - completion = { - ---@usage The minimum length of a word to complete on. - keyword_length = 1, + lvim.builtin.cmp.opts = { + enabled = function() + local buftype = vim.api.nvim_buf_get_option(0, "buftype") + if buftype == "prompt" then + return false + end + return lvim.builtin.cmp.active + end, + confirm_opts = { + behavior = cmp.ConfirmBehavior.Replace, + select = false, + }, + completion = { + ---@usage The minimum length of a word to complete on. + keyword_length = 1, + }, + experimental = { + ghost_text = false, + native_menu = false, + }, + formatting = { + fields = { "kind", "abbr", "menu" }, + max_width = 0, + kind_icons = lvim.icons.kind, + source_names = { + nvim_lsp = "(LSP)", + emoji = "(Emoji)", + path = "(Path)", + calc = "(Calc)", + cmp_tabnine = "(Tabnine)", + vsnip = "(Snippet)", + luasnip = "(Snippet)", + buffer = "(Buffer)", + tmux = "(TMUX)", + copilot = "(Copilot)", + treesitter = "(TreeSitter)", }, - experimental = { - ghost_text = false, - native_menu = false, + duplicates = { + buffer = 1, + path = 1, + nvim_lsp = 0, + luasnip = 1, }, - formatting = { - fields = { "kind", "abbr", "menu" }, - max_width = 0, - kind_icons = lvim.icons.kind, - source_names = { - nvim_lsp = "(LSP)", - emoji = "(Emoji)", - path = "(Path)", - calc = "(Calc)", - cmp_tabnine = "(Tabnine)", - vsnip = "(Snippet)", - luasnip = "(Snippet)", - buffer = "(Buffer)", - tmux = "(TMUX)", - copilot = "(Copilot)", - treesitter = "(TreeSitter)", - }, - duplicates = { - buffer = 1, - path = 1, - nvim_lsp = 0, - luasnip = 1, - }, - duplicates_default = 0, - format = function(entry, vim_item) - local max_width = lvim.builtin.cmp.opts.formatting.max_width - if max_width ~= 0 and #vim_item.abbr > max_width then - vim_item.abbr = string.sub(vim_item.abbr, 1, max_width - 1) .. lvim.icons.ui.Ellipsis + duplicates_default = 0, + format = function(entry, vim_item) + local max_width = lvim.builtin.cmp.opts.formatting.max_width + if max_width ~= 0 and #vim_item.abbr > max_width then + vim_item.abbr = string.sub(vim_item.abbr, 1, max_width - 1) .. lvim.icons.ui.Ellipsis + end + if lvim.use_icons then + vim_item.kind = lvim.builtin.cmp.opts.formatting.kind_icons[vim_item.kind] + + if entry.source.name == "copilot" then + vim_item.kind = lvim.icons.git.Octoface + vim_item.kind_hl_group = "CmpItemKindCopilot" end - if lvim.use_icons then - vim_item.kind = lvim.builtin.cmp.opts.formatting.kind_icons[vim_item.kind] - - if entry.source.name == "copilot" then - vim_item.kind = lvim.icons.git.Octoface - vim_item.kind_hl_group = "CmpItemKindCopilot" - end - - if entry.source.name == "cmp_tabnine" then - vim_item.kind = lvim.icons.misc.Robot - vim_item.kind_hl_group = "CmpItemKindTabnine" - end - - if entry.source.name == "crates" then - vim_item.kind = lvim.icons.misc.Package - vim_item.kind_hl_group = "CmpItemKindCrate" - end - - if entry.source.name == "lab.quick_data" then - vim_item.kind = lvim.icons.misc.CircuitBoard - vim_item.kind_hl_group = "CmpItemKindConstant" - end - - if entry.source.name == "emoji" then - vim_item.kind = lvim.icons.misc.Smiley - vim_item.kind_hl_group = "CmpItemKindEmoji" - end + + if entry.source.name == "cmp_tabnine" then + vim_item.kind = lvim.icons.misc.Robot + vim_item.kind_hl_group = "CmpItemKindTabnine" end - vim_item.menu = lvim.builtin.cmp.opts.formatting.source_names[entry.source.name] - vim_item.dup = lvim.builtin.cmp.opts.formatting.duplicates[entry.source.name] - or lvim.builtin.cmp.opts.formatting.duplicates_default - return vim_item - end, + + if entry.source.name == "crates" then + vim_item.kind = lvim.icons.misc.Package + vim_item.kind_hl_group = "CmpItemKindCrate" + end + + if entry.source.name == "lab.quick_data" then + vim_item.kind = lvim.icons.misc.CircuitBoard + vim_item.kind_hl_group = "CmpItemKindConstant" + end + + if entry.source.name == "emoji" then + vim_item.kind = lvim.icons.misc.Smiley + vim_item.kind_hl_group = "CmpItemKindEmoji" + end + end + vim_item.menu = lvim.builtin.cmp.opts.formatting.source_names[entry.source.name] + vim_item.dup = lvim.builtin.cmp.opts.formatting.duplicates[entry.source.name] + or lvim.builtin.cmp.opts.formatting.duplicates_default + return vim_item + end, + }, + snippet = { + expand = function(args) + require("luasnip").lsp_expand(args.body) + end, + }, + window = { + completion = cmp.config.window.bordered(), + documentation = cmp.config.window.bordered(), + }, + sources = { + { + name = "copilot", + -- keyword_length = 0, + max_item_count = 3, + trigger_characters = { + { + ".", + ":", + "(", + "'", + '"', + "[", + ",", + "#", + "*", + "@", + "|", + "=", + "-", + "{", + "/", + "\\", + "+", + "?", + " ", + -- "\t", + -- "\n", + }, + }, }, - snippet = { - expand = function(args) - require("luasnip").lsp_expand(args.body) + { + name = "nvim_lsp", + entry_filter = function(entry, ctx) + local kind = require("cmp.types").lsp.CompletionItemKind[entry:get_kind()] + if kind == "Snippet" and ctx.prev_context.filetype == "java" then + return false + end + if kind == "Text" then + return false + end + return true end, }, - window = { - completion = cmp.config.window.bordered(), - documentation = cmp.config.window.bordered(), - }, - sources = { - { - name = "copilot", - -- keyword_length = 0, - max_item_count = 3, - trigger_characters = { - { - ".", - ":", - "(", - "'", - '"', - "[", - ",", - "#", - "*", - "@", - "|", - "=", - "-", - "{", - "/", - "\\", - "+", - "?", - " ", - -- "\t", - -- "\n", - }, - }, - }, - { - name = "nvim_lsp", - entry_filter = function(entry, ctx) - local kind = require("cmp.types").lsp.CompletionItemKind[entry:get_kind()] - if kind == "Snippet" and ctx.prev_context.filetype == "java" then - return false - end - if kind == "Text" then - return false - end - return true - end, - }, - { name = "path" }, - { name = "luasnip" }, - { name = "cmp_tabnine" }, - { name = "nvim_lua" }, - { name = "buffer" }, - { name = "calc" }, - { name = "emoji" }, - { name = "treesitter" }, - { name = "crates" }, - { name = "tmux" }, - }, - mapping = cmp.mapping.preset.insert { - ["<C-k>"] = cmp.mapping(cmp.mapping.select_prev_item(), { "i", "c" }), - ["<C-j>"] = cmp.mapping(cmp.mapping.select_next_item(), { "i", "c" }), - ["<Down>"] = cmp.mapping(cmp.mapping.select_next_item { behavior = cmp.SelectBehavior.Select }, { "i" }), - ["<Up>"] = cmp.mapping(cmp.mapping.select_prev_item { behavior = cmp.SelectBehavior.Select }, { "i" }), - ["<C-d>"] = cmp.mapping.scroll_docs(-4), - ["<C-f>"] = cmp.mapping.scroll_docs(4), - ["<C-y>"] = 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, - }, - ["<Tab>"] = cmp.mapping(function(fallback) + { name = "path" }, + { name = "luasnip" }, + { name = "cmp_tabnine" }, + { name = "nvim_lua" }, + { name = "buffer" }, + { name = "calc" }, + { name = "emoji" }, + { name = "treesitter" }, + { name = "crates" }, + { name = "tmux" }, + }, + mapping = cmp.mapping.preset.insert { + ["<C-k>"] = cmp.mapping(cmp.mapping.select_prev_item(), { "i", "c" }), + ["<C-j>"] = cmp.mapping(cmp.mapping.select_next_item(), { "i", "c" }), + ["<Down>"] = cmp.mapping(cmp.mapping.select_next_item { behavior = cmp.SelectBehavior.Select }, { "i" }), + ["<Up>"] = cmp.mapping(cmp.mapping.select_prev_item { behavior = cmp.SelectBehavior.Select }, { "i" }), + ["<C-d>"] = cmp.mapping.scroll_docs(-4), + ["<C-f>"] = cmp.mapping.scroll_docs(4), + ["<C-y>"] = cmp.mapping { + i = cmp.mapping.confirm { behavior = cmp.ConfirmBehavior.Replace, select = false }, + c = function(fallback) if cmp.visible() then - cmp.select_next_item() - elseif luasnip.expand_or_locally_jumpable() then - luasnip.expand_or_jump() - elseif jumpable(1) then - luasnip.jump(1) - elseif has_words_before() then - -- cmp.complete() - fallback() + cmp.confirm { behavior = cmp.ConfirmBehavior.Replace, select = false } else fallback() end - end, { "i", "s" }), - ["<S-Tab>"] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_prev_item() - elseif luasnip.jumpable(-1) then - luasnip.jump(-1) - else - fallback() + end, + }, + ["<Tab>"] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif luasnip.expand_or_locally_jumpable() then + luasnip.expand_or_jump() + elseif jumpable(1) then + luasnip.jump(1) + elseif has_words_before() then + -- cmp.complete() + fallback() + else + fallback() + end + end, { "i", "s" }), + ["<S-Tab>"] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif luasnip.jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, { "i", "s" }), + ["<C-Space>"] = cmp.mapping.complete(), + ["<C-e>"] = cmp.mapping.abort(), + ["<CR>"] = cmp.mapping(function(fallback) + if cmp.visible() then + local confirm_opts = vim.deepcopy(lvim.builtin.cmp.opts.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 - end, { "i", "s" }), - ["<C-Space>"] = cmp.mapping.complete(), - ["<C-e>"] = cmp.mapping.abort(), - ["<CR>"] = 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 - end - if cmp.confirm(confirm_opts) then - return -- success, exit early - end + if is_insert_mode() then -- prevent overwriting brackets + confirm_opts.behavior = cmp.ConfirmBehavior.Insert end - fallback() -- if not exited early, always fallback - end), - }, - cmdline = { - enable = false, - options = { - { - type = ":", - sources = { - { name = "path" }, - { name = "cmdline" }, - }, + if cmp.confirm(confirm_opts) then + return -- success, exit early + end + end + fallback() -- if not exited early, always fallback + end), + }, + cmdline = { + enable = false, + options = { + { + type = ":", + sources = { + { name = "path" }, + { name = "cmdline" }, }, - { - type = { "/", "?" }, - sources = { - { name = "buffer" }, - }, + }, + { + type = { "/", "?" }, + sources = { + { name = "buffer" }, }, }, }, }, } - ---@cast config +LvimBuiltin - require("lvim.core.builtins").extend_defaults(config) - lvim.builtin.cmp = config + lvim.builtin.cmp = require("lvim.core.builtins").add_completion "cmp" end function M.setup() diff --git a/lua/lvim/core/comment.lua b/lua/lvim/core/comment.lua index 2f526c63..fc35b2e2 100644 --- a/lua/lvim/core/comment.lua +++ b/lua/lvim/core/comment.lua @@ -1,80 +1,76 @@ local M = {} function M.config() - local config = { - opts = { - ---Add a space b/w comment and the line - ---@type boolean - padding = true, + lvim.builtin.comment.opts = { + ---Add a space b/w comment and the line + ---@type boolean + padding = true, - ---Whether cursor should stay at the - ---same position. Only works in NORMAL - ---mode mappings - sticky = true, + ---Whether cursor should stay at the + ---same position. Only works in NORMAL + ---mode mappings + sticky = true, - ---Lines to be ignored while comment/uncomment. - ---Could be a regex string or a function that returns a regex string. - ---Example: Use '^$' to ignore empty lines - ---@type string|function - ignore = "^$", + ---Lines to be ignored while comment/uncomment. + ---Could be a regex string or a function that returns a regex string. + ---Example: Use '^$' to ignore empty lines + ---@type string|function + ignore = "^$", - ---Whether to create basic (operator-pending) and extra mappings for NORMAL/VISUAL mode - ---@type table - mappings = { - ---operator-pending mapping - ---Includes `gcc`, `gcb`, `gc[count]{motion}` and `gb[count]{motion}` - basic = true, - ---Extra mapping - ---Includes `gco`, `gcO`, `gcA` - extra = true, - }, + ---Whether to create basic (operator-pending) and extra mappings for NORMAL/VISUAL mode + ---@type table + mappings = { + ---operator-pending mapping + ---Includes `gcc`, `gcb`, `gc[count]{motion}` and `gb[count]{motion}` + basic = true, + ---Extra mapping + ---Includes `gco`, `gcO`, `gcA` + extra = true, + }, - ---LHS of line and block comment toggle mapping in NORMAL/VISUAL mode - ---@type table - toggler = { - ---line-comment toggle - line = "gcc", - ---block-comment toggle - block = "gbc", - }, + ---LHS of line and block comment toggle mapping in NORMAL/VISUAL mode + ---@type table + toggler = { + ---line-comment toggle + line = "gcc", + ---block-comment toggle + block = "gbc", + }, - ---LHS of line and block comment operator-mode mapping in NORMAL/VISUAL mode - ---@type table - opleader = { - ---line-comment opfunc mapping - line = "gc", - ---block-comment opfunc mapping - block = "gb", - }, + ---LHS of line and block comment operator-mode mapping in NORMAL/VISUAL mode + ---@type table + opleader = { + ---line-comment opfunc mapping + line = "gc", + ---block-comment opfunc mapping + block = "gb", + }, - ---LHS of extra mappings - ---@type table - extra = { - ---Add comment on the line above - above = "gcO", - ---Add comment on the line below - below = "gco", - ---Add comment at the end of line - eol = "gcA", - }, + ---LHS of extra mappings + ---@type table + extra = { + ---Add comment on the line above + above = "gcO", + ---Add comment on the line below + below = "gco", + ---Add comment at the end of line + eol = "gcA", + }, - ---Pre-hook, called before commenting the line - ---@type function|nil - 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, + ---Pre-hook, called before commenting the line + ---@type function|nil + 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 - post_hook = nil, - }, + ---Post-hook, called after commenting is done + ---@type function|nil + post_hook = nil, } - ---@cast config +LvimBuiltin - require("lvim.core.builtins").extend_defaults(config) - lvim.builtin.comment = config + lvim.builtin.comment = require("lvim.core.builtins").add_completion "comment" end function M.setup() diff --git a/lua/lvim/core/dap.lua b/lua/lvim/core/dap.lua index 9ad84b96..781ed847 100644 --- a/lua/lvim/core/dap.lua +++ b/lua/lvim/core/dap.lua @@ -1,101 +1,97 @@ local M = {} M.config = function() - local config = { - breakpoint = { - text = lvim.icons.ui.Bug, - texthl = "DiagnosticSignError", - linehl = "", - numhl = "", - }, - breakpoint_rejected = { - text = lvim.icons.ui.Bug, - texthl = "DiagnosticSignError", - linehl = "", - numhl = "", - }, - stopped = { - text = lvim.icons.ui.BoldArrowRight, - texthl = "DiagnosticSignWarn", - linehl = "Visual", - numhl = "DiagnosticSignWarn", - }, - log = { - level = "info", + lvim.builtin.dap.breakpoint = { + text = lvim.icons.ui.Bug, + texthl = "DiagnosticSignError", + linehl = "", + numhl = "", + } + lvim.builtin.dap.breakpoint_rejected = { + text = lvim.icons.ui.Bug, + texthl = "DiagnosticSignError", + linehl = "", + numhl = "", + } + lvim.builtin.dap.stopped = { + text = lvim.icons.ui.BoldArrowRight, + texthl = "DiagnosticSignWarn", + linehl = "Visual", + numhl = "DiagnosticSignWarn", + } + lvim.builtin.dap.log = { + level = "info", + } + lvim.builtin.dap.ui = { + auto_open = true, + notify = { + threshold = vim.log.levels.INFO, }, - ui = { - auto_open = true, - notify = { - threshold = vim.log.levels.INFO, + config = { + icons = { expanded = "", collapsed = "", circular = "" }, + mappings = { + -- Use a table to apply multiple mappings + expand = { "<CR>", "<2-LeftMouse>" }, + open = "o", + remove = "d", + edit = "e", + repl = "r", + toggle = "t", }, - config = { - icons = { expanded = "", collapsed = "", circular = "" }, - mappings = { - -- Use a table to apply multiple mappings - expand = { "<CR>", "<2-LeftMouse>" }, - open = "o", - remove = "d", - edit = "e", - repl = "r", - toggle = "t", - }, - -- Use this to override mappings for specific elements - element_mappings = {}, - expand_lines = true, - layouts = { - { - elements = { - { id = "scopes", size = 0.33 }, - { id = "breakpoints", size = 0.17 }, - { id = "stacks", size = 0.25 }, - { id = "watches", size = 0.25 }, - }, - size = 0.33, - position = "right", - }, - { - elements = { - { id = "repl", size = 0.45 }, - { id = "console", size = 0.55 }, - }, - size = 0.27, - position = "bottom", + -- Use this to override mappings for specific elements + element_mappings = {}, + expand_lines = true, + layouts = { + { + elements = { + { id = "scopes", size = 0.33 }, + { id = "breakpoints", size = 0.17 }, + { id = "stacks", size = 0.25 }, + { id = "watches", size = 0.25 }, }, + size = 0.33, + position = "right", }, - controls = { - enabled = true, - -- Display controls in this element - element = "repl", - icons = { - pause = "", - play = "", - step_into = "", - step_over = "", - step_out = "", - step_back = "", - run_last = "", - terminate = "", + { + elements = { + { id = "repl", size = 0.45 }, + { id = "console", size = 0.55 }, }, + size = 0.27, + position = "bottom", }, - floating = { - max_height = 0.9, - max_width = 0.5, -- Floats will be treated as percentage of your screen. - border = vim.g.border_chars, -- Border style. Can be 'single', 'double' or 'rounded' - mappings = { - close = { "q", "<Esc>" }, - }, + }, + controls = { + enabled = true, + -- Display controls in this element + element = "repl", + icons = { + pause = "", + play = "", + step_into = "", + step_over = "", + step_out = "", + step_back = "", + run_last = "", + terminate = "", }, - windows = { indent = 1 }, - render = { - max_type_length = nil, -- Can be integer or nil. - max_value_lines = 100, -- Can be integer or nil. + }, + floating = { + max_height = 0.9, + max_width = 0.5, -- Floats will be treated as percentage of your screen. + border = vim.g.border_chars, -- Border style. Can be 'single', 'double' or 'rounded' + mappings = { + close = { "q", "<Esc>" }, }, }, + windows = { indent = 1 }, + render = { + max_type_length = nil, -- Can be integer or nil. + max_value_lines = 100, -- Can be integer or nil. + }, }, } - ---@cast config +LvimBuiltin - require("lvim.core.builtins").extend_defaults(config) - lvim.builtin.dap = config + lvim.builtin.dap = require("lvim.core.builtins").add_completion "dap" end M.setup = function() diff --git a/lua/lvim/core/gitsigns.lua b/lua/lvim/core/gitsigns.lua index 1e1f4df9..e9d4189a 100644 --- a/lua/lvim/core/gitsigns.lua +++ b/lua/lvim/core/gitsigns.lua @@ -1,75 +1,71 @@ local M = {} M.config = function() - local config = { - opts = { - signs = { - add = { - hl = "GitSignsAdd", - text = lvim.icons.ui.BoldLineLeft, - numhl = "GitSignsAddNr", - linehl = "GitSignsAddLn", - }, - change = { - hl = "GitSignsChange", - text = lvim.icons.ui.BoldLineLeft, - numhl = "GitSignsChangeNr", - linehl = "GitSignsChangeLn", - }, - delete = { - hl = "GitSignsDelete", - text = lvim.icons.ui.Triangle, - numhl = "GitSignsDeleteNr", - linehl = "GitSignsDeleteLn", - }, - topdelete = { - hl = "GitSignsDelete", - text = lvim.icons.ui.Triangle, - numhl = "GitSignsDeleteNr", - linehl = "GitSignsDeleteLn", - }, - changedelete = { - hl = "GitSignsChange", - text = lvim.icons.ui.BoldLineLeft, - numhl = "GitSignsChangeNr", - linehl = "GitSignsChangeLn", - }, + lvim.builtin.gitsigns.opts = { + signs = { + add = { + hl = "GitSignsAdd", + text = lvim.icons.ui.BoldLineLeft, + numhl = "GitSignsAddNr", + linehl = "GitSignsAddLn", }, - signcolumn = true, - numhl = false, - linehl = false, - word_diff = false, - watch_gitdir = { - interval = 1000, - follow_files = true, + change = { + hl = "GitSignsChange", + text = lvim.icons.ui.BoldLineLeft, + numhl = "GitSignsChangeNr", + linehl = "GitSignsChangeLn", }, - attach_to_untracked = true, - current_line_blame = false, -- Toggle with `:Gitsigns toggle_current_line_blame` - current_line_blame_opts = { - virt_text = true, - virt_text_pos = "eol", -- 'eol' | 'overlay' | 'right_align' - delay = 1000, - ignore_whitespace = false, + delete = { + hl = "GitSignsDelete", + text = lvim.icons.ui.Triangle, + numhl = "GitSignsDeleteNr", + linehl = "GitSignsDeleteLn", }, - current_line_blame_formatter = "<author>, <author_time:%Y-%m-%d> - <summary>", - sign_priority = 6, - status_formatter = nil, -- Use default - update_debounce = 200, - max_file_length = 40000, - preview_config = { - -- Options passed to nvim_open_win - border = "rounded", - style = "minimal", - relative = "cursor", - row = 0, - col = 1, + topdelete = { + hl = "GitSignsDelete", + text = lvim.icons.ui.Triangle, + numhl = "GitSignsDeleteNr", + linehl = "GitSignsDeleteLn", }, - yadm = { enable = false }, + changedelete = { + hl = "GitSignsChange", + text = lvim.icons.ui.BoldLineLeft, + numhl = "GitSignsChangeNr", + linehl = "GitSignsChangeLn", + }, + }, + signcolumn = true, + numhl = false, + linehl = false, + word_diff = false, + watch_gitdir = { + interval = 1000, + follow_files = true, + }, + attach_to_untracked = true, + current_line_blame = false, -- Toggle with `:Gitsigns toggle_current_line_blame` + current_line_blame_opts = { + virt_text = true, + virt_text_pos = "eol", -- 'eol' | 'overlay' | 'right_align' + delay = 1000, + ignore_whitespace = false, + }, + current_line_blame_formatter = "<author>, <author_time:%Y-%m-%d> - <summary>", + sign_priority = 6, + status_formatter = nil, -- Use default + update_debounce = 200, + max_file_length = 40000, + preview_config = { + -- Options passed to nvim_open_win + border = "rounded", + style = "minimal", + relative = "cursor", + row = 0, + col = 1, }, + yadm = { enable = false }, } - ---@cast config +LvimBuiltin - require("lvim.core.builtins").extend_defaults(config) - lvim.builtin.gitsigns = config + lvim.builtin.gitsigns = require("lvim.core.builtins").add_completion "gitsigns" end M.setup = function() diff --git a/lua/lvim/core/illuminate.lua b/lua/lvim/core/illuminate.lua index f9b4e918..c1ba9a58 100644 --- a/lua/lvim/core/illuminate.lua +++ b/lua/lvim/core/illuminate.lua @@ -1,57 +1,53 @@ local M = {} M.config = function() - local config = { - opts = { - -- providers: provider used to get references in the buffer, ordered by priority - providers = { - "lsp", - "treesitter", - "regex", - }, - -- delay: delay in milliseconds - delay = 120, - -- filetype_overrides: filetype specific overrides. - -- The keys are strings to represent the filetype while the values are tables that - -- supports the same keys passed to .configure except for filetypes_denylist and filetypes_allowlist - filetype_overrides = {}, - -- filetypes_denylist: filetypes to not illuminate, this overrides filetypes_allowlist - filetypes_denylist = { - "dirvish", - "fugitive", - "alpha", - "NvimTree", - "lazy", - "neogitstatus", - "Trouble", - "lir", - "Outline", - "spectre_panel", - "toggleterm", - "DressingSelect", - "TelescopePrompt", - }, - -- filetypes_allowlist: filetypes to illuminate, this is overridden by filetypes_denylist - filetypes_allowlist = {}, - -- modes_denylist: modes to not illuminate, this overrides modes_allowlist - modes_denylist = {}, - -- modes_allowlist: modes to illuminate, this is overridden by modes_denylist - modes_allowlist = {}, - -- providers_regex_syntax_denylist: syntax to not illuminate, this overrides providers_regex_syntax_allowlist - -- Only applies to the 'regex' provider - -- Use :echom synIDattr(synIDtrans(synID(line('.'), col('.'), 1)), 'name') - providers_regex_syntax_denylist = {}, - -- providers_regex_syntax_allowlist: syntax to illuminate, this is overridden by providers_regex_syntax_denylist - -- Only applies to the 'regex' provider - -- Use :echom synIDattr(synIDtrans(synID(line('.'), col('.'), 1)), 'name') - providers_regex_syntax_allowlist = {}, - -- under_cursor: whether or not to illuminate under the cursor - under_cursor = true, + lvim.builtin.illuminate.opts = { + -- providers: provider used to get references in the buffer, ordered by priority + providers = { + "lsp", + "treesitter", + "regex", }, + -- delay: delay in milliseconds + delay = 120, + -- filetype_overrides: filetype specific overrides. + -- The keys are strings to represent the filetype while the values are tables that + -- supports the same keys passed to .configure except for filetypes_denylist and filetypes_allowlist + filetype_overrides = {}, + -- filetypes_denylist: filetypes to not illuminate, this overrides filetypes_allowlist + filetypes_denylist = { + "dirvish", + "fugitive", + "alpha", + "NvimTree", + "lazy", + "neogitstatus", + "Trouble", + "lir", + "Outline", + "spectre_panel", + "toggleterm", + "DressingSelect", + "TelescopePrompt", + }, + -- filetypes_allowlist: filetypes to illuminate, this is overridden by filetypes_denylist + filetypes_allowlist = {}, + -- modes_denylist: modes to not illuminate, this overrides modes_allowlist + modes_denylist = {}, + -- modes_allowlist: modes to illuminate, this is overridden by modes_denylist + modes_allowlist = {}, + -- providers_regex_syntax_denylist: syntax to not illuminate, this overrides providers_regex_syntax_allowlist + -- Only applies to the 'regex' provider + -- Use :echom synIDattr(synIDtrans(synID(line('.'), col('.'), 1)), 'name') + providers_regex_syntax_denylist = {}, + -- providers_regex_syntax_allowlist: syntax to illuminate, this is overridden by providers_regex_syntax_denylist + -- Only applies to the 'regex' provider + -- Use :echom synIDattr(synIDtrans(synID(line('.'), col('.'), 1)), 'name') + providers_regex_syntax_allowlist = {}, + -- under_cursor: whether or not to illuminate under the cursor + under_cursor = true, } - ---@cast config +LvimBuiltin - require("lvim.core.builtins").extend_defaults(config) - lvim.builtin.illuminate = config + lvim.builtin.illuminate = require("lvim.core.builtins").add_completion "illuminate" end M.setup = function() diff --git a/lua/lvim/core/indentlines.lua b/lua/lvim/core/indentlines.lua index 12521b3f..2c974b96 100644 --- a/lua/lvim/core/indentlines.lua +++ b/lua/lvim/core/indentlines.lua @@ -1,31 +1,27 @@ local M = {} M.config = function() - local config = { - opts = { - enabled = true, - buftype_exclude = { "terminal", "nofile" }, - filetype_exclude = { - "help", - "startify", - "dashboard", - "lazy", - "neogitstatus", - "NvimTree", - "Trouble", - "text", - }, - char = lvim.icons.ui.LineLeft, - context_char = lvim.icons.ui.LineLeft, - show_trailing_blankline_indent = false, - show_first_indent_level = true, - use_treesitter = true, - show_current_context = true, + lvim.builtin.indentlines.opts = { + enabled = true, + buftype_exclude = { "terminal", "nofile" }, + filetype_exclude = { + "help", + "startify", + "dashboard", + "lazy", + "neogitstatus", + "NvimTree", + "Trouble", + "text", }, + char = lvim.icons.ui.LineLeft, + context_char = lvim.icons.ui.LineLeft, + show_trailing_blankline_indent = false, + show_first_indent_level = true, + use_treesitter = true, + show_current_context = true, } - ---@cast config +LvimBuiltin - require("lvim.core.builtins").extend_defaults(config) - lvim.builtin.indentlines = config + lvim.builtin.indentlines = require("lvim.core.builtins").add_completion "indentlines" end M.setup = function() diff --git a/lua/lvim/core/lir.lua b/lua/lvim/core/lir.lua index 08b2e2fb..a8ea43f3 100644 --- a/lua/lvim/core/lir.lua +++ b/lua/lvim/core/lir.lua @@ -5,76 +5,72 @@ M.config = function() local actions = utils.require_on_exported_call "lir.actions" local clipboard_actions = utils.require_on_exported_call "lir.clipboard.actions" - local config = { - opts = { - icon = "", - show_hidden_files = false, - ignore = {}, -- { ".DS_Store" "node_modules" } etc. - devicons = { - enable = true, - highlight_dirname = true, - }, - mappings = { - ["l"] = actions.edit, - ["<CR>"] = actions.edit, - ["<C-s>"] = actions.split, - ["v"] = actions.vsplit, - ["<C-t>"] = actions.tabedit, + lvim.builtin.lir.opts = { + icon = "", + show_hidden_files = false, + ignore = {}, -- { ".DS_Store" "node_modules" } etc. + devicons = { + enable = true, + highlight_dirname = true, + }, + mappings = { + ["l"] = actions.edit, + ["<CR>"] = actions.edit, + ["<C-s>"] = actions.split, + ["v"] = actions.vsplit, + ["<C-t>"] = actions.tabedit, - ["h"] = actions.up, - ["q"] = actions.quit, + ["h"] = actions.up, + ["q"] = actions.quit, - ["A"] = actions.mkdir, - ["a"] = actions.newfile, - ["r"] = actions.rename, - ["@"] = actions.cd, - ["Y"] = actions.yank_path, - ["i"] = actions.toggle_show_hidden, - ["d"] = actions.delete, + ["A"] = actions.mkdir, + ["a"] = actions.newfile, + ["r"] = actions.rename, + ["@"] = actions.cd, + ["Y"] = actions.yank_path, + ["i"] = actions.toggle_show_hidden, + ["d"] = actions.delete, - ["J"] = function() - require("lir.mark.actions").toggle_mark() - vim.cmd "normal! j" - end, - ["c"] = clipboard_actions.copy, - ["x"] = clipboard_actions.cut, - ["p"] = clipboard_actions.paste, + ["J"] = function() + require("lir.mark.actions").toggle_mark() + vim.cmd "normal! j" + end, + ["c"] = clipboard_actions.copy, + ["x"] = clipboard_actions.cut, + ["p"] = clipboard_actions.paste, + }, + float = { + winblend = 0, + curdir_window = { + enable = false, + highlight_dirname = true, }, - float = { - winblend = 0, - curdir_window = { - enable = false, - highlight_dirname = true, - }, - -- You can define a function that returns a table to be passed as the third - -- argument of nvim_open_win(). - win_opts = function() - local width = math.floor(vim.o.columns * 0.7) - local height = math.floor(vim.o.lines * 0.7) - return { - border = "rounded", - width = width, - height = height, - } - end, - }, - hide_cursor = false, - on_init = function() - -- use visual mode - vim.api.nvim_buf_set_keymap( - 0, - "x", - "J", - ':<C-u>lua require"lir.mark.actions".toggle_mark("v")<CR>', - { noremap = true, silent = true } - ) + -- You can define a function that returns a table to be passed as the third + -- argument of nvim_open_win(). + win_opts = function() + local width = math.floor(vim.o.columns * 0.7) + local height = math.floor(vim.o.lines * 0.7) + return { + border = "rounded", + width = width, + height = height, + } end, }, + hide_cursor = false, + on_init = function() + -- use visual mode + vim.api.nvim_buf_set_keymap( + 0, + "x", + "J", + ':<C-u>lua require"lir.mark.actions".toggle_mark("v")<CR>', + { noremap = true, silent = true } + ) + end, } - ---@cast config +LvimBuiltin - require("lvim.core.builtins").extend_defaults(config) - lvim.builtin.lir = config + lvim.builtin.lir = require("lvim.core.builtins").add_completion "lir" end function M.icon_setup() diff --git a/lua/lvim/core/lualine/init.lua b/lua/lvim/core/lualine/init.lua index 9759d5a0..3485a91c 100644 --- a/lua/lvim/core/lualine/init.lua +++ b/lua/lvim/core/lualine/init.lua @@ -1,6 +1,6 @@ local M = {} M.config = function() - local config = { + lvim.builtin.lualine.opts = { style = "lvim", options = { icons_enabled = nil, @@ -31,9 +31,7 @@ M.config = function() tabline = nil, extensions = nil, } - ---@cast config +LvimBuiltin - require("lvim.core.builtins").extend_defaults(config) - lvim.builtin.lualine = config + lvim.builtin.lualine = require("lvim.core.builtins").add_completion "lualine" end M.setup = function() @@ -51,7 +49,7 @@ M.setup = function() require("lvim.core.lualine.styles").update() vim.opt.laststatus = 3 - lualine.setup(lvim.builtin.lualine) + lualine.setup(lvim.builtin.lualine.opts) end return M diff --git a/lua/lvim/core/lualine/styles.lua b/lua/lvim/core/lualine/styles.lua index 81dbbabb..4c11a337 100644 --- a/lua/lvim/core/lualine/styles.lua +++ b/lua/lvim/core/lualine/styles.lua @@ -149,16 +149,16 @@ function M.get_style(style) end function M.update() - local style = M.get_style(lvim.builtin.lualine.style) + local style = M.get_style(lvim.builtin.lualine.opts.style) - lvim.builtin.lualine = vim.tbl_deep_extend("keep", lvim.builtin.lualine, style) + lvim.builtin.lualine.opts = vim.tbl_deep_extend("keep", lvim.builtin.lualine.opts, style) local color_template = vim.g.colors_name or lvim.colorscheme local theme_supported, template = pcall(function() require("lualine.utils.loader").load_theme(color_template) end) if theme_supported and template then - lvim.builtin.lualine.options.theme = color_template + lvim.builtin.lualine.opts.options.theme = color_template end end diff --git a/lua/lvim/core/mason.lua b/lua/lvim/core/mason.lua index ab58c5c8..3a5bdd1c 100644 --- a/lua/lvim/core/mason.lua +++ b/lua/lvim/core/mason.lua @@ -3,58 +3,54 @@ local M = {} local join_paths = require("lvim.utils").join_paths function M.config() - local config = { - opts = { - ui = { - border = "rounded", - keymaps = { - toggle_package_expand = "<CR>", - install_package = "i", - update_package = "u", - check_package_version = "c", - update_all_packages = "U", - check_outdated_packages = "C", - uninstall_package = "X", - cancel_installation = "<C-c>", - apply_language_filter = "<C-f>", - }, + lvim.builtin.mason.opts = { + ui = { + border = "rounded", + keymaps = { + toggle_package_expand = "<CR>", + install_package = "i", + update_package = "u", + check_package_version = "c", + update_all_packages = "U", + check_outdated_packages = "C", + uninstall_package = "X", + cancel_installation = "<C-c>", + apply_language_filter = "<C-f>", }, + }, - -- NOTE: should be available in $PATH - install_root_dir = join_paths(vim.fn.stdpath "data", "mason"), + -- NOTE: should be available in $PATH + install_root_dir = join_paths(vim.fn.stdpath "data", "mason"), - -- NOTE: already handled in the bootstrap stage - PATH = "skip", + -- NOTE: already handled in the bootstrap stage + PATH = "skip", - pip = { - -- These args will be added to `pip install` calls. Note that setting extra args might impact intended behavior - -- and is not recommended. - -- - -- Example: { "--proxy", "https://proxyserver" } - install_args = {}, - }, + pip = { + -- These args will be added to `pip install` calls. Note that setting extra args might impact intended behavior + -- and is not recommended. + -- + -- Example: { "--proxy", "https://proxyserver" } + install_args = {}, + }, - -- Controls to which degree logs are written to the log file. It's useful to set this to vim.log.levels.DEBUG when - -- debugging issues with package installations. - log_level = vim.log.levels.INFO, + -- Controls to which degree logs are written to the log file. It's useful to set this to vim.log.levels.DEBUG when + -- debugging issues with package installations. + log_level = vim.log.levels.INFO, - -- Limit for the maximum amount of packages to be installed at the same time. Once this limit is reached, any further - -- packages that are requested to be installed will be put in a queue. - max_concurrent_installers = 4, + -- Limit for the maximum amount of packages to be installed at the same time. Once this limit is reached, any further + -- packages that are requested to be installed will be put in a queue. + 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", - }, + 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", }, } - ---@cast config +LvimBuiltin - require("lvim.core.builtins").extend_defaults(config) - lvim.builtin.mason = config + lvim.builtin.mason = require("lvim.core.builtins").add_completion "mason" end function M.get_prefix() diff --git a/lua/lvim/core/nvimtree.lua b/lua/lvim/core/nvimtree.lua index a82cdb00..9f974fa5 100644 --- a/lua/lvim/core/nvimtree.lua +++ b/lua/lvim/core/nvimtree.lua @@ -2,237 +2,233 @@ local M = {} local Log = require "lvim.core.log" function M.config() - local config = { - opts = { - auto_reload_on_write = false, - disable_netrw = false, - hijack_cursor = false, - 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, - sync_root_with_cwd = true, - reload_on_bufenter = false, - respect_buf_cwd = false, - on_attach = "disable", - remove_keymaps = false, - select_prompts = false, - view = { - adaptive_size = false, - centralize_selection = false, - width = 30, - hide_root_folder = false, - side = "left", - preserve_window_proportions = false, - number = false, - relativenumber = false, - signcolumn = "yes", - mappings = { - custom_only = false, - list = {}, + lvim.builtin.nvimtree.opts = { + auto_reload_on_write = false, + disable_netrw = false, + hijack_cursor = false, + 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, + sync_root_with_cwd = true, + reload_on_bufenter = false, + respect_buf_cwd = false, + on_attach = "disable", + remove_keymaps = false, + select_prompts = false, + view = { + adaptive_size = false, + centralize_selection = false, + width = 30, + hide_root_folder = false, + side = "left", + preserve_window_proportions = false, + number = false, + relativenumber = false, + signcolumn = "yes", + mappings = { + custom_only = false, + list = {}, + }, + float = { + enable = false, + quit_on_focus_loss = true, + open_win_config = { + relative = "editor", + border = "rounded", + width = 30, + height = 30, + row = 1, + col = 1, }, - float = { - enable = false, - quit_on_focus_loss = true, - open_win_config = { - relative = "editor", - border = "rounded", - width = 30, - height = 30, - row = 1, - col = 1, - }, + }, + }, + renderer = { + add_trailing = false, + group_empty = false, + highlight_git = true, + full_name = false, + highlight_opened_files = "none", + root_folder_label = ":t", + indent_width = 2, + indent_markers = { + enable = false, + inline_arrows = true, + icons = { + corner = "└", + edge = "│", + item = "│", + none = " ", }, }, - renderer = { - add_trailing = false, - group_empty = false, - highlight_git = true, - full_name = false, - highlight_opened_files = "none", - root_folder_label = ":t", - indent_width = 2, - indent_markers = { - enable = false, - inline_arrows = true, - icons = { - corner = "└", - edge = "│", - item = "│", - none = " ", - }, + icons = { + webdev_colors = lvim.use_icons, + git_placement = "before", + padding = " ", + symlink_arrow = " ➛ ", + show = { + file = lvim.use_icons, + folder = lvim.use_icons, + folder_arrow = lvim.use_icons, + git = lvim.use_icons, }, - icons = { - webdev_colors = lvim.use_icons, - git_placement = "before", - padding = " ", - symlink_arrow = " ➛ ", - show = { - file = lvim.use_icons, - folder = lvim.use_icons, - folder_arrow = lvim.use_icons, - git = lvim.use_icons, + glyphs = { + default = lvim.icons.ui.Text, + symlink = lvim.icons.ui.FileSymlink, + bookmark = lvim.icons.ui.BookMark, + folder = { + arrow_closed = lvim.icons.ui.TriangleShortArrowRight, + arrow_open = lvim.icons.ui.TriangleShortArrowDown, + default = lvim.icons.ui.Folder, + open = lvim.icons.ui.FolderOpen, + empty = lvim.icons.ui.EmptyFolder, + empty_open = lvim.icons.ui.EmptyFolderOpen, + symlink = lvim.icons.ui.FolderSymlink, + symlink_open = lvim.icons.ui.FolderOpen, }, - glyphs = { - default = lvim.icons.ui.Text, - symlink = lvim.icons.ui.FileSymlink, - bookmark = lvim.icons.ui.BookMark, - folder = { - arrow_closed = lvim.icons.ui.TriangleShortArrowRight, - arrow_open = lvim.icons.ui.TriangleShortArrowDown, - default = lvim.icons.ui.Folder, - open = lvim.icons.ui.FolderOpen, - empty = lvim.icons.ui.EmptyFolder, - empty_open = lvim.icons.ui.EmptyFolderOpen, - symlink = lvim.icons.ui.FolderSymlink, - symlink_open = lvim.icons.ui.FolderOpen, - }, - git = { - unstaged = lvim.icons.git.FileUnstaged, - staged = lvim.icons.git.FileStaged, - unmerged = lvim.icons.git.FileUnmerged, - renamed = lvim.icons.git.FileRenamed, - untracked = lvim.icons.git.FileUntracked, - deleted = lvim.icons.git.FileDeleted, - ignored = lvim.icons.git.FileIgnored, - }, + git = { + unstaged = lvim.icons.git.FileUnstaged, + staged = lvim.icons.git.FileStaged, + unmerged = lvim.icons.git.FileUnmerged, + renamed = lvim.icons.git.FileRenamed, + untracked = lvim.icons.git.FileUntracked, + deleted = lvim.icons.git.FileDeleted, + ignored = lvim.icons.git.FileIgnored, }, }, - special_files = { "Cargo.toml", "Makefile", "README.md", "readme.md" }, - symlink_destination = true, }, - hijack_directories = { - enable = false, - auto_open = true, - }, - update_focused_file = { - enable = true, - debounce_delay = 15, - update_root = true, - ignore_list = {}, + special_files = { "Cargo.toml", "Makefile", "README.md", "readme.md" }, + symlink_destination = true, + }, + hijack_directories = { + enable = false, + auto_open = true, + }, + update_focused_file = { + enable = true, + debounce_delay = 15, + update_root = true, + ignore_list = {}, + }, + ignore_ft_on_setup = { + "startify", + "dashboard", + "alpha", + }, + diagnostics = { + enable = lvim.use_icons, + show_on_dirs = false, + show_on_open_dirs = true, + debounce_delay = 50, + severity = { + min = vim.diagnostic.severity.HINT, + max = vim.diagnostic.severity.ERROR, }, - ignore_ft_on_setup = { - "startify", - "dashboard", - "alpha", + icons = { + hint = lvim.icons.diagnostics.BoldHint, + info = lvim.icons.diagnostics.BoldInformation, + warning = lvim.icons.diagnostics.BoldWarning, + error = lvim.icons.diagnostics.BoldError, }, - diagnostics = { - enable = lvim.use_icons, - show_on_dirs = false, - show_on_open_dirs = true, - debounce_delay = 50, - severity = { - min = vim.diagnostic.severity.HINT, - max = vim.diagnostic.severity.ERROR, - }, - icons = { - hint = lvim.icons.diagnostics.BoldHint, - info = lvim.icons.diagnostics.BoldInformation, - warning = lvim.icons.diagnostics.BoldWarning, - error = lvim.icons.diagnostics.BoldError, - }, + }, + filters = { + dotfiles = false, + git_clean = false, + no_buffer = false, + custom = { "node_modules", "\\.cache" }, + exclude = {}, + }, + filesystem_watchers = { + enable = true, + debounce_delay = 50, + ignore_dirs = {}, + }, + git = { + enable = true, + ignore = false, + show_on_dirs = true, + show_on_open_dirs = true, + timeout = 200, + }, + actions = { + use_system_clipboard = true, + change_dir = { + enable = true, + global = false, + restrict_above_cwd = false, }, - filters = { - dotfiles = false, - git_clean = false, - no_buffer = false, - custom = { "node_modules", "\\.cache" }, + expand_all = { + max_folder_discovery = 300, exclude = {}, }, - filesystem_watchers = { - enable = true, - debounce_delay = 50, - ignore_dirs = {}, - }, - git = { - enable = true, - ignore = false, - show_on_dirs = true, - show_on_open_dirs = true, - timeout = 200, + file_popup = { + open_win_config = { + col = 1, + row = 1, + relative = "cursor", + border = "shadow", + style = "minimal", + }, }, - actions = { - use_system_clipboard = true, - change_dir = { + open_file = { + quit_on_open = false, + resize_window = false, + window_picker = { enable = true, - global = false, - restrict_above_cwd = false, - }, - expand_all = { - max_folder_discovery = 300, - exclude = {}, - }, - file_popup = { - open_win_config = { - col = 1, - row = 1, - relative = "cursor", - border = "shadow", - style = "minimal", - }, - }, - open_file = { - quit_on_open = false, - resize_window = false, - window_picker = { - enable = true, - picker = "default", - chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890", - exclude = { - filetype = { "notify", "lazy", "qf", "diff", "fugitive", "fugitiveblame" }, - buftype = { "nofile", "terminal", "help" }, - }, + picker = "default", + chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890", + exclude = { + filetype = { "notify", "lazy", "qf", "diff", "fugitive", "fugitiveblame" }, + buftype = { "nofile", "terminal", "help" }, }, }, - remove_file = { - close_window = true, - }, - }, - trash = { - cmd = "trash", - require_confirm = true, - }, - live_filter = { - prefix = "[FILTER]: ", - always_show_folders = true, - }, - tab = { - sync = { - open = false, - close = false, - ignore = {}, - }, }, - notify = { - threshold = vim.log.levels.INFO, + remove_file = { + close_window = true, }, - log = { - enable = false, - truncate = false, - types = { - all = false, - config = false, - copy_paste = false, - dev = false, - diagnostics = false, - git = false, - profile = false, - watcher = false, - }, + }, + trash = { + cmd = "trash", + require_confirm = true, + }, + live_filter = { + prefix = "[FILTER]: ", + always_show_folders = true, + }, + tab = { + sync = { + open = false, + close = false, + ignore = {}, }, - system_open = { - cmd = nil, - args = {}, + }, + notify = { + threshold = vim.log.levels.INFO, + }, + log = { + enable = false, + truncate = false, + types = { + all = false, + config = false, + copy_paste = false, + dev = false, + diagnostics = false, + git = false, + profile = false, + watcher = false, }, }, + system_open = { + cmd = nil, + args = {}, + }, } - ---@cast config +LvimBuiltin - require("lvim.core.builtins").extend_defaults(config) - lvim.builtin.nvimtree = config + lvim.builtin.nvimtree = require("lvim.core.builtins").add_completion "nvimtree" end function M.setup() diff --git a/lua/lvim/core/project.lua b/lua/lvim/core/project.lua index 938ec6d9..e5d69085 100644 --- a/lua/lvim/core/project.lua +++ b/lua/lvim/core/project.lua @@ -1,53 +1,49 @@ local M = {} function M.config() - local config = { - opts = { - ---@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. - manual_mode = false, - - ---@usage Methods of detecting the root directory - --- Allowed values: **"lsp"** uses the native neovim lsp - --- **"pattern"** uses vim-rooter like glob pattern matching. Here - --- order matters: if one is not detected, the other is used as fallback. You - --- can also delete or rearangne the detection methods. - -- detection_methods = { "lsp", "pattern" }, -- NOTE: lsp detection will get annoying with multiple langs in one project - detection_methods = { "pattern" }, - - -- All the patterns used to detect root dir, when **"pattern"** is in - -- detection_methods - patterns = { ".git", "_darcs", ".hg", ".bzr", ".svn", "Makefile", "package.json", "pom.xml" }, - - -- Table of lsp clients to ignore by name - -- eg: { "efm", ... } - ignore_lsp = {}, - - -- Don't calculate root dir on specific directories - -- Ex: { "~/.cargo/*", ... } - exclude_dirs = {}, - - -- Show hidden files in telescope - show_hidden = false, - - -- When set to false, you will get a message when project.nvim changes your - -- directory. - silent_chdir = true, - - -- What scope to change the directory, valid options are - -- * global (default) - -- * tab - -- * win - scope_chdir = "global", - - ---@usage path to store the project history for use in telescope - datapath = get_cache_dir(), - }, + lvim.builtin.project.opts = { + ---@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. + manual_mode = false, + + ---@usage Methods of detecting the root directory + --- Allowed values: **"lsp"** uses the native neovim lsp + --- **"pattern"** uses vim-rooter like glob pattern matching. Here + --- order matters: if one is not detected, the other is used as fallback. You + --- can also delete or rearangne the detection methods. + -- detection_methods = { "lsp", "pattern" }, -- NOTE: lsp detection will get annoying with multiple langs in one project + detection_methods = { "pattern" }, + + -- All the patterns used to detect root dir, when **"pattern"** is in + -- detection_methods + patterns = { ".git", "_darcs", ".hg", ".bzr", ".svn", "Makefile", "package.json", "pom.xml" }, + + -- Table of lsp clients to ignore by name + -- eg: { "efm", ... } + ignore_lsp = {}, + + -- Don't calculate root dir on specific directories + -- Ex: { "~/.cargo/*", ... } + exclude_dirs = {}, + + -- Show hidden files in telescope + show_hidden = false, + + -- When set to false, you will get a message when project.nvim changes your + -- directory. + silent_chdir = true, + + -- What scope to change the directory, valid options are + -- * global (default) + -- * tab + -- * win + scope_chdir = "global", + + ---@usage path to store the project history for use in telescope + datapath = get_cache_dir(), } - ---@cast config +LvimBuiltin - require("lvim.core.builtins").extend_defaults(config) - lvim.builtin.project = config + lvim.builtin.project = require("lvim.core.builtins").add_completion "project" end function M.setup() diff --git a/lua/lvim/core/telescope.lua b/lua/lvim/core/telescope.lua index 332a0f50..31913d4f 100644 --- a/lua/lvim/core/telescope.lua +++ b/lua/lvim/core/telescope.lua @@ -8,107 +8,103 @@ local M = {} function M.config() local actions = require("lvim.utils.modules").require_on_exported_call "telescope.actions" - local config = { - theme = "dropdown", ---@type telescope_themes - opts = { - defaults = { - prompt_prefix = lvim.icons.ui.Telescope .. " ", - selection_caret = lvim.icons.ui.Forward .. " ", - entry_prefix = " ", - initial_mode = "insert", - selection_strategy = "reset", - sorting_strategy = nil, - layout_strategy = nil, - layout_config = {}, - vimgrep_arguments = { - "rg", - "--color=never", - "--no-heading", - "--with-filename", - "--line-number", - "--column", - "--smart-case", - "--hidden", - "--glob=!.git/", + lvim.builtin.terminal.theme = "dropdown" ---@type telescope_themes + lvim.builtin.terminal.opts = { + defaults = { + prompt_prefix = lvim.icons.ui.Telescope .. " ", + selection_caret = lvim.icons.ui.Forward .. " ", + entry_prefix = " ", + initial_mode = "insert", + selection_strategy = "reset", + sorting_strategy = nil, + layout_strategy = nil, + layout_config = {}, + vimgrep_arguments = { + "rg", + "--color=never", + "--no-heading", + "--with-filename", + "--line-number", + "--column", + "--smart-case", + "--hidden", + "--glob=!.git/", + }, + ---@usage Mappings are fully customizable. Many familiar mapping patterns are setup as defaults. + mappings = { + i = { + ["<C-n>"] = actions.move_selection_next, + ["<C-p>"] = actions.move_selection_previous, + ["<C-c>"] = actions.close, + ["<C-j>"] = actions.cycle_history_next, + ["<C-k>"] = actions.cycle_history_prev, + ["<C-q>"] = function(...) + actions.smart_send_to_qflist(...) + actions.open_qflist(...) + end, + ["<CR>"] = actions.select_default, + }, + n = { + ["<C-n>"] = actions.move_selection_next, + ["<C-p>"] = actions.move_selection_previous, + ["<C-q>"] = function(...) + actions.smart_send_to_qflist(...) + actions.open_qflist(...) + end, }, - ---@usage Mappings are fully customizable. Many familiar mapping patterns are setup as defaults. + }, + file_ignore_patterns = {}, + path_display = { "smart" }, + winblend = 0, + border = {}, + borderchars = nil, + color_devicons = true, + set_env = { ["COLORTERM"] = "truecolor" }, -- default = nil, + }, + pickers = { + find_files = { + hidden = true, + }, + live_grep = { + --@usage don't include the filename in the search results + only_sort_text = true, + }, + grep_string = { + only_sort_text = true, + }, + buffers = { + initial_mode = "normal", mappings = { i = { - ["<C-n>"] = actions.move_selection_next, - ["<C-p>"] = actions.move_selection_previous, - ["<C-c>"] = actions.close, - ["<C-j>"] = actions.cycle_history_next, - ["<C-k>"] = actions.cycle_history_prev, - ["<C-q>"] = function(...) - actions.smart_send_to_qflist(...) - actions.open_qflist(...) - end, - ["<CR>"] = actions.select_default, + ["<C-d>"] = actions.delete_buffer, }, n = { - ["<C-n>"] = actions.move_selection_next, - ["<C-p>"] = actions.move_selection_previous, - ["<C-q>"] = function(...) - actions.smart_send_to_qflist(...) - actions.open_qflist(...) - end, + ["dd"] = actions.delete_buffer, }, }, - file_ignore_patterns = {}, - path_display = { "smart" }, - winblend = 0, - border = {}, - borderchars = nil, - color_devicons = true, - set_env = { ["COLORTERM"] = "truecolor" }, -- default = nil, }, - pickers = { - find_files = { - hidden = true, - }, - live_grep = { - --@usage don't include the filename in the search results - only_sort_text = true, - }, - grep_string = { - only_sort_text = true, - }, - buffers = { - initial_mode = "normal", - mappings = { - i = { - ["<C-d>"] = actions.delete_buffer, - }, - n = { - ["dd"] = actions.delete_buffer, - }, - }, - }, - planets = { - show_pluto = true, - show_moon = true, - }, - git_files = { - hidden = true, - show_untracked = true, - }, - colorscheme = { - enable_preview = true, - }, + planets = { + show_pluto = true, + show_moon = true, }, - extensions = { - fzf = { - fuzzy = true, -- false will only do exact matching - override_generic_sorter = true, -- override the generic sorter - override_file_sorter = true, -- override the file sorter - case_mode = "smart_case", -- or "ignore_case" or "respect_case" - }, + git_files = { + hidden = true, + show_untracked = true, + }, + colorscheme = { + enable_preview = true, + }, + }, + extensions = { + fzf = { + fuzzy = true, -- false will only do exact matching + override_generic_sorter = true, -- override the generic sorter + override_file_sorter = true, -- override the file sorter + case_mode = "smart_case", -- or "ignore_case" or "respect_case" }, }, } - ---@cast config +LvimBuiltin - require("lvim.core.builtins").extend_defaults(config) - lvim.builtin.telescope = config + lvim.builtin.telescope = require("lvim.core.builtins").add_completion "telescope" end function M.setup() diff --git a/lua/lvim/core/terminal.lua b/lua/lvim/core/terminal.lua index 34892303..57606ef8 100644 --- a/lua/lvim/core/terminal.lua +++ b/lua/lvim/core/terminal.lua @@ -2,53 +2,49 @@ local M = {} local Log = require "lvim.core.log" M.config = function() - local config = { - opts = { - -- size can be a number or function which is passed the current terminal - size = 20, - open_mapping = [[<c-\>]], - hide_numbers = true, -- hide the number column in toggleterm buffers - shade_filetypes = {}, - shade_terminals = true, - shading_factor = 2, -- the degree by which to darken to terminal colour, default: 1 for dark backgrounds, 3 for light - start_in_insert = true, - insert_mappings = true, -- whether or not the open mapping applies in insert mode - persist_size = false, - -- direction = 'vertical' | 'horizontal' | 'window' | 'float', - direction = "float", - close_on_exit = true, -- close the terminal window when the process exits - shell = vim.o.shell, -- change the default shell - -- This field is only relevant if direction is set to 'float' - float_opts = { - -- The border key is *almost* the same as 'nvim_win_open' - -- see :h nvim_win_open for details on borders however - -- the 'curved' border is a custom border type - -- not natively supported but implemented in this plugin. - -- border = 'single' | 'double' | 'shadow' | 'curved' | ... other options supported by win open - border = "curved", - -- width = <value>, - -- height = <value>, - winblend = 0, - highlights = { - border = "Normal", - background = "Normal", - }, + lvim.builtin.terminal.opts = { + -- size can be a number or function which is passed the current terminal + size = 20, + open_mapping = [[<c-\>]], + hide_numbers = true, -- hide the number column in toggleterm buffers + shade_filetypes = {}, + shade_terminals = true, + shading_factor = 2, -- the degree by which to darken to terminal colour, default: 1 for dark backgrounds, 3 for light + start_in_insert = true, + insert_mappings = true, -- whether or not the open mapping applies in insert mode + persist_size = false, + -- direction = 'vertical' | 'horizontal' | 'window' | 'float', + direction = "float", + close_on_exit = true, -- close the terminal window when the process exits + shell = vim.o.shell, -- change the default shell + -- This field is only relevant if direction is set to 'float' + float_opts = { + -- The border key is *almost* the same as 'nvim_win_open' + -- see :h nvim_win_open for details on borders however + -- the 'curved' border is a custom border type + -- not natively supported but implemented in this plugin. + -- border = 'single' | 'double' | 'shadow' | 'curved' | ... other options supported by win open + border = "curved", + -- width = <value>, + -- height = <value>, + winblend = 0, + highlights = { + border = "Normal", + background = "Normal", }, - -- Add executables on the config.lua - -- { cmd, keymap, description, direction, size } - -- lvim.builtin.terminal.execs = {...} to overwrite - -- lvim.builtin.terminal.execs[#lvim.builtin.terminal.execs+1] = {"gdb", "tg", "GNU Debugger"} - -- TODO: pls add mappings in which key and refactor this - }, - execs = { - { nil, "<M-1>", "Horizontal Terminal", "horizontal", 0.3 }, - { nil, "<M-2>", "Vertical Terminal", "vertical", 0.4 }, - { nil, "<M-3>", "Float Terminal", "float", nil }, }, + -- Add executables on the config.lua + -- { cmd, keymap, description, direction, size } + -- lvim.builtin.terminal.execs = {...} to overwrite + -- lvim.builtin.terminal.execs[#lvim.builtin.terminal.execs+1] = {"gdb", "tg", "GNU Debugger"} + -- TODO: pls add mappings in which key and refactor this + } + lvim.builtin.terminal.execs = { + { nil, "<M-1>", "Horizontal Terminal", "horizontal", 0.3 }, + { nil, "<M-2>", "Vertical Terminal", "vertical", 0.4 }, + { nil, "<M-3>", "Float Terminal", "float", nil }, } - ---@cast config +LvimBuiltin - require("lvim.core.builtins").extend_defaults(config) - lvim.builtin.terminal = config + lvim.builtin.terminal = require("lvim.core.builtins").add_completion "terminal" end --- Get current buffer size diff --git a/lua/lvim/core/treesitter.lua b/lua/lvim/core/treesitter.lua index 96d97a95..97dc2968 100644 --- a/lua/lvim/core/treesitter.lua +++ b/lua/lvim/core/treesitter.lua @@ -2,100 +2,96 @@ local M = {} local Log = require "lvim.core.log" function M.config() - local config = { - opts = { - -- A list of parser names, or "all" - ensure_installed = {}, + lvim.builtin.treesitter.opts = { + -- A list of parser names, or "all" + ensure_installed = {}, - -- List of parsers to ignore installing (for "all") - ignore_install = {}, + -- List of parsers to ignore installing (for "all") + ignore_install = {}, - -- A directory to install the parsers into. - -- By default parsers are installed to either the package dir, or the "site" dir. - -- If a custom path is used (not nil) it must be added to the runtimepath. - parser_install_dir = nil, + -- A directory to install the parsers into. + -- By default parsers are installed to either the package dir, or the "site" dir. + -- If a custom path is used (not nil) it must be added to the runtimepath. + parser_install_dir = nil, - -- Install parsers synchronously (only applied to `ensure_installed`) - sync_install = false, + -- Install parsers synchronously (only applied to `ensure_installed`) + sync_install = false, - -- Automatically install missing parsers when entering buffer - auto_install = true, + -- Automatically install missing parsers when entering buffer + auto_install = true, - matchup = { - enable = false, -- mandatory, false will disable the whole extension - -- disable = { "c", "ruby" }, -- optional, list of language that will be disabled - }, - highlight = { - enable = true, -- false will disable the whole extension - additional_vim_regex_highlighting = false, - disable = function(lang, buf) - if vim.tbl_contains({ "latex" }, lang) then - return true - end + matchup = { + enable = false, -- mandatory, false will disable the whole extension + -- disable = { "c", "ruby" }, -- optional, list of language that will be disabled + }, + highlight = { + enable = true, -- false will disable the whole extension + additional_vim_regex_highlighting = false, + disable = function(lang, buf) + if vim.tbl_contains({ "latex" }, lang) then + return true + end - local status_ok, big_file_detected = pcall(vim.api.nvim_buf_get_var, buf, "bigfile_disable_treesitter") - return status_ok and big_file_detected - end, - }, - context_commentstring = { - enable = true, - enable_autocmd = false, - config = { - -- Languages that have a single comment style - typescript = "// %s", - css = "/* %s */", - scss = "/* %s */", - html = "<!-- %s -->", - svelte = "<!-- %s -->", - vue = "<!-- %s -->", - json = "", - }, - }, - indent = { enable = true, disable = { "yaml", "python", "c", "cpp" } }, - autotag = { enable = false }, - textobjects = { - swap = { - enable = false, - -- swap_next = textobj_swap_keymaps, - }, - -- move = textobj_move_keymaps, - select = { - enable = false, - -- keymaps = textobj_sel_keymaps, - }, + local status_ok, big_file_detected = pcall(vim.api.nvim_buf_get_var, buf, "bigfile_disable_treesitter") + return status_ok and big_file_detected + end, + }, + context_commentstring = { + enable = true, + enable_autocmd = false, + config = { + -- Languages that have a single comment style + typescript = "// %s", + css = "/* %s */", + scss = "/* %s */", + html = "<!-- %s -->", + svelte = "<!-- %s -->", + vue = "<!-- %s -->", + json = "", }, - textsubjects = { + }, + indent = { enable = true, disable = { "yaml", "python", "c", "cpp" } }, + autotag = { enable = false }, + textobjects = { + swap = { enable = false, - keymaps = { ["."] = "textsubjects-smart", [";"] = "textsubjects-big" }, + -- swap_next = textobj_swap_keymaps, }, - playground = { + -- move = textobj_move_keymaps, + select = { enable = false, - disable = {}, - updatetime = 25, -- Debounced time for highlighting nodes in the playground from source code - persist_queries = false, -- Whether the query persists across vim sessions - keybindings = { - toggle_query_editor = "o", - toggle_hl_groups = "i", - toggle_injected_languages = "t", - toggle_anonymous_nodes = "a", - toggle_language_display = "I", - focus_language = "f", - unfocus_language = "F", - update = "R", - goto_node = "<cr>", - show_help = "?", - }, + -- keymaps = textobj_sel_keymaps, }, - rainbow = { - enable = false, - extended_mode = true, -- Highlight also non-parentheses delimiters, boolean or table: lang -> boolean - max_file_lines = 1000, -- Do not enable for files with more than 1000 lines, int + }, + textsubjects = { + enable = false, + keymaps = { ["."] = "textsubjects-smart", [";"] = "textsubjects-big" }, + }, + playground = { + enable = false, + disable = {}, + updatetime = 25, -- Debounced time for highlighting nodes in the playground from source code + persist_queries = false, -- Whether the query persists across vim sessions + keybindings = { + toggle_query_editor = "o", + toggle_hl_groups = "i", + toggle_injected_languages = "t", + toggle_anonymous_nodes = "a", + toggle_language_display = "I", + focus_language = "f", + unfocus_language = "F", + update = "R", + goto_node = "<cr>", + show_help = "?", }, }, + rainbow = { + enable = false, + extended_mode = true, -- Highlight also non-parentheses delimiters, boolean or table: lang -> boolean + max_file_lines = 1000, -- Do not enable for files with more than 1000 lines, int + }, } - ---@cast config +LvimBuiltin - require("lvim.core.builtins").extend_defaults(config) - lvim.builtin.treesitter = config + lvim.builtin.treesitter = require("lvim.core.builtins").add_completion "treesitter" end function M.setup() diff --git a/lua/lvim/core/which-key.lua b/lua/lvim/core/which-key.lua index 7dd2367a..23c373b4 100644 --- a/lua/lvim/core/which-key.lua +++ b/lua/lvim/core/which-key.lua @@ -1,303 +1,298 @@ local M = {} M.config = function() - local config = { - opts = { - plugins = { - marks = false, -- shows a list of your marks on ' and ` - registers = false, -- shows your registers on " in NORMAL or <C-r> in INSERT mode - spelling = { - enabled = true, - suggestions = 20, - }, -- use which-key for spelling hints - -- the presets plugin, adds help for a bunch of default keybindings in Neovim - -- No actual key bindings are created - presets = { - operators = false, -- adds help for operators like d, y, ... - motions = false, -- adds help for motions - text_objects = false, -- help for text objects triggered after entering an operator - windows = false, -- default bindings on <c-w> - nav = false, -- misc bindings to work with windows - z = false, -- bindings for folds, spelling and others prefixed with z - g = false, -- bindings for prefixed with g - }, - }, - -- add operators that will trigger motion and text object completion - -- to enable all native operators, set the preset / operators plugin above - operators = { gc = "Comments" }, - key_labels = { - -- override the label used to display some keys. It doesn't effect WK in any other way. - -- For example: - -- ["<space>"] = "SPC", - -- ["<cr>"] = "RET", - -- ["<tab>"] = "TAB", - }, - icons = { - breadcrumb = lvim.icons.ui.DoubleChevronRight, -- symbol used in the command line area that shows your active key combo - separator = lvim.icons.ui.BoldArrowRight, -- symbol used between a key and it's label - group = lvim.icons.ui.Plus, -- symbol prepended to a group - }, - popup_mappings = { - scroll_down = "<c-d>", -- binding to scroll down inside the popup - scroll_up = "<c-u>", -- binding to scroll up inside the popup + lvim.builtin.which_key.opts = { + plugins = { + marks = false, -- shows a list of your marks on ' and ` + registers = false, -- shows your registers on " in NORMAL or <C-r> in INSERT mode + spelling = { + enabled = true, + suggestions = 20, + }, -- use which-key for spelling hints + -- the presets plugin, adds help for a bunch of default keybindings in Neovim + -- No actual key bindings are created + presets = { + operators = false, -- adds help for operators like d, y, ... + motions = false, -- adds help for motions + text_objects = false, -- help for text objects triggered after entering an operator + windows = false, -- default bindings on <c-w> + nav = false, -- misc bindings to work with windows + z = false, -- bindings for folds, spelling and others prefixed with z + g = false, -- bindings for prefixed with g }, - window = { - border = "single", -- none, single, double, shadow - position = "bottom", -- bottom, top - margin = { 1, 0, 1, 0 }, -- extra window margin [top, right, bottom, left] - padding = { 2, 2, 2, 2 }, -- extra window padding [top, right, bottom, left] - winblend = 0, + }, + -- add operators that will trigger motion and text object completion + -- to enable all native operators, set the preset / operators plugin above + operators = { gc = "Comments" }, + key_labels = { + -- override the label used to display some keys. It doesn't effect WK in any other way. + -- For example: + -- ["<space>"] = "SPC", + -- ["<cr>"] = "RET", + -- ["<tab>"] = "TAB", + }, + icons = { + breadcrumb = lvim.icons.ui.DoubleChevronRight, -- symbol used in the command line area that shows your active key combo + separator = lvim.icons.ui.BoldArrowRight, -- symbol used between a key and it's label + group = lvim.icons.ui.Plus, -- symbol prepended to a group + }, + popup_mappings = { + scroll_down = "<c-d>", -- binding to scroll down inside the popup + scroll_up = "<c-u>", -- binding to scroll up inside the popup + }, + window = { + border = "single", -- none, single, double, shadow + position = "bottom", -- bottom, top + margin = { 1, 0, 1, 0 }, -- extra window margin [top, right, bottom, left] + padding = { 2, 2, 2, 2 }, -- extra window padding [top, right, bottom, left] + winblend = 0, + }, + layout = { + height = { min = 4, max = 25 }, -- min and max height of the columns + width = { min = 20, max = 50 }, -- min and max width of the columns + spacing = 3, -- spacing between columns + align = "left", -- align columns left, center or right + }, + ignore_missing = false, -- enable this to hide mappings for which you didn't specify a label + hidden = { "<silent>", "<cmd>", "<Cmd>", "<CR>", "call", "lua", "^:", "^ " }, -- hide mapping boilerplate + show_help = true, -- show help message on the command line when the popup is visible + show_keys = true, -- show the currently pressed key and its label as a message in the command line + triggers = "auto", -- automatically setup triggers + -- triggers = {"<leader>"} -- or specify a list manually + triggers_blacklist = { + -- list of mode / prefixes that should never be hooked by WhichKey + -- this is mostly relevant for key maps that start with a native binding + -- most people should not need to change this + i = { "j", "k" }, + v = { "j", "k" }, + }, + -- disable the WhichKey popup for certain buf types and file types. + -- Disabled by deafult for Telescope + disable = { + buftypes = {}, + filetypes = { "TelescopePrompt" }, + }, + } + lvim.builtin.which_key.nopts = { + mode = "n", -- NORMAL mode + prefix = "<leader>", + buffer = nil, -- Global mappings. Specify a buffer number for buffer local mappings + silent = true, -- use `silent` when creating keymaps + noremap = true, -- use `noremap` when creating keymaps + nowait = true, -- use `nowait` when creating keymaps + } + lvim.builtin.which_key.vopts = { + mode = "v", -- VISUAL mode + prefix = "<leader>", + buffer = nil, -- Global mappings. Specify a buffer number for buffer local mappings + silent = true, -- use `silent` when creating keymaps + noremap = true, -- use `noremap` when creating keymaps + nowait = true, -- use `nowait` when creating keymaps + } + -- NOTE: Prefer using : over <cmd> as the latter avoids going back in normal-mode. + -- see https://neovim.io/doc/user/map.html#:map-cmd + lvim.builtin.which_key.vmappings = { + ["/"] = { "<Plug>(comment_toggle_linewise_visual)", "Comment toggle linewise (visual)" }, + } + lvim.builtin.which_key.mappings = { + [";"] = { "<cmd>Alpha<CR>", "Dashboard" }, + ["w"] = { "<cmd>w!<CR>", "Save" }, + ["q"] = { "<cmd>confirm q<CR>", "Quit" }, + ["/"] = { "<Plug>(comment_toggle_linewise_current)", "Comment toggle current line" }, + ["c"] = { "<cmd>BufferKill<CR>", "Close Buffer" }, + ["f"] = { + function() + require("lvim.core.telescope.custom-finders").find_project_files { previewer = false } + end, + "Find File", + }, + ["h"] = { "<cmd>nohlsearch<CR>", "No Highlight" }, + ["e"] = { "<cmd>NvimTreeToggle<CR>", "Explorer" }, + b = { + name = "Buffers", + j = { "<cmd>BufferLinePick<cr>", "Jump" }, + f = { "<cmd>Telescope buffers previewer=false<cr>", "Find" }, + b = { "<cmd>BufferLineCyclePrev<cr>", "Previous" }, + n = { "<cmd>BufferLineCycleNext<cr>", "Next" }, + W = { "<cmd>noautocmd w<cr>", "Save without formatting (noautocmd)" }, + -- w = { "<cmd>BufferWipeout<cr>", "Wipeout" }, -- TODO: implement this for bufferline + e = { + "<cmd>BufferLinePickClose<cr>", + "Pick which buffer to close", }, - layout = { - height = { min = 4, max = 25 }, -- min and max height of the columns - width = { min = 20, max = 50 }, -- min and max width of the columns - spacing = 3, -- spacing between columns - align = "left", -- align columns left, center or right + h = { "<cmd>BufferLineCloseLeft<cr>", "Close all to the left" }, + l = { + "<cmd>BufferLineCloseRight<cr>", + "Close all to the right", }, - ignore_missing = false, -- enable this to hide mappings for which you didn't specify a label - hidden = { "<silent>", "<cmd>", "<Cmd>", "<CR>", "call", "lua", "^:", "^ " }, -- hide mapping boilerplate - show_help = true, -- show help message on the command line when the popup is visible - show_keys = true, -- show the currently pressed key and its label as a message in the command line - triggers = "auto", -- automatically setup triggers - -- triggers = {"<leader>"} -- or specify a list manually - triggers_blacklist = { - -- list of mode / prefixes that should never be hooked by WhichKey - -- this is mostly relevant for key maps that start with a native binding - -- most people should not need to change this - i = { "j", "k" }, - v = { "j", "k" }, + D = { + "<cmd>BufferLineSortByDirectory<cr>", + "Sort by directory", }, - -- disable the WhichKey popup for certain buf types and file types. - -- Disabled by deafult for Telescope - disable = { - buftypes = {}, - filetypes = { "TelescopePrompt" }, + L = { + "<cmd>BufferLineSortByExtension<cr>", + "Sort by language", }, }, - - opts = { - mode = "n", -- NORMAL mode - prefix = "<leader>", - buffer = nil, -- Global mappings. Specify a buffer number for buffer local mappings - silent = true, -- use `silent` when creating keymaps - noremap = true, -- use `noremap` when creating keymaps - nowait = true, -- use `nowait` when creating keymaps - }, - vopts = { - mode = "v", -- VISUAL mode - prefix = "<leader>", - buffer = nil, -- Global mappings. Specify a buffer number for buffer local mappings - silent = true, -- use `silent` when creating keymaps - noremap = true, -- use `noremap` when creating keymaps - nowait = true, -- use `nowait` when creating keymaps + d = { + name = "Debug", + t = { "<cmd>lua require'dap'.toggle_breakpoint()<cr>", "Toggle Breakpoint" }, + b = { "<cmd>lua require'dap'.step_back()<cr>", "Step Back" }, + c = { "<cmd>lua require'dap'.continue()<cr>", "Continue" }, + C = { "<cmd>lua require'dap'.run_to_cursor()<cr>", "Run To Cursor" }, + d = { "<cmd>lua require'dap'.disconnect()<cr>", "Disconnect" }, + g = { "<cmd>lua require'dap'.session()<cr>", "Get Session" }, + i = { "<cmd>lua require'dap'.step_into()<cr>", "Step Into" }, + o = { "<cmd>lua require'dap'.step_over()<cr>", "Step Over" }, + u = { "<cmd>lua require'dap'.step_out()<cr>", "Step Out" }, + p = { "<cmd>lua require'dap'.pause()<cr>", "Pause" }, + r = { "<cmd>lua require'dap'.repl.toggle()<cr>", "Toggle Repl" }, + s = { "<cmd>lua require'dap'.continue()<cr>", "Start" }, + q = { "<cmd>lua require'dap'.close()<cr>", "Quit" }, + U = { "<cmd>lua require'dapui'.toggle({reset = true})<cr>", "Toggle UI" }, }, - -- NOTE: Prefer using : over <cmd> as the latter avoids going back in normal-mode. - -- see https://neovim.io/doc/user/map.html#:map-cmd - vmappings = { - ["/"] = { "<Plug>(comment_toggle_linewise_visual)", "Comment toggle linewise (visual)" }, + p = { + name = "Plugins", + i = { "<cmd>Lazy install<cr>", "Install" }, + s = { "<cmd>Lazy sync<cr>", "Sync" }, + S = { "<cmd>Lazy clear<cr>", "Status" }, + c = { "<cmd>Lazy clean<cr>", "Clean" }, + u = { "<cmd>Lazy update<cr>", "Update" }, + p = { "<cmd>Lazy profile<cr>", "Profile" }, + l = { "<cmd>Lazy log<cr>", "Log" }, + d = { "<cmd>Lazy debug<cr>", "Debug" }, }, - mappings = { - [";"] = { "<cmd>Alpha<CR>", "Dashboard" }, - ["w"] = { "<cmd>w!<CR>", "Save" }, - ["q"] = { "<cmd>confirm q<CR>", "Quit" }, - ["/"] = { "<Plug>(comment_toggle_linewise_current)", "Comment toggle current line" }, - ["c"] = { "<cmd>BufferKill<CR>", "Close Buffer" }, - ["f"] = { - function() - require("lvim.core.telescope.custom-finders").find_project_files { previewer = false } - end, - "Find File", + + -- " Available Debug Adapters: + -- " https://microsoft.github.io/debug-adapter-protocol/implementors/adapters/ + -- " Adapter configuration and installation instructions: + -- " https://github.com/mfussenegger/nvim-dap/wiki/Debug-Adapter-installation + -- " Debug Adapter protocol: + -- " https://microsoft.github.io/debug-adapter-protocol/ + -- " Debugging + g = { + name = "Git", + g = { "<cmd>lua require 'lvim.core.terminal'.lazygit_toggle()<cr>", "Lazygit" }, + j = { "<cmd>lua require 'gitsigns'.next_hunk({navigation_message = false})<cr>", "Next Hunk" }, + k = { "<cmd>lua require 'gitsigns'.prev_hunk({navigation_message = false})<cr>", "Prev Hunk" }, + l = { "<cmd>lua require 'gitsigns'.blame_line()<cr>", "Blame" }, + p = { "<cmd>lua require 'gitsigns'.preview_hunk()<cr>", "Preview Hunk" }, + r = { "<cmd>lua require 'gitsigns'.reset_hunk()<cr>", "Reset Hunk" }, + R = { "<cmd>lua require 'gitsigns'.reset_buffer()<cr>", "Reset Buffer" }, + s = { "<cmd>lua require 'gitsigns'.stage_hunk()<cr>", "Stage Hunk" }, + u = { + "<cmd>lua require 'gitsigns'.undo_stage_hunk()<cr>", + "Undo Stage Hunk", }, - ["h"] = { "<cmd>nohlsearch<CR>", "No Highlight" }, - ["e"] = { "<cmd>NvimTreeToggle<CR>", "Explorer" }, - b = { - name = "Buffers", - j = { "<cmd>BufferLinePick<cr>", "Jump" }, - f = { "<cmd>Telescope buffers previewer=false<cr>", "Find" }, - b = { "<cmd>BufferLineCyclePrev<cr>", "Previous" }, - n = { "<cmd>BufferLineCycleNext<cr>", "Next" }, - W = { "<cmd>noautocmd w<cr>", "Save without formatting (noautocmd)" }, - -- w = { "<cmd>BufferWipeout<cr>", "Wipeout" }, -- TODO: implement this for bufferline - e = { - "<cmd>BufferLinePickClose<cr>", - "Pick which buffer to close", - }, - h = { "<cmd>BufferLineCloseLeft<cr>", "Close all to the left" }, - l = { - "<cmd>BufferLineCloseRight<cr>", - "Close all to the right", - }, - D = { - "<cmd>BufferLineSortByDirectory<cr>", - "Sort by directory", - }, - L = { - "<cmd>BufferLineSortByExtension<cr>", - "Sort by language", - }, + o = { "<cmd>Telescope git_status<cr>", "Open changed file" }, + b = { "<cmd>Telescope git_branches<cr>", "Checkout branch" }, + c = { "<cmd>Telescope git_commits<cr>", "Checkout commit" }, + C = { + "<cmd>Telescope git_bcommits<cr>", + "Checkout commit(for current file)", }, d = { - name = "Debug", - t = { "<cmd>lua require'dap'.toggle_breakpoint()<cr>", "Toggle Breakpoint" }, - b = { "<cmd>lua require'dap'.step_back()<cr>", "Step Back" }, - c = { "<cmd>lua require'dap'.continue()<cr>", "Continue" }, - C = { "<cmd>lua require'dap'.run_to_cursor()<cr>", "Run To Cursor" }, - d = { "<cmd>lua require'dap'.disconnect()<cr>", "Disconnect" }, - g = { "<cmd>lua require'dap'.session()<cr>", "Get Session" }, - i = { "<cmd>lua require'dap'.step_into()<cr>", "Step Into" }, - o = { "<cmd>lua require'dap'.step_over()<cr>", "Step Over" }, - u = { "<cmd>lua require'dap'.step_out()<cr>", "Step Out" }, - p = { "<cmd>lua require'dap'.pause()<cr>", "Pause" }, - r = { "<cmd>lua require'dap'.repl.toggle()<cr>", "Toggle Repl" }, - s = { "<cmd>lua require'dap'.continue()<cr>", "Start" }, - q = { "<cmd>lua require'dap'.close()<cr>", "Quit" }, - U = { "<cmd>lua require'dapui'.toggle({reset = true})<cr>", "Toggle UI" }, + "<cmd>Gitsigns diffthis HEAD<cr>", + "Git Diff", }, - p = { - name = "Plugins", - i = { "<cmd>Lazy install<cr>", "Install" }, - s = { "<cmd>Lazy sync<cr>", "Sync" }, - S = { "<cmd>Lazy clear<cr>", "Status" }, - c = { "<cmd>Lazy clean<cr>", "Clean" }, - u = { "<cmd>Lazy update<cr>", "Update" }, - p = { "<cmd>Lazy profile<cr>", "Profile" }, - l = { "<cmd>Lazy log<cr>", "Log" }, - d = { "<cmd>Lazy debug<cr>", "Debug" }, + }, + l = { + name = "LSP", + a = { "<cmd>lua vim.lsp.buf.code_action()<cr>", "Code Action" }, + d = { "<cmd>Telescope diagnostics bufnr=0 theme=get_ivy<cr>", "Buffer Diagnostics" }, + w = { "<cmd>Telescope diagnostics<cr>", "Diagnostics" }, + f = { require("lvim.lsp.utils").format, "Format" }, + i = { "<cmd>LspInfo<cr>", "Info" }, + I = { "<cmd>Mason<cr>", "Mason Info" }, + j = { + vim.diagnostic.goto_next, + "Next Diagnostic", + }, + k = { + vim.diagnostic.goto_prev, + "Prev Diagnostic", + }, + l = { vim.lsp.codelens.run, "CodeLens Action" }, + q = { vim.diagnostic.setloclist, "Quickfix" }, + r = { vim.lsp.buf.rename, "Rename" }, + s = { "<cmd>Telescope lsp_document_symbols<cr>", "Document Symbols" }, + S = { + "<cmd>Telescope lsp_dynamic_workspace_symbols<cr>", + "Workspace Symbols", + }, + e = { "<cmd>Telescope quickfix<cr>", "Telescope Quickfix" }, + }, + L = { + name = "+LunarVim", + c = { + "<cmd>edit " .. get_config_dir() .. "/config.lua<cr>", + "Edit config.lua", + }, + d = { "<cmd>LvimDocs<cr>", "View LunarVim's docs" }, + f = { + "<cmd>lua require('lvim.core.telescope.custom-finders').find_lunarvim_files()<cr>", + "Find LunarVim files", }, - - -- " Available Debug Adapters: - -- " https://microsoft.github.io/debug-adapter-protocol/implementors/adapters/ - -- " Adapter configuration and installation instructions: - -- " https://github.com/mfussenegger/nvim-dap/wiki/Debug-Adapter-installation - -- " Debug Adapter protocol: - -- " https://microsoft.github.io/debug-adapter-protocol/ - -- " Debugging g = { - name = "Git", - g = { "<cmd>lua require 'lvim.core.terminal'.lazygit_toggle()<cr>", "Lazygit" }, - j = { "<cmd>lua require 'gitsigns'.next_hunk({navigation_message = false})<cr>", "Next Hunk" }, - k = { "<cmd>lua require 'gitsigns'.prev_hunk({navigation_message = false})<cr>", "Prev Hunk" }, - l = { "<cmd>lua require 'gitsigns'.blame_line()<cr>", "Blame" }, - p = { "<cmd>lua require 'gitsigns'.preview_hunk()<cr>", "Preview Hunk" }, - r = { "<cmd>lua require 'gitsigns'.reset_hunk()<cr>", "Reset Hunk" }, - R = { "<cmd>lua require 'gitsigns'.reset_buffer()<cr>", "Reset Buffer" }, - s = { "<cmd>lua require 'gitsigns'.stage_hunk()<cr>", "Stage Hunk" }, - u = { - "<cmd>lua require 'gitsigns'.undo_stage_hunk()<cr>", - "Undo Stage Hunk", - }, - o = { "<cmd>Telescope git_status<cr>", "Open changed file" }, - b = { "<cmd>Telescope git_branches<cr>", "Checkout branch" }, - c = { "<cmd>Telescope git_commits<cr>", "Checkout commit" }, - C = { - "<cmd>Telescope git_bcommits<cr>", - "Checkout commit(for current file)", - }, - d = { - "<cmd>Gitsigns diffthis HEAD<cr>", - "Git Diff", - }, + "<cmd>lua require('lvim.core.telescope.custom-finders').grep_lunarvim_files()<cr>", + "Grep LunarVim files", }, - l = { - name = "LSP", - a = { "<cmd>lua vim.lsp.buf.code_action()<cr>", "Code Action" }, - d = { "<cmd>Telescope diagnostics bufnr=0 theme=get_ivy<cr>", "Buffer Diagnostics" }, - w = { "<cmd>Telescope diagnostics<cr>", "Diagnostics" }, - f = { require("lvim.lsp.utils").format, "Format" }, - i = { "<cmd>LspInfo<cr>", "Info" }, - I = { "<cmd>Mason<cr>", "Mason Info" }, - j = { - vim.diagnostic.goto_next, - "Next Diagnostic", - }, - k = { - vim.diagnostic.goto_prev, - "Prev Diagnostic", - }, - l = { vim.lsp.codelens.run, "CodeLens Action" }, - q = { vim.diagnostic.setloclist, "Quickfix" }, - r = { vim.lsp.buf.rename, "Rename" }, - s = { "<cmd>Telescope lsp_document_symbols<cr>", "Document Symbols" }, - S = { - "<cmd>Telescope lsp_dynamic_workspace_symbols<cr>", - "Workspace Symbols", - }, - e = { "<cmd>Telescope quickfix<cr>", "Telescope Quickfix" }, + k = { "<cmd>Telescope keymaps<cr>", "View LunarVim's keymappings" }, + i = { + "<cmd>lua require('lvim.core.info').toggle_popup(vim.bo.filetype)<cr>", + "Toggle LunarVim Info", }, - L = { - name = "+LunarVim", - c = { - "<cmd>edit " .. get_config_dir() .. "/config.lua<cr>", - "Edit config.lua", - }, - d = { "<cmd>LvimDocs<cr>", "View LunarVim's docs" }, - f = { - "<cmd>lua require('lvim.core.telescope.custom-finders').find_lunarvim_files()<cr>", - "Find LunarVim files", - }, - g = { - "<cmd>lua require('lvim.core.telescope.custom-finders').grep_lunarvim_files()<cr>", - "Grep LunarVim files", - }, - k = { "<cmd>Telescope keymaps<cr>", "View LunarVim's keymappings" }, - i = { - "<cmd>lua require('lvim.core.info').toggle_popup(vim.bo.filetype)<cr>", - "Toggle LunarVim Info", + I = { + "<cmd>lua require('lvim.core.telescope.custom-finders').view_lunarvim_changelog()<cr>", + "View LunarVim's changelog", + }, + l = { + name = "+logs", + d = { + "<cmd>lua require('lvim.core.terminal').toggle_log_view(require('lvim.core.log').get_path())<cr>", + "view default log", }, - I = { - "<cmd>lua require('lvim.core.telescope.custom-finders').view_lunarvim_changelog()<cr>", - "View LunarVim's changelog", + D = { + "<cmd>lua vim.fn.execute('edit ' .. require('lvim.core.log').get_path())<cr>", + "Open the default logfile", }, l = { - name = "+logs", - d = { - "<cmd>lua require('lvim.core.terminal').toggle_log_view(require('lvim.core.log').get_path())<cr>", - "view default log", - }, - D = { - "<cmd>lua vim.fn.execute('edit ' .. require('lvim.core.log').get_path())<cr>", - "Open the default logfile", - }, - l = { - "<cmd>lua require('lvim.core.terminal').toggle_log_view(vim.lsp.get_log_path())<cr>", - "view lsp log", - }, - L = { "<cmd>lua vim.fn.execute('edit ' .. vim.lsp.get_log_path())<cr>", "Open the LSP logfile" }, - n = { - "<cmd>lua require('lvim.core.terminal').toggle_log_view(os.getenv('NVIM_LOG_FILE'))<cr>", - "view neovim log", - }, - N = { "<cmd>edit $NVIM_LOG_FILE<cr>", "Open the Neovim logfile" }, + "<cmd>lua require('lvim.core.terminal').toggle_log_view(vim.lsp.get_log_path())<cr>", + "view lsp log", }, - r = { "<cmd>LvimReload<cr>", "Reload LunarVim's configuration" }, - u = { "<cmd>LvimUpdate<cr>", "Update LunarVim" }, - }, - s = { - name = "Search", - b = { "<cmd>Telescope git_branches<cr>", "Checkout branch" }, - c = { "<cmd>Telescope colorscheme<cr>", "Colorscheme" }, - f = { "<cmd>Telescope find_files<cr>", "Find File" }, - h = { "<cmd>Telescope help_tags<cr>", "Find Help" }, - H = { "<cmd>Telescope highlights<cr>", "Find highlight groups" }, - M = { "<cmd>Telescope man_pages<cr>", "Man Pages" }, - r = { "<cmd>Telescope oldfiles<cr>", "Open Recent File" }, - R = { "<cmd>Telescope registers<cr>", "Registers" }, - t = { "<cmd>Telescope live_grep<cr>", "Text" }, - k = { "<cmd>Telescope keymaps<cr>", "Keymaps" }, - C = { "<cmd>Telescope commands<cr>", "Commands" }, - p = { - "<cmd>lua require('telescope.builtin').colorscheme({enable_preview = true})<cr>", - "Colorscheme with Preview", + L = { "<cmd>lua vim.fn.execute('edit ' .. vim.lsp.get_log_path())<cr>", "Open the LSP logfile" }, + n = { + "<cmd>lua require('lvim.core.terminal').toggle_log_view(os.getenv('NVIM_LOG_FILE'))<cr>", + "view neovim log", }, + N = { "<cmd>edit $NVIM_LOG_FILE<cr>", "Open the Neovim logfile" }, }, - T = { - name = "Treesitter", - i = { ":TSConfigInfo<cr>", "Info" }, + r = { "<cmd>LvimReload<cr>", "Reload LunarVim's configuration" }, + u = { "<cmd>LvimUpdate<cr>", "Update LunarVim" }, + }, + s = { + name = "Search", + b = { "<cmd>Telescope git_branches<cr>", "Checkout branch" }, + c = { "<cmd>Telescope colorscheme<cr>", "Colorscheme" }, + f = { "<cmd>Telescope find_files<cr>", "Find File" }, + h = { "<cmd>Telescope help_tags<cr>", "Find Help" }, + H = { "<cmd>Telescope highlights<cr>", "Find highlight groups" }, + M = { "<cmd>Telescope man_pages<cr>", "Man Pages" }, + r = { "<cmd>Telescope oldfiles<cr>", "Open Recent File" }, + R = { "<cmd>Telescope registers<cr>", "Registers" }, + t = { "<cmd>Telescope live_grep<cr>", "Text" }, + k = { "<cmd>Telescope keymaps<cr>", "Keymaps" }, + C = { "<cmd>Telescope commands<cr>", "Commands" }, + p = { + "<cmd>lua require('telescope.builtin').colorscheme({enable_preview = true})<cr>", + "Colorscheme with Preview", }, }, + T = { + name = "Treesitter", + i = { ":TSConfigInfo<cr>", "Info" }, + }, } - ---@cast config +LvimBuiltin - require("lvim.core.builtins").extend_defaults(config) - lvim.builtin.which_key = config + lvim.builtin.which_key = require("lvim.core.builtins").add_completion "which_key" end M.setup = function() @@ -305,7 +300,7 @@ M.setup = function() which_key.setup(lvim.builtin.which_key.opts) - local opts = lvim.builtin.which_key.opts + local opts = lvim.builtin.which_key.nopts local vopts = lvim.builtin.which_key.vopts local mappings = lvim.builtin.which_key.mappings |