feat: add nvimdots

This commit is contained in:
2024-07-21 02:51:17 -04:00
parent f16942be42
commit e78c5ce3f5
149 changed files with 10623 additions and 43 deletions
+138
View File
@@ -0,0 +1,138 @@
return function()
local dashboard = require("alpha.themes.dashboard")
require("modules.utils").gen_alpha_hl()
dashboard.section.header.val = require("core.settings").dashboard_image
dashboard.section.header.opts.hl = "AlphaHeader"
local function button(sc, txt, leader_txt, keybind, keybind_opts)
local sc_after = sc:gsub("%s", ""):gsub(leader_txt, "<leader>")
local opts = {
position = "center",
shortcut = sc,
cursor = 5,
width = 50,
align_shortcut = "right",
hl = "AlphaButtons",
hl_shortcut = "AlphaShortcut",
}
if nil == keybind then
keybind = sc_after
end
keybind_opts = vim.F.if_nil(keybind_opts, { noremap = true, silent = true, nowait = true })
opts.keymap = { "n", sc_after, keybind, keybind_opts }
local function on_press()
-- local key = vim.api.nvim_replace_termcodes(keybind .. '<Ignore>', true, false, true)
local key = vim.api.nvim_replace_termcodes(sc_after .. "<Ignore>", true, false, true)
vim.api.nvim_feedkeys(key, "t", false)
end
return {
type = "button",
val = txt,
on_press = on_press,
opts = opts,
}
end
local leader = " "
local icons = {
documents = require("modules.utils.icons").get("documents", true),
git = require("modules.utils.icons").get("git", true),
ui = require("modules.utils.icons").get("ui", true),
misc = require("modules.utils.icons").get("misc", true),
}
dashboard.section.buttons.val = {
button(
"space f c",
icons.misc.Neovim .. "Telescope collections",
leader,
nil,
{ noremap = true, silent = true, nowait = true }
),
button(
"space f f",
icons.documents.FileFind .. "Find files",
leader,
nil,
{ noremap = true, silent = true, nowait = true }
),
button(
"space f d",
icons.ui.FolderWithHeart .. "Retrieve dossiers",
leader,
nil,
{ noremap = true, silent = true, nowait = true }
),
button(
"space f p",
icons.documents.Word .. "Find patterns",
leader,
nil,
{ noremap = true, silent = true, nowait = true }
),
button(
"space f g",
icons.git.Git .. "Locate Git objects",
leader,
nil,
{ noremap = true, silent = true, nowait = true }
),
button(
"space f m",
icons.misc.Ghost .. "Miscellaneous artifacts",
leader,
nil,
{ noremap = true, silent = true, nowait = true }
),
}
dashboard.section.buttons.opts.hl = "AlphaButtons"
local function footer()
local stats = require("lazy").stats()
local ms = (math.floor(stats.startuptime * 100 + 0.5) / 100)
return "  Have Fun with neovim"
.. " 󰀨 v"
.. vim.version().major
.. "."
.. vim.version().minor
.. "."
.. vim.version().patch
.. " 󰂖 "
.. stats.count
.. " plugins in "
.. ms
.. "ms"
end
dashboard.section.footer.val = footer()
dashboard.section.footer.opts.hl = "AlphaFooter"
local head_butt_padding = 2
local occu_height = #dashboard.section.header.val + 2 * #dashboard.section.buttons.val + head_butt_padding
local header_padding = math.max(0, math.ceil((vim.fn.winheight(0) - occu_height) * 0.25))
local foot_butt_padding = 1
dashboard.config.layout = {
{ type = "padding", val = header_padding },
dashboard.section.header,
{ type = "padding", val = head_butt_padding },
dashboard.section.buttons,
{ type = "padding", val = foot_butt_padding },
dashboard.section.footer,
}
require("modules.utils").load_plugin("alpha", dashboard.opts)
vim.api.nvim_create_autocmd("User", {
pattern = "LazyVimStarted",
callback = function()
dashboard.section.footer.val = footer()
pcall(vim.cmd.AlphaRedraw)
end,
})
end
@@ -0,0 +1,73 @@
return function()
local icons = { ui = require("modules.utils.icons").get("ui") }
local opts = {
options = {
number = nil,
close_command = "BufDel! %d",
right_mouse_command = "BufDel! %d",
modified_icon = icons.ui.Modified,
buffer_close_icon = icons.ui.Close,
left_trunc_marker = icons.ui.Left,
right_trunc_marker = icons.ui.Right,
max_name_length = 20,
max_prefix_length = 13,
tab_size = 20,
color_icons = true,
show_buffer_icons = true,
show_buffer_close_icons = true,
show_close_icon = true,
show_tab_indicators = true,
enforce_regular_tabs = false,
persist_buffer_sort = true,
always_show_bufferline = true,
separator_style = "thin",
diagnostics = "nvim_lsp",
diagnostics_indicator = function(count)
return "(" .. count .. ")"
end,
offsets = {
{
filetype = "NvimTree",
text = "File Explorer",
text_align = "center",
padding = 0,
},
{
filetype = "aerial",
text = "Symbol Outline",
text_align = "center",
padding = 0,
},
},
},
-- Change bufferline's highlights here! See `:h bufferline-highlights` for detailed explanation.
-- Note: If you use catppuccin then modify the colors below!
highlights = {},
}
if vim.g.colors_name:find("catppuccin") then
local cp = require("modules.utils").get_palette() -- Get the palette.
local catppuccin_hl_overwrite = {
highlights = require("catppuccin.groups.integrations.bufferline").get({
styles = { "italic", "bold" },
custom = {
all = {
-- Hint
hint = { fg = cp.rosewater },
hint_visible = { fg = cp.rosewater },
hint_selected = { fg = cp.rosewater },
hint_diagnostic = { fg = cp.rosewater },
hint_diagnostic_visible = { fg = cp.rosewater },
hint_diagnostic_selected = { fg = cp.rosewater },
},
},
}),
}
opts = vim.tbl_deep_extend("force", opts, catppuccin_hl_overwrite)
end
require("modules.utils").load_plugin("bufferline", opts)
end
+182
View File
@@ -0,0 +1,182 @@
return function()
local transparent_background = require("core.settings").transparent_background
local clear = {}
require("modules.utils").load_plugin("catppuccin", {
background = { light = "latte", dark = "mocha" }, -- latte, frappe, macchiato, mocha
dim_inactive = {
enabled = false,
-- Dim inactive splits/windows/buffers.
-- NOT recommended if you use old palette (a.k.a., mocha).
shade = "dark",
percentage = 0.15,
},
transparent_background = transparent_background,
show_end_of_buffer = false, -- show the '~' characters after the end of buffers
term_colors = true,
compile_path = vim.fn.stdpath("cache") .. "/catppuccin",
styles = {
comments = { "italic" },
functions = { "bold" },
keywords = { "italic" },
operators = { "bold" },
conditionals = { "bold" },
loops = { "bold" },
booleans = { "bold", "italic" },
numbers = {},
types = {},
strings = {},
variables = {},
properties = {},
},
integrations = {
treesitter = true,
native_lsp = {
enabled = true,
virtual_text = {
errors = { "italic" },
hints = { "italic" },
warnings = { "italic" },
information = { "italic" },
},
underlines = {
errors = { "underline" },
hints = { "underline" },
warnings = { "underline" },
information = { "underline" },
},
},
aerial = true,
alpha = false,
barbar = false,
beacon = false,
cmp = true,
coc_nvim = false,
dap = true,
dap_ui = true,
dashboard = false,
dropbar = { enabled = true, color_mode = true },
fern = false,
fidget = true,
flash = true,
gitgutter = false,
gitsigns = true,
harpoon = false,
headlines = false,
hop = true,
illuminate = true,
indent_blankline = { enabled = true, colored_indent_levels = false },
leap = false,
lightspeed = false,
lsp_saga = true,
lsp_trouble = true,
markdown = true,
mason = true,
mini = false,
navic = { enabled = false },
neogit = false,
neotest = false,
neotree = { enabled = false, show_root = true, transparent_panel = false },
noice = false,
notify = true,
nvimtree = true,
overseer = false,
pounce = false,
rainbow_delimiters = true,
sandwich = false,
semantic_tokens = true,
symbols_outline = false,
telekasten = false,
telescope = { enabled = true, style = "nvchad" },
treesitter_context = true,
ts_rainbow = false,
vim_sneak = false,
vimwiki = false,
which_key = true,
},
color_overrides = {},
highlight_overrides = {
---@param cp palette
all = function(cp)
return {
-- For base configs
NormalFloat = { fg = cp.text, bg = transparent_background and cp.none or cp.mantle },
FloatBorder = {
fg = transparent_background and cp.blue or cp.mantle,
bg = transparent_background and cp.none or cp.mantle,
},
CursorLineNr = { fg = cp.green },
-- For native lsp configs
DiagnosticVirtualTextError = { bg = cp.none },
DiagnosticVirtualTextWarn = { bg = cp.none },
DiagnosticVirtualTextInfo = { bg = cp.none },
DiagnosticVirtualTextHint = { bg = cp.none },
LspInfoBorder = { link = "FloatBorder" },
-- For mason.nvim
MasonNormal = { link = "NormalFloat" },
-- For indent-blankline
IblIndent = { fg = cp.surface0 },
IblScope = { fg = cp.surface2, style = { "bold" } },
-- For nvim-cmp and wilder.nvim
Pmenu = { fg = cp.overlay2, bg = transparent_background and cp.none or cp.base },
PmenuBorder = { fg = cp.surface1, bg = transparent_background and cp.none or cp.base },
PmenuSel = { bg = cp.green, fg = cp.base },
CmpItemAbbr = { fg = cp.overlay2 },
CmpItemAbbrMatch = { fg = cp.blue, style = { "bold" } },
CmpDoc = { link = "NormalFloat" },
CmpDocBorder = {
fg = transparent_background and cp.surface1 or cp.mantle,
bg = transparent_background and cp.none or cp.mantle,
},
-- For fidget
FidgetTask = { bg = cp.none, fg = cp.surface2 },
FidgetTitle = { fg = cp.blue, style = { "bold" } },
-- For nvim-notify
NotifyBackground = { bg = cp.base },
-- For nvim-tree
NvimTreeRootFolder = { fg = cp.pink },
NvimTreeIndentMarker = { fg = cp.surface2 },
-- For trouble.nvim
TroubleNormal = { bg = transparent_background and cp.none or cp.base },
TroubleNormalNC = { bg = transparent_background and cp.none or cp.base },
-- For telescope.nvim
TelescopeMatching = { fg = cp.lavender },
TelescopeResultsDiffAdd = { fg = cp.green },
TelescopeResultsDiffChange = { fg = cp.yellow },
TelescopeResultsDiffDelete = { fg = cp.red },
-- For glance.nvim
GlanceWinBarFilename = { fg = cp.subtext1, style = { "bold" } },
GlanceWinBarFilepath = { fg = cp.subtext0, style = { "italic" } },
GlanceWinBarTitle = { fg = cp.teal, style = { "bold" } },
GlanceListCount = { fg = cp.lavender },
GlanceListFilepath = { link = "Comment" },
GlanceListFilename = { fg = cp.blue },
GlanceListMatch = { fg = cp.lavender, style = { "bold" } },
GlanceFoldIcon = { fg = cp.green },
-- For nvim-treehopper
TSNodeKey = {
fg = cp.peach,
bg = transparent_background and cp.none or cp.base,
style = { "bold", "underline" },
},
-- For treesitter
["@keyword.return"] = { fg = cp.pink, style = clear },
["@error.c"] = { fg = cp.none, style = clear },
["@error.cpp"] = { fg = cp.none, style = clear },
}
end,
},
})
end
+25
View File
@@ -0,0 +1,25 @@
return function()
local icons = {
ui = require("modules.utils.icons").get("ui"),
}
require("modules.utils").load_plugin("fidget", {
progress = {
suppress_on_insert = false, -- Suppress new messages while in insert mode
ignore_done_already = false, -- Ignore new tasks that are already complete
ignore = { "null-ls" }, -- List of LSP servers to ignore
display = {
render_limit = 5, -- How many LSP messages to show at once
done_ttl = 2, -- How long a message should persist after completion
done_icon = icons.ui.Accepted, -- Icon shown when all LSP progress tasks are complete
},
},
notification = {
override_vim_notify = false, -- Automatically override vim.notify() with Fidget
window = {
winblend = 0, -- Background color opacity in the notification window
zindex = 75, -- Stacking priority of the notification window
},
},
})
end
+23
View File
@@ -0,0 +1,23 @@
return function()
local mapping = require("keymap.ui")
require("modules.utils").load_plugin("gitsigns", {
signs = {
add = { text = "" },
change = { text = "" },
delete = { text = "_" },
topdelete = { text = "" },
changedelete = { text = "~" },
untracked = { text = "" },
},
auto_attach = true,
on_attach = mapping.gitsigns,
signcolumn = true,
sign_priority = 6,
update_debounce = 100,
word_diff = false,
current_line_blame = true,
diff_opts = { internal = true },
watch_gitdir = { follow_files = true },
current_line_blame_opts = { delay = 1000, virt_text = true, virtual_text_pos = "eol" },
})
end
@@ -0,0 +1,578 @@
return function()
-- This list delineates the per-language nodes used for guiding |ibl| in highlighting the current scope
-- It is extracted from each language's `indents.scm` file
-- NOTE: Only a subset of the supported programming languages is included
-- If your preferred language isn't listed, you can add it to the user config
local nodes = {
bibtex = {
"entry",
},
c = {
"case_statement",
"compound_literal_expression",
"enumerator_list",
"field_declaration_list",
"initializer_list",
"init_declarator",
},
cmake = {
"block_def",
"foreach_loop",
"function_def",
"if_condition",
"macro_def",
"normal_command",
"while_loop",
},
cpp = {
"case_statement",
"compound_literal_expression",
"condition_clause",
"enumerator_list",
"field_declaration_list",
"field_initializer_list",
"init_declarator",
"initializer_list",
"namespace_definition",
},
css = {
"block",
"declaration",
},
d = {
"aggregate_body",
"block_statement",
"case_statement",
"expression_statement",
"function_body",
"parameters",
"scope_statement",
"template_parameters",
},
dart = {
"arguments",
"class_body",
"formal_parameter",
"formal_parameter_list",
"function_body",
"function_expression_body",
"initializers",
"list_literal",
"return_statement",
"switch_block",
},
dot = {
"block",
"attr_list",
},
ecma = {
"arguments",
"array",
"binary_expression",
"call_expression",
"class_body",
"export_clause",
"formal_parameters",
"named_imports",
"object",
"object_pattern",
"parenthesized_expression",
"return_statement",
"switch_case",
"switch_default",
"switch_statement",
"template_substitution",
"ternary_expression",
},
elixir = {
"arguments",
"block",
"do_block",
"list",
"map",
"tuple",
},
firrtl = {
"memory",
},
fortran = {
"derived_type_definition",
"do_loop_statement",
"enum",
"function",
"if_statement",
"module",
"program",
"subroutine",
"where_statement",
},
gleam = {
"anonymous_function",
"assert",
"case",
"constant",
"external_function",
"function",
"import",
"let",
"list",
"constant",
"function",
"type_definition",
"type_alias",
"todo",
"tuple",
},
go = {
"call_expression",
"communication_case",
"const_declaration",
"default_case",
"expression_case",
"import_declaration",
"literal_value",
"parameter_list",
"struct_type",
"type_case",
"type_declaration",
"var_declaration",
},
html = {
"start_tag",
"self_closing_tag",
},
java = {
"annotation_argument_list",
"annotation_type_body",
"argument_list",
"array_initializer",
"class_body",
"constructor_body",
"element_value_array_initializer",
"enum_body",
"formal_parameters",
"interface_body",
"method_invocation",
"switch_block",
},
javascript = {
"arguments",
"array",
"binary_expression",
"call_expression",
"class_body",
"export_clause",
"formal_parameters",
"jsx_expression",
"jsx_self_closing_element",
"named_imports",
"object",
"object_pattern",
"parenthesized_expression",
"return_statement",
"switch_case",
"switch_default",
"switch_statement",
"template_substitution",
"ternary_expression",
},
julia = {
"assignment",
"call_expression",
"compound_statement",
"comprehension_expression",
"for_binding",
"if_statement",
"matrix_expression",
"parenthesized_expression",
"struct_definition",
"tuple_expression",
"vector_expression",
},
just = {
"external_command",
"recipe",
"string",
},
linkerscript = {
"memory_command",
"output_section",
"phdrs_command",
"sections_command",
},
lua = {
"arguments",
"field",
"method_index_expression",
"return_statement",
"table_constructor",
},
matlab = {
"class_definition",
"enumeration",
"events",
"for_statement",
"if_statement",
"methods",
"properties",
"switch_statement",
"try_statement",
"while_statement",
},
ninja = {
"build",
"pool",
"rule",
},
ocaml = {
"application_expression",
"do_clause",
"external",
"field_expression",
"if_expression",
"list_expression",
"parenthesized_expression",
"record_declaration",
"record_expression",
"try_expression",
"type_binding",
"value_specification",
},
pascal = {
"arrInitializer",
"block",
"declArgs",
"declClass",
"declConsts",
"declProc",
"declTypes",
"declUses",
"declVars",
"defaultValue",
"exprArgs",
"exprBrackets",
"exprParens",
"exprSubscript",
"recInitializer",
"statement",
},
php = {
"arguments",
"array_creation_expression",
"binary_expression",
"case_statement",
"compound_statement",
"declaration_list",
"default_statement",
"enum_declaration_list",
"formal_parameters",
"match_block",
"member_call_expression",
"parenthesized_expression",
"return_statement",
"switch_block",
},
python = {
"binary_operator",
"case_clause",
"concatenated_string",
"for_statement",
"generator_expression",
"if_statement",
"import_from_statement",
"lambda",
"list_pattern",
"match_statement",
"parenthesized_expression",
"try_statement",
"tuple_pattern",
"while_statement",
"with_statement",
},
query = {
"list",
"predicate",
},
r = {
"brace_list",
"call",
"paren_list",
"pipe",
"special",
},
readline = {
"conditional_construct",
},
ruby = {
"argument_list",
"array",
"assignment",
"begin",
"call",
"case",
"for",
"hash",
"if",
"module",
"parenthesized_statements",
"singleton_class",
"singleton_method",
"unless",
"until",
"while",
},
rust = {
"arguments",
"array_expression",
"assignment_expression",
"call_expression",
"enum_variant_list",
"field_declaration_list",
"macro_definition",
"match_block",
"mod_item",
"ordered_field_declaration_list",
"parameters",
"struct_expression",
"struct_pattern",
"token_repetition",
"token_tree",
"trait_item",
"tuple_expression",
"tuple_pattern",
"tuple_struct_pattern",
"tuple_type",
"use_list",
"where_clause",
},
scss = {
"block",
"declaration",
"each_statement",
"mixin_statement",
"while_statement",
},
sql = {
"case",
"column_definitions",
"cte",
"insert",
"select",
"subquery",
"when_clause",
},
ssh_config = {
"host_declaration",
"match_declaration",
},
swift = {
"array_literal",
"array_type",
"assignment",
"call_expression",
"class_body",
"computed_getter",
"computed_property",
"computed_setter",
"control_transfer_statement",
"deinit_declaration",
"dictionary_literal",
"dictionary_type",
"didset_clause",
"enum_class_body",
"init_declaration",
"lambda_literal",
"protocol_body",
"subscript_declaration",
"tuple_expression",
"tuple_type",
"type_parameters",
"willset_clause",
"willset_didset_block",
},
tablegen = {
"assert",
"value_suffix",
},
tcl = {
"braced_word_simple",
"command",
"command_substitution",
"conditional",
"foreach",
"namespace",
"procedure",
"try",
"while",
},
teal = {
"record_declaration",
"function_body",
"table_constructor",
"return_statement",
"while_statement",
},
terraform = {
"block",
"function_call",
"object",
"tuple",
},
textproto = {
"message_list",
"message_value",
"scalar_list",
},
toml = {
"array",
"inline_table",
},
typescript = {
"arguments",
"array",
"binary_expression",
"call_expression",
"class_body",
"enum_declaration",
"export_clause",
"formal_parameters",
"interface_declaration",
"named_imports",
"object",
"object_pattern",
"object_type",
"parenthesized_expression",
"return_statement",
"switch_case",
"switch_default",
"switch_statement",
"template_substitution",
"ternary_expression",
},
vue = {
"start_tag",
},
xml = {
"element",
},
zig = {
"Block",
"ContainerDecl",
"InitList",
"SwitchExpr",
},
}
require("modules.utils").load_plugin("ibl", {
enabled = true,
debounce = 200,
indent = {
char = "",
tab_char = "",
smart_indent_cap = true,
priority = 2,
},
whitespace = { remove_blankline_trail = true },
-- Note: The `scope` field requires treesitter to be set up
scope = {
enabled = true,
char = "",
show_start = false,
show_end = false,
injected_languages = true,
priority = 1000,
include = {
node_type = {
angular = nodes.html,
arduino = nodes.cpp,
astro = nodes.html,
bibtex = nodes.bibtex,
c = nodes.c,
cmake = nodes.cmake,
cpp = nodes.cpp,
css = nodes.css,
cuda = nodes.cpp,
d = nodes.d,
dart = nodes.dart,
dot = nodes.dot,
ecma = nodes.ecma,
elixir = nodes.elixir,
firrtl = nodes.firrtl,
fortran = nodes.fortran,
glsl = nodes.c,
gleam = nodes.gleam,
go = nodes.go,
hlsl = nodes.cpp,
html = nodes.html,
java = nodes.java,
javascript = nodes.javascript,
julia = nodes.julia,
just = nodes.just,
linkerscript = nodes.linkerscript,
lua = nodes.lua,
luau = nodes.lua,
matlab = nodes.matlab,
ninja = nodes.ninja,
objc = nodes.c,
ocaml = nodes.ocaml,
ocaml_interface = nodes.ocaml,
pascal = nodes.pascal,
php = nodes.php,
python = nodes.python,
query = nodes.query,
r = nodes.r,
readline = nodes.readline,
ruby = nodes.ruby,
rust = nodes.rust,
scss = nodes.scss,
sql = nodes.sql,
ssh_config = nodes.ssh_config,
swift = nodes.swift,
tablegen = nodes.tablegen,
tcl = nodes.tcl,
teal = nodes.teal,
terraform = nodes.terraform,
textproto = nodes.textproto,
toml = nodes.toml,
typescript = nodes.typescript,
vue = nodes.vue,
xml = nodes.xml,
zig = nodes.zig,
},
},
},
exclude = {
buftypes = {
"help",
"nofile",
"prompt",
"quickfix",
"terminal",
},
filetypes = {
"", -- for all buffers without a file type
"alpha",
"bigfile",
"checkhealth",
"dap-repl",
"diff",
"fugitive",
"fugitiveblame",
"git",
"gitcommit",
"help",
"log",
"markdown",
"notify",
"NvimTree",
"Outline",
"qf",
"TelescopePrompt",
"text",
"toggleterm",
"undotree",
"vimwiki",
},
},
})
end
+347
View File
@@ -0,0 +1,347 @@
return function()
local has_catppuccin = vim.g.colors_name:find("catppuccin") ~= nil
local colors = require("modules.utils").get_palette()
local icons = {
diagnostics = require("modules.utils.icons").get("diagnostics", true),
git = require("modules.utils.icons").get("git", true),
git_nosep = require("modules.utils.icons").get("git"),
misc = require("modules.utils.icons").get("misc", true),
ui = require("modules.utils.icons").get("ui", true),
}
local function custom_theme()
vim.api.nvim_create_autocmd("ColorScheme", {
group = vim.api.nvim_create_augroup("LualineColorScheme", { clear = true }),
pattern = "*",
callback = function()
has_catppuccin = vim.g.colors_name:find("catppuccin") ~= nil
require("lualine").setup({ options = { theme = custom_theme() } })
end,
})
if has_catppuccin then
colors = require("modules.utils").get_palette()
local universal_bg = require("core.settings").transparent_background and "NONE" or colors.mantle
return {
normal = {
a = { fg = colors.lavender, bg = colors.surface0, gui = "bold" },
b = { fg = colors.text, bg = universal_bg },
c = { fg = colors.text, bg = universal_bg },
},
command = {
a = { fg = colors.peach, bg = colors.surface0, gui = "bold" },
},
insert = {
a = { fg = colors.green, bg = colors.surface0, gui = "bold" },
},
visual = {
a = { fg = colors.flamingo, bg = colors.surface0, gui = "bold" },
},
terminal = {
a = { fg = colors.teal, bg = colors.surface0, gui = "bold" },
},
replace = {
a = { fg = colors.red, bg = colors.surface0, gui = "bold" },
},
inactive = {
a = { fg = colors.subtext0, bg = universal_bg, gui = "bold" },
b = { fg = colors.subtext0, bg = universal_bg },
c = { fg = colors.subtext0, bg = universal_bg },
},
}
else
return "auto"
end
end
local conditionals = {
has_enough_room = function()
return vim.o.columns > 100
end,
has_comp_before = function()
return vim.bo.filetype ~= ""
end,
has_git = function()
local gitdir = vim.fs.find(".git", {
limit = 1,
upward = true,
type = "directory",
path = vim.fn.expand("%:p:h"),
})
return #gitdir > 0
end,
}
---@class lualine_hlgrp
---@field fg string
---@field bg string
---@field gui string?
local utils = {
force_centering = function()
return "%="
end,
abbreviate_path = function(path)
local home = require("core.global").home
if path:find(home, 1, true) == 1 then
path = "~" .. path:sub(#home + 1)
end
return path
end,
---Generate <func>`color` for any component
---@param fg string @Foreground hl group
---@param gen_bg boolean @Generate guibg from hl group |StatusLine|?
---@param special_nobg boolean @Disable guibg for transparent backgrounds?
---@param bg string? @Background hl group
---@param gui string? @GUI highlight arguments
---@return nil|fun():lualine_hlgrp
gen_hl = function(fg, gen_bg, special_nobg, bg, gui)
if has_catppuccin then
return function()
local guifg = colors[fg]
local guibg = gen_bg and require("modules.utils").hl_to_rgb("StatusLine", true, colors.mantle)
or colors[bg]
local nobg = special_nobg and require("core.settings").transparent_background
return {
fg = guifg and guifg or colors.none,
bg = (guibg and not nobg) and guibg or colors.none,
gui = gui and gui or nil,
}
end
else
-- Return `nil` if the theme is user-defined
return nil
end
end,
}
local function diff_source()
local gitsigns = vim.b.gitsigns_status_dict
if gitsigns then
return {
added = gitsigns.added,
modified = gitsigns.changed,
removed = gitsigns.removed,
}
end
end
local components = {
separator = { -- use as section separators
function()
return ""
end,
padding = 0,
color = utils.gen_hl("surface1", true, true),
separator = { left = "", right = "" },
},
file_status = {
function()
local function is_new_file()
local filename = vim.fn.expand("%")
return filename ~= "" and vim.bo.buftype == "" and vim.fn.filereadable(filename) == 0
end
local symbols = {}
if vim.bo.modified then
table.insert(symbols, "[+]")
end
if vim.bo.modifiable == false then
table.insert(symbols, "[-]")
end
if vim.bo.readonly == true then
table.insert(symbols, "[RO]")
end
if is_new_file() then
table.insert(symbols, "[New]")
end
return #symbols > 0 and table.concat(symbols, "") or ""
end,
padding = { left = -1, right = 1 },
cond = conditionals.has_comp_before,
},
lsp = {
function()
local buf_ft = vim.bo.filetype
local clients = vim.lsp.get_clients({ buffer = vim.api.nvim_get_current_buf() })
local lsp_lists = {}
local available_servers = {}
if next(clients) == nil then
return icons.misc.NoActiveLsp -- No server available
end
for _, client in ipairs(clients) do
local filetypes = client.config.filetypes
local client_name = client.name
if filetypes and vim.fn.index(filetypes, buf_ft) ~= -1 then
-- Avoid adding servers that already exists.
if not lsp_lists[client_name] then
lsp_lists[client_name] = true
table.insert(available_servers, client_name)
end
end
end
return next(available_servers) == nil and icons.misc.NoActiveLsp
or string.format("%s[%s]", icons.misc.LspAvailable, table.concat(available_servers, ", "))
end,
color = utils.gen_hl("blue", true, true, nil, "bold"),
cond = conditionals.has_enough_room,
},
python_venv = {
function()
local function env_cleanup(venv)
if string.find(venv, "/") then
local final_venv = venv
for w in venv:gmatch("([^/]+)") do
final_venv = w
end
venv = final_venv
end
return venv
end
if vim.bo.filetype == "python" then
local venv = os.getenv("CONDA_DEFAULT_ENV")
if venv then
return icons.misc.PyEnv .. env_cleanup(venv)
end
venv = os.getenv("VIRTUAL_ENV")
if venv then
return icons.misc.PyEnv .. env_cleanup(venv)
end
end
return ""
end,
color = utils.gen_hl("green", true, true),
cond = conditionals.has_enough_room,
},
tabwidth = {
function()
return icons.ui.Tab .. vim.bo.tabstop
end,
padding = 1,
},
cwd = {
function()
return icons.ui.FolderWithHeart .. utils.abbreviate_path(vim.fs.normalize(vim.fn.getcwd()))
end,
color = utils.gen_hl("subtext0", true, true, nil, "bold"),
},
file_location = {
function()
local cursorline = vim.fn.line(".")
local cursorcol = vim.fn.virtcol(".")
local filelines = vim.fn.line("$")
local position
if cursorline == 1 then
position = "Top"
elseif cursorline == filelines then
position = "Bot"
else
position = string.format("%2d%%%%", math.floor(cursorline / filelines * 100))
end
return string.format("%s · %3d:%-2d", position, cursorline, cursorcol)
end,
},
}
require("modules.utils").load_plugin("lualine", {
options = {
icons_enabled = true,
theme = custom_theme(),
disabled_filetypes = { statusline = { "alpha" } },
component_separators = "",
section_separators = { left = "", right = "" },
},
sections = {
lualine_a = { "mode" },
lualine_b = {
{
"filetype",
colored = true,
icon_only = false,
icon = { align = "left" },
},
components.file_status,
vim.tbl_extend("force", components.separator, {
cond = function()
return conditionals.has_git() and conditionals.has_comp_before()
end,
}),
},
lualine_c = {
{
"branch",
icon = icons.git_nosep.Branch,
color = utils.gen_hl("subtext0", true, true, nil, "bold"),
cond = conditionals.has_git,
},
{
"diff",
symbols = {
added = icons.git.Add,
modified = icons.git.Mod_alt,
removed = icons.git.Remove,
},
source = diff_source,
colored = false,
color = utils.gen_hl("subtext0", true, true),
cond = conditionals.has_git,
padding = { right = 1 },
},
{ utils.force_centering },
{
"diagnostics",
sources = { "nvim_diagnostic" },
sections = { "error", "warn", "info", "hint" },
symbols = {
error = icons.diagnostics.Error,
warn = icons.diagnostics.Warning,
info = icons.diagnostics.Information,
hint = icons.diagnostics.Hint_alt,
},
},
components.lsp,
},
lualine_x = {
{
"encoding",
fmt = string.upper,
padding = { left = 1 },
cond = conditionals.has_enough_room,
},
{
"fileformat",
symbols = {
unix = "LF",
dos = "CRLF",
mac = "CR", -- Legacy macOS
},
padding = { left = 1 },
},
components.tabwidth,
},
lualine_y = {
components.separator,
components.python_venv,
components.cwd,
},
lualine_z = { components.file_location },
},
inactive_sections = {
lualine_a = {},
lualine_b = {},
lualine_c = { "filename" },
lualine_x = { "location" },
lualine_y = {},
lualine_z = {},
},
tabline = {},
extensions = {},
})
end
+37
View File
@@ -0,0 +1,37 @@
return function()
local blend_color = require("modules.utils").gen_neodim_blend_attr()
require("modules.utils").load_plugin("neodim", {
alpha = 0.45,
blend_color = blend_color,
refresh_delay = 75, -- time in ms to wait after typing before refreshing diagnostics
hide = {
virtual_text = true,
signs = false,
underline = false,
},
priority = 80,
disable = {
"alpha",
"bigfile",
"checkhealth",
"dap-repl",
"diff",
"fugitive",
"fugitiveblame",
"git",
"gitcommit",
"help",
"log",
"notify",
"NvimTree",
"Outline",
"qf",
"TelescopePrompt",
"text",
"toggleterm",
"undotree",
"vimwiki",
},
})
end
+24
View File
@@ -0,0 +1,24 @@
return function()
require("modules.utils").load_plugin("neoscroll", {
-- All these keys will be mapped to their corresponding default scrolling animation
mappings = {
"<C-u>",
"<C-d>",
"<C-b>",
"<C-f>",
"<C-y>",
"<C-e>",
"zt",
"zz",
"zb",
},
hide_cursor = true, -- Hide cursor while scrolling
stop_eof = true, -- Stop at <EOF> when scrolling downwards
use_local_scrolloff = false, -- Use the local scope of scrolloff instead of the global scope
respect_scrolloff = false, -- Stop scrolling when the cursor reaches the scrolloff margin of the file
cursor_scrolls_alone = true, -- The cursor will keep on scrolling even if the window cannot scroll further
easing_function = nil, -- Default easing function
pre_hook = nil, -- Function to run before the scrolling animation starts
post_hook = nil, -- Function to run after the scrolling animation ends
})
end
+41
View File
@@ -0,0 +1,41 @@
return function()
local notify = require("notify")
local icons = {
diagnostics = require("modules.utils.icons").get("diagnostics"),
ui = require("modules.utils.icons").get("ui"),
}
require("modules.utils").load_plugin("notify", {
---@usage Animation style one of { "fade", "slide", "fade_in_slide_out", "static" }
stages = "fade",
---@usage Function called when a new window is opened, use for changing win settings/config
on_open = function(win)
vim.api.nvim_set_option_value("winblend", 0, { scope = "local", win = win })
vim.api.nvim_win_set_config(win, { zindex = 90 })
end,
---@usage Function called when a window is closed
on_close = nil,
---@usage timeout for notifications in ms, default 5000
timeout = 2000,
-- @usage User render fps value
fps = 20,
-- Render function for notifications. See notify-render()
render = "default",
---@usage highlight behind the window for stages that change opacity
background_colour = "NotifyBackground",
---@usage minimum width for notification windows
minimum_width = 50,
---@usage notifications with level lower than this would be ignored. [ERROR > WARN > INFO > DEBUG > TRACE]
level = "INFO",
---@usage Icons for the different levels
icons = {
ERROR = icons.diagnostics.Error,
WARN = icons.diagnostics.Warning,
INFO = icons.diagnostics.Information,
DEBUG = icons.ui.Bug,
TRACE = icons.ui.Pencil,
},
})
vim.notify = notify
end
+20
View File
@@ -0,0 +1,20 @@
return function()
require("modules.utils").load_plugin("paint", {
---type PaintHighlight[]
highlights = {
{
-- filter can be a table of buffer options that should match,
-- or a function called with buf as param that should return true.
-- The example below will paint @something in comments with Constant
filter = { filetype = "lua" },
pattern = "%s*%-%-%-%s*(@%w+)",
hl = "Constant",
},
{
filter = { filetype = "python" },
pattern = "%s*([_%w]+:)",
hl = "Constant",
},
},
})
end
@@ -0,0 +1,24 @@
return function()
local icons = { diagnostics = require("modules.utils.icons").get("diagnostics", true) }
require("modules.utils").load_plugin("scrollview", {
mode = "virtual",
winblend = 0,
signs_on_startup = { "diagnostics", "folds", "marks", "search", "spell" },
diagnostics_error_symbol = icons.diagnostics.Error,
diagnostics_warn_symbol = icons.diagnostics.Warning,
diagnostics_info_symbol = icons.diagnostics.Information,
diagnostics_hint_symbol = icons.diagnostics.Hint,
excluded_filetypes = {
"alpha",
"fugitive",
"git",
"notify",
"NvimTree",
"Outline",
"TelescopePrompt",
"toggleterm",
"undotree",
},
})
end
+58
View File
@@ -0,0 +1,58 @@
return function()
local icons = {
diagnostics = require("modules.utils.icons").get("diagnostics"),
ui = require("modules.utils.icons").get("ui"),
}
require("modules.utils").load_plugin("todo-comments", {
signs = false, -- show icons in the signs column
keywords = {
FIX = {
icon = icons.ui.Bug,
color = "error",
alt = { "FIXME", "BUG", "FIXIT", "ISSUE" },
},
TODO = { icon = icons.ui.Accepted, color = "info" },
-- HACK = { icon = icons.ui.Fire, color = "warning" },
WARN = { icon = icons.diagnostics.Warning, color = "warning", alt = { "WARNING", "XXX" } },
PERF = { icon = icons.ui.Perf, alt = { "OPTIM", "PERFORMANCE", "OPTIMIZE" } },
NOTE = { icon = icons.ui.Note, color = "hint", alt = { "INFO" } },
TEST = { icon = icons.ui.Lock, color = "test", alt = { "TESTING", "PASSED", "FAILED" } },
},
gui_style = {
fg = "NONE",
bg = "BOLD",
},
merge_keywords = true,
highlight = {
multiline = false,
keyword = "wide", -- "fg", "bg", "wide", "wide_bg", "wide_fg" or empty.
after = "",
comments_only = true,
max_line_len = 500,
exclude = {
"alpha",
"bigfile",
"checkhealth",
"dap-repl",
"diff",
"help",
"log",
"notify",
"NvimTree",
"Outline",
"qf",
"TelescopePrompt",
"toggleterm",
"undotree",
},
},
colors = {
error = { "DiagnosticError", "ErrorMsg", "#DC2626" },
warning = { "DiagnosticWarn", "WarningMsg", "#FBBF24" },
info = { "DiagnosticInfo", "#2563EB" },
hint = { "DiagnosticHint", "#F5C2E7" },
default = { "Conditional", "#7C3AED" },
},
})
end