♻️ refactor(full-scope)!: major revision refactoring

Code layout has been changed and improoved. Annotations are added for documentation. Automated through utility functions and data tables

BREAKING CHANGE: Tested from clean. Now properly uses LuaRocks to install dependencies.
This commit is contained in:
2024-09-04 16:07:12 -04:00
parent b2731cff01
commit 273580f533
48 changed files with 1962 additions and 750 deletions
+1
View File
@@ -12,3 +12,4 @@ debug/
.ignore-deps .ignore-deps
profile.json profile.json
rocks.toml rocks.toml
/home/rootiest/.cache/nvim
+43 -4
View File
@@ -51,9 +51,6 @@
-- ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ -- ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
-- The rootiest NeoVim configuration! -- The rootiest NeoVim configuration!
---━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ OPTIONS ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
-- Neovim options are configured in the lua/config/options.lua file
---━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ROOTIEST ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ---━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ROOTIEST ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
-- Rootiest Configuration -- Rootiest Configuration
require("config.rootiest").setup() -- Set up Rootiest options require("config.rootiest").setup() -- Set up Rootiest options
@@ -78,5 +75,47 @@ require("config.profile") -- Set profiling options with environment variables:
-- │ :lua require("profile").start("lualine") │ -- │ :lua require("profile").start("lualine") │
-- ╰─────────────────────────────────────────────────────────────────────╯ -- ╰─────────────────────────────────────────────────────────────────────╯
-- ╔═════════════════════════════════════════════════════════╗
-- ║ CONFIGURATION STRUCTURE ║
-- ╚═════════════════════════════════════════════════════════╝
-- ╭─────────────────────────────────────────────────────────────────────╮
-- │ Configuration modules are organized into categories: │
-- │ - Options │
-- │ - Keymaps │
-- │ - Autocommands │
-- │ - Utility functions │
-- │ - Plugins │
-- │ - Commands │
-- │ - Dashboards │
-- │ - Types │
-- │ - Dependencies │
-- ╰─────────────────────────────────────────────────────────────────────╯
---━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ OPTIONS ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
-- Neovim options are configured in the lua/config/options.lua file
---━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ KEYMAPS ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ---━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ KEYMAPS ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
-- Custom keymaps are configured in the lua/config/keymaps.lua file -- Custom keymaps and plugin keys are configured in the lua/data/keys.lua file
---━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ AUTOCOMMANDS ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
-- Custom autocommands are configured in the lua/config/autocmds.lua file
---━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ UTILITY FUNCTIONS ━━━━━━━━━━━━━━━━━━━━━━━━━━━
-- Utility functions can be found in the lua/data/func.lua file
---━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ PLUGINS ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
-- Plugin specs are defined in the lua/config/plugins.lua file
-- Plugin keys, cmds, dependencies, and opts/config tables are
-- defined in the lua/data/*.lua files. This allows all plugin configurations
-- to be defined in a centralized location and keeps them organised.
---━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ COMMANDS ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
-- Plugin cmds are configured in the lua/data/cmds.lua file
---━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ DASHBOARDS ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
-- Dashboard configurations can be found in the lua/data/dash.lua file
---━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ TYPES ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
-- Plugin configuration tables are configured in the lua/data/types.lua file
---━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ DEPENDENCIES ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
-- Plugin depenendencies are configured in the lua/data/deps.lua file
+14
View File
@@ -1,3 +1,5 @@
--- @module "config.autocmds"
--- This module defines the autocommands for the Neovim configuration.
-- ╭─────────────────────────────────────────────────────────╮ -- ╭─────────────────────────────────────────────────────────╮
-- │ Autocommands │ -- │ Autocommands │
-- ╰─────────────────────────────────────────────────────────╯ -- ╰─────────────────────────────────────────────────────────╯
@@ -52,6 +54,18 @@ autocmd({ "BufEnter", "FocusGained" }, {
end, end,
}) })
-- TodoFzfLua command override to use Telescope
-- when fzf-lua is not installed
autogrp("TodoFzfLua", { clear = true })
autocmd({ "BufEnter" }, {
group = "TodoFzfLua",
callback = function()
if not pcall(require, "fzf-lua") then
vim.cmd([[command! -nargs=* TodoFzfLua :TodoTelescope]])
end
end,
})
-- Set up autocommands and highlight settings -- Set up autocommands and highlight settings
local load_highlight = require("utils.highlight") local load_highlight = require("utils.highlight")
load_highlight.setup_autocommands() load_highlight.setup_autocommands()
+3
View File
@@ -1,3 +1,6 @@
--- @module "config.keymaps"
--- This module defines the keymapping operations for the Neovim configuration.
--- The actual keybindings are defined in lua/data/keys.lua
-- ╭─────────────────────────────────────────────────────────╮ -- ╭─────────────────────────────────────────────────────────╮
-- │ Keybinds │ -- │ Keybinds │
-- ╰─────────────────────────────────────────────────────────╯ -- ╰─────────────────────────────────────────────────────────╯
+22 -8
View File
@@ -1,8 +1,9 @@
---@module "config.lazy"
--- This module bootstraps Lazy.nvim.
--- Lazy is a plugin manager for Neovim.
-- ╭─────────────────────────────────────────────────────────╮ -- ╭─────────────────────────────────────────────────────────╮
-- │ Lazy │ -- │ Lazy │
-- ╰─────────────────────────────────────────────────────────╯ -- ╰─────────────────────────────────────────────────────────╯
---@module "config.lazy"
--- Bootstrap the lazy.nvim plugin manager
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.uv.fs_stat(lazypath) then if not vim.uv.fs_stat(lazypath) then
-- stylua: ignore -- stylua: ignore
@@ -17,14 +18,28 @@ end
vim.opt.rtp:prepend(vim.env.LAZY or lazypath) vim.opt.rtp:prepend(vim.env.LAZY or lazypath)
-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ PLUGINS ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ PLUGINS ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
require("lazy").setup({
spec = { local plugin_specs = {
{ {
"LazyVim/LazyVim", "LazyVim/LazyVim", -- LazyVim
import = "lazyvim.plugins", import = "lazyvim.plugins", -- LazyVim Core Plugins
}, },
{ import = "plugins" }, -- General Plugins { import = "plugins" }, -- General Plugins
}, }
-- Automatically import all subdirectories of `lua/plugins`
local plugin_dirs = vim.fn.glob("~/.config/nvim/lua/plugins/*", true, true)
for _, dir in ipairs(plugin_dirs) do
if vim.fn.isdirectory(dir) == 1 then
table.insert( -- Add directory to the plugin import table
plugin_specs,
{ import = "plugins." .. vim.fn.fnamemodify(dir, ":t") }
)
end
end
require("lazy").setup({
spec = plugin_specs,
defaults = { defaults = {
lazy = false, lazy = false,
version = false, version = false,
@@ -44,7 +59,6 @@ require("lazy").setup({
}, },
}, },
profiling = { profiling = {
-- Track the time spent loading plugins
loader = true, loader = true,
require = true, require = true,
}, },
+2
View File
@@ -1,3 +1,5 @@
--- @module "config.neovide"
--- This module defines the neovide options for the Neovim configuration.
-- ╭─────────────────────────────────────────────────────────╮ -- ╭─────────────────────────────────────────────────────────╮
-- │ Neovide │ -- │ Neovide │
-- ╰─────────────────────────────────────────────────────────╯ -- ╰─────────────────────────────────────────────────────────╯
+62 -32
View File
@@ -1,41 +1,78 @@
--- @module "config.options"
--- This module defines the user options for the Neovim configuration.
--- Variables defined here set configuration options for the rest
--- of the Neovim configuration.
-- ╭─────────────────────────────────────────────────────────╮ -- ╭─────────────────────────────────────────────────────────╮
-- │ Options │ -- │ Options │
-- ╰─────────────────────────────────────────────────────────╯ -- ╰─────────────────────────────────────────────────────────╯
-- stylua: ignore start -- stylua: ignore start
-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Leader Key ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Leader Key ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
vim.g.mapleader = " " --- @type string Options: <leader> vim.g.mapleader = " " ---@type string Options: <leader>
vim.g.maplocalleader = " " --- @type string Options: <localleader> vim.g.maplocalleader = " " ---@type string Options: <localleader>
-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ LSP ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ LSP ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
-- We don't need perl -- We don't need perl
vim.g.loaded_perl_provider = 0 --- @type integer Options: <0|1> vim.g.loaded_perl_provider = 0 ---@type integer Options: <0|1>
vim.g.loaded_ruby_provider = 0 --- @type integer Options: <0|1> vim.g.loaded_ruby_provider = 0 ---@type integer Options: <0|1>
-- Prefer basedpyright -- Prefer basedpyright
vim.g.lazyvim_python_lsp = "basedpyright" --- @type string Options: [python lsp] vim.g.lazyvim_python_lsp = "basedpyright" ---@type string Options: [python lsp]
-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ OS ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ OS ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
-- Check if we are on windows -- Check if we are on windows
vim.g.is_windows = vim.fn.has("win32") == 1 or vim.fn.has("win64") == 1 vim.g.is_windows = vim.fn.has("win32") == 1 or vim.fn.has("win64") == 1
-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ROOTIEST ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ROOTIEST ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
-- ╭───────────────────────────╮ Options: vim.g.usewakatime = true ---@type boolean Options: <true|false>
-- │ │  codeium vim.g.usemusic = true ---@type boolean Options: <true|false>
-- │ AI Tools: │  copilot vim.g.usehardtime = false ---@type boolean Options: <true|false>
-- │ Choose an AI provider │  tabnine vim.g.useimage = true ---@type boolean Options: <true|false>
-- │ from the list  │  minuet vim.g.ignore_no_lazy = false ---@type boolean Options: <true|false>
-- │ │  ollama vim.g.codesnap = true ---@type boolean Options: <true|false>
-- ╰───────────────────────────╯  none vim.g.auto_cursorline = true ---@type boolean Options: <true|false>
vim.g.aitool = "codeium" --- @type string Options: [ai tool] vim.g.auto_save = true ---@type boolean Options: <true|false>
vim.g.usewakatime = true --- @type boolean Options: <true|false> -- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ AI TOOL ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
vim.g.usehardtime = false --- @type boolean Options: <true|false> vim.g.aitool = "codeium" ---@type string Options: [ai tool]
vim.g.useimage = true --- @type boolean Options: <true|false> -- ╭───────────────────────────╮  codeium
-- │ │  copilot
-- │ AI Tools: │  tabnine
-- │ Choose an AI provider │  minuet
-- │ from the list  │  ollama
-- │ │  none
-- ╰───────────────────────────╯
-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Lualine Stats ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ STATUS LINE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
vim.g.stats_wakatime = true --- @type boolean Options: <true|false> vim.g.statusline = "lualine" ---@type string Options: [statusline]
vim.g.stats_music = true --- @type boolean Options: <true|false> -- ╭───────────────────────────╮  lualine
vim.g.stats_ignored_players = { --- @type string[] Options: [ignored players] -- │ │  heirline
-- │ Status Lines: │  basic
-- │ Choose a plugin from │  none
-- │ the list  │
-- │ │
-- ╰───────────────────────────╯
-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ STATUS COLUMN ━━━━━━━━━━━━━━━━━━━━━━━━━━━━
vim.g.statuscolumn = "native" ---@type string Options: [statuscolumn]
-- ╭───────────────────────────╮  barsNlines
-- │ │  native
-- │ Status Columns: │
-- │ Choose a plugin from │
-- │ the list  │
-- │ │
-- ╰───────────────────────────╯
-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ BUFFER LINE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
vim.g.tabline = "bufferline" ---@type string Options: [tabline]
-- ╭───────────────────────────╮  bufferline
-- │ │  barsNlines
-- │ Tab Lines: │  none
-- │ Choose a plugin from │
-- │ the list  │
-- │ │
-- ╰───────────────────────────╯
vim.g.statusline_clickable_git = false ---@type boolean Options: <true|false>
vim.g.stats_wakatime = true ---@type boolean Options: <true|false>
vim.g.stats_music = true ---@type boolean Options: <true|false>
vim.g.stats_ignored_players = { ---@type string[] Options: [ignored players]
"chromium", "chromium",
"firefox", "firefox",
"kdeconnect", "kdeconnect",
@@ -46,20 +83,13 @@ vim.g.stats_ignored_players = { --- @type string[] Options: [ignored players]
-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ COLOR ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ COLOR ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
-- Background color -- Background color
vim.o.background = "dark" --- @type string Options: <dark|light> vim.o.background = "dark" ---@type string Options: <dark|light>
-- Dashboard header color -- Dashboard header color
vim.g.DashboardHeaderColor = "#88fc9a" --- @type string Options: [hex color] vim.g.DashboardHeaderColor = "#88fc9a"---@type string Options: [hex color]
-- Disable Transparency -- Disable Transparency
vim.g.disable_transparency = true --- @type boolean Options: <true|false> vim.g.disable_transparency = true ---@type boolean Options: <true|false>
-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━ BLINKY CURSOR ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Completion ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
-- Setup the blinky cursor
require("utils.blinky").enable()
-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ OTHER ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
-- Suda smart edit: Automatically edit files in sudo mode when needed
vim.g.suda_smart_edit = 1 --- @type integer Options: <0|1>
vim.cmd("let g:suda#prompt = '  Enter Sudo Password  '")
-- Cmp Window Border -- Cmp Window Border
vim.g.completion_round_borders_enabled = true vim.g.completion_round_borders_enabled = true ---Options: <true|false>
-- stylua: ignore end -- stylua: ignore end
+9
View File
@@ -1,3 +1,12 @@
--- @module "config.profile"
--- This module configures the profiler for the Neovim configuration.
--- This tool can be used to profile specific modules or all modules.
---
--- The profiler can be toggled with the leader keybinding `d<f1>`
--- or with the `NVIM_PROFILE` environment variable.
---
--- Specific modules can be selected with the `NVIM_PROFILE_MODULE`
--- environment variable.
-- ╭─────────────────────────────────────────────────────────╮ -- ╭─────────────────────────────────────────────────────────╮
-- │ PROFILER │ -- │ PROFILER │
-- ╰─────────────────────────────────────────────────────────╯ -- ╰─────────────────────────────────────────────────────────╯
+27 -1
View File
@@ -1,6 +1,10 @@
--- @module "config.rocks"
--- This module bootstraps rocks.nvim.
--- Rocks is a package manager for Neovim.
-- ╭─────────────────────────────────────────────────────────╮ -- ╭─────────────────────────────────────────────────────────╮
-- │ ROCKS │ -- │ ROCKS │
-- ╰─────────────────────────────────────────────────────────╯ -- ╰─────────────────────────────────────────────────────────╯
local M = {}
-- ━━━━━━━━━━━━━━━━━━━━━━━━ Bootstrap rocks.nvim ━━━━━━━━━━━━━━━━━━━━━ -- ━━━━━━━━━━━━━━━━━━━━━━━━ Bootstrap rocks.nvim ━━━━━━━━━━━━━━━━━━━━━
do do
@@ -73,5 +77,27 @@ if not pcall(require, "rocks") then
vim.fn.delete(rocks_location, "rf") vim.fn.delete(rocks_location, "rf")
end end
-- ━━━━━━━━━━━━━━━━━━━━━━━━━━ Rocks plugin spec ━━━━━━━━━━━━━━━━━━━━━━
M.plugin_spec = {
"vhyrro/luarocks.nvim",
priority = 1000, -- Very high priority is required, luarocks.nvim should run as the first plugin in your config.
opts = {
rocks = { "magick" }, -- specifies a list of rocks to install
},
}
-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Load plugins ━━━━━━━━━━━━━━━━━━━━━━━━━ -- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Load plugins ━━━━━━━━━━━━━━━━━━━━━━━━━
require("rocks") -- Load rocks package manager
M.load_rocks = function()
require("rocks")
end
-- Perform setup
M.setup = function()
M.load_rocks()
end
-- Execute the setup function
M.setup()
return M
+15 -3
View File
@@ -1,5 +1,6 @@
---@module "config.rootiest" ---@module "config.rootiest"
--- This module contains the configuration for the rootiest distro. --- This module contains the configuration options and functions
--- for the rootiest distro.
-- ╭─────────────────────────────────────────────────────────╮ -- ╭─────────────────────────────────────────────────────────╮
-- │ Rootiest Module │ -- │ Rootiest Module │
-- ╰─────────────────────────────────────────────────────────╯ -- ╰─────────────────────────────────────────────────────────╯
@@ -83,10 +84,13 @@ function M.toggle_lazygit_float(my_args)
if my_args ~= "" or my_args ~= nil then if my_args ~= "" or my_args ~= nil then
Util.terminal.open( Util.terminal.open(
{ "lazygit", my_args }, { "lazygit", my_args },
{ cwd = Util.root(), esc_esc = false } { cwd = Util.root(), interactive = true, esc_esc = false }
) )
else else
Util.terminal.open({ "lazygit" }, { cwd = Util.root(), esc_esc = false }) Util.terminal.open(
{ "lazygit" },
{ cwd = Util.root(), interactive = true, esc_esc = false }
)
end end
return true return true
else else
@@ -191,6 +195,14 @@ function M.setup()
-- Setup Rootiest cmd window (override default command-line behavior) -- Setup Rootiest cmd window (override default command-line behavior)
-- require("utils.cmd_window").setup({ override_cmdline = true }) -- require("utils.cmd_window").setup({ override_cmdline = true })
-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━ BLINKY CURSOR ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
-- Setup the blinky cursor if it is enabled
if vim.g.blinky ~= false then
require("utils").blinky.enable()
else
require("utils").blinky.disable()
end
end end
return M return M
+63
View File
@@ -0,0 +1,63 @@
---@module "data.autocmd"
--- This module defines the autocommands for the Neovim configuration.
-- ╭─────────────────────────────────────────────────────────╮
-- │ Autocommands │
-- ╰─────────────────────────────────────────────────────────╯
local M = {}
M.minifiles = function(opts)
vim.api.nvim_create_autocmd("User", {
pattern = "MiniFilesBufferCreate",
callback = function(args)
local buf_id = args.data.buf_id
vim.keymap.set(
"n",
opts.mappings and opts.mappings.toggle_hidden or "g.",
toggle_dotfiles,
{ buffer = buf_id, desc = "Toggle hidden files" }
)
vim.keymap.set(
"n",
opts.mappings and opts.mappings.change_cwd or "gc",
files_set_cwd,
{ buffer = args.data.buf_id, desc = "Set cwd" }
)
map_split(
buf_id,
opts.mappings and opts.mappings.go_in_horizontal or "<C-w>s",
"horizontal",
false
)
map_split(
buf_id,
opts.mappings and opts.mappings.go_in_vertical or "<C-w>v",
"vertical",
false
)
map_split(
buf_id,
opts.mappings and opts.mappings.go_in_horizontal_plus or "<C-w>S",
"horizontal",
true
)
map_split(
buf_id,
opts.mappings and opts.mappings.go_in_vertical_plus or "<C-w>V",
"vertical",
true
)
end,
})
vim.api.nvim_create_autocmd("User", {
pattern = "MiniFilesActionRename",
callback = function(event)
LazyVim.lsp.on_rename(event.data.from, event.data.to)
end,
})
end
return M
+16 -16
View File
@@ -1,13 +1,17 @@
--- @module "data.cmd"
--- This module contains the commands for the plugins.
-- ╭─────────────────────────────────────────────────────────╮ -- ╭─────────────────────────────────────────────────────────╮
-- │ CMD DATA │ -- │ CMD DATA │
-- ╰─────────────────────────────────────────────────────────╯ -- ╰─────────────────────────────────────────────────────────╯
local M = {} local M = {}
--- Autosave plugin cmds
M.autosave = { M.autosave = {
"ASToggle", "ASToggle",
} }
--- Codesnap plugin cmds
M.codesnap = { M.codesnap = {
"CodeSnap", "CodeSnap",
"CodeSnapSave", "CodeSnapSave",
@@ -15,37 +19,25 @@ M.codesnap = {
"CodeSnapASCII", "CodeSnapASCII",
} }
M.diffview = { --- Gists plugin cmds
"DiffviewOpen",
"DiffviewClose",
"DiffviewToggleFiles",
"DiffviewFocusFiles",
"DiffviewRefresh",
"DiffviewFileHistory",
"DiffviewLog",
}
M.fugit = {
"Fugit2",
"Fugit2Diff",
"Fugit2Graph",
}
M.gist = { M.gist = {
"GistCreate", "GistCreate",
"GistCreateFromFile", "GistCreateFromFile",
"GistsList", "GistsList",
} }
--- Gx plugin cmds
M.gx = { M.gx = {
"Browse", "Browse",
} }
--- Kitty-Scrollback plugin cmds
M.kitty_scrollback = { M.kitty_scrollback = {
"KittyScrollbackGenerateKittens", "KittyScrollbackGenerateKittens",
"KittyScrollbackCheckHealth", "KittyScrollbackCheckHealth",
} }
--- LazyGit plugin cmds
M.lazygit = { M.lazygit = {
"LazyGit", "LazyGit",
"LazyGitConfig", "LazyGitConfig",
@@ -54,8 +46,10 @@ M.lazygit = {
"LazyGitFilterCurrentFile", "LazyGitFilterCurrentFile",
} }
--- Nekifoch plugin cmds
M.nekifoch = "Nekifoch" M.nekifoch = "Nekifoch"
--- Thanks plugin cmds
M.thanks = { M.thanks = {
"ThanksAll", "ThanksAll",
"ThanksGithubAuth", "ThanksGithubAuth",
@@ -63,31 +57,37 @@ M.thanks = {
"ThanksClearCache", "ThanksClearCache",
} }
--- Gitlinker plugin cmds
M.gitlinker = { M.gitlinker = {
"GitLink", "GitLink",
} }
--- Qalc plugin cmds
M.qalc = { M.qalc = {
"Qalc", "Qalc",
"QalcAttach", "QalcAttach",
"QalcYank", "QalcYank",
} }
--- Ripsub plugin cmds
M.ripsub = { M.ripsub = {
"RipSubstitute", "RipSubstitute",
} }
--- Suda plugin cmds
M.suda = { M.suda = {
"SudaWrite", "SudaWrite",
"SudaRead", "SudaRead",
} }
--- Transparent plugin cmds
M.transparent = { M.transparent = {
"TransparentEnable", "TransparentEnable",
"TransparentDisable", "TransparentDisable",
"TransparentToggle", "TransparentToggle",
} }
--- Trouble plugin cmds
M.trouble = { M.trouble = {
"Trouble", "Trouble",
} }
+49 -3
View File
@@ -1,10 +1,55 @@
---@module "data.dash"
--- This module contains the data for the dashboard plugins.
-- ╭─────────────────────────────────────────────────────────╮ -- ╭─────────────────────────────────────────────────────────╮
-- │ DASH DATA │ -- │ DASH DATA │
-- ╰─────────────────────────────────────────────────────────╯ -- ╰─────────────────────────────────────────────────────────╯
local M = {} local M = {}
M.choices = { --- Function to setup the Alpha dashboard options
---@return table The alpha dashboard options
M.alpha = {
opts = function()
local dashboard = require("alpha.themes.dashboard")
local logo = [[
██████╗ ██████╗ ██████╗ ████████╗██╗███████╗███████╗████████╗ ███╗ ██╗██╗ ██╗██╗███╗ ███╗
██╔══██╗██╔═══██╗██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝╚══██╔══╝ ████╗ ██║██║ ██║██║████╗ ████║
██████╔╝██║ ██║██║ ██║ ██║ ██║█████╗ ███████╗ ██║ ██╔██╗ ██║██║ ██║██║██╔████╔██║
██╔══██╗██║ ██║██║ ██║ ██║ ██║██╔══╝ ╚════██║ ██║  ██║╚██╗██║╚██╗ ██╔╝██║██║╚██╔╝██║
██║ ██║╚██████╔╝╚██████╔╝ ██║ ██║███████╗███████║ ██║ ██║ ╚████║ ╚████╔╝ ██║██║ ╚═╝ ██║
╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚══════╝ ╚═╝ ╚═╝ ╚═══╝ ╚═══╝ ╚═╝╚═╝ ╚═╝
]]
dashboard.section.header.val = vim.split(logo, "\n")
-- stylua: ignore start
dashboard.section.buttons.val = {
---@diagnostic disable: param-type-mismatch
dashboard.button("f", "" .. " Find file", LazyVim.pick()),
dashboard.button("n", "" .. " New file", [[<cmd> ene <BAR> startinsert <cr>]]),
dashboard.button("r", "" .. " Recent files", LazyVim.pick("oldfiles")),
dashboard.button("g", "" .. " Grep text", LazyVim.pick("live_grep")),
dashboard.button("z", "" .. " LazyGit", "<cmd>lua require('config.rootiest').toggle_lazygit_float() <cr>"),
dashboard.button("c", "" .. " Config", LazyVim.pick.config_files()),
dashboard.button("s", "" .. " Restore Session", [[<cmd> lua require("persistence").load() <cr>]]),
dashboard.button("S", "" .. " Remote Session", [[<cmd> lua require("config.rootiest").load_remote() <cr>]]),
dashboard.button("l", "󰒲 " .. " Lazy", "<cmd> Lazy <cr>"),
dashboard.button("q", "" .. " Quit", "<cmd> qa <cr>"),
}
-- stylua: ignore end
for _, button in ipairs(dashboard.section.buttons.val) do
button.opts.hl = "AlphaButtons"
button.opts.hl_shortcut = "AlphaShortcut"
end
dashboard.section.header.opts.hl = "AlphaHeader"
dashboard.section.buttons.opts.hl = "AlphaButtons"
dashboard.section.footer.opts.hl = "AlphaFooter"
dashboard.opts.layout[1].val = 10
return dashboard
end,
}
M.dashboard_nvim = {
choices = {
{ -- Find File { -- Find File
action = "lua LazyVim.pick()()", action = "lua LazyVim.pick()()",
desc = " Find File", desc = " Find File",
@@ -50,8 +95,8 @@ M.choices = {
{ -- Remote Session { -- Remote Session
action = 'lua require("config.rootiest").load_remote()', action = 'lua require("config.rootiest").load_remote()',
desc = " Remote Session", desc = " Remote Session",
icon = "󰢹 ", icon = " ",
key = "S", key = "s",
}, },
{ -- Lazy { -- Lazy
action = "Lazy", action = "Lazy",
@@ -67,6 +112,7 @@ M.choices = {
icon = "", icon = "",
key = "q", key = "q",
}, },
},
} }
return M return M
+21 -1
View File
@@ -1,12 +1,18 @@
---@module "data.deps" ---@module "data.deps"
--- This module aggregates various dependencies used throughout the configuration. --- This module aggregates various dependencies used throughout the configuration.
--- It provides a centralized way to access dependencies. --- It provides a centralized way to access dependencies.
-- ╭─────────────────────────────────────────────────────────╮
-- │ DEPENDENCIES │
-- ╰─────────────────────────────────────────────────────────╯
local M = {} local M = {}
--- nvim-cmp dependencies
---@return table The nvim-cmp dependencies
M.cmp = { M.cmp = {
{ {
"L3MON4D3/LuaSnip", "L3MON4D3/LuaSnip",
--- Function to build the dependencies
---@return string|nil The command to build the dependencies
build = (function() build = (function()
if vim.fn.has("win32") == 1 or vim.fn.executable("make") == 0 then if vim.fn.has("win32") == 1 or vim.fn.executable("make") == 0 then
return return
@@ -25,6 +31,8 @@ M.cmp = {
{ {
"petertriho/cmp-git", "petertriho/cmp-git",
opts = {}, opts = {},
--- Function to configure the cmp-git dependency
---@return table|nil The cmp-git config
config = function() config = function()
local cmp = require("cmp") local cmp = require("cmp")
cmp.setup.filetype("gitcommit", { cmp.setup.filetype("gitcommit", {
@@ -60,42 +68,51 @@ M.cmp = {
"Dynge/gitmoji.nvim", "Dynge/gitmoji.nvim",
} }
--- Gx plugin dependencies
M.gx = { M.gx = {
"nvim-lua/plenary.nvim", "nvim-lua/plenary.nvim",
} }
--- Hardtime plugin dependencies
M.hardtime = { M.hardtime = {
"MunifTanjim/nui.nvim", "MunifTanjim/nui.nvim",
"nvim-lua/plenary.nvim", "nvim-lua/plenary.nvim",
} }
--- LazyGit plugin dependencies
M.lazygit = { M.lazygit = {
"nvim-telescope/telescope.nvim", "nvim-telescope/telescope.nvim",
"nvim-lua/plenary.nvim", "nvim-lua/plenary.nvim",
} }
--- Lualine plugin dependencies
M.lualine = { M.lualine = {
{ "bezhermoso/todos-lualine.nvim" }, { "bezhermoso/todos-lualine.nvim" },
{ "folke/todo-comments.nvim" }, { "folke/todo-comments.nvim" },
} }
--- Minuet plugin dependencies
M.minuet = { M.minuet = {
{ "nvim-lua/plenary.nvim" }, { "nvim-lua/plenary.nvim" },
{ "hrsh7th/nvim-cmp" }, { "hrsh7th/nvim-cmp" },
} }
--- MusicControls plugin dependencies
M.musiccontrols = { M.musiccontrols = {
"rcarriga/nvim-notify", "rcarriga/nvim-notify",
} }
--- Table for plugins that need Telescope as a dependency
M.needs_telescope = { M.needs_telescope = {
"nvim-telescope/telescope.nvim", "nvim-telescope/telescope.nvim",
} }
--- Table for plugins that need Treesitter as a dependency
M.needs_treesitter = { M.needs_treesitter = {
"nvim-treesitter/nvim-treesitter", "nvim-treesitter/nvim-treesitter",
} }
--- Neotest plugin adapters and dependencies
M.neotest = { M.neotest = {
adapters = { adapters = {
"neotest-plenary", "neotest-plenary",
@@ -114,16 +131,19 @@ M.neotest = {
}, },
} }
--- Recorder plugin dependencies
M.recorder = { M.recorder = {
"rcarriga/nvim-notify", "rcarriga/nvim-notify",
} }
--- nvim-remote plugin dependencies
M.remotenvim = { M.remotenvim = {
"nvim-lua/plenary.nvim", -- For standard functions "nvim-lua/plenary.nvim", -- For standard functions
"MunifTanjim/nui.nvim", -- To build the plugin UI "MunifTanjim/nui.nvim", -- To build the plugin UI
"nvim-telescope/telescope.nvim", -- For picking b/w different remote methods "nvim-telescope/telescope.nvim", -- For picking b/w different remote methods
} }
--- Zenbones plugin dependencies
M.zenbones = { M.zenbones = {
"rktjmp/lush.nvim", "rktjmp/lush.nvim",
} }
+305 -65
View File
@@ -1,3 +1,5 @@
---@module "data.func"
--- This module contains utility functions used throughout the configuration.
-- ╭─────────────────────────────────────────────────────────╮ -- ╭─────────────────────────────────────────────────────────╮
-- │ Utility Functions │ -- │ Utility Functions │
-- ╰─────────────────────────────────────────────────────────╯ -- ╰─────────────────────────────────────────────────────────╯
@@ -5,10 +7,7 @@
-- Define a namespace for utility functions -- Define a namespace for utility functions
local M = {} local M = {}
-- Load data module ---@function Check if the terminal is kitty
local data = require("data")
--- Check if the terminal is kitty
---@return boolean condition true if the terminal is kitty, false otherwise ---@return boolean condition true if the terminal is kitty, false otherwise
function M.is_kitty() function M.is_kitty()
local term = os.getenv("TERM") or "" local term = os.getenv("TERM") or ""
@@ -16,7 +15,7 @@ function M.is_kitty()
return kit ~= nil return kit ~= nil
end end
--- Check if using kitty-scrollback ---@function Check if using kitty-scrollback
---@return boolean condition true if using kitty-scrollback, false otherwise ---@return boolean condition true if using kitty-scrollback, false otherwise
function M.is_kitty_scrollback() function M.is_kitty_scrollback()
if vim.env.KITTY_SCROLLBACK_NVIM == "true" then if vim.env.KITTY_SCROLLBACK_NVIM == "true" then
@@ -25,7 +24,7 @@ function M.is_kitty_scrollback()
return false return false
end end
--- Check if the terminal is alacritty ---@function Check if the terminal is alacritty
---@return boolean condition true if the terminal is alacritty, false otherwise ---@return boolean condition true if the terminal is alacritty, false otherwise
function M.is_alacritty() function M.is_alacritty()
local term = os.getenv("TERM") or "" local term = os.getenv("TERM") or ""
@@ -33,7 +32,7 @@ function M.is_alacritty()
return alc ~= nil return alc ~= nil
end end
--- Check if the terminal is tmux ---@function Check if the terminal is tmux
---@return boolean condition true if the terminal is tmux, false otherwise ---@return boolean condition true if the terminal is tmux, false otherwise
function M.is_tmux() function M.is_tmux()
local tterm = os.getenv("TERM") local tterm = os.getenv("TERM")
@@ -49,7 +48,7 @@ function M.is_tmux()
return false return false
end end
--- Check if the terminal is wezterm ---@function Check if the terminal is wezterm
---@return boolean condition true if the terminal is wezterm, false otherwise ---@return boolean condition true if the terminal is wezterm, false otherwise
function M.is_wezterm() function M.is_wezterm()
local wterm = os.getenv("TERM_PROGRAM") local wterm = os.getenv("TERM_PROGRAM")
@@ -59,7 +58,7 @@ function M.is_wezterm()
return false return false
end end
--- Check if the terminal is neovide ---@function Check if the terminal is neovide
---@return boolean condition true if the terminal is neovide, false otherwise ---@return boolean condition true if the terminal is neovide, false otherwise
function M.is_neovide() function M.is_neovide()
local neovide = vim.g.neovide local neovide = vim.g.neovide
@@ -69,7 +68,7 @@ function M.is_neovide()
return false return false
end end
--- Check if the terminal is ssh ---@function Check if the terminal is ssh
---@return boolean condition true if the terminal is ssh, false otherwise ---@return boolean condition true if the terminal is ssh, false otherwise
function M.is_ssh() function M.is_ssh()
local ssh = os.getenv("SSH_TTY") or false local ssh = os.getenv("SSH_TTY") or false
@@ -79,7 +78,7 @@ function M.is_ssh()
return false return false
end end
--- Check if OS is Windows ---@function Check if OS is Windows
---@return boolean condition true if the OS is Windows, false otherwise ---@return boolean condition true if the OS is Windows, false otherwise
function M.is_windows() function M.is_windows()
local win = vim.fn.has("win32") == 1 or vim.fn.has("win64") == 1 local win = vim.fn.has("win32") == 1 or vim.fn.has("win64") == 1
@@ -89,7 +88,7 @@ function M.is_windows()
return false return false
end end
--- Check if OS is macOS ---@function Check if OS is macOS
---@return boolean condition true if the OS is macOS, false otherwise ---@return boolean condition true if the OS is macOS, false otherwise
function M.is_mac() function M.is_mac()
local mac = vim.fn.has("macunix") local mac = vim.fn.has("macunix")
@@ -99,7 +98,7 @@ function M.is_mac()
return false return false
end end
--- Check if OS is Linux ---@function Check if OS is Linux
---@return boolean condition true if the OS is Linux, false otherwise ---@return boolean condition true if the OS is Linux, false otherwise
function M.is_linux() function M.is_linux()
local lin = vim.fn.has("unix") local lin = vim.fn.has("unix")
@@ -109,14 +108,14 @@ function M.is_linux()
return false return false
end end
--- Get the name of the OS. ---@function Get the name of the OS.
--- @param format string The format of the OS name. ---@param format string The format of the OS name.
--- Possible values: --- Possible values:
--- - "verbose": Returns the full name of the OS. --- - "verbose": Returns the full name of the OS.
--- - "short": Returns a short name or abbreviation. --- - "short": Returns a short name or abbreviation.
--- - "code": Returns a code or identifier. --- - "code": Returns a code or identifier.
--- - "platform": Returns either "windows", "osx", or "linux". --- - "platform": Returns either "windows", "osx", or "linux".
--- @return string os The name of the OS. ---@return string os The name of the OS.
function M.get_os(format) function M.get_os(format)
---@diagnostic disable-next-line: undefined-field ---@diagnostic disable-next-line: undefined-field
local uname = vim.loop and vim.loop.os_uname and vim.loop.os_uname() or {} local uname = vim.loop and vim.loop.os_uname and vim.loop.os_uname() or {}
@@ -219,24 +218,64 @@ function M.get_os(format)
end end
end end
--- Function to send a notification ---@function Function to send a notification
---@param message string The message to send ---@param message string The message to send
---@param level string The level of the notification (default: "info") ---@param level string|nil The level of the notification (default: "info")
---@param title string|nil The title of the notification
---@return boolean condition true if the notification was sent successfully, false otherwise ---@return boolean condition true if the notification was sent successfully, false otherwise
function M.notify(message, level) function M.notify(message, level, title)
level = level or "info" level = level or "info"
if title then
vim.notify(message, vim.log.levels[level:upper()], { title = title })
else
vim.notify(message, vim.log.levels[level:upper()]) vim.notify(message, vim.log.levels[level:upper()])
end
return true return true
end end
--- Function to reload all plugins. ---@function Function to reload all plugins.
--- This is a messy operation. It's not recommended to use it. --- This is a messy operation. It's not recommended to use it.
--- If you do, please define the exclusion list in your config.lua file. --- If you do, please define the exclusion list in your config.lua file.
--- @see data.types.plugin_reloader.exclusion_list --- Suggested defaults:
--- @return nil --- vim.g.plugin_reloader_exclusion_list = {
--- ["lazy.nvim"] = true,
--- ["noice.nvim"] = true,
--- ["unception.nvim"] = true,
--- ["nvim-unception"] = true,
--- ["nui.nvim"] = true,
--- ["packer.nvim"] = true,
--- ["trouble.nvim"] = true,
--- ["which-key.nvim"] = true,
--- },
---
--- You should add any other plugins that won't handle a live reload
--- well to this exclusion list and define it in your configuration.
--- The exclusion list can be defined with:
--- 'vim.g.plugin_reloader_exclusion_list'
---@see data.types.plugin_reloader.exclusion_list
---@return nil
function M.reload_all_plugins() function M.reload_all_plugins()
-- Define the exclusion list -- Define the exclusion list
local exclude = data.types.plugin_reloader.exclusion_list local exclude = {}
if vim.g.plugin_reloader.exclusion_list then
-- Use global variable if provided
exclude = vim.g.plugin_reloader.exclusion_list
elseif pcall(require, "data.types") then
-- Use data.types if available
exclude = require("data.types").plugin_reloader.exclusion_list
else
-- Fallback to default
exclude = {
["lazy.nvim"] = true,
["noice.nvim"] = true,
["unception.nvim"] = true,
["nvim-unception"] = true,
["nui.nvim"] = true,
["packer.nvim"] = true,
["trouble.nvim"] = true,
["which-key.nvim"] = true,
}
end
-- Get the list of currently loaded plugins -- Get the list of currently loaded plugins
local plugins = require("lazy.core.config").plugins local plugins = require("lazy.core.config").plugins
@@ -249,30 +288,55 @@ function M.reload_all_plugins()
end end
end end
--- Check if a plugin is installed. ---@function Check if a plugin is installed.
---@param plugin string The name of the plugin module to check. ---@param plugins string|table The name of the plugin module(s) to check.
---@return boolean condition true if the plugin is installed, false otherwise. --- Options:
function M.is_installed(plugin) --- - string: The name of the plugin module to check.
-- Check for lazy.nvim --- - table: A list of plugin modules to check.
---@return boolean|table condition The installed state of the plugin(s).
--- - boolean: The installed state of the plugin.
--- - table: A list of installed states of the plugins.
--- - boolean: The installed state of the plugin.
--- The return type is determined based on the input type.
--- If the input is a table of plugin modules, the return type is a table.
function M.is_installed(plugins)
local is_single = type(plugins) == "string"
if type(plugins) == "string" then
plugins = { plugins }
end
local installed_plugins = {}
for _, plugin in ipairs(plugins) do
local installed = false
local lazy_installed = pcall(require, "lazy") local lazy_installed = pcall(require, "lazy")
if lazy_installed then if lazy_installed then
return require("lazy.core.config").plugins[plugin] ~= nil installed = require("lazy.core.config").plugins[plugin] ~= nil
end end
-- Check for packer.nvim
local packer_installed = pcall(require, "packer_plugins") local packer_installed = pcall(require, "packer_plugins")
if packer_installed then if packer_installed then
---@diagnostic disable-next-line: undefined-field ---@diagnostic disable-next-line: undefined-field
return _G.packer_plugins and _G.packer_plugins[plugin] ~= nil installed = _G.packer_plugins and _G.packer_plugins[plugin] ~= nil
end end
-- Check for vim-plug
if vim.fn.exists("g:plugs") == 1 then if vim.fn.exists("g:plugs") == 1 then
return vim.g.plugs[plugin] ~= nil installed = vim.g.plugs[plugin] ~= nil
end
if not installed then
local has_plug = pcall(require, plugin)
if has_plug then
installed = true
end
end
installed_plugins[plugin] = installed
end
if is_single then
return installed_plugins[plugins[1]]
else
return installed_plugins
end end
-- Plugin not found
return false
end end
--- Condition function to check filetype is not in list ---@function Condition function to check filetype is not in list
---@param disabled_filetypes string[] The list of filetypes to check ---@param disabled_filetypes string[] The list of filetypes to check
---@return boolean|function true if filetype is not in list, false otherwise ---@return boolean|function true if filetype is not in list, false otherwise
function M.disable_on_filetypes(disabled_filetypes) function M.disable_on_filetypes(disabled_filetypes)
@@ -282,16 +346,18 @@ function M.disable_on_filetypes(disabled_filetypes)
end end
end end
--- Helper function to add keymaps with common properties ---@function Helper function to add keymaps with common properties
---@param lhs string|table The keybind (or list of keybinds) ---@param lhs string|table The keybind (or list of keybinds)
--- This field can be the following: --- This field can be the following:
--- - A string representing the keybind --- - A string representing the keybind
--- - A list of strings representing a set of keybinds --- - A list of strings representing a set of keybinds
--- - A table of multiple keybind specifications --- - A table of multiple keybind specifications
---@param rhs string|function The function to execute when the key is pressed --- This field is required.
---@param rhs string|function|nil The function to execute when the key is pressed
--- This field can be the following: --- This field can be the following:
--- - A string representing the vimscript command --- - A string representing the vimscript command
--- - A lua function (only when using which-key.nvim or global keymaps) --- - A lua function (only when using which-key.nvim or global keymaps)
--- This field is required.
---@param desc string|nil The description of the keybind (optional) ---@param desc string|nil The description of the keybind (optional)
--- This field can be the following: --- This field can be the following:
--- - A string representing the description --- - A string representing the description
@@ -310,6 +376,12 @@ end
--- This field can be the following: --- This field can be the following:
--- - A number representing the buffer --- - A number representing the buffer
--- This option is incompatible with some extended keymap options --- This option is incompatible with some extended keymap options
---@param hidden boolean|nil Whether the keybind should be hidden (optional)
--- This field can be the following:
--- - A boolean representing whether to hide the keymap in which-key menus
--- This option is only compatible with which-key configurations
--- It will be ignored if which-key is not installed
--- The default value is false
---@return boolean condition true if the keybind was added, false otherwise ---@return boolean condition true if the keybind was added, false otherwise
--- There are three main types of keymaps: --- There are three main types of keymaps:
--- - Global keymaps --- - Global keymaps
@@ -334,7 +406,8 @@ function M.add_keymap(
mode, -- Mode(s) in which the keybind should be added mode, -- Mode(s) in which the keybind should be added
icon, -- Icon to use for the keybind menu icon, -- Icon to use for the keybind menu
group, -- Group to use for the keybind menu group, -- Group to use for the keybind menu
bufnr -- Buffer number to add the keymap to bufnr, -- Buffer number to add the keymap to
hidden
) )
-- Check if which-key.nvim is installed -- Check if which-key.nvim is installed
if M.is_installed("which-key.nvim") and not bufnr then if M.is_installed("which-key.nvim") and not bufnr then
@@ -347,6 +420,7 @@ function M.add_keymap(
mode = mode or "n", -- Default to "n" (normal mode) if mode is not provided mode = mode or "n", -- Default to "n" (normal mode) if mode is not provided
icon = icon, -- Icon to use for the keybind icon = icon, -- Icon to use for the keybind
group = group, -- Group to add the keybind to group = group, -- Group to add the keybind to
hidden = hidden, -- Hide the keybind in which-key menus
}, },
-- stylua: ignore end -- stylua: ignore end
}) })
@@ -369,6 +443,7 @@ function M.add_keymap(
vim.keymap.set( vim.keymap.set(
keymap_mode, -- Mode(s) in which the keybind should be added keymap_mode, -- Mode(s) in which the keybind should be added
keymap_lhs, -- The keybind keymap_lhs, -- The keybind
---@diagnostic disable-next-line: param-type-mismatch
keymap_rhs, -- Function to execute when the key is pressed keymap_rhs, -- Function to execute when the key is pressed
{ desc = keymap_desc } -- Description of the keybind { desc = keymap_desc } -- Description of the keybind
) )
@@ -390,6 +465,7 @@ function M.add_keymap(
bufnr, bufnr,
keymap_mode, keymap_mode,
keymap_lhs, keymap_lhs,
---@diagnostic disable-next-line: param-type-mismatch
keymap_rhs, keymap_rhs,
{ desc = keymap_desc } { desc = keymap_desc }
) )
@@ -412,6 +488,7 @@ function M.add_keymap(
vim.keymap.set( vim.keymap.set(
mode or "n", -- Default to "n" (normal mode) if mode is not provided mode or "n", -- Default to "n" (normal mode) if mode is not provided
lhs, -- The keybind lhs, -- The keybind
---@diagnostic disable-next-line: param-type-mismatch
rhs, -- Function to execute when the key is pressed rhs, -- Function to execute when the key is pressed
{ desc = desc } -- Description of the keybind and optional buffer number { desc = desc } -- Description of the keybind and optional buffer number
) )
@@ -433,6 +510,7 @@ function M.add_keymap(
bufnr, bufnr,
mode or "n", mode or "n",
lhs, lhs,
---@diagnostic disable-next-line: param-type-mismatch
rhs, rhs,
{ desc = desc } { desc = desc }
) )
@@ -451,7 +529,152 @@ function M.add_keymap(
end end
end end
--- Helper function to remove keymaps ---@function Add a new keymap with optional which-key integration
---@param lhs string|table The keybind or a table containing multiple keymaps
---@param rhs string|function|nil The function to execute when the keybind is pressed
---@param desc string|nil The description of the keybind
---@param mode string|table|nil The mode(s) in which the keybind should be added
---@param icon string|nil The icon to associate with the which-key entry (optional)
---@param group string|nil The which-key group to add the keybind to (optional)
---@param bufnr number|nil The buffer number to add the keymap to (optional, for buffer-specific mappings)
---@return boolean success True if all keymaps were successfully added, false otherwise
function M.add_km(lhs, rhs, desc, mode, icon, group, bufnr)
local function is_mode(value)
-- Identify common vim modes; this can be expanded based on requirements
local common_modes =
{ n = true, i = true, v = true, x = true, s = true, o = true, c = true }
if type(value) == "string" and #value == 1 then
return common_modes[value] ~= nil
elseif type(value) == "table" then
for _, v in ipairs(value) do
if not common_modes[v] then
return false
end
end
return true
end
return false
end
local function correct_swapped_params()
-- Try to correct common mistakes where rhs and mode might be swapped
if type(rhs) == "string" and is_mode(rhs) then
if type(mode) == "string" or type(mode) == "function" then
-- Swap them if it looks like rhs is mode and mode is rhs
---@diagnostic disable-next-line: cast-local-type
rhs, mode = mode, rhs
elseif type(mode) == "table" and is_mode(mode) then
-- Swap if rhs is mode and mode is list of modes
---@diagnostic disable-next-line: cast-local-type
rhs, mode = mode, rhs
end
elseif
type(rhs) == "function"
and type(mode) == "string"
and not is_mode(mode)
then
-- This checks if mode is actually an rhs-like string or command
rhs, mode = mode, rhs
end
end
-- Attempt to correct any common parameter swapping issues
correct_swapped_params()
-- Helper function to set keymaps using native functions
local function set_keymap(
keymap_lhs,
keymap_rhs,
keymap_desc,
keymap_mode,
keymap_bufnr
)
if keymap_bufnr then
vim.api.nvim_buf_set_keymap(
keymap_bufnr,
keymap_mode,
keymap_lhs,
keymap_rhs,
{ desc = keymap_desc }
)
else
vim.keymap.set(
keymap_mode,
keymap_lhs,
keymap_rhs,
{ desc = keymap_desc }
)
end
end
-- Determine if which-key is available and should be used
local use_which_key = M.is_installed
and M.is_installed("which-key.nvim")
and not bufnr
-- Process a single keymap entry
---@function Helper function to process a single keymap
---@param keymap table The table containing a keymap
---@return boolean success True if the keymap was processed successfully, false otherwise
local function process_keymap(keymap)
local keymap_lhs = type(keymap) == "table" and keymap.lhs or lhs
local keymap_rhs = type(keymap) == "table" and (keymap.rhs or rhs) or rhs
local keymap_desc = type(keymap) == "table" and (keymap.desc or desc)
or desc
local keymap_mode = type(keymap) == "table" and (keymap.mode or mode)
or mode
or "n"
local keymap_icon = type(keymap) == "table" and (keymap.icon or icon)
or icon
local keymap_group = type(keymap) == "table" and (keymap.group or group)
or group
-- Use which-key if possible; fallback to native keymap functions if not
if use_which_key then
require("which-key").add({
[keymap_lhs] = {
keymap_rhs,
keymap_desc,
mode = keymap_mode,
icon = keymap_icon,
group = keymap_group,
},
})
else
-- Attempt to fall back to the native keymap functions
local success, err_msg = pcall(
set_keymap,
keymap_lhs,
keymap_rhs,
keymap_desc,
keymap_mode,
bufnr
)
if not success then
-- Notify the user about the failed mapping
M.notify(("Failed to map %s: %s"):format(keymap_lhs, err_msg), "WARN")
return false
end
end
return true
end
-- Handle the scenario where lhs is a table containing multiple keymaps
if type(lhs) == "table" then
for _, keymap in ipairs(lhs) do
if not process_keymap(keymap) then
return false
end
end
return true
else
-- Handle a single keymap entry
return process_keymap({})
end
end
---@function Helper function to remove keymaps
---@param lhs string The keybind ---@param lhs string The keybind
---@param mode string|nil The mode in which the keybind should be removed (optional) ---@param mode string|nil The mode in which the keybind should be removed (optional)
---@param bufnr number|nil The buffer number to remove the keymap from (optional) ---@param bufnr number|nil The buffer number to remove the keymap from (optional)
@@ -465,13 +688,13 @@ function M.rm_keymap(
) )
mode = mode or "n" -- Default to "n" (normal mode) if mode is not provided mode = mode or "n" -- Default to "n" (normal mode) if mode is not provided
--- @class Keymap ---@class Keymap
--- @field lhs string The keybind ---@field lhs string The keybind
--- @field rhs string|function The function or command associated with the keybind ---@field rhs string|function The function or command associated with the keybind
if bufnr then if bufnr then
-- If a buffer number is provided, remove the keymap from the specified buffer -- If a buffer number is provided, remove the keymap from the specified buffer
--- @type Keymap[] ---@type Keymap[]
local keymaps = vim.api.nvim_buf_get_keymap(bufnr, mode) local keymaps = vim.api.nvim_buf_get_keymap(bufnr, mode)
for _, keymap in pairs(keymaps) do for _, keymap in pairs(keymaps) do
if keymap.lhs and keymap.lhs == lhs then if keymap.lhs and keymap.lhs == lhs then
@@ -481,7 +704,7 @@ function M.rm_keymap(
end end
else else
-- If no buffer number is provided, remove the global keymap -- If no buffer number is provided, remove the global keymap
--- @type Keymap[] ---@type Keymap[]
local keymaps = vim.api.nvim_get_keymap(mode) local keymaps = vim.api.nvim_get_keymap(mode)
for _, keymap in pairs(keymaps) do for _, keymap in pairs(keymaps) do
if keymap.lhs and keymap.lhs == lhs then if keymap.lhs and keymap.lhs == lhs then
@@ -494,7 +717,7 @@ function M.rm_keymap(
return false -- Indicate that the keymap did not exist return false -- Indicate that the keymap did not exist
end end
--- Helper function to add a mark ---@function Helper function to add a mark
---@param mark string The mark to add ---@param mark string The mark to add
---@param line integer The line to add the mark to ---@param line integer The line to add the mark to
---@param col integer The column to add the mark to ---@param col integer The column to add the mark to
@@ -505,7 +728,7 @@ function M.add_mark(mark, line, col)
return true -- Indicate that the mark was successfully added return true -- Indicate that the mark was successfully added
end end
--- Helper function to remove a mark ---@function Helper function to remove a mark
---@param mark string The mark to remove ---@param mark string The mark to remove
---@return boolean condition true if the mark was removed, false otherwise ---@return boolean condition true if the mark was removed, false otherwise
function M.rm_mark(mark) function M.rm_mark(mark)
@@ -522,25 +745,25 @@ function M.rm_mark(mark)
return false -- Indicate that the mark did not exist return false -- Indicate that the mark did not exist
end end
--- Function to check if buffer is modified ---@function Function to check if buffer is modified
---@return boolean condition true if buffer is modified, false otherwise ---@return boolean condition true if buffer is modified, false otherwise
function M.is_buffer_modified() function M.is_buffer_modified()
return vim.bo.modified return vim.bo.modified
end end
--- Function to check if buffer is empty ---@function Function to check if buffer is empty
---@return boolean condition true if buffer is empty, false otherwise ---@return boolean condition true if buffer is empty, false otherwise
function M.is_buffer_empty() function M.is_buffer_empty()
return vim.fn.empty(vim.fn.expand("%:t")) == 1 return vim.fn.empty(vim.fn.expand("%:t")) == 1
end end
--- Function to check if buffer is read-only ---@function Function to check if buffer is read-only
---@return boolean condition true if buffer is read-only, false otherwise ---@return boolean condition true if buffer is read-only, false otherwise
function M.is_buffer_readonly() function M.is_buffer_readonly()
return vim.bo.readonly return vim.bo.readonly
end end
--- Function to check if file exists ---@function Function to check if file exists
---@param filepath string The path to the file ---@param filepath string The path to the file
---@return boolean condition true if file exists, false otherwise ---@return boolean condition true if file exists, false otherwise
function M.file_exists(filepath) function M.file_exists(filepath)
@@ -551,7 +774,7 @@ function M.file_exists(filepath)
return f ~= nil return f ~= nil
end end
--- Function to get the current git branch ---@function Function to get the current git branch
---@return string branch git branch name or "No branch" ---@return string branch git branch name or "No branch"
function M.get_git_branch() function M.get_git_branch()
local branch = vim.fn.systemlist("git rev-parse --abbrev-ref HEAD")[1] local branch = vim.fn.systemlist("git rev-parse --abbrev-ref HEAD")[1]
@@ -562,7 +785,7 @@ function M.get_git_branch()
end end
end end
--- Function to get the current git commit hash ---@function Function to get the current git commit hash
---@return string The current git commit hash or "No commit hash" ---@return string The current git commit hash or "No commit hash"
function M.get_git_commit_hash() function M.get_git_commit_hash()
local commit_hash = vim.fn.systemlist("git rev-parse --short HEAD")[1] local commit_hash = vim.fn.systemlist("git rev-parse --short HEAD")[1]
@@ -573,7 +796,7 @@ function M.get_git_commit_hash()
end end
end end
--- Function to run a shell command ---@function Function to run a shell command
---@param cmd string The command to run ---@param cmd string The command to run
---@return string|nil result The output of the command ---@return string|nil result The output of the command
function M.run_shell_command(cmd) function M.run_shell_command(cmd)
@@ -584,12 +807,12 @@ function M.run_shell_command(cmd)
return result return result
else else
-- Handle the error case where `handle` is nil -- Handle the error case where `handle` is nil
vim.notify("Failed to run the command: " .. cmd, vim.log.levels.ERROR) M.notify("Failed to run the command: " .. cmd, "ERROR")
return nil return nil
end end
end end
--- Function to get the dimensions of the current window ---@function Function to get the dimensions of the current window
---@param format string The format of the dimensions ---@param format string The format of the dimensions
---@return string|table dimensions dimensions of the current window ---@return string|table dimensions dimensions of the current window
function M.get_ws_dimensions(format) function M.get_ws_dimensions(format)
@@ -614,7 +837,7 @@ function M.get_ws_dimensions(format)
end end
end end
--- Function to get the cursor position ---@function Function to get the cursor position
---@return integer row The current line number ---@return integer row The current line number
---@return integer col The current column number ---@return integer col The current column number
function M.get_cursor_position() function M.get_cursor_position()
@@ -622,7 +845,24 @@ function M.get_cursor_position()
return row, col return row, col
end end
--- Function to split a string ---@function Function to check if a global variable is set
---@param var_name string The name of the global variable
---@param expected_value any The expected value of the global variable
---@param default_value any The default value of the global variable
---@return boolean condition true if the global variable is set to the expected value, false otherwise
function M.check_global_var(var_name, expected_value, default_value)
local actual_value = vim.g[var_name]
-- If the global variable is not set, use the default value (if provided)
if actual_value == nil and default_value ~= nil then
actual_value = default_value
end
-- Return whether the actual value matches the expected value
return actual_value == expected_value
end
---@function Function to split a string
---@param inputstr string The string to split ---@param inputstr string The string to split
---@param sep string The separator ---@param sep string The separator
---@return table output The split string ---@return table output The split string
@@ -637,14 +877,14 @@ function M.split_string(inputstr, sep)
return output return output
end end
--- Function to convert RGB to hexadecimal ---@function Function to convert RGB to hexadecimal
---@param rgb table The RGB color ---@param rgb table The RGB color
---@return string hex The hexadecimal color ---@return string hex The hexadecimal color
function M.rgb_to_hex(rgb) function M.rgb_to_hex(rgb)
return string.format("#%02x%02x%02x", rgb[1], rgb[2], rgb[3]) return string.format("#%02x%02x%02x", rgb[1], rgb[2], rgb[3])
end end
--- Function to get the foreground color of a highlight group ---@function Function to get the foreground color of a highlight group
---@param hlgroup string The name of the highlight group ---@param hlgroup string The name of the highlight group
---@return string|nil hex The foreground color of the highlight group ---@return string|nil hex The foreground color of the highlight group
function M.get_fg_color(hlgroup) function M.get_fg_color(hlgroup)
@@ -660,7 +900,7 @@ function M.get_fg_color(hlgroup)
return nil return nil
end end
--- Function to get the background color of a highlight group ---@function Function to get the background color of a highlight group
---@param hlgroup string The name of the highlight group ---@param hlgroup string The name of the highlight group
---@return string|nil hex The background color of the highlight group ---@return string|nil hex The background color of the highlight group
function M.get_bg_color(hlgroup) function M.get_bg_color(hlgroup)
@@ -676,7 +916,7 @@ function M.get_bg_color(hlgroup)
return nil return nil
end end
--- Function to check if the window is wide enough ---@function Function to check if the window is wide enough
---@param width_limit number The minimum width of the window ---@param width_limit number The minimum width of the window
---@return boolean condition true if the window is wide enough, false otherwise ---@return boolean condition true if the window is wide enough, false otherwise
function M.is_window_wide_enough(width_limit) function M.is_window_wide_enough(width_limit)
@@ -684,7 +924,7 @@ function M.is_window_wide_enough(width_limit)
return width >= width_limit return width >= width_limit
end end
--- Function to check if the window is tall enough ---@function Function to check if the window is tall enough
---@param height_limit number The minimum height of the window ---@param height_limit number The minimum height of the window
---@return boolean condition true if the window is tall enough, false otherwise ---@return boolean condition true if the window is tall enough, false otherwise
function M.is_window_tall_enough(height_limit) function M.is_window_tall_enough(height_limit)
@@ -692,13 +932,13 @@ function M.is_window_tall_enough(height_limit)
return height >= height_limit return height >= height_limit
end end
--- Function to get the current date ---@function Function to get the current date
---@return string|osdate date The current date ---@return string|osdate date The current date
function M.get_date() function M.get_date()
return os.date("%Y-%m-%d") return os.date("%Y-%m-%d")
end end
--- Function to exit neovim ---@function Function to exit neovim
---@return nil ---@return nil
function M.exit() function M.exit()
vim.api.nvim_command("wqall") vim.api.nvim_command("wqall")
+32 -20
View File
@@ -1,25 +1,37 @@
---@module "data" ---@module "data"
--- This module aggregates various utility modules used throughout the configuration. --- This module aggregates various data tables used throughout the configuration.
--- It provides a centralized way to access keymaps, data types, utility functions, commands, and dashboard utilities. local M = {}
local keys = require("data.keys") -- Explicitly specify for LSP support
local types = require("data.types") M.keys = require("data.keys")
local func = require("data.func") M.types = require("data.types")
local cmd = require("data.cmd") M.func = require("data.func")
local deps = require("data.deps") M.cmd = require("data.cmd")
local dash = require("data.dash") M.deps = require("data.deps")
M.dash = require("data.dash")
---@alias DataModule -- Function to iterate over files in the directory
---| { keys: table, types: table, func: table, cmd: table, deps: table, dash: table } local function read_data_dir()
-- Getting the root path for the current module directory
local dir_path = vim.fn.fnamemodify(debug.getinfo(1, "S").source:sub(2), ":h")
---@type DataModule -- Open the directory
local data = { local files = vim.fn.readdir(dir_path)
keys = keys,
types = types,
func = func,
cmd = cmd,
deps = deps,
dash = dash,
}
return data for _, file in ipairs(files) do
-- Skip init.lua
if file ~= "init.lua" and file:match(".*%.lua$") then
-- Get the module name without the .lua extension
local module_name = file:sub(1, -5)
-- Load the module if not already explicitly set
if not M[module_name] then
M[module_name] = require("data." .. module_name)
end
end
end
end
-- Read the directory and load any additional modules
read_data_dir()
return M
+99 -78
View File
@@ -1,3 +1,7 @@
---@module "data.keys"
--- This module contains the keymaps for the plugins and commands.
--- Keymaps use the add_keymap function from data.func for flexible
--- keybinding functionality.
-- ╭─────────────────────────────────────────────────────────╮ -- ╭─────────────────────────────────────────────────────────╮
-- │ KEYS DATA │ -- │ KEYS DATA │
-- ╰─────────────────────────────────────────────────────────╯ -- ╰─────────────────────────────────────────────────────────╯
@@ -54,7 +58,7 @@ M.codesnap = {
} }
M.flash = { M.flash = {
{ { -- Flash jump to next
"<CR>", "<CR>",
function() function()
require("flash").jump() require("flash").jump()
@@ -65,52 +69,72 @@ M.flash = {
} }
M.minimap = { M.minimap = {
{ "<leader>nt", "<cmd>Neominimap toggle<cr>", desc = "Toggle minimap" }, { -- Toggle minimap
{ "<leader>no", "<cmd>Neominimap on<cr>", desc = "Enable minimap" }, "<leader>nt",
{ "<leader>nc", "<cmd>Neominimap off<cr>", desc = "Disable minimap" }, "<cmd>Neominimap toggle<cr>",
{ "<leader>nf", "<cmd>Neominimap focus<cr>", desc = "Focus on minimap" }, desc = "Toggle minimap",
{ "<leader>nu", "<cmd>Neominimap unfocus<cr>", desc = "Unfocus minimap" }, },
{ { -- Enable minimap
"<leader>no",
"<cmd>Neominimap on<cr>",
desc = "Enable minimap",
},
{ -- Disable minimap
"<leader>nc",
"<cmd>Neominimap off<cr>",
desc = "Disable minimap",
},
{ -- Refresh minimap
"<leader>nf",
"<cmd>Neominimap focus<cr>",
desc = "Focus on minimap",
},
{ -- Unfocus minimap
"<leader>nu",
"<cmd>Neominimap unfocus<cr>",
desc = "Unfocus minimap",
},
{ -- Toggle focus
"<leader>ns", "<leader>ns",
"<cmd>Neominimap toggleFocus<cr>", "<cmd>Neominimap toggleFocus<cr>",
desc = "Toggle focus on minimap", desc = "Toggle focus on minimap",
}, },
{ { -- Toggle minimap for current window
"<leader>nwt", "<leader>nwt",
"<cmd>Neominimap winToggle<cr>", "<cmd>Neominimap winToggle<cr>",
desc = "Toggle minimap for current window", desc = "Toggle minimap for current window",
}, },
{ { -- Refresh minimap for current window
"<leader>nwr", "<leader>nwr",
"<cmd>Neominimap winRefresh<cr>", "<cmd>Neominimap winRefresh<cr>",
desc = "Refresh minimap for current window", desc = "Refresh minimap for current window",
}, },
{ { -- Enable minimap for current window
"<leader>nwo", "<leader>nwo",
"<cmd>Neominimap winOn<cr>", "<cmd>Neominimap winOn<cr>",
desc = "Enable minimap for current window", desc = "Enable minimap for current window",
}, },
{ { -- Disable minimap for current window
"<leader>nwc", "<leader>nwc",
"<cmd>Neominimap winOff<cr>", "<cmd>Neominimap winOff<cr>",
desc = "Disable minimap for current window", desc = "Disable minimap for current window",
}, },
{ { -- Toggle minimap for current buffer
"<leader>nbt", "<leader>nbt",
"<cmd>Neominimap bufToggle<cr>", "<cmd>Neominimap bufToggle<cr>",
desc = "Toggle minimap for current buffer", desc = "Toggle minimap for current buffer",
}, },
{ { -- Refresh minimap for current buffer
"<leader>nbr", "<leader>nbr",
"<cmd>Neominimap bufRefresh<cr>", "<cmd>Neominimap bufRefresh<cr>",
desc = "Refresh minimap for current buffer", desc = "Refresh minimap for current buffer",
}, },
{ { -- Enable minimap for current buffer
"<leader>nbo", "<leader>nbo",
"<cmd>Neominimap bufOn<cr>", "<cmd>Neominimap bufOn<cr>",
desc = "Enable minimap for current buffer", desc = "Enable minimap for current buffer",
}, },
{ { -- Disable minimap for current buffer
"<leader>nbc", "<leader>nbc",
"<cmd>Neominimap bufOff<cr>", "<cmd>Neominimap bufOff<cr>",
desc = "Disable minimap for current buffer", desc = "Disable minimap for current buffer",
@@ -187,14 +211,6 @@ M.foldnav = {
}, },
} }
M.fugit = {
{ -- Open Fugit
"<leader>F",
mode = "n",
"<cmd>Fugit2<cr>",
},
}
M.gitlinker = { M.gitlinker = {
{ -- Yank git link { -- Yank git link
"<leader>gy", "<leader>gy",
@@ -235,32 +251,27 @@ M.gist = {
} }
M.groups = { M.groups = {
-- Icon picker { -- Icon picker menu
{
lhs = "<leader>I", lhs = "<leader>I",
group = "IconPicker", group = "IconPicker",
icon = { icon = "󰥸", color = "orange" }, icon = { icon = "󰥸", color = "orange" },
}, },
-- Gists menu { -- Gists menu
{
lhs = "<leader>gn", lhs = "<leader>gn",
group = "Gists", group = "Gists",
icon = { icon = "", color = "orange" }, icon = { icon = "", color = "orange" },
}, },
-- Lazy menu { -- Lazy menu
{
lhs = "<leader>l", lhs = "<leader>l",
group = "Lazy", group = "Lazy",
icon = { icon = "󰒲", color = "red" }, icon = { icon = "󰒲", color = "red" },
}, },
-- MiniMap menu { -- MiniMap menu
{
lhs = "<leader>n", lhs = "<leader>n",
group = "MiniMap", group = "MiniMap",
icon = { icon = "", color = "green" }, icon = { icon = "", color = "green" },
}, },
-- Code action menu { -- Code action menu
{
lhs = "<leader>C", lhs = "<leader>C",
group = "CodeActions", group = "CodeActions",
icon = { icon = "", color = "yellow" }, icon = { icon = "", color = "yellow" },
@@ -314,65 +325,74 @@ M.lazygit = {
}, },
} }
M.misc = { M.minifiles = {
-- Yank line (without whitespace)
{ {
"<leader>fm",
function()
require("mini.files").open(vim.api.nvim_buf_get_name(0), true)
end,
desc = "Open mini.files (Directory of Current File)",
},
{
"<leader>fM",
function()
require("mini.files").open(vim.uv.cwd(), true)
end,
desc = "Open mini.files (cwd)",
},
}
M.misc = {
{ -- Yank line (without whitespace)
lhs = "yo", lhs = "yo",
rhs = function() rhs = function()
rootiest.yank_line() rootiest.yank_line()
end, end,
desc = "Yank Line-text", desc = "Yank Line-text",
}, },
-- Hardmode { -- Hardmode
{
lhs = "<leader>uH", lhs = "<leader>uH",
rhs = function() rhs = function()
rootiest.toggle_hardmode() rootiest.toggle_hardmode()
end, end,
desc = "Toggle Hardmode", desc = "Toggle Hardmode",
}, },
-- Yank buffer { -- Yank buffer
{
lhs = "<leader>Y", lhs = "<leader>Y",
rhs = "<cmd>%y<cr>", rhs = "<cmd>%y<cr>",
desc = "Yank buffer contents", desc = "Yank buffer contents",
}, },
-- Select all { -- Select all
{
lhs = "<C-a>", lhs = "<C-a>",
rhs = "<cmd>norm ggVG<cr>", rhs = "<cmd>norm ggVG<cr>",
desc = "Select all", desc = "Select all",
}, },
-- Neotree { -- Neotree
{
lhs = "|", lhs = "|",
rhs = "<cmd>Neotree reveal toggle<cr>", rhs = "<cmd>Neotree reveal toggle<cr>",
desc = "Neotree toggle", desc = "Neotree toggle",
}, },
-- Exit Neovim { -- Exit Neovim
{
lhs = "<leader>Q", lhs = "<leader>Q",
rhs = "<cmd>lua require('data').func.exit()<cr>", rhs = "<cmd>lua require('data').func.exit()<cr>",
desc = "Exit Neovim", desc = "Exit Neovim",
}, },
-- LazyVim { -- LazyVim
{
lhs = "<leader>lv", lhs = "<leader>lv",
rhs = "<cmd>Lazy<cr>", rhs = "<cmd>Lazy<cr>",
desc = "LazyVim", desc = "LazyVim",
}, },
-- LazyExtras { -- LazyExtras
{
lhs = "<leader>lx", lhs = "<leader>lx",
rhs = "<cmd>LazyExtras<cr>", rhs = "<cmd>LazyExtras<cr>",
desc = "LazyExtras", desc = "LazyExtras",
}, },
-- De-map 's' to avoid conflicts with mini.surround { -- De-map Ctrl+Shift+LeftClick to avoid conflicts with WezTerm
{ lhs = "<C-S-LeftMouse>",
lhs = "s",
rhs = "<Nop>", rhs = "<Nop>",
desc = "Nos", desc = "Prevent conflict with WezTerm hyperlinks",
mode = { "n", "x" }, mode = "n",
hidden = true,
}, },
} }
@@ -438,102 +458,102 @@ M.splitjoin = {
M.splits = { M.splits = {
resize = { resize = {
{ { -- Resize split leftwards
"<A-h>", "<A-h>",
function() function()
require("smart-splits").resize_left() require("smart-splits").resize_left()
end, end,
"Resize split left", "Resize split left",
}, },
{ { -- Resize split downwards
"<A-j>", "<A-j>",
function() function()
require("smart-splits").resize_down() require("smart-splits").resize_down()
end, end,
"Resize split down", "Resize split down",
}, },
{ { -- Resize split upwards
"<A-k>", "<A-k>",
function() function()
require("smart-splits").resize_up() require("smart-splits").resize_up()
end, end,
"Resize split up", "Resize split up",
}, },
{ { -- Resize split rightwards
"<A-l>", "<A-l>",
function() function()
require("smart-splits").resize_right() require("smart-splits").resize_right()
end, end,
"Resize split right", "Resize split right",
}, },
{ { -- Start interactive split resizing
"<A-r>", "<A-r>",
function() function()
require("smart-splits").start_resize_mode() require("smart-splits").start_resize_mode()
end, end,
"Resize split to previous size", "Resize split interactively",
}, },
}, },
move = { move = {
{ { -- Move cursor to split left
"<C-S-h>", "<C-S-h>",
function() function()
require("smart-splits").move_cursor_left() require("smart-splits").move_cursor_left()
end, end,
"Move cursor left", "Move to split left",
}, },
{ { -- Move cursor to split below
"<C-S-j>", "<C-S-j>",
function() function()
require("smart-splits").move_cursor_down() require("smart-splits").move_cursor_down()
end, end,
"Move cursor down", "Move to split below",
}, },
{ { -- Move cursor to split above
"<C-S-k>", "<C-S-k>",
function() function()
require("smart-splits").move_cursor_up() require("smart-splits").move_cursor_up()
end, end,
"Move cursor up", "Move to split above",
}, },
{ { -- Move cursor to split right
"<C-S-l>", "<C-S-l>",
function() function()
require("smart-splits").move_cursor_right() require("smart-splits").move_cursor_right()
end, end,
"Move cursor right", "Move to split right",
}, },
{ { -- Move cursor to previous split
"<C-\\>", "<C-\\>",
function() function()
require("smart-splits").move_cursor_previous() require("smart-splits").move_cursor_previous()
end, end,
"Move cursor to previous split", "Move to previous split",
}, },
}, },
swap = { swap = {
{ { -- Swap buffer with the one to the left
"<A-S-h>", "<A-S-h>",
function() function()
require("smart-splits").swap_buf_left() require("smart-splits").swap_buf_left()
end, end,
"Swap buffer left", "Swap buffer left",
}, },
{ { -- Swap buffer with the one below
"<A-S-j>", "<A-S-j>",
function() function()
require("smart-splits").swap_buf_down() require("smart-splits").swap_buf_down()
end, end,
"Swap buffer down", "Swap buffer down",
}, },
{ { -- Swap buffer with the one above
"<A-S-k>", "<A-S-k>",
function() function()
require("smart-splits").swap_buf_up() require("smart-splits").swap_buf_up()
end, end,
"Swap buffer up", "Swap buffer up",
}, },
{ { -- Swap buffer with the one to the right
"<A-S-l>", "<A-S-l>",
function() function()
require("smart-splits").swap_buf_right() require("smart-splits").swap_buf_right()
@@ -584,11 +604,12 @@ M.substitute = {
} }
M.surround = { M.surround = {
{ -- De-map 's' to prevent conflicts { -- De-map 's' to avoid conflicts with mini.surround
"s", lhs = "s",
"<Nop>", rhs = "<Nop>",
desc = "Nos", desc = "Prevent conflict with mini.surround",
mode = { "n", "x" }, mode = { "n", "x" },
hidden = true,
}, },
} }
+500 -26
View File
@@ -1,14 +1,142 @@
---@module "M"
--- This module aggregates various types used throughout the configuration.
--- Plugin opts/config tables/functions are defined in this module.
--- Other general tables and lists are also defined here.
-- ╭─────────────────────────────────────────────────────────╮ -- ╭─────────────────────────────────────────────────────────╮
-- │ TYPES │ -- │ TYPES │
-- ╰─────────────────────────────────────────────────────────╯ -- ╰─────────────────────────────────────────────────────────╯
local M = {} local M = {}
M.logo = { -- ━━━━━━━━━━━━━━━━━━━━━━━━━━━ Mode Indicators ━━━━━━━━━━━━━━━━━━━━━━━━━━━
M.mode = {
n = { -- Normal mode
icon = "", icon = "",
name = "NORMAL",
color = "Special", color = "Special",
},
no = { -- Operator-pending mode
icon = "",
name = "NORMAL OPERATOR PENDING",
color = "Special",
},
nov = { -- Operator-pending (charwise) mode
icon = "",
name = "NORMAL OP (CHARWISE)",
color = "Special",
},
nt = { -- Terminal-mode within Normal mode
icon = "",
name = "NORMAL TERMINAL",
color = "Special",
},
i = { -- Insert mode
icon = "",
name = "INSERT",
color = "Special",
},
ic = { -- Insert completion mode
icon = "",
name = "INSERT COMPLETION",
color = "Special",
},
R = { -- Replace mode
icon = "",
name = "REPLACE",
color = "Special",
},
Rv = { -- Virtual replace mode
icon = "",
name = "REPLACE VIRT",
color = "Special",
},
v = { -- Visual mode
icon = "󰸿",
name = "VISUAL",
color = "Special",
},
V = { -- Visual Line mode
icon = "󰸽",
name = "VISUAL LINE",
color = "Special",
},
[""] = { -- Visual Block mode
icon = "󰹀",
name = "VISUAL BLOCK",
color = "Special",
},
c = { -- Command mode
icon = "󰑮",
name = "COMMAND",
color = "Special",
},
s = { -- Select mode
icon = "",
name = "SELECT",
color = "Special",
},
S = { -- Select Line mode
icon = "",
name = "SELECT LINE",
color = "Special",
},
t = { -- Terminal mode
icon = "",
name = "INSERT TERMINAL",
color = "Special",
},
--- A collection of functions that return icons and names for
--- the current mode.
--- These use the tables defined above in `M.mode`.
current = {
--- Returns an icon representing the current mode
--- Ex: ""
---@return string|function icon The current mode icon
icon = function()
local current_mode = vim.api.nvim_get_mode().mode
-- Check if current_mode exists in full in M.mode
if M.mode[current_mode] then
return M.mode[current_mode].icon
end
-- Fallback to single-character mode if full mode isn't available
local fallback_mode = current_mode:sub(1, 1)
return M.mode[fallback_mode] and M.mode[fallback_mode].icon or ""
end,
--- Returns the name of the current mode
--- Ex: "NORMAL"
---@return string|function name The current mode name
name = function()
local current_mode = vim.api.nvim_get_mode().mode
-- Check if current_mode exists in full in M.mode
if M.mode[current_mode] then
return M.mode[current_mode].name
end
-- Fallback to single-character mode if full mode isn't available
local fallback_mode = current_mode:sub(1, 1)
return M.mode[fallback_mode] and M.mode[fallback_mode].name or "UNKNOWN"
end,
--- Returns a string representing the current mode with icon and name
--- Ex: " NORMAL"
---@return string|function icon_text The current mode icon and name
icon_text = function()
return M.mode.current.icon() .. " " .. M.mode.current.name()
end,
--- Returns a string representing the current mode with icon and name
--- Ex: " NORMAL"
---@return string|function icon_text The current mode icon and name
lualine = function()
return M.mode.current.icon_text()
end,
},
} }
-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Type tables ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
--- General exclusion list for buffers and filetypes
M.general = { M.general = {
-- Excluded buffer types -- Excluded buffer types
buf = { buf = {
@@ -32,7 +160,7 @@ M.general = {
}, },
} }
-- All modes for keymaps --- All-modes table for keymaps
M.all_modes = { M.all_modes = {
"n", "n",
"i", "i",
@@ -44,7 +172,7 @@ M.all_modes = {
"t", "t",
} }
-- Filetypes for Alternate plugin --- Filetypes for Alternate plugin
M.alternate = { M.alternate = {
"cpp", "cpp",
"h", "h",
@@ -52,14 +180,17 @@ M.alternate = {
"c", "c",
} }
--- Arrow config options
M.arrow = { M.arrow = {
show_icons = true, show_icons = true,
leader_key = ";", -- Recommended to be a single key leader_key = ";", -- Recommended to be a single key
buffer_leader_key = "m", -- Per Buffer Mappings buffer_leader_key = "m", -- Per Buffer Mappings
} }
-- Bufferline configuration options --- Bufferline configuration options
M.bufferline = { M.bufferline = {
opts = {
options = {
themable = true, themable = true,
color_icons = true, color_icons = true,
numbers = "ordinal", numbers = "ordinal",
@@ -79,25 +210,242 @@ M.bufferline = {
end end
return s return s
end, end,
},
},
} }
-- Nvim-cmp excluded filetypes --- LazyVim configuration options
M.lazyvim = {
opts = {
colorscheme = vim.g.my_colorscheme or "catppuccin-mocha",
news = {
lazyvim = true,
neovim = true,
},
},
}
--- Nvim-cmp excluded filetypes
M.cmp = { M.cmp = {
"dashboard", "dashboard",
"qalc", "qalc",
} }
-- Git-Blame configuration M.neotree = {
opts = {
default_component_configs = {
git_status = {
symbols = {
untracked = "󱀶",
ignored = "",
unstaged = "󰄱",
staged = "󰱒",
conflict = "",
},
},
},
},
}
M.minifiles = {
opts = {
windows = {
preview = true,
width_focus = 30,
width_preview = 80,
},
options = {
-- Whether to use for editing directories
-- Disabled by default in LazyVim because neo-tree is used for that
use_as_default_explorer = false,
-- Whether to permanently delete or use trash
permanent_delete = false,
},
},
config = function(_, opts)
require("mini.files").setup(opts)
local show_dotfiles = true
local filter_show = function(_)
return true
end
local filter_hide = function(fs_entry)
return not vim.startswith(fs_entry.name, ".")
end
local toggle_dotfiles = function()
show_dotfiles = not show_dotfiles
local new_filter = show_dotfiles and filter_show or filter_hide
require("mini.files").refresh({ content = { filter = new_filter } })
end
local map_split = function(buf_id, lhs, direction, close_on_file)
local rhs = function()
local new_target_window
local cur_target_window = require("mini.files").get_target_window()
if cur_target_window ~= nil then
vim.api.nvim_win_call(cur_target_window, function()
vim.cmd("belowright " .. direction .. " split")
new_target_window = vim.api.nvim_get_current_win()
end)
require("mini.files").set_target_window(new_target_window)
require("mini.files").go_in({ close_on_file = close_on_file })
end
end
local desc = "Open in " .. direction .. " split"
if close_on_file then
desc = desc .. " and close"
end
vim.keymap.set("n", lhs, rhs, { buffer = buf_id, desc = desc })
end
local files_set_cwd = function()
---@diagnostic disable-next-line: undefined-global
local cur_entry_path = MiniFiles.get_fs_entry().path
local cur_directory = vim.fs.dirname(cur_entry_path)
if cur_directory ~= nil then
vim.fn.chdir(cur_directory)
end
end
vim.api.nvim_create_autocmd("User", {
pattern = "MiniFilesBufferCreate",
callback = function(args)
local buf_id = args.data.buf_id
vim.keymap.set(
"n",
opts.mappings and opts.mappings.toggle_hidden or "g.",
toggle_dotfiles,
{ buffer = buf_id, desc = "Toggle hidden files" }
)
vim.keymap.set(
"n",
opts.mappings and opts.mappings.change_cwd or "gc",
files_set_cwd,
{ buffer = args.data.buf_id, desc = "Set cwd" }
)
map_split(
buf_id,
opts.mappings and opts.mappings.go_in_horizontal or "<C-w>s",
"horizontal",
false
)
map_split(
buf_id,
opts.mappings and opts.mappings.go_in_vertical or "<C-w>v",
"vertical",
false
)
map_split(
buf_id,
opts.mappings and opts.mappings.go_in_horizontal_plus or "<C-w>S",
"horizontal",
true
)
map_split(
buf_id,
opts.mappings and opts.mappings.go_in_vertical_plus or "<C-w>V",
"vertical",
true
)
end,
})
vim.api.nvim_create_autocmd("User", {
pattern = "MiniFilesActionRename",
callback = function(event)
LazyVim.lsp.on_rename(event.data.from, event.data.to)
end,
})
end,
}
--- Git-Blame configuration options
M.gitblame = { M.gitblame = {
opts = function()
if vim.g.statusline == "lualine" or vim.g.statusline == nil then
-- Get the current lualine configuration
local config = require("lualine").get_config()
local git_blame = require("gitblame")
local funcs = require("data.func")
-- Define the width limit for displaying the Git blame component
local width_limit = 245 -- Adjust this value as needed
-- Add Git-blame to lualine_c section
table.insert(config.sections.lualine_c, {
git_blame.get_current_blame_text,
cond = function() -- Only show if text is available
return git_blame.is_blame_text_available()
and funcs.is_window_wide_enough(width_limit)
end,
color = { fg = funcs.get_fg_color("GitSignsCurrentLineBlame") },
padding = { left = 1, right = 0 },
on_click = function()
if vim.g.statusline_clickable_git ~= false then
require("config.rootiest").toggle_lazygit_float()
end
end,
})
-- Apply the lualine configuration
require("lualine").setup(config)
end
-- Return the git-blame options
return M.gitblame.style
end,
style = {
display_virtual_text = 0, -- Disable virtual text display_virtual_text = 0, -- Disable virtual text
date_format = "%r", -- Relative date format date_format = "%r", -- Relative date format
message_when_not_committed = " Not yet committed", message_when_not_committed = " Not yet committed",
message_template = "<author> • <date> • <summary>", message_template = "<author> • <date> • <summary>",
},
} }
-- Git-Graph plugin options --- Neocodeium configuration options
M.neocodeium = {
opts = {
manual = false,
silent = true,
debounce = false,
},
}
--- Thanks configuration options
M.thanks = {
opts = {
star_on_install = false,
},
}
--- LSPConfig configuration options
M.lspconfig = {
opts = {
setup = {
clangd = function(_, opts)
opts.capabilities.offsetEncoding = { "utf-16" }
end,
},
},
}
--- Which-Key configuration options
M.whichkey = {
opts = {
preset = "modern",
win = {
wo = {
winblend = 10,
},
},
},
}
--- Git-Graph plugin options
M.gitgraph = { M.gitgraph = {
-- Git-graph symbols check for kitty --- Git-graph symbols check for kitty
symbols = function() symbols = function()
if require("data.func").is_kitty() then if require("data.func").is_kitty() then
return { return {
@@ -142,7 +490,7 @@ M.gitgraph = {
fields = { "hash", "timestamp", "author", "branch_name", "tag" }, fields = { "hash", "timestamp", "author", "branch_name", "tag" },
} }
-- Highlights module options --- Highlights module options
M.highlights = { M.highlights = {
-- Excluded buffer types -- Excluded buffer types
exclude = { exclude = {
@@ -150,7 +498,7 @@ M.highlights = {
}, },
} }
-- Indent characters --- Indent characters
M.ibl = { M.ibl = {
indent_char = { indent_char = {
fancy = { fancy = {
@@ -179,7 +527,10 @@ M.ibl = {
}, },
} }
--- Smart-Splits plugin options
M.smart_splits = { M.smart_splits = {
--- Function to check if kitty is running
--- and install Smart-Splits kittens if it is.
build = function() build = function()
if require("data.func").is_kitty() then if require("data.func").is_kitty() then
return "./kitty/install-kittens.bash" return "./kitty/install-kittens.bash"
@@ -189,6 +540,7 @@ M.smart_splits = {
end, end,
} }
--- Neominiap plugin options
M.minimap = { M.minimap = {
-- Width of minimap -- Width of minimap
width = 20, width = 20,
@@ -210,14 +562,14 @@ M.minimap = {
"neorg", "neorg",
}, },
-- Function to initialize or manipulate minimap settings --- Function to initialize or manipulate minimap settings
init = function() init = function()
M.setup() M.setup()
vim.g.neominimap = { vim.g.neominimap = {
auto_enable = true, auto_enable = true,
layout = "float", layout = "float",
exclude_filetypes = require("data.types").minimap.file, exclude_filetypes = M.minimap.file,
exclude_buftypes = require("data.types").minimap.buf, exclude_buftypes = M.minimap.buf,
x_multiplier = 4, x_multiplier = 4,
y_multiplier = 1, y_multiplier = 1,
click = { click = {
@@ -238,7 +590,7 @@ M.minimap = {
} }
end, end,
-- Function to check if minimap should be enabled --- Function to check if minimap should be enabled
cond = function() cond = function()
M.setup() M.setup()
local ex_ft = M.minimap.ft local ex_ft = M.minimap.ft
@@ -252,6 +604,7 @@ M.minimap = {
end, end,
} }
--- Llama Copilot plugin options
M.llama_copilot = { M.llama_copilot = {
host = "localhost", host = "localhost",
port = "11434", port = "11434",
@@ -260,6 +613,7 @@ M.llama_copilot = {
debug = false, debug = false,
} }
--- Plugin reloader function options
M.plugin_reloader = { M.plugin_reloader = {
exclusion_list = { -- Define the exclusion list exclusion_list = { -- Define the exclusion list
-- stylua: ignore start -- stylua: ignore start
@@ -280,6 +634,69 @@ M.plugin_reloader = {
}, },
} }
M.trouble = {
opts = {
modes = {
symbols = { -- Configure symbols mode
win = {
type = "split", -- split window
relative = "win", -- relative to current window
position = "right", -- right side
size = 0.3, -- 30% of the window
},
},
},
},
}
--- Function to set up bars-n-lines plugin options
M.barsNlines = function()
require("bars").setup({
exclude_filetypes = M.minimap.ft,
exclude_buftypes = M.minimap.buf,
statuscolumn = {
enable = true,
parts = {
{
type = "fold",
markers = {
default = {
content = { " " },
},
open = {
{ "", "BarsStatuscolumnFold1" },
},
close = {
{ "╴", "BarsStatuscolumnFold1" },
},
scope = {
{ "", "BarsStatuscolumnFold1" },
},
divider = {
{ "├╴", "BarsStatuscolumnFold1" },
},
foldend = {
{ "╰╼", "BarsStatuscolumnFold1" },
},
},
},
{
type = "number",
mode = "hybrid",
hl = "LineNr",
lnum_hl = "BarsStatusColumnNum",
relnum_hl = "LineNr",
virtnum_hl = "TablineSel",
wrap_hl = "TablineSel",
},
},
},
tabline = false,
statusline = false,
})
end
--- Function to setup Pigeon plugin options
M.pigeon = function() M.pigeon = function()
local data = require("data") local data = require("data")
local platform = data.func.get_os("platform") local platform = data.func.get_os("platform")
@@ -315,6 +732,7 @@ M.pigeon = function()
require("pigeon").setup(config) require("pigeon").setup(config)
end end
--- Substitute plugin options
M.substitute = { M.substitute = {
yank_substituted_text = false, yank_substituted_text = false,
preserve_cursor_position = true, preserve_cursor_position = true,
@@ -323,7 +741,7 @@ M.substitute = {
end, end,
} }
-- Hightlight-colors --- Hightlight-colors plugin options
M.hightlight_colors = { M.hightlight_colors = {
render = "virtual", render = "virtual",
virtual_symbol = "", virtual_symbol = "",
@@ -348,7 +766,7 @@ M.hightlight_colors = {
exclude_buftypes = {}, exclude_buftypes = {},
} }
-- Catppuccin opts --- Catppuccin options
M.catppuccin = { M.catppuccin = {
background = { -- :h background background = { -- :h background
light = "latte", light = "latte",
@@ -398,15 +816,17 @@ M.catppuccin = {
}, },
} }
-- Auto Dark Mode opts --- Auto Dark Mode plugin options
M.auto_dark_mode = { M.auto_dark_mode = {
update_interval = 2000, update_interval = 2000,
--- Function that runs when dark mode is enabled
set_dark_mode = function() set_dark_mode = function()
vim.o.background = "dark" vim.o.background = "dark"
vim.cmd.colorscheme( vim.cmd.colorscheme(
require("astral").colortheme or "catppuccin-mocha" or "tokyonight" require("astral").colortheme or "catppuccin-mocha" or "tokyonight"
) )
end, end,
--- Function that runs when light mode is enabled
set_light_mode = function() set_light_mode = function()
vim.o.background = "light" vim.o.background = "light"
vim.cmd.colorscheme( vim.cmd.colorscheme(
@@ -415,33 +835,63 @@ M.auto_dark_mode = {
end, end,
} }
-- Image.nvim filetypes --- Image.nvim enabled filetypes
M.image = "markdown" M.image = "markdown"
-- Todo-comments --- Todo-comments plugin options
M.todo = { M.todo = {
keywords = { keywords = {
FIX = { FIX = {
icon = "", -- icon used for the sign, and in search results icon = "", -- icon used for the sign, and in search results
color = "error", -- can be a hex color, or a named color (see below) color = "error", -- can be a hex color, or a named color
alt = { "FIXME", "BUG", "FIXIT", "ISSUE" }, -- a set of other keywords that all map to this FIX keywords alt = { -- a set of other keywords that all map to this FIX keywords
-- signs = false, -- configure signs for some keywords individually "FIXME",
"BUG",
"FIXIT",
"ISSUE",
}, },
TODO = { icon = "", color = "info" }, },
TODO = { icon = "", color = "info" },
HACK = { icon = "", color = "warning" }, HACK = { icon = "", color = "warning" },
WARN = { icon = "", color = "warning", alt = { "WARNING", "XXX" } }, WARN = { icon = "", color = "warning", alt = { "WARNING", "XXX" } },
PERF = { icon = "", alt = { "OPTIM", "PERFORMANCE", "OPTIMIZE" } }, PERF = { icon = "", alt = { "OPTIM", "PERFORMANCE", "OPTIMIZE" } },
NOTE = { icon = "", color = "hint", alt = { "INFO" } }, NOTE = { icon = "", color = "hint", alt = { "INFO" } },
BUST = {
icon = "󰇷 ",
color = "broken",
alt = { "BROKEN", "UNAVAILABLE", "POOP" },
},
JUNK = {
icon = "",
color = "trash",
alt = { "TRASH", "WASTE", "DUMP", "GARBAGE" },
},
TEST = { TEST = {
icon = " ", icon = " ",
color = "test", color = "test",
alt = { "TESTING", "PASSED", "FAILED" }, alt = { "TESTING", "PASSED", "FAILED" },
}, },
}, },
colors = {
error = { "DiagnosticError", "ErrorMsg", "#DC2626" },
warning = { "DiagnosticWarn", "WarningMsg", "#FBBF24" },
info = { "DiagnosticInfo", "#2563EB" },
hint = { "DiagnosticHint", "#10B981" },
default = { "Identifier", "#7C3AED" },
test = { "Identifier", "#FF00FF" },
broken = { "DiagnosticError", "ErrorMsg", "#DC2626" },
trash = { "DiagnosticUnnecessary", "Comment", "#DC2626" },
},
lualine = function() lualine = function()
local config = { local config = {
-- The todo-comments types to show & in what order: -- The todo-comments types to show & in what order:
order = { "TODO", "FIX", "HACK", "WARN", "NOTE", "PERF", "TEST" }, order = {
"TODO",
"FIX",
"WARN",
"BUST",
"JUNK",
},
keywords = M.todo.keywords, keywords = M.todo.keywords,
when_empty = "", when_empty = "",
} }
@@ -449,8 +899,26 @@ M.todo = {
end, end,
} }
-- Toggleterm plugin options --- Colorful Window Separators plugin options
M.colorful_winsep = {
symbols = { "", "", "", "", "", "" },
no_exec_files = {
"packer",
"TelescopePrompt",
"mason",
"CompetiTest",
"NvimTree",
"neotree",
"lazy",
"neominimap",
},
}
--- Toggleterm plugin options
M.toggleterm = { M.toggleterm = {
--- Sets the terminal panel size
---@param term table The terminal object
---@return number|nil The terminal size
size = function(term) size = function(term)
if term.direction == "horizontal" then if term.direction == "horizontal" then
return 10 return 10
@@ -478,12 +946,18 @@ M.toggleterm = {
}, },
winbar = { winbar = {
enabled = true, enabled = true,
--- Function that formats the name of the terminal
---@param term table The terminal object
---@return string The formatted name
name_formatter = function(term) name_formatter = function(term)
return term.name return term.name
end, end,
}, },
} }
--- Function to extend minimap.buf with general exclusions
---@private
---@return nil
function M.setup() function M.setup()
-- Extend minimap.buf with general exclusions -- Extend minimap.buf with general exclusions
for _, v in ipairs(M.general.buf) do for _, v in ipairs(M.general.buf) do
+4 -6
View File
@@ -1,18 +1,16 @@
---@module "plugins.ai"
--- This module defines the AI plugins spec for the Neovim configuration.
-- ╭─────────────────────────────────────────────────────────╮ -- ╭─────────────────────────────────────────────────────────╮
-- │ AI Tools │ -- │ AI Tools │
-- ╰─────────────────────────────────────────────────────────╯ -- ╰─────────────────────────────────────────────────────────╯
local data = require("data") local data = require("data")
return { return {
{ { --
-- Neocodeium -- Neocodeium
"monkoose/neocodeium", "monkoose/neocodeium",
event = "VeryLazy", event = "VeryLazy",
opts = { opts = data.types.neocodeium.opts,
manual = false,
silent = true,
debounce = false,
},
keys = data.keys.neocodeium, keys = data.keys.neocodeium,
}, },
{ -- Copilot { -- Copilot
-79
View File
@@ -1,79 +0,0 @@
-- ╭─────────────────────────────────────────────────────────╮
-- │ ALPHA │
-- ╰─────────────────────────────────────────────────────────╯
return {
"goolord/alpha-nvim",
event = "VimEnter",
enabled = true,
init = false,
opts = function()
local dashboard = require("alpha.themes.dashboard")
local logo = [[
]]
dashboard.section.header.val = vim.split(logo, "\n")
-- stylua: ignore start
dashboard.section.buttons.val = {
---@diagnostic disable: param-type-mismatch
dashboard.button("f", "" .. " Find file", LazyVim.pick()),
dashboard.button("n", "" .. " New file", [[<cmd> ene <BAR> startinsert <cr>]]),
dashboard.button("r", "" .. " Recent files", LazyVim.pick("oldfiles")),
dashboard.button("g", "" .. " Grep text", LazyVim.pick("live_grep")),
dashboard.button("z", "" .. " LazyGit", "<cmd> LazyGit <cr>"),
dashboard.button("c", "" .. " Config", LazyVim.pick.config_files()),
dashboard.button("s", "" .. " Restore Session", [[<cmd> lua require("persistence").load() <cr>]]),
dashboard.button("S", "󰢹 " .. " Remote Session", [[<cmd> lua require("config.rootiest").load_remote() <cr>]]),
dashboard.button("l", "󰒲 " .. " Lazy", "<cmd> Lazy <cr>"),
dashboard.button("q", "" .. " Quit", "<cmd> qa <cr>"),
}
-- stylua: ignore end
for _, button in ipairs(dashboard.section.buttons.val) do
button.opts.hl = "AlphaButtons"
button.opts.hl_shortcut = "AlphaShortcut"
end
dashboard.section.header.opts.hl = "AlphaHeader"
dashboard.section.buttons.opts.hl = "AlphaButtons"
dashboard.section.footer.opts.hl = "AlphaFooter"
dashboard.opts.layout[1].val = 10
return dashboard
end,
config = function(_, dashboard)
-- close Lazy and re-open when the dashboard is ready
if vim.o.filetype == "lazy" then
vim.cmd.close()
vim.api.nvim_create_autocmd("User", {
once = true,
pattern = "AlphaReady",
callback = function()
require("lazy").show()
end,
})
end
require("alpha").setup(dashboard.opts)
vim.api.nvim_create_autocmd("User", {
once = true,
pattern = "LazyVimStarted",
callback = function()
local stats = require("lazy").stats()
local ms = (math.floor(stats.startuptime * 100 + 0.5) / 100)
dashboard.section.footer.val = "⚡ Neovim loaded "
.. stats.loaded
.. "/"
.. stats.count
.. " plugins in "
.. ms
.. "ms"
pcall(vim.cmd.AlphaRedraw)
end,
})
end,
}
+3 -3
View File
@@ -1,8 +1,9 @@
--- @module "plugins.astral"
--- This module defines the astral plugin spec for the Neovim configuration.
-- ╭─────────────────────────────────────────────────────────╮ -- ╭─────────────────────────────────────────────────────────╮
-- │ Astral Plugin │ -- │ Astral Plugin │
-- ╰─────────────────────────────────────────────────────────╯ -- ╰─────────────────────────────────────────────────────────╯
return { return { -- Astral
{
"rootiest/astral.nvim", "rootiest/astral.nvim",
version = "*", -- Pin to GitHub releases version = "*", -- Pin to GitHub releases
opts = { opts = {
@@ -16,5 +17,4 @@ return {
}, },
}, },
-- dev = true, -- Use local codebase -- dev = true, -- Use local codebase
},
} }
+5 -7
View File
@@ -1,10 +1,11 @@
--- @module "plugins.cmp"
--- This module defines the cmp plugin spec for the Neovim configuration.
-- ╭─────────────────────────────────────────────────────────╮ -- ╭─────────────────────────────────────────────────────────╮
-- │ Auto Completion │ -- │ Auto Completion │
-- ╰─────────────────────────────────────────────────────────╯ -- ╰─────────────────────────────────────────────────────────╯
local data = require("data") local data = require("data")
return { return { --
{
"hrsh7th/nvim-cmp", "hrsh7th/nvim-cmp",
-- HACK: Experiemental cmp performance fork -- HACK: Experiemental cmp performance fork
dev = true, dev = true,
@@ -83,10 +84,8 @@ return {
fields = { "abbr", "kind", "menu" }, fields = { "abbr", "kind", "menu" },
expandable_indicator = true, expandable_indicator = true,
format = function(entry, item) format = function(entry, item)
local color_item = require("nvim-highlight-colors").format( local color_item =
entry, require("nvim-highlight-colors").format(entry, { kind = item.kind })
{ kind = item.kind }
)
item = require("lspkind").cmp_format({ item = require("lspkind").cmp_format({
require("tailwind-tools.cmp").lspkind_format, require("tailwind-tools.cmp").lspkind_format,
})(entry, item) })(entry, item)
@@ -141,5 +140,4 @@ return {
}) })
end end
end, end,
},
} }
+7 -26
View File
@@ -1,3 +1,5 @@
--- @module "plugins.coding"
--- This module defines the coding plugins spec for the Neovim configuration.
-- ╭─────────────────────────────────────────────────────────╮ -- ╭─────────────────────────────────────────────────────────╮
-- │ Coding │ -- │ Coding │
-- ╰─────────────────────────────────────────────────────────╯ -- ╰─────────────────────────────────────────────────────────╯
@@ -10,15 +12,9 @@ return {
automatic_installation = true, automatic_installation = true,
}, },
}, },
{ { --
"neovim/nvim-lspconfig", "neovim/nvim-lspconfig",
opts = { opts = data.types.lspconfig.opts,
setup = {
clangd = function(_, opts)
opts.capabilities.offsetEncoding = { "utf-16" }
end,
},
},
}, },
{ -- Yanky { -- Yanky
import = "lazyvim.plugins.extras.coding.yanky", import = "lazyvim.plugins.extras.coding.yanky",
@@ -32,13 +28,6 @@ return {
{ -- G-code { -- G-code
"wilriker/gcode.vim", "wilriker/gcode.vim",
}, },
{ -- Mini Align
"echasnovski/mini.align",
event = "InsertEnter",
config = function()
require("mini.align").setup()
end,
},
{ -- Alternate { -- Alternate
"ton/vim-alternate", "ton/vim-alternate",
lazy = true, lazy = true,
@@ -57,16 +46,8 @@ return {
opts = data.types.substitute, opts = data.types.substitute,
keys = data.keys.substitute, keys = data.keys.substitute,
}, },
{ -- mini.splitjoin {
"echasnovski/mini.splitjoin", "iamcco/markdown-preview.nvim",
event = "InsertEnter", build = "cd app && yarn install",
opts = {
mappings = data.keys.splitjoin,
},
},
{ -- mini-surround
"echasnovski/mini.surround",
opts = {},
keys = data.keys.surround,
}, },
} }
+7 -21
View File
@@ -1,38 +1,24 @@
--- @module "plugins.core"
--- This module defines the core plugins spec for the Neovim configuration.
-- ╭─────────────────────────────────────────────────────────╮ -- ╭─────────────────────────────────────────────────────────╮
-- │ Core │ -- │ Core │
-- ╰─────────────────────────────────────────────────────────╯ -- ╰─────────────────────────────────────────────────────────╯
local data = require("data") local data = require("data")
return { return {
require("config.rocks").plugin_spec,
{ -- LazyVim { -- LazyVim
"LazyVim/LazyVim", "LazyVim/LazyVim",
opts = { priority = 900,
colorscheme = vim.g.my_colorscheme or "catppuccin-mocha", opts = data.types.lazyvim.opts,
news = {
lazyvim = true,
neovim = true,
},
},
},
{ -- Mini-animate
import = "lazyvim.plugins.extras.ui.mini-animate",
}, },
{ -- Bufferline { -- Bufferline
"akinsho/bufferline.nvim", "akinsho/bufferline.nvim",
opts = { opts = data.types.bufferline.opts,
options = data.types.bufferline,
},
}, },
{ -- Which-Key { -- Which-Key
"folke/which-key.nvim", "folke/which-key.nvim",
lazy = true, lazy = true,
opts = { opts = data.types.whichkey.opts,
preset = "modern",
win = {
wo = {
winblend = 10,
},
},
},
}, },
} }
+49
View File
@@ -0,0 +1,49 @@
--- @module "plugins.dashboard.alpha"
--- This module defines the alpha plugin spec for the Neovim configuration.
-- ╭─────────────────────────────────────────────────────────╮
-- │ ALPHA │
-- ╰─────────────────────────────────────────────────────────╯
return { -- Alpha
"goolord/alpha-nvim",
event = "VimEnter",
enabled = true,
opts = require("data").dash.alpha.opts,
config = function(_, dashboard)
-- close Lazy and re-open when the dashboard is ready
if vim.o.filetype == "lazy" then
vim.cmd.close()
vim.api.nvim_create_autocmd("User", {
once = true,
pattern = "AlphaReady",
callback = function()
require("lazy").show()
end,
})
end
-- Setup the dashboard
require("alpha").setup(dashboard.opts)
-- Open Alpha when Vim is started with no file arguments
vim.api.nvim_create_autocmd("User", {
once = true,
pattern = "LazyVimStarted",
callback = function()
local stats = require("lazy").stats()
local ms = (math.floor(stats.startuptime * 100 + 0.5) / 100)
-- If auto-cursorline is installed, disable it
if pcall(require, "auto-cursorline") then
require("auto-cursorline").disable({ buffer = true })
end
dashboard.section.footer.val = "⚡ Neovim loaded "
.. stats.loaded
.. "/"
.. stats.count
.. " plugins in "
.. ms
.. "ms"
pcall(vim.cmd.AlphaRedraw)
end,
})
end,
}
@@ -1,11 +1,12 @@
--- @module "plugins.dashboard.nvim-dashboard"
--- This module defines the dashboard plugin spec for the Neovim configuration.
-- ╭─────────────────────────────────────────────────────────╮ -- ╭─────────────────────────────────────────────────────────╮
-- │ Dashboard │ -- │ Dashboard │
-- ╰─────────────────────────────────────────────────────────╯ -- ╰─────────────────────────────────────────────────────────╯
local data = require("data") local data = require("data")
return { return { --
-- Dashboard -- Dashboard
enabled = false,
"nvimdev/dashboard-nvim", "nvimdev/dashboard-nvim",
event = "UIEnter", event = "UIEnter",
version = false, version = false,
@@ -64,7 +65,7 @@ return {
file_height = logo_dimensions.height, file_height = logo_dimensions.height,
}, },
config = { config = {
center = data.dash.choices, center = data.dash.dashboard_nvim.choices,
footer = function() footer = function()
local stats = require("lazy").stats() local stats = require("lazy").stats()
local ms = (math.floor(stats.startuptime * 100 + 0.5) / 100) local ms = (math.floor(stats.startuptime * 100 + 0.5) / 100)
@@ -110,4 +111,5 @@ return {
return opts return opts
end, end,
enabled = false,
} }
+6 -2
View File
@@ -1,3 +1,5 @@
--- @module "plugins.debug"
--- This module defines the debug plugins spec for the Neovim configuration.
-- ╭─────────────────────────────────────────────────────────╮ -- ╭─────────────────────────────────────────────────────────╮
-- │ Debug │ -- │ Debug │
-- ╰─────────────────────────────────────────────────────────╯ -- ╰─────────────────────────────────────────────────────────╯
@@ -13,8 +15,10 @@ return {
{ -- NeoTest { -- NeoTest
import = "lazyvim.plugins.extras.test.core", import = "lazyvim.plugins.extras.test.core",
}, },
{ "nvim-neotest/neotest-plenary" }, { -- Neotest Plenary
{ "nvim-neotest/neotest-plenary",
},
{ -- Neotest
"nvim-neotest/neotest", "nvim-neotest/neotest",
opts = { opts = {
adapters = data.deps.neotest.adapters, adapters = data.deps.neotest.adapters,
+22 -30
View File
@@ -1,3 +1,5 @@
--- @module "plugins.editor"
--- This module defines the editor plugins spec for the Neovim configuration.
-- ╭─────────────────────────────────────────────────────────╮ -- ╭─────────────────────────────────────────────────────────╮
-- │ Editor │ -- │ Editor │
-- ╰─────────────────────────────────────────────────────────╯ -- ╰─────────────────────────────────────────────────────────╯
@@ -22,24 +24,10 @@ return {
{ -- Treesitter-context { -- Treesitter-context
import = "lazyvim.plugins.extras.ui.treesitter-context", import = "lazyvim.plugins.extras.ui.treesitter-context",
}, },
{ -- Mini.move { -- Trouble
import = "lazyvim.plugins.extras.editor.mini-move",
},
{
"folke/trouble.nvim", "folke/trouble.nvim",
cmd = data.cmd.trouble, cmd = data.cmd.trouble,
opts = { opts = data.types.trouble.opts,
modes = {
symbols = { -- Configure symbols mode
win = {
type = "split", -- split window
relative = "win", -- relative to current window
position = "right", -- right side
size = 0.3, -- 30% of the window
},
},
},
},
}, },
{ -- Flash { -- Flash
"folke/flash.nvim", "folke/flash.nvim",
@@ -48,6 +36,10 @@ return {
}, },
keys = data.keys.flash, keys = data.keys.flash,
}, },
{
"nvim-neo-tree/neo-tree.nvim",
opts = data.types.neotree.opts,
},
{ -- Arrow { -- Arrow
"otavioschwanck/arrow.nvim", "otavioschwanck/arrow.nvim",
opts = data.types.arrow, opts = data.types.arrow,
@@ -114,9 +106,7 @@ return {
}, },
{ -- Todo Comments { -- Todo Comments
"folke/todo-comments.nvim", "folke/todo-comments.nvim",
opts = { opts = data.types.todo.opts,
keywords = data.types.todo.keywords,
},
}, },
{ -- Rainbow Delimeters { -- Rainbow Delimeters
"HiPhish/rainbow-delimiters.nvim", "HiPhish/rainbow-delimiters.nvim",
@@ -125,24 +115,26 @@ return {
"nvim-zh/colorful-winsep.nvim", "nvim-zh/colorful-winsep.nvim",
opts = { opts = {
only_line_seq = false, only_line_seq = false,
symbols = { "", "", "", "", "", "" }, symbols = data.types.colorful_winsep.symbols,
no_exec_files = { no_exec_files = data.types.colorful_winsep.no_exec_files,
"packer",
"TelescopePrompt",
"mason",
"CompetiTest",
"NvimTree",
"neotree",
"lazy",
"neominimap",
},
}, },
event = { "WinLeave" }, event = { "WinLeave" },
}, },
{ -- Auto Cursorline { -- Auto Cursorline
"delphinus/auto-cursorline.nvim", "delphinus/auto-cursorline.nvim",
enabled = data.func.check_global_var("auto_cursorline", true, true),
opts = { opts = {
wait_ms = 2000, wait_ms = 2000,
}, },
}, },
{ -- Bars N Lines
"OXY2DEV/bars-N-lines.nvim",
enabled = data.func.check_global_var(
"statuscolumn",
"barsNlines",
"native"
),
lazy = false,
config = data.types.barsNlines,
},
} }
+4 -33
View File
@@ -1,3 +1,5 @@
--- @module "plugins.git"
--- This module defines the git plugins spec for the Neovim configuration.
-- ╭─────────────────────────────────────────────────────────╮ -- ╭─────────────────────────────────────────────────────────╮
-- │ Git Plugins │ -- │ Git Plugins │
-- ╰─────────────────────────────────────────────────────────╯ -- ╰─────────────────────────────────────────────────────────╯
@@ -7,11 +9,6 @@ return {
{ -- Octo plugin { -- Octo plugin
import = "lazyvim.plugins.extras.util.octo", import = "lazyvim.plugins.extras.util.octo",
}, },
{ -- DiffView
"sindrets/diffview.nvim",
lazy = true,
cmd = data.cmd.diffview,
},
{ -- Gist Tools { -- Gist Tools
"Rawnly/gist.nvim", "Rawnly/gist.nvim",
lazy = true, lazy = true,
@@ -33,9 +30,7 @@ return {
"jsongerber/thanks.nvim", "jsongerber/thanks.nvim",
lazy = true, lazy = true,
cmd = data.cmd.thanks, cmd = data.cmd.thanks,
opts = { opts = data.types.thanks.opts,
star_on_install = false,
},
}, },
{ -- GitLinker { -- GitLinker
"linrongbin16/gitlinker.nvim", "linrongbin16/gitlinker.nvim",
@@ -47,31 +42,7 @@ return {
{ -- Git Blame { -- Git Blame
"f-person/git-blame.nvim", "f-person/git-blame.nvim",
event = "VeryLazy", event = "VeryLazy",
opts = function() opts = data.types.gitblame.opts,
-- Get the current lualine configuration
local config = require("lualine").get_config()
local git_blame = require("gitblame")
local funcs = data.func
-- Define the width limit for displaying the Git blame component
local width_limit = 245 -- Adjust this value as needed
-- Add Git-blame to lualine_c section
table.insert(config.sections.lualine_c, {
git_blame.get_current_blame_text,
cond = function() -- Only show if text is available
return git_blame.is_blame_text_available()
and funcs.is_window_wide_enough(width_limit)
end,
color = { fg = funcs.get_fg_color("GitSignsCurrentLineBlame") },
padding = { left = 1, right = 0 },
on_click = function()
vim.cmd("LazyGit")
end,
})
-- Apply the lualine configuration
require("lualine").setup(config)
-- Return the git-blame options
return data.types.gitblame
end,
}, },
{ -- Git Graph { -- Git Graph
"isakbm/gitgraph.nvim", "isakbm/gitgraph.nvim",
+54
View File
@@ -0,0 +1,54 @@
---@module "plugins"
--- This module defines the plugins for the Neovim configuration.
---
--- If lazy.nvim is installed, this module returns an empty table
--- to defer plugin management to lazy.nvim.
---
--- If lazy.nvim is not installed, the module loads each
--- Lua file in the `plugins` directory.
---
--- Note:
--- A warning will be triggered if lazy.nvim is not installed unless
--- the variable `vim.g.ignore_no_lazy` is set to `true`.
--
-- ╭─────────────────────────────────────────────────────────╮
-- │ PLUGINS DATA │
-- ╰─────────────────────────────────────────────────────────╯
local M = {}
-- Check if lazy.nvim is installed
if pcall(require, "lazy") then
-- If lazy.nvim is installed, return an empty table and do nothing
return M
else
-- If lazy.nvim is not installed and vim.g.ignore_no_lazy is not set, display a warning
if not vim.g.ignore_no_lazy then
require("data").func.notify("lazy.nvim is not installed", "WARNING")
end
-- Function to iterate over files in the directory and load them dynamically
local function read_plugins_dir()
-- Get the root path for the plugins directory
local dir_path =
vim.fn.fnamemodify(debug.getinfo(1, "S").source:sub(2), ":h")
-- Open the directory
local files = vim.fn.readdir(dir_path)
for _, file in ipairs(files) do
-- Skip init.lua
if file ~= "init.lua" and file:match(".*%.lua$") then
-- Get the module name without the .lua extension
local plugin_name = file:sub(1, -5)
-- Load the plugin configuration file
require("plugins." .. plugin_name)
end
end
end
-- Read the directory and load plugin configuration files when lazy.nvim is not installed
read_plugins_dir()
end
return M
+2
View File
@@ -1,3 +1,5 @@
--- @module "plugins.languages"
--- This module defines the languages plugins spec for the Neovim configuration.
-- ╭─────────────────────────────────────────────────────────╮ -- ╭─────────────────────────────────────────────────────────╮
-- │ Languages │ -- │ Languages │
-- ╰─────────────────────────────────────────────────────────╯ -- ╰─────────────────────────────────────────────────────────╯
+42
View File
@@ -0,0 +1,42 @@
---@module "plugins.mini"
--- This module defines the mini plugins spec for the Neovim configuration.
-- ╭─────────────────────────────────────────────────────────╮
-- │ Mini │
-- ╰─────────────────────────────────────────────────────────╯
local data = require("data")
return {
{ -- mini.animate
import = "lazyvim.plugins.extras.ui.mini-animate",
},
{ -- mini.move
import = "lazyvim.plugins.extras.editor.mini-move",
},
{ -- mini.align
"echasnovski/mini.align",
event = "InsertEnter",
config = function()
require("mini.align").setup()
end,
},
{ -- mini.splitjoin
"echasnovski/mini.splitjoin",
event = "InsertEnter",
opts = {
mappings = data.keys.splitjoin,
},
},
{ -- mini.surround
"echasnovski/mini.surround",
opts = {},
keys = function()
data.func.add_keymap(data.keys.surround)
end,
},
{ -- mini.files
"echasnovski/mini.files",
opts = data.types.minifiles.opts,
keys = data.keys.minifiles,
config = data.types.minifiles.config,
},
}
+29
View File
@@ -0,0 +1,29 @@
---@module "plugins.override"
--- This module defines the plugin spec overrides for the Neovim configuration.
--- This is used to prioritize certain plugins over others or to override
--- the default behavior of a core plugin.
---
-- ╭─────────────────────────────────────────────────────────╮
-- │ Overrides │
-- ╰─────────────────────────────────────────────────────────╯
return {
{ -- Override build for markdown-preview
"iamcco/markdown-preview.nvim",
priority = 1001,
build = "cd app && yarn install",
},
{ -- Prioritize dadbod
"kristijanhusak/vim-dadbod-completion",
priority = 1001,
dependencies = "vim-dadbod",
},
{ -- Prioritize dadbod
"kristijanhusak/vim-dadbod-ui",
priority = 1001,
dependencies = "vim-dadbod",
},
{ -- Prioritize dadbod
"tpope/vim-dadbod",
priority = 1002,
},
}
+21
View File
@@ -0,0 +1,21 @@
---@module "plugins.statusline.basic"
--- This module defines the basic statusline spec for the Neovim configuration.
--- This option uses the native statusline feature to create a basic statusline
---
--- Activate this module by setting the 'vim.g.statusline' variable to 'basic'
-- ╭─────────────────────────────────────────────────────────╮
-- │ BASIC │
-- ╰─────────────────────────────────────────────────────────╯
-- If basic statusline is not enabled, return an empty table
if vim.g.statusline ~= "basic" then
return {}
end
-- Set up the basic statusline
---TODO: Write a basic statusline configuration using the
--- native statusline feature.
-- No lazy.nvim plugin necessary
return {}
+19
View File
@@ -0,0 +1,19 @@
--- @module "plugins.statusline.heirline"
--- This module defines the heirline plugin spec for the Neovim configuration.
--- This option uses the heirline plugin to create a statusline for Neovim
---
--- Activate this module by setting the 'vim.g.statusline' variable to 'heirline'
-- ╭─────────────────────────────────────────────────────────╮
-- │ Heirline │
-- ╰─────────────────────────────────────────────────────────╯
local data = require("data")
return {
{
"rebelot/heirline.nvim",
enabled = data.func.check_global_var("statusline", "heirline", "lualine"),
event = "UIEnter",
opts = {},
},
}
@@ -1,13 +1,26 @@
--- @module "plugins.statusline.lualine"
--- This module defines the lualine plugin spec for the Neovim configuration.
--- This option uses the lualine plugin to create a statusline for Neovim
---
--- Activate this module by setting the 'vim.g.statusline' variable to 'lualine'
-- ╭─────────────────────────────────────────────────────────╮ -- ╭─────────────────────────────────────────────────────────╮
-- │ Lualine │ -- │ Lualine │
-- ╰─────────────────────────────────────────────────────────╯ -- ╰─────────────────────────────────────────────────────────╯
local utils = require("utils") local wakatime_stats = require("utils.wakatime_stats")
local music_stats = require("utils.music_stats")
local data = require("data") local data = require("data")
local funcs = data.func local funcs = data.func
return { -- Use lualine by default
if vim.g.statusline == nil then
vim.g.statusline = "lualine"
end
return { -- Lualine
"nvim-lualine/lualine.nvim", "nvim-lualine/lualine.nvim",
enabled = data.func.check_global_var("statusline", "lualine", "lualine"),
dependencies = data.deps.lualine, dependencies = data.deps.lualine,
init = function() init = function()
vim.g.lualine_laststatus = vim.o.laststatus vim.g.lualine_laststatus = vim.o.laststatus
@@ -41,9 +54,11 @@ return {
}, },
sections = { -- Sections sections = { -- Sections
lualine_a = { lualine_a = {
{ -- Mode {
"mode", -- Calls the current.lualine() function to get the mode string
icon = data.types.logo.icon, function()
return data.types.mode.current.lualine()
end,
padding = { left = 1, right = 0 }, padding = { left = 1, right = 0 },
}, },
}, },
@@ -128,7 +143,9 @@ return {
removed = icons.git.removed, removed = icons.git.removed,
padding = { left = 0, right = 0 }, padding = { left = 0, right = 0 },
on_click = function() on_click = function()
vim.cmd("LazyGit") if vim.g.statusline_clickable_git ~= false then
require("config.rootiest").toggle_lazygit_float()
end
end, end,
}, },
{ -- GitSigns { -- GitSigns
@@ -147,16 +164,18 @@ return {
end, end,
padding = { left = 0, right = 0 }, padding = { left = 0, right = 0 },
on_click = function() on_click = function()
vim.cmd("LazyGit") if vim.g.statusline_clickable_git ~= false then
require("config.rootiest").toggle_lazygit_float()
end
end, end,
}, },
}, },
{ -- Wakatime { -- Wakatime
function() function()
return utils.wakatime_stats.get_icon_with_text() return wakatime_stats.get_icon_with_text()
end, end,
color = function() color = function()
return utils.wakatime_stats.get_color() return wakatime_stats.get_color()
end, end,
cond = function() cond = function()
return funcs.is_window_wide_enough(100) return funcs.is_window_wide_enough(100)
@@ -165,7 +184,7 @@ return {
}, },
{ -- Music { -- Music
function() function()
return utils.music_stats.get_icon_with_text() return music_stats.get_icon_with_text()
end, end,
cond = function() cond = function()
return funcs.is_window_wide_enough(100) return funcs.is_window_wide_enough(100)
+20
View File
@@ -0,0 +1,20 @@
---@module "plugins.statusline.none"
--- This module sets up the no-statusline optional mode for the Neovim configuration.
--- This option disables the statusline entirely for a more minimalistic appearance.
---
--- Activate this module by setting the 'vim.g.statusline' variable to 'none'
-- ╭─────────────────────────────────────────────────────────╮
-- │ No Statusline │
-- ╰─────────────────────────────────────────────────────────╯
if vim.g.statusline ~= "none" then
return {}
end
-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ NO-STATUSLINE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━
-- Set up the no-statusline
vim.o.laststatus = 0
-- No lazy.nvim plugin necessary
return {}
+10 -10
View File
@@ -1,15 +1,8 @@
---@module "plugins.terminal"
--- This module defines the terminal plugins spec for the Neovim configuration.
-- ╭─────────────────────────────────────────────────────────╮ -- ╭─────────────────────────────────────────────────────────╮
-- │ Terminals │ -- │ Terminals │
-- ╰─────────────────────────────────────────────────────────╯ -- ╰─────────────────────────────────────────────────────────╯
-- package.path = package.path
-- .. ";"
-- .. vim.fn.expand("$HOME")
-- .. "/.luarocks/share/lua/5.1/?/init.lua"
-- package.path = package.path
-- .. ";"
-- .. vim.fn.expand("$HOME")
-- .. "/.luarocks/share/lua/5.1/?.lua"
local data = require("data") local data = require("data")
return { return {
@@ -24,7 +17,14 @@ return {
config = function() config = function()
require("image").setup() require("image").setup()
end, end,
cond = vim.g.useimage and not vim.g.neovide, cond = function()
-- Disable image rendering in Neovide
-- or when vim.g.useimage = false
if vim.g.useimage == false then
return false
end
return not vim.g.neovide
end,
}, },
{ -- ToggleTerm { -- ToggleTerm
"akinsho/toggleterm.nvim", "akinsho/toggleterm.nvim",
+2
View File
@@ -1,3 +1,5 @@
--- @module "plugins.themes"
--- This module defines the themes plugins spec for the Neovim configuration.
-- ╭─────────────────────────────────────────────────────────╮ -- ╭─────────────────────────────────────────────────────────╮
-- │ Themes │ -- │ Themes │
-- ╰─────────────────────────────────────────────────────────╯ -- ╰─────────────────────────────────────────────────────────╯
+10 -1
View File
@@ -1,3 +1,5 @@
--- @module "plugins.util"
--- This module defines the utility plugins spec for the Neovim configuration.
-- ╭─────────────────────────────────────────────────────────╮ -- ╭─────────────────────────────────────────────────────────╮
-- │ Utilities │ -- │ Utilities │
-- ╰─────────────────────────────────────────────────────────╯ -- ╰─────────────────────────────────────────────────────────╯
@@ -27,6 +29,7 @@ return {
}, },
{ -- Auto-save { -- Auto-save
"okuuva/auto-save.nvim", "okuuva/auto-save.nvim",
enabled = data.func.check_global_var("auto_save", true, true),
cmd = data.cmd.autosave, cmd = data.cmd.autosave,
event = { "InsertLeave", "TextChanged" }, event = { "InsertLeave", "TextChanged" },
opts = { opts = {
@@ -55,6 +58,7 @@ return {
}, },
{ -- Codesnap { -- Codesnap
"mistricky/codesnap.nvim", "mistricky/codesnap.nvim",
enabled = data.func.check_global_var("codesnap", true, true),
lazy = true, lazy = true,
build = "make", build = "make",
opts = { opts = {
@@ -89,6 +93,7 @@ return {
}, },
{ -- Music Controls { -- Music Controls
"AntonVanAssche/music-controls.nvim", "AntonVanAssche/music-controls.nvim",
enabled = data.func.check_global_var("usemusic", true, true),
dependencies = data.deps.musiccontrols, dependencies = data.deps.musiccontrols,
opts = { opts = {
default_player = "YoutubeMusic", default_player = "YoutubeMusic",
@@ -129,6 +134,10 @@ return {
{ -- Suda { -- Suda
"lambdalisue/vim-suda", "lambdalisue/vim-suda",
cmd = data.cmd.suda, cmd = data.cmd.suda,
config = function()
vim.g.suda_smart_edit = 1
vim.cmd("let g:suda#prompt = '  Enter Sudo Password  '")
end,
}, },
{ -- Spell checker { -- Spell checker
"matkrin/telescope-spell-errors.nvim", "matkrin/telescope-spell-errors.nvim",
@@ -137,7 +146,7 @@ return {
end, end,
dependencies = data.deps.needs_telescope, dependencies = data.deps.needs_telescope,
}, },
{ { --
"Pheon-Dev/pigeon", "Pheon-Dev/pigeon",
config = data.types.pigeon, config = data.types.pigeon,
}, },
+3
View File
@@ -1,3 +1,6 @@
---@module "utils.blinky"
--- This module provides a function to set up and disable the blinky cursor.
local M = {} local M = {}
--- Function to set up blinky cursor --- Function to set up blinky cursor
+15 -8
View File
@@ -1,8 +1,11 @@
---@module "utils.cache_stats"
--- This module provides a function to update the cached statistics.
-- ╭─────────────────────────────────────────────────────────╮ -- ╭─────────────────────────────────────────────────────────╮
-- │ Cache Stats │ -- │ Cache Stats │
-- ╰─────────────────────────────────────────────────────────╯ -- ╰─────────────────────────────────────────────────────────╯
local M = {} local M = {}
-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Options ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Options ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
-- Options can be set with: -- Options can be set with:
-- vim.g.stats_wakatime = true|false (default: true) -- vim.g.stats_wakatime = true|false (default: true)
@@ -14,6 +17,10 @@ local M = {}
local config_dir = vim.fn.stdpath("config") --[[@as string]] local config_dir = vim.fn.stdpath("config") --[[@as string]]
local cache_script = vim.fs.joinpath(config_dir, "scripts", "update_cache.sh") local cache_script = vim.fs.joinpath(config_dir, "scripts", "update_cache.sh")
-- Path to the Neovim cache directory
_G.cache_stats_dir = -- Cache directory
vim.fn.stdpath("cache") --[[@as string]]
-- Flag to check if the script has already been run -- Flag to check if the script has already been run
local script_run_once = false local script_run_once = false
@@ -32,13 +39,9 @@ for _, player in ipairs(vim.g.stats_ignored_players or {}) do
table.insert(ignored_players, player) table.insert(ignored_players, player)
end end
if vim.g.stats_music == nil then -- Set the default values for the options
vim.g.stats_music = true vim.g.stats_music = vim.g.stats_music or true
end vim.g.stats_wakatime = vim.g.stats_wakatime or true
if vim.g.stats_wakatime == nil then
vim.g.stats_wakatime = true
end
--- Function to run the cache script --- Function to run the cache script
---@return boolean|number pid The pid of the script ---@return boolean|number pid The pid of the script
@@ -47,6 +50,10 @@ function M.setup_script()
-- Build the arguments for the cache script -- Build the arguments for the cache script
local args = { cache_script } local args = { cache_script }
-- Add the --cache-dir option
table.insert(args, "--cache-dir")
table.insert(args, _G.cache_stats_dir)
-- Add the --ignore option with the ignored players -- Add the --ignore option with the ignored players
if #ignored_players > 0 then if #ignored_players > 0 then
table.insert(args, "--ignore") table.insert(args, "--ignore")
@@ -77,7 +84,7 @@ function M.setup_script()
return false return false
end end
-- Run the setup script only once -- Run the setup script
M.setup_script() M.setup_script()
return M return M
+2
View File
@@ -1,3 +1,5 @@
---@module "utils.cmd_window"
--- This module provides a function to open a floating window with a completion menu.
-- ╭─────────────────────────────────────────────────────────╮ -- ╭─────────────────────────────────────────────────────────╮
-- │ Rootiest Command Window │ -- │ Rootiest Command Window │
-- ╰─────────────────────────────────────────────────────────╯ -- ╰─────────────────────────────────────────────────────────╯
+2 -2
View File
@@ -1,8 +1,8 @@
---@module "utils.highlight"
--- This module provides functions to apply highlights to the statusline and other components.
-- ╭─────────────────────────────────────────────────────────╮ -- ╭─────────────────────────────────────────────────────────╮
-- │ Highlight │ -- │ Highlight │
-- ╰─────────────────────────────────────────────────────────╯ -- ╰─────────────────────────────────────────────────────────╯
---@module "utils.highlight"
--- This module provides functions to apply highlights to the statusline and other components.
local M = {} local M = {}
+35 -18
View File
@@ -1,25 +1,42 @@
---@module "utils" ---@module "utils"
--- This module aggregates various utility functions used across the configuration. --- This module aggregates various utility functions used across the configuration.
--- It provides access to caching mechanisms, Git utilities, WakaTime statistics, music status, highlighting utilities, and a blinking effect utility. --- It provides access to caching mechanisms, Git utilities, WakaTime statistics, music status, highlight utilities, and a blinking effect utility.
local cache = require("utils.cache_stats") local utils = {}
local git = require("utils.git")
local wakatime = require("utils.wakatime_stats")
local music = require("utils.music_stats")
local highlight = require("utils.highlight")
local blinky = require("utils.blinky")
---@alias UtilsModule -- Explicitly specify modules for LSP support
---| { cache_stats: table, git: table, wakatime_stats: table, music_stats: table, highlight: table, blinky: table } utils.cache_stats = require("utils.cache_stats")
utils.git = require("utils.git")
utils.wakatime_stats = require("utils.wakatime_stats")
utils.music_stats = require("utils.music_stats")
utils.highlight = require("utils.highlight")
utils.blinky = require("utils.blinky")
-- Function to iterate over files in the directory and load them dynamically
local function read_utils_dir()
-- Getting the root path for the current module directory
local dir_path = vim.fn.fnamemodify(debug.getinfo(1, "S").source:sub(2), ":h")
-- Open the directory
local files = vim.fn.readdir(dir_path)
for _, file in ipairs(files) do
-- Skip init.lua
if file ~= "init.lua" and file:match(".*%.lua$") then
-- Get the module name without the .lua extension
local module_name = file:sub(1, -5)
-- Load the module if not already explicitly set
if not utils[module_name] then
utils[module_name] = require("utils." .. module_name)
end
end
end
end
-- Read the directory to load any additional modules
read_utils_dir()
---@alias UtilsModule table<string, any>
---@type UtilsModule ---@type UtilsModule
local utils = {
cache_stats = cache,
git = git,
wakatime_stats = wakatime,
music_stats = music,
highlight = highlight,
blinky = blinky,
}
return utils return utils
+1 -1
View File
@@ -4,7 +4,7 @@
local M = {} local M = {}
require("utils.cache_stats") require("utils.cache_stats")
local cache_file = os.getenv("HOME") .. "/.cache/music_cache.txt" local cache_file = vim.fs.joinpath(_G.cache_stats_dir, "music_cache.txt")
local separator = "" local separator = ""
local last_known_value = "" local last_known_value = ""
+7 -2
View File
@@ -1,10 +1,12 @@
---@module "utils.wakatime_stats"
--- This module provides functions to retrieve wakatime statistics from the cache file.
-- ╭─────────────────────────────────────────────────────────╮ -- ╭─────────────────────────────────────────────────────────╮
-- │ WakaTime Stats │ -- │ WakaTime Stats │
-- ╰─────────────────────────────────────────────────────────╯ -- ╰─────────────────────────────────────────────────────────╯
local M = {} local M = {}
require("utils.cache_stats") require("utils.cache_stats")
local cache_file = os.getenv("HOME") .. "/.cache/wakatime_cache.txt" local cache_file = vim.fs.joinpath(_G.cache_stats_dir, "wakatime_cache.txt")
-- Local variable to store the last known value -- Local variable to store the last known value
local last_known_value = "" local last_known_value = ""
@@ -41,7 +43,10 @@ end
--- Function to get the wakatime today status --- Function to get the wakatime today status
---@return string status The wakatime today status ---@return string status The wakatime today status
function M.get_today() function M.get_today()
return get_wakatime_today() local text = get_wakatime_today()
-- Check if it starts with "0 hrs " and remove it
text = text:gsub("^0 hrs%s*", "")
return text
end end
--- Function to get the wakatime today icon --- Function to get the wakatime today icon
+37 -4
View File
@@ -9,6 +9,7 @@ ignored_sources=""
# Flags for disabling functionality # Flags for disabling functionality
disable_wakatime=false disable_wakatime=false
no_music=false no_music=false
custom_cache_dir=""
# Function to print usage # Function to print usage
print_usage() { print_usage() {
@@ -18,6 +19,7 @@ print_usage() {
echo " -i, --ignore Comma-separated list of sources to ignore" echo " -i, --ignore Comma-separated list of sources to ignore"
echo " -d, --disable-wakatime Disable wakatime integration" echo " -d, --disable-wakatime Disable wakatime integration"
echo " -n, --no-music Disable music integration" echo " -n, --no-music Disable music integration"
echo " -c, --cache-dir Specify a custom cache directory"
exit 0 exit 0
} }
@@ -42,6 +44,15 @@ while [[ $# -gt 0 ]]; do
-n | --no-music) -n | --no-music)
no_music=true no_music=true
;; ;;
-c | --cache-dir)
if [[ -n $2 && $2 != -* ]]; then
custom_cache_dir=$2
shift
else
echo "Error: --cache-dir requires an argument."
exit 1
fi
;;
*) *)
echo "Unknown option: $1" echo "Unknown option: $1"
print_usage print_usage
@@ -50,15 +61,20 @@ while [[ $# -gt 0 ]]; do
shift shift
done done
# Use custom cache directory if provided, else use Neovim's cache directory
cache_dir="${custom_cache_dir:-\
${NVIM_CACHE_DIR:-\
${XDG_CACHE_HOME:-$HOME/.cache}/nvim}}"
mkdir -p "$cache_dir"
# Lock file path # Lock file path
lock_file="/tmp/music_wakatime_update.lock" lock_file="$cache_dir/music_wakatime_update.lock"
# Create a lock file to ensure only one instance of the script runs # Create a lock file to ensure only one instance of the script runs
if [[ -e $lock_file ]]; then if [[ -e $lock_file ]]; then
echo "Another instance of this script is already running." echo "Another instance of this script is already running."
exit 1 exit 1
else else
# Create the lock file
touch "$lock_file" touch "$lock_file"
fi fi
@@ -68,10 +84,27 @@ cleanup() {
} }
trap cleanup EXIT trap cleanup EXIT
# Check if playerctl is available
if ! command -v playerctl &>/dev/null; then
echo "Warning: playerctl not found. Disabling music integration."
no_music=true
fi
# Check if wakatime-cli is available
if ! command -v wakatime-cli &>/dev/null; then
echo "Warning: wakatime-cli not found. Disabling wakatime integration."
disable_wakatime=true
fi
# Update the music cache file every second, if not disabled # Update the music cache file every second, if not disabled
if ! $no_music; then if ! $no_music; then
while true; do while true; do
playerctl --ignore-player "${ignored_sources}" metadata --format "{{ artist }}${separator}{{ title }}${separator}{{ album }}${separator}{{ status }}${separator}{{ volume }}${separator}{{ loop }}${separator}{{ shuffle }}" >~/.cache/music_cache.txt playerctl --ignore-player "${ignored_sources}" \
metadata \
--format "{{ artist }}${separator}{{ title }}${separator} \
{{ album }}${separator}{{ status }}${separator}{{ volume }}${separator} \
{{ loop }}${separator}{{ shuffle }}" \
>"$cache_dir/music_cache.txt"
sleep 1 sleep 1
done & # Run this loop in the background done & # Run this loop in the background
fi fi
@@ -79,7 +112,7 @@ fi
# Update the Wakatime cache file every 60 seconds, if not disabled # Update the Wakatime cache file every 60 seconds, if not disabled
if ! $disable_wakatime; then if ! $disable_wakatime; then
while true; do while true; do
~/.wakatime/wakatime-cli --today >~/.cache/wakatime_cache.txt 2>/dev/null wakatime-cli --today >"$cache_dir/wakatime_cache.txt" 2>/dev/null
sleep 60 sleep 60
done & # Run this loop in the background done & # Run this loop in the background
fi fi