diff --git a/Untitled b/Untitled new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/Untitled @@ -0,0 +1 @@ + diff --git a/docs.md b/docs.md new file mode 100644 index 0000000..e69de29 diff --git a/lua/config/keymaps.lua b/lua/config/keymaps.lua index 18f1e12..b59c791 100644 --- a/lua/config/keymaps.lua +++ b/lua/config/keymaps.lua @@ -16,33 +16,47 @@ local data = require("data") local add_keymap = data.func.add_keymap -- ━━━━━━━━━━━━━━━━━━━━━━━━━━ General Keybinds ━━━━━━━━━━━━━━━━━━━━━━━ - -- Add keymaps for miscellaneous keybinds for _, item in ipairs(data.keys.misc) do add_keymap(item) end -- ━━━━━━━━━━━━━━━━━━━━━━━━━━━ Group Keybinds ━━━━━━━━━━━━━━━━━━━━━━━━ - -- Add keymaps for menu groups for _, item in ipairs(data.keys.groups) do add_keymap(item) end -- ━━━━━━━━━━━━━━━━━━━━━━━━━━━ Resizing splits ━━━━━━━━━━━━━━━━━━━━━━━━━━━ - +-- Add keymaps for resizing splits for _, map in ipairs(data.keys.splits.resize) do add_keymap(map[1], map[2], map[3], data.types.all_modes) end -- ━━━━━━━━━━━━━━━━━━━━━━━━ Moving between splits ━━━━━━━━━━━━━━━━━━━━━━━━ - +-- Add keymaps for moving between splits for _, map in ipairs(data.keys.splits.move) do add_keymap(map[1], map[2], map[3], data.types.all_modes) end -- ━━━━━━━━━━━━━━━━━━ Swapping buffers between windows ━━━━━━━━━━━━━━━ - +-- Add keymaps for swapping buffers for _, map in ipairs(data.keys.splits.swap) do add_keymap(map[1], map[2], map[3], data.types.all_modes) end + +-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Overrides ━━━━━━━━━━━━━━━━━━━━━━━━━━ +-- Add keymaps for overrides +add_keymap(data.keys.overrides) + +add_keymap("qP", function() + data.func.InputPrompt("Enter your name: ", function(input) + if input then + -- trim whitespace from end of input + input = input:gsub("%s+$", "") + print("👋😎 Hello " .. input .. "!") + else + print("Input was canceled") + end + end) +end, "Test Prompt") diff --git a/lua/config/options.lua b/lua/config/options.lua index 06cafd5..3c4e53d 100644 --- a/lua/config/options.lua +++ b/lua/config/options.lua @@ -7,30 +7,42 @@ -- ╰─────────────────────────────────────────────────────────╯ -- stylua: ignore start --- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Leader Key ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -vim.g.mapleader = " " ---@type string Options: -vim.g.maplocalleader = " " ---@type string Options: +-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Key Options ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +vim.g.mapleader = " " ---@type string Options: +vim.g.maplocalleader = " " ---@type string Options: +-- vim.g.timeoutlen = 1000 ---@type integer Options: -- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ LSP ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -- We don't need perl -vim.g.loaded_perl_provider = 0 ---@type integer Options: <0|1> -vim.g.loaded_ruby_provider = 0 ---@type integer Options: <0|1> --- Prefer basedpyright -vim.g.lazyvim_python_lsp = "basedpyright" ---@type string Options: [python lsp] - --- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ OS ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ --- Check if we are on windows -vim.g.is_windows = vim.fn.has("win32") == 1 or vim.fn.has("win64") == 1 +vim.g.loaded_perl_provider = 0 ---@type integer Options: <0|1> +-- or ruby +vim.g.loaded_ruby_provider = 0 ---@type integer Options: <0|1> +-- Prefer basedpyright for python +vim.g.lazyvim_python_lsp = "basedpyright" ---@type string Options: [python lsp] +-- Open all folds by default +vim.opt.foldlevel = 99 ---@type integer Options: <0-99> -- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ROOTIEST ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +-- Use WakaTime for code stats vim.g.usewakatime = true ---@type boolean Options: -vim.g.usemusic = true ---@type boolean Options: +-- Allow music controls and stats +vim.g.usemusic = false ---@type boolean Options: +-- Enable HardTime on startup vim.g.usehardtime = false ---@type boolean Options: +-- Enable Image plugin on compatible terminals vim.g.useimage = true ---@type boolean Options: +-- Ignore missing lazy.nvim plugin manager vim.g.ignore_no_lazy = false ---@type boolean Options: +-- Enable codesnap for code screenshots vim.g.codesnap = true ---@type boolean Options: +-- Enable Auto-hiding cursorline vim.g.auto_cursorline = true ---@type boolean Options: +-- Enable Auto-save vim.g.auto_save = true ---@type boolean Options: +-- Animate blinky cursor +vim.g.blinky = true ---@type boolean Options: +-- Use Rootiest cmd window instead of cmdline +vim.g.rootiest_cmd = false ---@type boolean Options: -- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ AI TOOL ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ vim.g.aitool = "codeium" ---@type string Options: [ai tool] @@ -42,15 +54,6 @@ vim.g.aitool = "codeium" ---@type string Options: [ai tool] -- │ │  none -- ╰───────────────────────────╯ --- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ STATUS LINE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -vim.g.statusline = "lualine" ---@type string Options: [statusline] --- ╭───────────────────────────╮  lualine --- │ │  heirline --- │ Status Lines: │  basic --- │ Choose a plugin from │  none --- │ the list  │ --- │ │ --- ╰───────────────────────────╯ -- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ STATUS COLUMN ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ vim.g.statuscolumn = "native" ---@type string Options: [statuscolumn] -- ╭───────────────────────────╮  barsNlines @@ -60,8 +63,9 @@ vim.g.statuscolumn = "native" ---@type string Options: [statuscolumn] -- │ the list  │ -- │ │ -- ╰───────────────────────────╯ + -- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ BUFFER LINE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -vim.g.tabline = "bufferline" ---@type string Options: [tabline] +vim.g.tabline = "none" ---@type string Options: [tabline] -- ╭───────────────────────────╮  bufferline -- │ │  barsNlines -- │ Tab Lines: │  none @@ -69,17 +73,32 @@ vim.g.tabline = "bufferline" ---@type string Options: [tabline] -- │ the list  │ -- │ │ -- ╰───────────────────────────╯ + +-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ STATUS LINE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +vim.g.statusline = "lualine" ---@type string Options: [statusline] +-- ╭───────────────────────────╮  lualine +-- │ │  heirline +-- │ Status Lines: │  barsNlines +-- │ Choose a plugin from │  basic +-- │ the list  │  none +-- │ │ +-- ╰───────────────────────────╯ +-- +-- Click git components on statusline to open LazyGit vim.g.statusline_clickable_git = false ---@type boolean Options: +-- Show wakatime stats on statusline vim.g.stats_wakatime = true ---@type boolean Options: +-- Show music stats on statusline vim.g.stats_music = true ---@type boolean Options: +-- Ignored player sources for music stats vim.g.stats_ignored_players = { ---@type string[] Options: [ignored players] - "chromium", - "firefox", - "kdeconnect", - "haruna", - "plasma-browser-integration", - "plasma-browser-integration-76042", -} + "chromium", + "firefox", + "kdeconnect", + "haruna", + "plasma-browser-integration", + "plasma-browser-integration-76042", + } -- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ COLOR ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -- Background color @@ -91,5 +110,9 @@ vim.g.disable_transparency = true ---@type boolean Options: -- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Completion ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -- Cmp Window Border -vim.g.completion_round_borders_enabled = true ---Options: +vim.g.completion_round_borders_enabled = true ---@type boolean Options: + -- stylua: ignore end + +-- Post-Config Operations +require("config.post-ops") diff --git a/lua/config/post-ops.lua b/lua/config/post-ops.lua new file mode 100644 index 0000000..196efc4 --- /dev/null +++ b/lua/config/post-ops.lua @@ -0,0 +1,28 @@ +---@module "config.post_ops" +--- This module contains the functions that exectute after +--- the options.lua file has been loaded. +-- ╭─────────────────────────────────────────────────────────╮ +-- │ Post Ops │ +-- ╰─────────────────────────────────────────────────────────╯ + +local M = {} + +M.apply_options = function() + -- Setup blinky cursor + require("utils.blinky").setup(vim.g.blinky) + + -- Setup Rootiest cmd window + require("utils.cmd_window").setup({ + override_cmdline = vim.g.rootiest_cmd and true or nil, + }) +end + +-- Setup post-ops module +M.setup = function() + M.apply_options() +end + +-- Call setup +M.setup() + +return M diff --git a/lua/config/rocks.lua b/lua/config/rocks.lua index 7eaf1b6..5e6314a 100644 --- a/lua/config/rocks.lua +++ b/lua/config/rocks.lua @@ -7,80 +7,118 @@ local M = {} -- ━━━━━━━━━━━━━━━━━━━━━━━━ Bootstrap rocks.nvim ━━━━━━━━━━━━━━━━━━━━━ -do - local rocks_config = { - rocks_path = vim.env.HOME .. "/.local/share/nvim/rocks", - } +function M.bootstrap() + do + local rocks_config = { + rocks_path = vim.env.HOME .. "/.local/share/nvim/rocks", + } - vim.g.rocks_nvim = rocks_config + vim.g.rocks_nvim = rocks_config - local luarocks_path = { - vim.fs.joinpath(rocks_config.rocks_path, "share", "lua", "5.1", "?.lua"), - vim.fs.joinpath( - rocks_config.rocks_path, - "share", - "lua", - "5.1", - "?", - "init.lua" - ), - } - package.path = package.path .. ";" .. table.concat(luarocks_path, ";") + local luarocks_path = { + vim.fs.joinpath(rocks_config.rocks_path, "share", "lua", "5.1", "?.lua"), + vim.fs.joinpath( + rocks_config.rocks_path, + "share", + "lua", + "5.1", + "?", + "init.lua" + ), + } + package.path = package.path .. ";" .. table.concat(luarocks_path, ";") - local luarocks_cpath = { - vim.fs.joinpath(rocks_config.rocks_path, "lib", "lua", "5.1", "?.so"), - vim.fs.joinpath(rocks_config.rocks_path, "lib64", "lua", "5.1", "?.so"), - -- Remove the dylib and dll paths if you do not need macos or windows support - vim.fs.joinpath(rocks_config.rocks_path, "lib", "lua", "5.1", "?.dylib"), - vim.fs.joinpath(rocks_config.rocks_path, "lib64", "lua", "5.1", "?.dylib"), - vim.fs.joinpath(rocks_config.rocks_path, "lib", "lua", "5.1", "?.dll"), - vim.fs.joinpath(rocks_config.rocks_path, "lib64", "lua", "5.1", "?.dll"), - } - package.cpath = package.cpath .. ";" .. table.concat(luarocks_cpath, ";") + local luarocks_cpath = { + vim.fs.joinpath(rocks_config.rocks_path, "lib", "lua", "5.1", "?.so"), + vim.fs.joinpath(rocks_config.rocks_path, "lib64", "lua", "5.1", "?.so"), + -- Remove the dylib and dll paths if you do not need macos or windows support + vim.fs.joinpath(rocks_config.rocks_path, "lib", "lua", "5.1", "?.dylib"), + vim.fs.joinpath( + rocks_config.rocks_path, + "lib64", + "lua", + "5.1", + "?.dylib" + ), + vim.fs.joinpath(rocks_config.rocks_path, "lib", "lua", "5.1", "?.dll"), + vim.fs.joinpath(rocks_config.rocks_path, "lib64", "lua", "5.1", "?.dll"), + } + package.cpath = package.cpath .. ";" .. table.concat(luarocks_cpath, ";") - vim.opt.runtimepath:append( - vim.fs.joinpath( - rocks_config.rocks_path, - "lib", - "luarocks", - "rocks-5.1", - "rocks.nvim", - "*" + vim.opt.runtimepath:append( + vim.fs.joinpath( + rocks_config.rocks_path, + "lib", + "luarocks", + "rocks-5.1", + "rocks.nvim", + "*" + ) ) - ) -end - --- If rocks.nvim is not installed then install it! -if not pcall(require, "rocks") then - ---@diagnostic disable-next-line: param-type-mismatch - local rocks_location = vim.fs.joinpath(vim.fn.stdpath("cache"), "rocks.nvim") - - if not vim.uv.fs_stat(rocks_location) then - -- Pull down rocks.nvim - vim.fn.system({ - "git", - "clone", - "--filter=blob:none", - "https://github.com/nvim-neorocks/rocks.nvim", - rocks_location, - }) end - -- If the clone was successful then source the bootstrapping script - assert( - vim.v.shell_error == 0, - "rocks.nvim installation failed. Try exiting and re-entering Neovim!" - ) + -- If rocks.nvim is not installed then install it! + if not pcall(require, "rocks") then + local rocks_location = + ---@diagnostic disable-next-line: param-type-mismatch + vim.fs.joinpath(vim.fn.stdpath("cache"), "rocks.nvim") - vim.cmd.source(vim.fs.joinpath(rocks_location, "bootstrap.lua")) + if not vim.uv.fs_stat(rocks_location) then + -- Pull down rocks.nvim + vim.fn.system({ + "git", + "clone", + "--filter=blob:none", + "https://github.com/nvim-neorocks/rocks.nvim", + rocks_location, + }) + end - vim.fn.delete(rocks_location, "rf") + -- If the clone was successful then source the bootstrapping script + assert( + vim.v.shell_error == 0, + "rocks.nvim installation failed. Try exiting and re-entering Neovim!" + ) + + vim.cmd.source(vim.fs.joinpath(rocks_location, "bootstrap.lua")) + + vim.fn.delete(rocks_location, "rf") + end end +-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━ Ensure Luarocks ━━━━━━━━━━━━━━━━━━━━━━━ +function M.ensure_luarocks() + -- Check if 'luarocks' command is available + if os.execute("luarocks --version") ~= 0 then + -- 'luarocks' is not installed, set up 'luarocks.nvim' plugin + local status_ok, lazy = pcall(require, "lazy") + if not status_ok then + vim.notify( + "Lazy.nvim not found. Please install it to manage plugins.", + vim.log.levels.ERROR + ) + return + end + + lazy.setup({ + { + "vhyrro/luarocks.nvim", + priority = 1000, -- Ensure this plugin loads first + opts = { + rocks = { "magick" }, -- Example of a rock that you want to install + }, + config = function() + -- Restart Neovim to apply changes after 'luarocks.nvim' sets up + vim.cmd("source $MYVIMRC | qa") + end, + }, + }) + 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. + priority = 1000, -- Very high priority is required opts = { rocks = { "magick" }, -- specifies a list of rocks to install }, @@ -94,6 +132,8 @@ end -- Perform setup M.setup = function() + M.bootstrap() + M.ensure_luarocks() M.load_rocks() end diff --git a/lua/config/rootiest.lua b/lua/config/rootiest.lua index 957f907..919785c 100644 --- a/lua/config/rootiest.lua +++ b/lua/config/rootiest.lua @@ -13,6 +13,11 @@ local function trigger_error(message) return require("data").func.notify(message, "ERROR") end +local function setup_os_vars() + -- Check if we are on windows + vim.g.is_windows = vim.fn.has("win32") == 1 or vim.fn.has("win64") == 1 +end + --- Yank line without leading/trailing whitespace ---@return nil function M.yank_line() @@ -180,6 +185,7 @@ end --- Set up rootiest module function M.setup() + setup_os_vars() M.eval_neovide() M.define_commands() @@ -187,22 +193,6 @@ function M.setup() require("data.types").setup() -- Setup indentor require("utils.indentor") - - ---━━━━━━━━━━━━━━━━━━━━━━━━━━ Rootiest cmd window ━━━━━━━━━━━━━━━━━━━━━━━━━ - -- - -- Setup Rootiest cmd window utility - require("utils.cmd_window").setup() - - -- Setup Rootiest cmd window (override default command-line behavior) - -- 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 return M diff --git a/lua/data/cmd.lua b/lua/data/cmd.lua index 5d21402..0acd6ff 100644 --- a/lua/data/cmd.lua +++ b/lua/data/cmd.lua @@ -74,6 +74,10 @@ M.ripsub = { "RipSubstitute", } +M.spell_errors = { + "Telescope spell_errors", +} + --- Suda plugin cmds M.suda = { "SudaWrite", diff --git a/lua/data/dash.lua b/lua/data/dash.lua index 1ae044f..477637d 100644 --- a/lua/data/dash.lua +++ b/lua/data/dash.lua @@ -24,7 +24,7 @@ M.alpha = { -- stylua: ignore start dashboard.section.buttons.val = { ---@diagnostic disable: param-type-mismatch - dashboard.button("f", " " .. " Find file", LazyVim.pick()), + dashboard.button("f", " " .. " Find file", "Telescope frecency workspace=CWD "), dashboard.button("n", " " .. " New file", [[ ene startinsert ]]), dashboard.button("r", " " .. " Recent files", LazyVim.pick("oldfiles")), dashboard.button("g", " " .. " Grep text", LazyVim.pick("live_grep")), diff --git a/lua/data/func.lua b/lua/data/func.lua index 05eff28..07e6ae5 100644 --- a/lua/data/func.lua +++ b/lua/data/func.lua @@ -233,6 +233,218 @@ function M.notify(message, level, title) return true end +---@function Function to generate a y/n confirmation prompt +---@param prompt string The prompt text to display +---@param action function|string The action to execute if the user confirms the prompt, or a Vim command as a string +---@return boolean condition true if the user confirms the prompt, false otherwise +function M.ConfirmPrompt(prompt, action) + -- Validate the action parameter + local function perform_action() + if type(action) == "function" then + action() -- Call the function + elseif type(action) == "string" then + vim.cmd(action) -- Run the Vim command + else + M.notify( + "Action must be a function or a string", + "ERROR", + "Configuration Error" + ) + end + end + -- Create a new buffer + local buf = vim.api.nvim_create_buf(false, true) -- Create a new empty buffer + -- Set the prompt text in the buffer + vim.api.nvim_buf_set_lines(buf, 0, -1, false, { prompt, "y/n: " }) + -- Create a floating window to display the buffer + local win_height = 2 -- Height of floating window + local win_width = math.floor(vim.o.columns * 0.25) -- Width of floating window + local row = math.floor((vim.o.lines - win_height) / 2) -- Position row + local col = math.floor((vim.o.columns - win_width) / 2) -- Position column + local win_border = "rounded" + local style = "minimal" + -- Create a floating window + local win = vim.api.nvim_open_win(buf, true, { + relative = "editor", + width = win_width, + height = win_height, + col = col, + row = row, + style = style, + border = win_border, + }) + -- Move the cursor to the end of the buffer + vim.api.nvim_win_set_cursor(win, { 2, 5 }) + -- Define the yes function + local yes = function() + vim.api.nvim_win_close(win, true) + perform_action() -- Perform the action + return true + end + -- Define the no function + local no = function() + vim.api.nvim_win_close(win, true) + M.notify("Action Canceled", "INFO", "Info") + end + -- Define buffer-specific key mappings + local keymaps = { + y = function() + yes() + end, + n = function() + no() + end, + q = function() + no() + end, + [""] = function() + no() + end, + } + -- Set the key mappings + for key, callback in pairs(keymaps) do + vim.api.nvim_buf_set_keymap(buf, "n", key, "", { + noremap = true, + nowait = true, + callback = callback, + }) + end + + return false +end + +---@function Function to generate an input prompt +---@param prompt string The prompt text to display +---@param callback function The function to call with the user input +function M.InputPrompt(prompt, callback) + -- Create a new buffer + local buf = vim.api.nvim_create_buf(false, true) -- Create a new empty buffer + + -- Set the buffer name + vim.api.nvim_buf_set_name(buf, "Input") + -- Set the buffer filetype (e.g., for custom behavior or syntax highlighting) + vim.bo[buf].filetype = "input" + -- Set the buffer type to "nofile" to avoid editing or saving the buffer + vim.bo[buf].buftype = "nofile" + -- Set the prompt text in the buffer + vim.api.nvim_buf_set_lines(buf, 0, -1, false, { prompt, "Input: " }) + + -- Create a floating window to display the buffer + local win_height = 2 -- Height of floating window + local win_width = math.floor(vim.o.columns * 0.25) -- Width of floating window + local row = math.floor((vim.o.lines - win_height) / 2) -- Position row + local col = math.floor((vim.o.columns - win_width) / 2) -- Position column + local win_border = "rounded" + local style = "minimal" + + -- Create a floating window + local win = vim.api.nvim_open_win(buf, true, { + relative = "editor", + width = win_width, + height = win_height, + col = col, + row = row, + style = style, + border = win_border, + }) + + -- Move the cursor to the end of the buffer + vim.api.nvim_win_set_cursor(win, { 2, 8 }) + -- Set input mode + vim.api.nvim_command("startinsert") + + -- Function to close the window + local function exit_win() + vim.api.nvim_command("stopinsert") + vim.api.nvim_win_close(win, true) + end + + -- Function to handle input and close the window + local function handle_input() + -- Get the text after the "Input: " string + local input = vim.api.nvim_buf_get_lines(buf, 1, 2, false)[1]:sub(7) -- Adjust to trim "Input: " + return input + end + + ---@function Function to return user input + local function yes() + local user_input = handle_input() -- Get the input from the buffer + exit_win() + if callback then + callback(user_input) -- Call the callback with the user input + end + end + + ---@function Function to cancel user input + local function no() + exit_win() + if callback then + callback(nil) -- Call the callback with nil to indicate cancellation + end + end + + -- Define buffer-specific key mappings + local keymaps = { + [""] = yes, + [""] = no, + } + + -- Set the key mappings + for key, keyback in pairs(keymaps) do + vim.api.nvim_buf_set_keymap(buf, "n", key, "", { + noremap = true, + nowait = true, + callback = keyback, + }) + vim.api.nvim_buf_set_keymap(buf, "i", key, "", { + noremap = true, + nowait = true, + callback = keyback, + }) + end +end + +---@function Function to reload the user's Neovim configuration +---@return nil +function M.reload_config() + -- Notify the user about the reload process + M.notify("Reloading configuration...", "WARN", "Reloading Config") + -- 1. Save all buffers + vim.cmd("silent! wa") + -- 2. Record the list of open buffers to reopen later + local buffer_list = vim.api.nvim_list_bufs() + local buffers_to_reopen = {} + for _, buf in ipairs(buffer_list) do + if vim.api.nvim_buf_is_loaded(buf) and vim.fn.bufname(buf) ~= "" then + table.insert( + buffers_to_reopen, + { buf = buf, file = vim.api.nvim_buf_get_name(buf) } + ) + end + end + -- 3. Close all buffers + vim.cmd("silent! bufdo! bwipeout") + -- 4. Clear loaded lua modules related to your custom configuration + for name, _ in pairs(package.loaded) do + -- Replace 'userconfig' and 'plugin' with your actual config module names + if name:match("^userconfig") or name:match("^plugins") then + package.loaded[name] = nil + end + end + -- 5. Reload the vim script (init.lua) + vim.cmd("source $MYVIMRC") + -- 6. Reopen the buffers + for _, bufinfo in ipairs(buffers_to_reopen) do + local buf = vim.fn.bufadd(bufinfo.file) + vim.cmd("buffer " .. buf) + vim.api.nvim_buf_call(buf, function() + -- You could also restore the exact cursor position if desired + vim.cmd('silent! normal! g`"') + end) + end -- Notify the user that the config has been reloaded + M.notify("Configuration reloaded successfully!", "INFO", "Reloaded Config") +end + ---@function Function to reload all plugins. --- 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. diff --git a/lua/data/keys.lua b/lua/data/keys.lua index 5f9fb38..de76a8d 100644 --- a/lua/data/keys.lua +++ b/lua/data/keys.lua @@ -357,6 +357,13 @@ M.misc = { end, desc = "Toggle Hardmode", }, + { -- Reload config + lhs = "qr", + rhs = function() + require("data.func").reload_config() + end, + desc = "Reload Config", + }, { -- Yank buffer lhs = "Y", rhs = "%y", @@ -372,6 +379,21 @@ M.misc = { rhs = "Neotree reveal toggle", desc = "Neotree toggle", }, + { -- Neotree + lhs = "\\", + rhs = "Neotree reveal toggle", + desc = "Neotree toggle", + }, + { -- Mini.files + lhs = ".", + rhs = "lua require('mini.files').open()", + desc = "Open mini.files", + }, + { -- Telescope Frecency + lhs = "", + rhs = "Telescope frecency workspace=CWD", + desc = "Telescope frecency", + }, { -- Exit Neovim lhs = "Q", rhs = "lua require('data').func.exit()", @@ -603,13 +625,12 @@ M.substitute = { }, } -M.surround = { +M.overrides = { { -- De-map 's' to avoid conflicts with mini.surround lhs = "s", rhs = "", - desc = "Prevent conflict with mini.surround", + desc = "Surround", mode = { "n", "x" }, - hidden = true, }, } diff --git a/lua/data/types.lua b/lua/data/types.lua index 46e9d15..a3cdfa2 100644 --- a/lua/data/types.lua +++ b/lua/data/types.lua @@ -189,6 +189,23 @@ M.arrow = { --- Bufferline configuration options M.bufferline = { + enabled = function() + if + require("data.func").check_global_var( + "tabline", + "bufferline", + "bufferline" + ) + or require("data.func").check_global_var( + "tabline", + "barsNlines", + "bufferline" + ) + then + return true + end + return false + end, opts = { options = { themable = true, @@ -440,6 +457,10 @@ M.whichkey = { winblend = 10, }, }, + triggers = { + { "", mode = { "n", "v" } }, + { "s", mode = { "n", "x" } }, + }, }, } @@ -479,8 +500,10 @@ M.gitgraph = { else -- Fallback return { - merge_commit = "M", - commit = "*", + merge_commit = "", + commit = "", + merge_commit_end = "", + commit_end = "", } end end, @@ -518,6 +541,7 @@ M.ibl = { }, scope_char = { light = { "" }, + hard = { "│" }, none = { " " }, fancy = { "‖" }, strong = { "⦀" }, @@ -650,56 +674,122 @@ M.trouble = { } --- 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" }, +M.barsNlines = { + enabled = function() + if + require("data.func").check_global_var( + "statuscolumn", + "barsNlines", + "native" + ) + or require("data.func").check_global_var( + "tabline", + "barsNlines", + "bufferline" + ) + or require("data.func").check_global_var( + "statusline", + "barsNlines", + "lualine" + ) + then + return true + end + return false + end, + config = function() + require("bars").setup({ + exclude_filetypes = M.minimap.ft, + exclude_buftypes = M.minimap.buf, + statuscolumn = { + enable = require("data.func").check_global_var( + "statuscolumn", + "barsNlines", + "native" + ), + 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", + { + type = "number", + mode = "hybrid", + hl = "LineNr", + lnum_hl = "BarsStatusColumnNum", + relnum_hl = "LineNr", + virtnum_hl = "TablineSel", + wrap_hl = "TablineSel", + }, }, }, - }, - tabline = false, - statusline = false, - }) -end + tabline = { + enable = require("data.func").check_global_var( + "tabline", + "barsNlines", + "bufferline" + ), + parts = { + { + -- Part name + type = "bufs", + + -- Active buffer configuration + active = { + corner_left = { "", "BarsTablineBufActiveSep" }, + corner_right = { "", "BarsTablineBufActiveSep" }, + + padding_left = { " ", "BarsTablineBufActive" }, + padding_right = { " " }, + }, + + -- Inactive buffer configuration + inactive = { + corner_left = { "", "BarsTablineBufInactiveSep" }, + corner_right = { "", "BarsTablineBufInactiveSep" }, + + padding_left = { " ", "BarsTablineBufInactive" }, + padding_right = { " " }, + }, + + -- List of patterns to ignore + ignore = {}, + }, + }, + }, + statusline = { + enable = require("data.func").check_global_var( + "statusline", + "barsNlines", + "lualine" + ), + }, + }) + end, +} --- Function to setup Pigeon plugin options M.pigeon = function() - local data = require("data") - local platform = data.func.get_os("platform") + local platform = require("data.func").get_os("platform") local lazy_installed = pcall(require, "lazy") local packer_installed = pcall(require, "packer_plugins") local pigeon_enabled = true -- default @@ -711,7 +801,7 @@ M.pigeon = function() elseif vim.fn.exists("g:plugs") == 1 then plugman = "vim-plug" else - data.func.notify( + require("data.func").notify( "Failed to detect package manager.\nPigeon disabled.", "ERROR" ) @@ -955,6 +1045,38 @@ M.toggleterm = { }, } +M.treesitter = { + opts = { + ensure_installed = { + "bash", + "c", + "css", + "diff", + "html", + "javascript", + "jsdoc", + "json", + "jsonc", + "lua", + "luadoc", + "luap", + "markdown", + "markdown_inline", + "printf", + "python", + "query", + "regex", + "toml", + "tsx", + "typescript", + "vim", + "vimdoc", + "xml", + "yaml", + }, + }, +} + --- Function to extend minimap.buf with general exclusions ---@private ---@return nil diff --git a/lua/plugins/astral.lua b/lua/plugins/astral.lua index 7fe579d..22f3f54 100644 --- a/lua/plugins/astral.lua +++ b/lua/plugins/astral.lua @@ -16,5 +16,5 @@ return { -- Astral "default", }, }, - -- dev = true, -- Use local codebase + dev = true, -- Use local codebase } diff --git a/lua/plugins/cmp.lua b/lua/plugins/cmp.lua index 419f3db..7dcb14e 100644 --- a/lua/plugins/cmp.lua +++ b/lua/plugins/cmp.lua @@ -125,6 +125,11 @@ return { -- }, }) + -- Input filetype + cmp.setup.filetype("input", { + sources = {}, + }) + -- Custom filetype configuration cmp.setup.filetype("config", { sources = vim.tbl_filter(function(source) diff --git a/lua/plugins/coding.lua b/lua/plugins/coding.lua index d1592ca..c916a05 100644 --- a/lua/plugins/coding.lua +++ b/lua/plugins/coding.lua @@ -12,6 +12,10 @@ return { automatic_installation = true, }, }, + { + "nvim-treesitter/nvim-treesitter", + opts = data.types.treesitter.opts, + }, { -- "neovim/nvim-lspconfig", opts = data.types.lspconfig.opts, diff --git a/lua/plugins/core.lua b/lua/plugins/core.lua index fdab396..0f8f532 100644 --- a/lua/plugins/core.lua +++ b/lua/plugins/core.lua @@ -14,6 +14,7 @@ return { }, { -- Bufferline "akinsho/bufferline.nvim", + enabled = data.types.bufferline.enabled, opts = data.types.bufferline.opts, }, { -- Which-Key diff --git a/lua/plugins/editor.lua b/lua/plugins/editor.lua index 9e16a22..2d85238 100644 --- a/lua/plugins/editor.lua +++ b/lua/plugins/editor.lua @@ -113,6 +113,7 @@ return { }, { -- Colorful window separators "nvim-zh/colorful-winsep.nvim", + lazy = true, opts = { only_line_seq = false, symbols = data.types.colorful_winsep.symbols, @@ -129,12 +130,14 @@ return { }, { -- Bars N Lines "OXY2DEV/bars-N-lines.nvim", - enabled = data.func.check_global_var( - "statuscolumn", - "barsNlines", - "native" - ), + enabled = data.types.barsNlines.enabled, lazy = false, - config = data.types.barsNlines, + config = data.types.barsNlines.config, + }, + { + "nvim-telescope/telescope-frecency.nvim", + config = function() + require("telescope").load_extension("frecency") + end, }, } diff --git a/lua/plugins/languages.lua b/lua/plugins/languages.lua index d4cc793..0171f78 100644 --- a/lua/plugins/languages.lua +++ b/lua/plugins/languages.lua @@ -40,4 +40,7 @@ return { { -- Sql import = "lazyvim.plugins.extras.lang.sql", }, + { -- Jinja + "armyers/Vim-Jinja2-Syntax", + }, } diff --git a/lua/plugins/mini.lua b/lua/plugins/mini.lua index ab58a97..b5896fe 100644 --- a/lua/plugins/mini.lua +++ b/lua/plugins/mini.lua @@ -29,9 +29,6 @@ return { { -- mini.surround "echasnovski/mini.surround", opts = {}, - keys = function() - data.func.add_keymap(data.keys.surround) - end, }, { -- mini.files "echasnovski/mini.files", diff --git a/lua/plugins/util.lua b/lua/plugins/util.lua index c080f3e..b50df6d 100644 --- a/lua/plugins/util.lua +++ b/lua/plugins/util.lua @@ -123,14 +123,14 @@ return { ft = "help", dependencies = data.deps.needs_treesitter, }, - { -- Docker-compose logs - "adelowo/dockercomposelogs.nvim", - config = function() - require("dockercomposelogs").setup({}) - end, - event = "VeryLazy", - dependencies = data.deps.needs_telescope, - }, + -- { -- Docker-compose logs + -- "adelowo/dockercomposelogs.nvim", + -- config = function() + -- require("dockercomposelogs").setup({}) + -- end, + -- event = "VeryLazy", + -- dependencies = data.deps.needs_telescope, + -- }, { -- Suda "lambdalisue/vim-suda", cmd = data.cmd.suda, @@ -141,13 +141,21 @@ return { }, { -- Spell checker "matkrin/telescope-spell-errors.nvim", + lazy = true, + cmd = data.cmd.spell_errors, config = function() require("telescope").load_extension("spell_errors") end, dependencies = data.deps.needs_telescope, }, - { -- + { -- Pigeon "Pheon-Dev/pigeon", config = data.types.pigeon, }, + { -- Discord Presence + "andweeb/presence.nvim", + opts = { + enable_line_number = true, + }, + }, } diff --git a/lua/utils/blinky.lua b/lua/utils/blinky.lua index 09e552a..5062889 100644 --- a/lua/utils/blinky.lua +++ b/lua/utils/blinky.lua @@ -24,4 +24,17 @@ function M.disable() return false end +---@function Function to setup blinky cursor option +---@param enable boolean|nil enable blinky cursor option +function M.setup(enable) + if enable then + vim.g.blinky = enable + end + if vim.g.blinky ~= false then + M.enable() + else + M.disable() + end +end + return M diff --git a/lua/utils/cache_stats.lua b/lua/utils/cache_stats.lua index 3126107..8f7b941 100644 --- a/lua/utils/cache_stats.lua +++ b/lua/utils/cache_stats.lua @@ -24,6 +24,10 @@ _G.cache_stats_dir = -- Cache directory -- Flag to check if the script has already been run local script_run_once = false +-- Variable to track the pid +---@type number|boolean +M.pid = false + -- Default list of players/sources to ignore when updating the status local ignored_players = { "chromium", @@ -84,7 +88,42 @@ function M.setup_script() return false end +---@function Function to force the script to reset +--- This will kill the script if it's running and delete the lock file. +--- Optionally the cache files will be deleted if wipe is true. +--- By default, the cache files will not be deleted. +--- If the script is not running, this function will start the script. +---@param wipe boolean|nil Whether to wipe the cache files (default: false) +--- If true, the cache files will be deleted. +--- If false, the cache files will not be deleted. +--- +--- The cache files are: +--- - music_cache.txt +--- - wakatime_cache.txt +---@return boolean|number pid The pid of the script +function M.reset_script(wipe) + -- Try to kill the script if it's running + if M.pid and vim.fn.jobstop(M.pid) == 0 then + M.pid = false + end + -- Remove the lockfile + vim.fn.delete( + vim.fs.joinpath(_G.cache_stats_dir, "music_wakatime_update.lock") + ) + -- Wipe the cache files + if wipe then + vim.fn.delete(vim.fs.joinpath(_G.cache_stats_dir, "music_cache.txt")) + vim.fn.delete(vim.fs.joinpath(_G.cache_stats_dir, "wakatime_cache.txt")) + end + -- Reset the script_run_once flag + script_run_once = false + -- Re-run the script + M.pid = M.setup_script() + -- Return the pid + return M.pid +end + -- Run the setup script -M.setup_script() +M.pid = M.setup_script() return M diff --git a/lua/utils/highlight.lua b/lua/utils/highlight.lua index 52a0652..9213108 100644 --- a/lua/utils/highlight.lua +++ b/lua/utils/highlight.lua @@ -84,7 +84,7 @@ function M.setup_indent_highlight() "IndentsScopeHighlight", "IndentsScopeHighlight", }, - char = vim.g.scope_char or data.types.ibl.scope_char.light, + char = vim.g.scope_char or data.types.ibl.scope_char.hard, }, whitespace = { remove_blankline_trail = true, diff --git a/spell/en.utf-8.add b/spell/en.utf-8.add index 6913fbf..28b9304 100644 --- a/spell/en.utf-8.add +++ b/spell/en.utf-8.add @@ -2,3 +2,4 @@ NeoVim Rootiest colorscheme catppuccin +Rootiest diff --git a/spell/en.utf-8.add.spl b/spell/en.utf-8.add.spl new file mode 100644 index 0000000..3c4b9d1 Binary files /dev/null and b/spell/en.utf-8.add.spl differ