diff --git a/lua/config/autocmds.lua b/lua/config/autocmds.lua index a289458..e5d8fd4 100644 --- a/lua/config/autocmds.lua +++ b/lua/config/autocmds.lua @@ -2,10 +2,15 @@ -- -------------------------------- AUTOCMDS ----------------------------------- -- ----------------------------------------------------------------------------- +local autogrp = vim.api.nvim_create_augroup +local autocmd = vim.api.nvim_create_autocmd + -- GIT CONFLICT MARKERS -- if there are conflicts, jump to first conflict, highlight conflict markers, -- and disable diagnostics (simplified version of `git-conflict.nvim`) -vim.api.nvim_create_autocmd({ "BufEnter", "FocusGained" }, { +autogrp("GitConflictMarkers", { clear = true }) +autocmd({ "BufEnter", "FocusGained" }, { + group = "GitConflictMarkers", callback = function(ctx) local hlgroup = "DiagnosticVirtualTextInfo" -- CONFIG diff --git a/lua/config/highlight.lua b/lua/config/highlight.lua index 3dac614..9e567fc 100644 --- a/lua/config/highlight.lua +++ b/lua/config/highlight.lua @@ -183,15 +183,6 @@ function M.setup_autocommands() local autogrp = vim.api.nvim_create_augroup local autocmd = vim.api.nvim_create_autocmd autogrp("IndentHighlight", { clear = true }) - -- Autocommand to trigger setup on FileType - -- autocmd("FileType", { - -- pattern = "*", - -- group = "IndentHighlight", - -- callback = function() - -- M.setup_indent_highlight() - -- M.setup_dashboard_highlight() - -- end, - -- }) -- List of filetypes to exclude local excluded_filetypes = { @@ -209,7 +200,7 @@ function M.setup_autocommands() } -- Autocommand to trigger setup on FileType - vim.api.nvim_create_autocmd("FileType", { + autocmd("FileType", { group = "IndentHighlight", callback = function() local filetype = vim.bo.filetype diff --git a/lua/config/keymaps.lua b/lua/config/keymaps.lua index 57c128b..c88bc4f 100644 --- a/lua/config/keymaps.lua +++ b/lua/config/keymaps.lua @@ -7,12 +7,6 @@ -- Initialize which-key local wk = require("which-key") wk.add({ - { -- Toggle Terminal - mode = "n", - "", - ":ToggleTerm", - desc = "Toggle Terminal", - }, { -- Open LazyGit in terminal "gt", rhs = function() @@ -26,42 +20,6 @@ wk.add({ lhs = "I", group = "IconPicker", icon = { icon = "󰥸", color = "orange" }, - cond = function() - return pcall(require, "icon-picker") - end, - }, - -- Pick Icon - { - mode = "n", - lhs = "Ii", - rhs = "IconPickerNormal", - desc = "Pick Icon", - group = "IconPicker", - cond = function() - return pcall(require, "icon-picker") - end, - }, - -- Yank Icon - { - mode = "n", - lhs = "Iy", - rhs = "IconPickerYank", - desc = "Yank Icon", - group = "IconPicker", - cond = function() - return pcall(require, "icon-picker") - end, - }, - -- Insert Icon in insert mode - { - mode = "i", - lhs = "", - rhs = "IconPickerInsert", - desc = "Insert Icon", - group = "IconPicker", - cond = function() - return pcall(require, "icon-picker") - end, }, -- Gists group { @@ -69,29 +27,6 @@ wk.add({ lhs = "gn", group = "Gists", icon = { icon = "", color = "orange" }, - cond = function() - return pcall(require, "gist") - end, - }, - -- Create Gist - { - mode = { "n", "x" }, - lhs = "gnc", - rhs = "GistCreate", - desc = "Create Gist", - cond = function() - return pcall(require, "gist") - end, - }, - -- Find Gists - { - mode = "n", - lhs = "gnf", - rhs = "GistList", - desc = "Find Gists", - cond = function() - return pcall(require, "gist") - end, }, { -- Lazy group "l", @@ -112,140 +47,6 @@ wk.add({ group = "MiniMap", icon = { icon = "", color = "yellow" }, }, - -- Save selected code snapshot into clipboard - { - mode = "x", - lhs = "cy", - rhs = "CodeSnap", - desc = "Save selected code snapshot into clipboard", - cond = function() - return pcall(require, "codesnap") - end, - }, - -- Save selected code snapshot in ~/Pictures - { - mode = "x", - lhs = "cs", - rhs = "CodeSnapSave", - desc = "Save selected code snapshot in ~/Pictures", - cond = function() - return pcall(require, "codesnap") - end, - }, - -- Highlight and snapshot selected code into clipboard - { - mode = "x", - lhs = "ch", - rhs = "CodeSnapHighlight", - desc = "Highlight and snapshot selected code into clipboard", - cond = function() - return pcall(require, "codesnap") - end, - }, - -- Save ASCII code snapshot into clipboard - { - mode = "x", - lhs = "ci", - rhs = "CodeSnapASCII", - desc = "Save ASCII code snapshot into clipboard", - cond = function() - return pcall(require, "codesnap") - end, - }, - { - "gx", - "Browse", - mode = { "n", "x" }, - desc = "Open URL/Link", - }, - { - "lg", - "LazyGit", - desc = "LazyGit", - }, - { - "fs", - rhs = function() - require("rip-substitute").sub() - end, - mode = { "n", "x" }, - desc = "Rip Substitute", - }, - { - "", - rhs = function() - require("kitty-navigator").navigateLeft() - end, - desc = "KittyNavigateLeft", - cond = function() -- Using Kitty - return require("config.rootiest").using_kitty() - end, - }, - { - "", - rhs = function() - require("kitty-navigator").navigateDown() - end, - desc = "KittyNavigateDown", - cond = function() -- Using Kitty - return require("config.rootiest").using_kitty() - end, - }, - { - "", - rhs = function() - require("kitty-navigator").navigateUp() - end, - desc = "KittyNavigateUp", - cond = function() -- Using Kitty - return require("config.rootiest").using_kitty() - end, - }, - { - "", - rhs = function() - require("kitty-navigator").navigateRight() - end, - desc = "KittyNavigateRight", - cond = function() -- Using Kitty - return require("config.rootiest").using_kitty() - end, - }, - { - "zk", - rhs = function() - require("config.rootiest").toggle_precognition() - end, - desc = "Toggle Precognition", - }, - { - "a", - "Alternate", - desc = "Toggle Alternate", - cond = function() - return ( - vim.bo.filetype == "c" - or vim.bo.filetype == "h" - or vim.bo.filetype == "cpp" - or vim.bo.filetype == "hpp" - ) - end, - }, - { - "wt", - rhs = function() - require("transparent").toggle() - end, - desc = "Toggle Transparency", - }, - { - mode = "x", - lhs = "r", - rhs = function() - require("substitute").visual() - end, - desc = "Substitute", - }, { "yo", rhs = function() @@ -260,82 +61,7 @@ wk.add({ end, desc = "Toggle Hardmode", }, - { -- Toggle ZenMode - "z", - rhs = function() - require("zen-mode").toggle() - end, - desc = "Toggle ZenMode", - }, - -- Substitute operator in normal mode - { - mode = "n", - lhs = "x", - rhs = function() - require("substitute").operator() - end, - desc = "Substitute operator", - cond = function() - return pcall(require, "substitute") - end, - }, - -- Substitute line in normal mode - { - mode = "n", - lhs = "xx", - rhs = function() - require("substitute").line() - end, - desc = "Substitute line", - cond = function() - return pcall(require, "substitute") - end, - }, - -- Substitute end of line in normal mode - { - mode = "n", - lhs = "X", - rhs = function() - require("substitute").eol() - end, - desc = "Substitute end of line", - cond = function() - return pcall(require, "substitute") - end, - }, - -- Substitute visual selection in visual mode - { - mode = "x", - lhs = "x", - rhs = function() - require("substitute").visual() - end, - desc = "Substitute visual selection", - cond = function() - return pcall(require, "substitute") - end, - }, { "u,", group = "Font" }, - { "u,l", "Nekifoch list", desc = "Fonts list" }, - { - "u,c", - "Nekifoch check", - desc = "Check current font settings", - }, - { - "u,f", - rhs = function() - require("nekifoch.nui_set_font")() - end, - desc = "Set font family", - }, - { - "u,s", - rhs = function() - require("nekifoch.nui_set_size")() - end, - desc = "Set font size", - }, { -- Yank buffer contents "Y", "%y", diff --git a/lua/config/rootiest.lua b/lua/config/rootiest.lua index 01de56e..194ab7b 100644 --- a/lua/config/rootiest.lua +++ b/lua/config/rootiest.lua @@ -110,31 +110,6 @@ function M.set_cursor_icons() end end --- Evaluate dependencies and print warnings if needed -function M.eval_dependencies() - local function should_suppress_warnings() - return false - end - - local function check_executable(executable) - if vim.fn.executable(executable) ~= 1 then - vim.api.nvim_notify( - executable .. " is not installed!", - vim.log.levels.WARN, - {} - ) - end - end - - if not should_suppress_warnings() then - local executables = - { "lazygit", "gh", "rg", "fzf", "fd", "git", "luarocks" } - for _, executable in ipairs(executables) do - check_executable(executable) - end - end -end - -- Evaluate Neovide settings function M.eval_neovide() if vim.g.neovide then @@ -158,11 +133,40 @@ function M.define_commands() end, { force = true, desc = "Yank line without leading whitespace" }) end +function M.define_autocommands() + local autogrp = vim.api.nvim_create_augroup + local autocmd = vim.api.nvim_create_autocmd + autogrp("AutoSpellCorrections", { clear = true }) + -- List of filetypes to exclude + local excluded_filetypes = { + "help", + "alpha", + "dashboard", + "neo-tree", + "Trouble", + "trouble", + "lazy", + "mason", + "notify", + "toggleterm", + "lazyterm", + } + -- Autocommand to trigger setup on FileType + autocmd("FileType", { + group = "AutoSpellCorrections", + callback = function() + local filetype = vim.bo.filetype + if not vim.tbl_contains(excluded_filetypes, filetype) then + M.define_autocorrections() + end + end, + }) +end + function M.setup() - M.eval_dependencies() M.eval_neovide() - M.define_autocorrections() M.define_commands() + M.define_autocommands() end return M diff --git a/lua/plugins/coding.lua b/lua/plugins/coding.lua index 497adb2..f86ed49 100644 --- a/lua/plugins/coding.lua +++ b/lua/plugins/coding.lua @@ -58,7 +58,15 @@ return { }, { -- Alternate "ton/vim-alternate", + lazy = true, ft = { "cpp", "h", "hpp", "c" }, + keys = { + { -- Toggle Alternate + "a", + "Alternate", + desc = "Toggle Alternate", + }, + }, }, { -- Completion "hrsh7th/nvim-cmp", @@ -104,18 +112,57 @@ return { }, { -- Colorizer "norcalli/nvim-colorizer.lua", - event = "InsertEnter", + event = "BufEnter", config = function() require("colorizer").setup() end, }, { -- Substitute "gbprod/substitute.nvim", - event = "InsertEnter", + lazy = true, opts = { yank_substituted_text = false, preserve_cursor_position = true, }, + keys = { + { -- Substitute operator in normal mode + "x", + function() + require("substitute").operator() + end, + desc = "Substitute operator", + }, + { -- Substitute line in normal mode + "xx", + function() + require("substitute").line() + end, + desc = "Substitute line", + }, + { -- Substitute end of line in normal mode + "X", + function() + require("substitute").eol() + end, + desc = "Substitute end of line", + }, + { -- Substitute visual selection in visual mode + "x", + function() + require("substitute").visual() + end, + desc = "Substitute visual selection", + mode = "x", + }, + { + "r", + function() + require("substitute").visual() + end, + desc = "Substitute", + mode = "x", + }, + }, }, { -- mini.splitjoin "echasnovski/mini.splitjoin", diff --git a/lua/plugins/editor.lua b/lua/plugins/editor.lua index 02646b2..932f906 100644 --- a/lua/plugins/editor.lua +++ b/lua/plugins/editor.lua @@ -42,15 +42,14 @@ return { }, { -- indent-blankline "lukas-reineke/indent-blankline.nvim", + lazy = true, }, { -- Outline import = "lazyvim.plugins.extras.editor.outline", }, - { -- Telescope - import = "lazyvim.plugins.extras.editor.telescope", - }, { -- FoldNav "domharries/foldnav.nvim", + lazy = true, keys = { { "", @@ -80,6 +79,7 @@ return { }, { -- Which-Key "folke/which-key.nvim", + lazy = true, opts = { preset = "modern", win = { @@ -118,12 +118,30 @@ return { "tris203/precognition.nvim", lazy = true, opts = {}, + keys = { + { + "zk", + function() + require("config.rootiest").toggle_precognition() + end, + desc = "Toggle Precognition", + }, + }, }, { -- Zen Mode "folke/zen-mode.nvim", --event = "VeryLazy", lazy = true, opts = {}, + keys = { + { -- Toggle ZenMode + "z", + function() + require("zen-mode").toggle() + end, + desc = "Toggle ZenMode", + }, + }, }, { -- SmoothCursor "gen740/SmoothCursor.nvim", diff --git a/lua/plugins/terminal.lua b/lua/plugins/terminal.lua index 23712e1..91dbad9 100644 --- a/lua/plugins/terminal.lua +++ b/lua/plugins/terminal.lua @@ -15,6 +15,14 @@ return { { -- ToggleTerm "akinsho/toggleterm.nvim", event = "VeryLazy", + keys = { + { -- Toggle Terminal + "", + "ToggleTerm", + desc = "Toggle Terminal", + mode = "n", + }, + }, config = function() require("toggleterm").setup({ -- size can be a number or function which is passed the current terminal @@ -63,6 +71,36 @@ return { local kit = string.find(term, "kitty") return kit ~= nil end, + keys = { + { + "", + function() + require("kitty-navigator").navigateLeft() + end, + desc = "KittyNavigateLeft", + }, + { + "", + function() + require("kitty-navigator").navigateDown() + end, + desc = "KittyNavigateDown", + }, + { + "", + function() + require("kitty-navigator").navigateUp() + end, + desc = "KittyNavigateUp", + }, + { + "", + function() + require("kitty-navigator").navigateRight() + end, + desc = "KittyNavigateRight", + }, + }, }, { -- Kitty-Runner "jghauser/kitty-runner.nvim", @@ -87,10 +125,37 @@ return { }, { "NeViRAIDE/nekifoch.nvim", + lazy = true, cmd = "Nekifoch", opts = { kitty_conf_path = vim.env.HOME .. "/.kittyoverrides", }, + keys = { + { + "u,l", + "Nekifoch list", + desc = "Fonts list", + }, + { + "u,c", + "Nekifoch check", + desc = "Check current font settings", + }, + { + "u,f", + function() + require("nekifoch.nui_set_font")() + end, + desc = "Set font family", + }, + { + "u,s", + function() + require("nekifoch.nui_set_size")() + end, + desc = "Set font size", + }, + }, cond = function() -- Using Kitty local term = os.getenv("TERM") or "" local kit = string.find(term, "kitty") diff --git a/lua/plugins/themes.lua b/lua/plugins/themes.lua index 7eb4c14..68e0648 100644 --- a/lua/plugins/themes.lua +++ b/lua/plugins/themes.lua @@ -72,6 +72,15 @@ return { "xiyaowong/transparent.nvim", lazy = true, config = true, + keys = { + { + "wt", + function() + require("transparent").toggle() + end, + desc = "Toggle Transparency", + }, + }, }, { -- Auto Dark Mode "f-person/auto-dark-mode.nvim", diff --git a/lua/plugins/util.lua b/lua/plugins/util.lua index 9683f4a..8b6cb5f 100644 --- a/lua/plugins/util.lua +++ b/lua/plugins/util.lua @@ -21,10 +21,6 @@ local function get_fg_color(hlgroup) end return { - { -- Project management - import = "lazyvim.plugins.extras.util.project", - opts = { manual_mode = false }, - }, { -- Chezmoi import = "lazyvim.plugins.extras.util.chezmoi", }, @@ -43,8 +39,16 @@ return { }, { -- Link following "chrishrb/gx.nvim", - event = "VeryLazy", + lazy = true, cmd = { "Browse" }, + keys = { + { -- Open URL/Link + "gx", + "Browse", + mode = { "n", "x" }, + desc = "Open URL/Link", + }, + }, init = function() vim.g.netrw_nogx = 1 end, @@ -55,19 +59,42 @@ return { "Pocco81/auto-save.nvim", event = "BufEnter", }, - { -- User is bored - "mikesmithgh/ugbi", - event = "InsertEnter", - }, { -- Ripgrep substitute "chrisgrieser/nvim-rip-substitute", event = "InsertEnter", cmd = "RipSubstitute", + keys = { + { -- Rip Substitute + "fs", + function() + require("rip-substitute").sub() + end, + mode = { "n", "x" }, + desc = "Rip Substitute", + }, + }, }, { -- Gist Tools "Rawnly/gist.nvim", - event = "InsertEnter", - cmd = { "GistCreate", "GistCreateFromFile", "GistsList" }, + lazy = true, + cmd = { + "GistCreate", + "GistCreateFromFile", + "GistsList", + }, + keys = { + { -- Create Gist + "gnc", + "GistCreate", + desc = "Create Gist", + mode = { "n", "x" }, + }, + { -- Find Gists + "gnf", + "GistList", + desc = "Find Gists", + }, + }, config = true, }, { -- Unception @@ -78,10 +105,28 @@ return { }, { -- 🍎 Icon Picker "ziontee113/icon-picker.nvim", - event = "InsertEnter", + lazy = true, config = function() require("icon-picker").setup({ disable_legacy_commands = true }) end, + keys = { + { -- Pick Icon + "Ii", + "IconPickerNormal", + desc = "Pick Icon", + }, + { -- Yank Icon + "Iy", + "IconPickerYank", + desc = "Yank Icon", + }, + { -- Insert Icon in insert mode + "", + "IconPickerInsert", + desc = "Insert Icon", + mode = "i", + }, + }, }, { -- LazyGit "kdheepak/lazygit.nvim", @@ -93,13 +138,20 @@ return { "LazyGitFilter", "LazyGitFilterCurrentFile", }, + keys = { + { + "lg", + "LazyGit", + desc = "LazyGit", + }, + }, dependencies = { "nvim-lua/plenary.nvim", }, }, { -- Codesnap "mistricky/codesnap.nvim", - event = "InsertEnter", + lazy = true, build = "make", opts = { save_path = "~/Pictures/Screenshots/", @@ -110,6 +162,38 @@ return { code_font_family = "Iosevka NF", code_font_size = 12, }, + cmd = { + "CodeSnap", + "CodeSnapSave", + "CodeSnapHighlight", + "CodeSnapASCII", + }, + keys = { + { -- Save selected code snapshot into clipboard + "cy", + "CodeSnap", + desc = "Save selected code snapshot into clipboard", + mode = "x", + }, + { -- Save selected code snapshot in ~/Pictures + "cs", + "CodeSnapSave", + desc = "Save selected code snapshot in ~/Pictures", + mode = "x", + }, + { -- Highlight and snapshot selected code into clipboard + "ch", + "CodeSnapHighlight", + desc = "Highlight and snapshot selected code into clipboard", + mode = "x", + }, + { -- Save ASCII code snapshot into clipboard + "ci", + "CodeSnapASCII", + desc = "Save ASCII code snapshot into clipboard", + mode = "x", + }, + }, }, { -- Kulala "mistweaverco/kulala.nvim", @@ -120,7 +204,13 @@ return { }, { -- Thanks/github-stars "jsongerber/thanks.nvim", - event = "VeryLazy", + lazy = true, + cmd = { + "ThanksAll", + "ThanksGithubAuth", + "ThanksGithubLogout", + "ThanksClearCache", + }, opts = { star_on_install = false, }, @@ -158,9 +248,12 @@ return { opts = {}, keys = { { - mode = { "i", "n" }, "", - "lua require('caps-word').toggle()", + function() + require("caps-word").toggle() + end, + desc = "Toggle CapsWord", + mode = { "i", "n" }, }, }, },