summaryrefslogtreecommitdiff
path: root/lua/lvim/core
diff options
context:
space:
mode:
Diffstat (limited to 'lua/lvim/core')
-rw-r--r--lua/lvim/core/autopairs.lua89
-rw-r--r--lua/lvim/core/breadcrumbs.lua4
-rw-r--r--lua/lvim/core/bufferline.lua181
-rw-r--r--lua/lvim/core/builtins/init.lua12
-rw-r--r--lua/lvim/core/cmp.lua416
-rw-r--r--lua/lvim/core/comment.lua122
-rw-r--r--lua/lvim/core/illuminate.lua7
-rw-r--r--lua/lvim/core/indentlines.lua4
-rw-r--r--lua/lvim/core/lir.lua120
-rw-r--r--lua/lvim/core/mason.lua80
-rw-r--r--lua/lvim/core/nvimtree.lua2
-rw-r--r--lua/lvim/core/project.lua85
-rw-r--r--lua/lvim/core/telescope.lua178
-rw-r--r--lua/lvim/core/terminal.lua78
-rw-r--r--lua/lvim/core/treesitter.lua152
-rw-r--r--lua/lvim/core/which-key.lua4
16 files changed, 765 insertions, 769 deletions
diff --git a/lua/lvim/core/autopairs.lua b/lua/lvim/core/autopairs.lua
index 7f6def4d..c7033d2b 100644
--- a/lua/lvim/core/autopairs.lua
+++ b/lua/lvim/core/autopairs.lua
@@ -2,44 +2,41 @@ local M = {}
function M.config()
local config = {
- ---@usage modifies the function or method delimiter by filetypes
- map_char = {
- all = "(",
- tex = "{",
- },
- ---@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",
+ 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
@@ -57,21 +54,7 @@ M.setup = function()
return
end
- autopairs.setup {
- check_ts = lvim.builtin.autopairs.check_ts,
- enable_check_bracket_line = lvim.builtin.autopairs.enable_check_bracket_line,
- ts_config = lvim.builtin.autopairs.ts_config,
- disable_filetype = lvim.builtin.autopairs.disable_filetype,
- disable_in_macro = lvim.builtin.autopairs.disable_in_macro,
- ignored_next_char = lvim.builtin.autopairs.ignored_next_char,
- enable_moveright = lvim.builtin.autopairs.enable_moveright,
- enable_afterquote = lvim.builtin.autopairs.enable_afterquote,
- map_c_w = lvim.builtin.autopairs.map_c_w,
- map_bs = lvim.builtin.autopairs.map_bs,
- disable_in_visualblock = lvim.builtin.autopairs.disable_in_visualblock,
- fast_wrap = lvim.builtin.autopairs.fast_wrap,
- }
-
+ autopairs.setup(lvim.builtin.autopairs)
pcall(function()
require "nvim-autopairs.completion.cmp"
require("cmp").event:off("confirm_done", on_confirm_done)
diff --git a/lua/lvim/core/breadcrumbs.lua b/lua/lvim/core/breadcrumbs.lua
index e962c4a7..7ebf5259 100644
--- a/lua/lvim/core/breadcrumbs.lua
+++ b/lua/lvim/core/breadcrumbs.lua
@@ -32,7 +32,7 @@ M.config = function()
"noice",
"",
},
- options = {
+ opts = {
icons = {
Array = icons.Array .. " ",
Boolean = icons.Boolean,
@@ -87,7 +87,7 @@ M.setup = function()
end
M.create_winbar()
- navic.setup(lvim.builtin.breadcrumbs.options)
+ navic.setup(lvim.builtin.breadcrumbs.opts)
end
M.get_filename = function()
diff --git a/lua/lvim/core/bufferline.lua b/lua/lvim/core/bufferline.lua
index bb3afd80..a48bffb9 100644
--- a/lua/lvim/core/bufferline.lua
+++ b/lua/lvim/core/bufferline.lua
@@ -45,99 +45,101 @@ M.config = function()
keymap = {
normal_mode = {},
},
- highlights = {
- background = {
- italic = true,
- },
- buffer_selected = {
- bold = 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,
+ opts = {
+ highlights = {
+ background = {
+ italic = true,
},
- {
- filetype = "NvimTree",
- text = "Explorer",
- highlight = "PanelHeading",
- padding = 1,
+ buffer_selected = {
+ bold = true,
},
- {
- filetype = "DiffviewFiles",
- text = "Diff View",
- 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 = "flutterToolsOutline",
- text = "Flutter Outline",
- highlight = "PanelHeading",
+ 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 = "lazy",
- text = "Lazy",
- highlight = "PanelHeading",
- padding = 1,
+ 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",
},
- 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
@@ -155,10 +157,7 @@ M.setup = function()
vim.opt.showtabline = 2
- bufferline.setup {
- options = lvim.builtin.bufferline.options,
- highlights = lvim.builtin.bufferline.highlights,
- }
+ bufferline.setup(lvim.builtin.bufferline.opts)
end
--stylua: ignore
diff --git a/lua/lvim/core/builtins/init.lua b/lua/lvim/core/builtins/init.lua
index 1c94d41d..17fcd892 100644
--- a/lua/lvim/core/builtins/init.lua
+++ b/lua/lvim/core/builtins/init.lua
@@ -25,7 +25,7 @@ local builtins = {
function M.extend_defaults(config)
---@class LvimBuiltin
---@field active boolean is builtin enabled
- ---@field setup table options passed to setup()
+ ---@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
@@ -40,17 +40,19 @@ function M.init()
reload("lvim.core.theme").config()
- lvim.builtin.cmp.cmdline = { enable = false }
+ lvim.builtin.cmp.opts = { cmdline = { enable = false } }
lvim.builtin.luasnip = {
- sources = {
- friendly_snippets = true,
+ opts = {
+ sources = {
+ friendly_snippets = true,
+ },
},
}
lvim.builtin.bigfile = {
active = true,
- config = {
+ opts = {
configure_treesitter = false,
},
}
diff --git a/lua/lvim/core/cmp.lua b/lua/lvim/core/cmp.lua
index db16d84a..fc855e34 100644
--- a/lua/lvim/core/cmp.lua
+++ b/lua/lvim/core/cmp.lua
@@ -128,225 +128,227 @@ M.config = function()
end
local config = {
- 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)",
- },
- duplicates = {
- buffer = 1,
- path = 1,
- nvim_lsp = 0,
- luasnip = 1,
- },
- duplicates_default = 0,
- format = function(entry, vim_item)
- local max_width = lvim.builtin.cmp.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
+ opts = {
+ enabled = function()
+ local buftype = vim.api.nvim_buf_get_option(0, "buftype")
+ if buftype == "prompt" then
+ return false
end
- if lvim.use_icons then
- vim_item.kind = lvim.builtin.cmp.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
- end
- vim_item.menu = lvim.builtin.cmp.formatting.source_names[entry.source.name]
- vim_item.dup = lvim.builtin.cmp.formatting.duplicates[entry.source.name]
- or lvim.builtin.cmp.formatting.duplicates_default
- return vim_item
+ return lvim.builtin.cmp.active
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",
- },
- },
+ confirm_opts = {
+ behavior = cmp.ConfirmBehavior.Replace,
+ select = false,
+ },
+ completion = {
+ ---@usage The minimum length of a word to complete on.
+ keyword_length = 1,
},
- {
- 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
+ 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)",
+ },
+ 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
end
- if kind == "Text" then
- return false
+ 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
end
- return true
+ 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",
+ },
+ },
+ },
+ {
+ 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)
+ { 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)
if cmp.visible() then
- cmp.confirm { behavior = cmp.ConfirmBehavior.Replace, select = false }
+ 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,
- },
- ["<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.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, { "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
- if cmp.confirm(confirm_opts) then
- return -- success, exit early
+ 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
end
- end
- fallback() -- if not exited early, always fallback
- end),
- },
- cmdline = {
- enable = false,
- options = {
- {
- type = ":",
- sources = {
- { name = "path" },
- { name = "cmdline" },
+ 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" },
+ },
},
},
},
@@ -359,10 +361,10 @@ end
function M.setup()
local cmp = require "cmp"
- cmp.setup(lvim.builtin.cmp)
+ cmp.setup(lvim.builtin.cmp.opts)
- if lvim.builtin.cmp.cmdline.enable then
- for _, option in ipairs(lvim.builtin.cmp.cmdline.options) do
+ if lvim.builtin.cmp.opts.cmdline.enable then
+ for _, option in ipairs(lvim.builtin.cmp.opts.cmdline.options) do
cmp.setup.cmdline(option.type, {
mapping = cmp.mapping.preset.cmdline(),
sources = option.sources,
diff --git a/lua/lvim/core/comment.lua b/lua/lvim/core/comment.lua
index 48e776de..2f526c63 100644
--- a/lua/lvim/core/comment.lua
+++ b/lua/lvim/core/comment.lua
@@ -2,73 +2,75 @@ local M = {}
function M.config()
local config = {
- ---Add a space b/w comment and the line
- ---@type boolean
- padding = true,
+ 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)
@@ -78,7 +80,7 @@ end
function M.setup()
local nvim_comment = require "Comment"
- nvim_comment.setup(lvim.builtin.comment)
+ nvim_comment.setup(lvim.builtin.comment.opts)
end
return M
diff --git a/lua/lvim/core/illuminate.lua b/lua/lvim/core/illuminate.lua
index dbed9c3a..f9b4e918 100644
--- a/lua/lvim/core/illuminate.lua
+++ b/lua/lvim/core/illuminate.lua
@@ -2,7 +2,7 @@ local M = {}
M.config = function()
local config = {
- options = {
+ opts = {
-- providers: provider used to get references in the buffer, ordered by priority
providers = {
"lsp",
@@ -60,10 +60,7 @@ M.setup = function()
return
end
- local config_ok, _ = pcall(illuminate.configure, lvim.builtin.illuminate.options)
- if not config_ok then
- return
- end
+ pcall(illuminate.configure, lvim.builtin.illuminate.opts)
end
return M
diff --git a/lua/lvim/core/indentlines.lua b/lua/lvim/core/indentlines.lua
index 1d134a4a..12521b3f 100644
--- a/lua/lvim/core/indentlines.lua
+++ b/lua/lvim/core/indentlines.lua
@@ -2,7 +2,7 @@ local M = {}
M.config = function()
local config = {
- options = {
+ opts = {
enabled = true,
buftype_exclude = { "terminal", "nofile" },
filetype_exclude = {
@@ -34,7 +34,7 @@ M.setup = function()
return
end
- indent_blankline.setup(lvim.builtin.indentlines.options)
+ indent_blankline.setup(lvim.builtin.indentlines.opts)
end
return M
diff --git a/lua/lvim/core/lir.lua b/lua/lvim/core/lir.lua
index af3e1840..08b2e2fb 100644
--- a/lua/lvim/core/lir.lua
+++ b/lua/lvim/core/lir.lua
@@ -6,69 +6,71 @@ M.config = function()
local clipboard_actions = utils.require_on_exported_call "lir.clipboard.actions"
local config = {
- 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,
+ 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,
- },
- float = {
- winblend = 0,
- curdir_window = {
- enable = false,
- highlight_dirname = true,
+ ["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,
+ },
- -- 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,
- }
+ -- 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,
},
- 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)
@@ -93,7 +95,7 @@ function M.icon_setup()
devicons.set_icon {
lir_folder_icon = {
- icon = lvim.builtin.lir.icon,
+ icon = lvim.builtin.lir.opts.icon,
color = icon_hl,
name = "LirFolderNode",
},
@@ -107,10 +109,10 @@ function M.setup()
end
if not lvim.use_icons then
- lvim.builtin.lir.devicons.enable = false
+ lvim.builtin.lir.opts.devicons.enable = false
end
- lir.setup(lvim.builtin.lir)
+ lir.setup(lvim.builtin.lir.setup)
M.icon_setup()
end
diff --git a/lua/lvim/core/mason.lua b/lua/lvim/core/mason.lua
index a6613897..ab58c5c8 100644
--- a/lua/lvim/core/mason.lua
+++ b/lua/lvim/core/mason.lua
@@ -4,50 +4,52 @@ local join_paths = require("lvim.utils").join_paths
function M.config()
local config = {
- 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>",
+ 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
@@ -84,9 +86,9 @@ function M.setup()
return
end
- add_to_path(lvim.builtin.mason.PATH == "append")
+ add_to_path(lvim.builtin.mason.opts.PATH == "append")
- mason.setup(lvim.builtin.mason)
+ mason.setup(lvim.builtin.mason.opts)
end
return M
diff --git a/lua/lvim/core/nvimtree.lua b/lua/lvim/core/nvimtree.lua
index 9f8495e1..a82cdb00 100644
--- a/lua/lvim/core/nvimtree.lua
+++ b/lua/lvim/core/nvimtree.lua
@@ -3,7 +3,7 @@ local Log = require "lvim.core.log"
function M.config()
local config = {
- setup = {
+ opts = {
auto_reload_on_write = false,
disable_netrw = false,
hijack_cursor = false,
diff --git a/lua/lvim/core/project.lua b/lua/lvim/core/project.lua
index cf96d842..938ec6d9 100644
--- a/lua/lvim/core/project.lua
+++ b/lua/lvim/core/project.lua
@@ -2,47 +2,48 @@ local M = {}
function M.config()
local config = {
- ---@usage set to true to disable setting the current-woriking directory
- --- Manual mode doesn't automatically change your root directory, so you have
- --- the option to manually do so using `:ProjectRoot` command.
- 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",
-
- ---@type string
- ---@usage path to store the project history for use in telescope
- datapath = get_cache_dir(),
+ 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)
@@ -55,7 +56,7 @@ function M.setup()
return
end
- project.setup(lvim.builtin.project)
+ project.setup(lvim.builtin.project.opts)
end
return M
diff --git a/lua/lvim/core/telescope.lua b/lua/lvim/core/telescope.lua
index 74163b6c..332a0f50 100644
--- a/lua/lvim/core/telescope.lua
+++ b/lua/lvim/core/telescope.lua
@@ -10,97 +10,99 @@ function M.config()
local actions = require("lvim.utils.modules").require_on_exported_call "telescope.actions"
local config = {
theme = "dropdown", ---@type telescope_themes
- 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,
+ 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/",
},
- },
- 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",
+ ---@usage Mappings are fully customizable. Many familiar mapping patterns are setup as defaults.
mappings = {
i = {
- ["<C-d>"] = actions.delete_buffer,
+ ["<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 = {
- ["dd"] = actions.delete_buffer,
+ ["<C-n>"] = actions.move_selection_next,
+ ["<C-p>"] = actions.move_selection_previous,
+ ["<C-q>"] = function(...)
+ actions.smart_send_to_qflist(...)
+ actions.open_qflist(...)
+ end,
},
},
+ file_ignore_patterns = {},
+ path_display = { "smart" },
+ winblend = 0,
+ border = {},
+ borderchars = nil,
+ color_devicons = true,
+ set_env = { ["COLORTERM"] = "truecolor" }, -- default = nil,
},
- planets = {
- show_pluto = true,
- show_moon = true,
- },
- git_files = {
- hidden = true,
- show_untracked = true,
- },
- colorscheme = {
- enable_preview = true,
+ 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,
+ },
},
- },
- 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"
+ 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"
+ },
},
},
}
@@ -113,22 +115,22 @@ function M.setup()
local previewers = require "telescope.previewers"
local sorters = require "telescope.sorters"
- lvim.builtin.telescope = vim.tbl_extend("keep", {
+ lvim.builtin.telescope.opts = vim.tbl_extend("keep", {
file_previewer = previewers.vim_buffer_cat.new,
grep_previewer = previewers.vim_buffer_vimgrep.new,
qflist_previewer = previewers.vim_buffer_qflist.new,
file_sorter = sorters.get_fuzzy_file,
generic_sorter = sorters.get_generic_fuzzy_sorter,
- }, lvim.builtin.telescope)
+ }, lvim.builtin.telescope.opts)
local telescope = require "telescope"
- local theme = require("telescope.themes")["get_" .. (lvim.builtin.telescope.theme or "")]
+ local theme = require("telescope.themes")["get_" .. (lvim.builtin.telescope.opts.theme or "")]
if theme then
- lvim.builtin.telescope.defaults = theme(lvim.builtin.telescope.defaults)
+ lvim.builtin.telescope.opts.defaults = theme(lvim.builtin.telescope.opts.defaults)
end
- telescope.setup(lvim.builtin.telescope)
+ telescope.setup(lvim.builtin.telescope.setup)
if lvim.builtin.project.active then
pcall(function()
@@ -136,7 +138,7 @@ function M.setup()
end)
end
- if lvim.builtin.telescope.extensions and lvim.builtin.telescope.extensions.fzf then
+ if lvim.builtin.telescope.setup.extensions and lvim.builtin.telescope.setup.extensions.fzf then
pcall(function()
require("telescope").load_extension "fzf"
end)
diff --git a/lua/lvim/core/terminal.lua b/lua/lvim/core/terminal.lua
index e9c46182..34892303 100644
--- a/lua/lvim/core/terminal.lua
+++ b/lua/lvim/core/terminal.lua
@@ -3,41 +3,43 @@ local Log = require "lvim.core.log"
M.config = function()
local config = {
- -- 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",
+ 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
},
- -- 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 },
@@ -67,7 +69,7 @@ end
---@param size number
---@return integer
local function get_dynamic_terminal_size(direction, size)
- size = size or lvim.builtin.terminal.size
+ size = size or lvim.builtin.terminal.opts.size
if direction ~= "float" and tostring(size):find(".", 1, true) then
size = math.min(size, 1.0)
local buf_sizes = get_buf_size()
@@ -80,13 +82,13 @@ end
M.setup = function()
local terminal = require "toggleterm"
- terminal.setup(lvim.builtin.terminal)
+ terminal.setup(lvim.builtin.terminal.opts)
for i, exec in pairs(lvim.builtin.terminal.execs) do
- local direction = exec[4] or lvim.builtin.terminal.direction
+ local direction = exec[4] or lvim.builtin.terminal.opts.direction
local opts = {
- cmd = exec[1] or lvim.builtin.terminal.shell,
+ cmd = exec[1] or lvim.builtin.terminal.opts.shell,
keymap = exec[2],
label = exec[3],
-- NOTE: unable to consistently bind id/count <= 9, see #2146
@@ -128,7 +130,7 @@ M.toggle_log_view = function(logfile)
end
Log:debug("attempting to open: " .. logfile)
log_viewer = log_viewer .. " " .. logfile
- local term_opts = vim.tbl_deep_extend("force", lvim.builtin.terminal, {
+ local term_opts = vim.tbl_deep_extend("force", lvim.builtin.terminal.opts, {
cmd = log_viewer,
open_mapping = lvim.log.viewer.layout_config.open_mapping,
direction = lvim.log.viewer.layout_config.direction,
diff --git a/lua/lvim/core/treesitter.lua b/lua/lvim/core/treesitter.lua
index c7ab4382..96d97a95 100644
--- a/lua/lvim/core/treesitter.lua
+++ b/lua/lvim/core/treesitter.lua
@@ -3,93 +3,95 @@ local Log = require "lvim.core.log"
function M.config()
local config = {
- -- A list of parser names, or "all"
- ensure_installed = {},
+ 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 = "",
+ 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,
},
- },
- indent = { enable = true, disable = { "yaml", "python", "c", "cpp" } },
- autotag = { enable = false },
- textobjects = {
- swap = {
+ 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,
+ },
+ },
+ textsubjects = {
enable = false,
- -- swap_next = textobj_swap_keymaps,
+ keymaps = { ["."] = "textsubjects-smart", [";"] = "textsubjects-big" },
},
- -- move = textobj_move_keymaps,
- select = {
+ playground = {
enable = false,
- -- keymaps = textobj_sel_keymaps,
+ 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 = "?",
+ },
},
- },
- 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
},
},
- 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)
@@ -109,7 +111,7 @@ function M.setup()
return
end
- local opts = vim.deepcopy(lvim.builtin.treesitter)
+ local opts = vim.deepcopy(lvim.builtin.treesitter.opts)
treesitter_configs.setup(opts)
end
diff --git a/lua/lvim/core/which-key.lua b/lua/lvim/core/which-key.lua
index ddfd7904..7dd2367a 100644
--- a/lua/lvim/core/which-key.lua
+++ b/lua/lvim/core/which-key.lua
@@ -1,7 +1,7 @@
local M = {}
M.config = function()
local config = {
- setup = {
+ 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
@@ -303,7 +303,7 @@ end
M.setup = function()
local which_key = require "which-key"
- which_key.setup(lvim.builtin.which_key.setup)
+ which_key.setup(lvim.builtin.which_key.opts)
local opts = lvim.builtin.which_key.opts
local vopts = lvim.builtin.which_key.vopts