🪄 Substitution/Navigation

- Faster/smarter plugin loading
- Substitution motions with the 'x' and 'X' keys
- Fold navigation with Ctrl+hjkl
- Various small tweaks for usability
This commit is contained in:
2024-07-23 04:59:45 -04:00
parent e16d2a4c8e
commit c028da522b
8 changed files with 116 additions and 52 deletions
+31 -2
View File
@@ -5,9 +5,8 @@
-- -------------------------------- Commands -----------------------------------
-- Make :Q close all of the buffers
vim.api.nvim_create_user_command("Q", function()
vim.cmd.bdelete()
vim.cmd.qall()
end, { force = true })
end, { force = true, desc = "Close all buffers" })
-- Yank line without leading/trailing whitespace
vim.api.nvim_create_user_command("YankLine", function()
@@ -22,6 +21,12 @@ vim.api.nvim_create_user_command("RestoreColorscheme", function()
)
end, { force = true })
-- Load/start Remote
vim.api.nvim_create_user_command("LoadRemote", function()
require("remote-nvim").setup()
vim.cmd("RemoteStart")
end, { force = true, desc = "Load/start Remote" })
-- ------------------------------ Auto-Commands --------------------------------
-- Autosave Colorscheme
-- When the colorscheme changes, store the name in .colorscheme
@@ -36,6 +41,30 @@ vim.api.nvim_create_autocmd("ColorScheme", {
end,
})
-- Define cursor color/icon based on mode
local autocmd = vim.api.nvim_create_autocmd
autocmd({ "ModeChanged", "BufEnter" }, {
callback = function()
local current_mode = vim.fn.mode()
if current_mode == "n" then
vim.api.nvim_set_hl(0, "SmoothCursor", { fg = "#8aa8f3" })
vim.fn.sign_define("smoothcursor", { text = "" })
elseif current_mode == "v" then
vim.api.nvim_set_hl(0, "SmoothCursor", { fg = "#d298eb" })
vim.fn.sign_define("smoothcursor", { text = "" })
elseif current_mode == "V" then
vim.api.nvim_set_hl(0, "SmoothCursor", { fg = "#d298eb" })
vim.fn.sign_define("smoothcursor", { text = "" })
elseif current_mode == "" then
vim.api.nvim_set_hl(0, "SmoothCursor", { fg = "#bf616a" })
vim.fn.sign_define("smoothcursor", { text = "" })
elseif current_mode == "i" then
vim.api.nvim_set_hl(0, "SmoothCursor", { fg = "#9bd482" })
vim.fn.sign_define("smoothcursor", { text = "" })
end
end,
})
-- GIT CONFLICT MARKERS
-- if there are conflicts, jump to first conflict, highlight conflict markers,
-- and disable diagnostics (simplified version of `git-conflict.nvim`)
+20 -2
View File
@@ -45,7 +45,9 @@ wk.add({
},
{
"<leader>gS",
"<cmd>LazyGit<cr>",
rhs = function()
require("lazygit").lazygit()
end,
desc = "LazyGit",
},
{
@@ -196,7 +198,9 @@ wk.add({
},
{
"<leader>wt",
"<cmd>TransparentToggle<cr>",
rhs = function()
require("transparent").toggle()
end,
desc = "Toggle Transparency",
},
{
@@ -220,7 +224,21 @@ wk.add({
end,
desc = "Toggle Hardmode",
},
{ -- Toggle ZenMode
"<leader>z",
rhs = function()
require("zen-mode").toggle()
end,
desc = "Toggle ZenMode",
},
})
-- Substitute
-- Define substitue mappings
vim.keymap.set("n", "x", require("substitute").operator, { noremap = true })
vim.keymap.set("n", "xx", require("substitute").line, { noremap = true })
vim.keymap.set("n", "X", require("substitute").eol, { noremap = true })
vim.keymap.set("x", "x", require("substitute").visual, { noremap = true })
-- ---------------------------- Spell Correction -------------------------------
require("config.spellcheck")
+5
View File
@@ -18,6 +18,11 @@ STORED_THEME = vim.fn.readfile(vim.fn.stdpath("config") .. "/.colorscheme")[1]
vim.g.loaded_perl_provider = 0
vim.g.lazyvim_python_lsp = "basedpyright"
-- ----------------------------------- FOLDS --------------------------------------
vim.opt.foldmethod = "expr"
vim.opt.foldexpr = "v:lua.vim.treesitter.foldexpr()"
vim.opt.foldlevelstart = 99 -- load buffers with folds open
-- ------------------------------- CLIENT APPS ---------------------------------
if vim.g.neovide then
-- ----------------------- Neovide -------------------------
+1 -5
View File
@@ -11,7 +11,7 @@ return {
},
{ -- Transparent
"xiyaowong/transparent.nvim",
event = "VeryLazy",
lazy = true,
config = true,
},
{ -- Auto Dark Mode
@@ -117,8 +117,4 @@ return {
require("hlchunk").setup(common_config)
end,
},
{ -- Alternate
"ton/vim-alternate",
event = "VeryLazy",
},
}
+5 -4
View File
@@ -67,7 +67,11 @@ return {
require("mini.align").setup()
end,
},
{ -- Emoji completion
{ -- Alternate
"ton/vim-alternate",
ft = { "cpp", "h", "hpp", "c" },
},
{ -- Completion
"hrsh7th/nvim-cmp",
---@param opts cmp.ConfigSchema
opts = function(_, opts)
@@ -122,9 +126,6 @@ return {
opts = {
yank_substituted_text = false,
preserve_cursor_position = true,
highlight_substituted_text = {
enabled = false,
},
},
},
}
+1 -1
View File
@@ -53,7 +53,7 @@ return { -- Dashboard
{ action = "LazyGit", desc = " LazyGit", icon = "", key = "G" },
{ action = 'lua LazyVim.pick.config_files()()', desc = " Config", icon = "", key = "c" },
{ action = 'lua require("persistence").load()', desc = " Restore Session", icon = "", key = "s" },
{ action = 'RemoteStart', desc = " Remote Session", icon = "󰢹 ", key = "S" },
{ action = 'LoadRemote', desc = " Remote Session", icon = "󰢹 ", key = "S" },
{ action = "LazyExtras", desc = " Lazy Extras", icon = "", key = "x" },
{ action = "Lazy", desc = " Lazy", icon = "󰒲 ", key = "l" },
{ action = function() vim.api.nvim_input("<cmd>qa<cr>") end, desc = " Quit", icon = "", key = "q" },
+46 -36
View File
@@ -12,8 +12,15 @@ return {
{ -- Illuminate
import = "lazyvim.plugins.extras.editor.illuminate",
},
{ -- Leap
import = "lazyvim.plugins.extras.editor.leap",
{
"folke/flash.nvim",
opts = {
modes = {
char = {
jump_labels = true,
},
},
},
},
{ -- Outline
import = "lazyvim.plugins.extras.editor.outline",
@@ -21,6 +28,35 @@ return {
{ -- Telescope
import = "lazyvim.plugins.extras.editor.telescope",
},
{ -- FoldNav
"domharries/foldnav.nvim",
keys = {
{
"<C-h>",
function()
require("foldnav").goto_start()
end,
},
{
"<C-j>",
function()
require("foldnav").goto_next()
end,
},
{
"<C-k>",
function()
require("foldnav").goto_prev_start()
end,
},
{
"<C-l>",
function()
require("foldnav").goto_end()
end,
},
},
},
{ -- Which-Key
"folke/which-key.nvim",
opts = {
@@ -69,7 +105,7 @@ return {
},
{ -- Remote-nvim
"amitds1997/remote-nvim.nvim",
event = "VeryLazy",
lazy = true,
version = "*", -- Pin to GitHub releases
dependencies = {
"nvim-lua/plenary.nvim", -- For standard functions
@@ -80,7 +116,7 @@ return {
},
{ -- DeadColumn
"Bekaboo/deadcolumn.nvim",
event = "VeryLazy",
event = "InsertEnter",
config = function()
require("deadcolumn").setup({
scope = "line", ---@type string|fun(): integer
@@ -109,11 +145,13 @@ return {
},
{ -- Precognition
"tris203/precognition.nvim",
event = "VeryLazy",
lazy = true,
opts = {},
},
{ -- Zen Mode
"folke/zen-mode.nvim",
event = "VeryLazy",
--event = "VeryLazy",
lazy = true,
opts = {},
},
{ -- SmoothCursor
@@ -127,7 +165,7 @@ return {
texthl = "SmoothCursor",
fancy = {
enable = true, -- enable fancy mode
head = { cursor = "", texthl = nil, linehl = nil },
head = { cursor = "" },
body = {},
tail = { false }, -- false to disable fancy tail
},
@@ -137,7 +175,6 @@ return {
texthl = {
"SmoothCursor",
},
linehl = nil, -- No line highlight for the head
},
body = {
length = 6, -- Specifies the length of the cursor body
@@ -147,7 +184,6 @@ return {
},
},
tail = {
cursor = nil,
texthl = {
"SmoothCursor",
},
@@ -156,7 +192,7 @@ return {
},
autostart = true, -- Automatically start SmoothCursor
always_redraw = true, -- Redraw the screen on each update
flyin_effect = nil, -- Choose "bottom" or "top" for flying effect
flyin_effect = "bottom", -- Choose "bottom" or "top" for flying effect
speed = 25, -- Max speed is 100 to stick with your current position
intervals = 35, -- Update intervals in milliseconds
priority = 10, -- Set marker priority
@@ -164,32 +200,6 @@ return {
threshold = 3, -- Animate only if cursor moves more than this many lines
max_threshold = 2000, -- If you move more than this many lines, don't animate (if `nil`, deactivate check)
disable_float_win = false, -- Disable in floating windows
enabled_filetypes = nil, -- Enable only for specific file types, e.g., { "lua", "vim" }
disabled_filetypes = nil, -- Disable for these file types
show_last_positions = nil,
})
-- Define cursor color/icon based on mode
local autocmd = vim.api.nvim_create_autocmd
autocmd({ "ModeChanged", "BufEnter" }, {
callback = function()
local current_mode = vim.fn.mode()
if current_mode == "n" then
vim.api.nvim_set_hl(0, "SmoothCursor", { fg = "#8aa8f3" })
vim.fn.sign_define("smoothcursor", { text = "" })
elseif current_mode == "v" then
vim.api.nvim_set_hl(0, "SmoothCursor", { fg = "#d298eb" })
vim.fn.sign_define("smoothcursor", { text = "" })
elseif current_mode == "V" then
vim.api.nvim_set_hl(0, "SmoothCursor", { fg = "#d298eb" })
vim.fn.sign_define("smoothcursor", { text = "" })
elseif current_mode == "" then
vim.api.nvim_set_hl(0, "SmoothCursor", { fg = "#bf616a" })
vim.fn.sign_define("smoothcursor", { text = "" })
elseif current_mode == "i" then
vim.api.nvim_set_hl(0, "SmoothCursor", { fg = "#9bd482" })
vim.fn.sign_define("smoothcursor", { text = "" })
end
end,
})
-- Define last cursor position icon
vim.fn.sign_define("smoothcursor_n", { text = "" })
+7 -2
View File
@@ -32,6 +32,7 @@ return {
},
{ -- Link following
"chrishrb/gx.nvim",
event = "VeryLazy",
cmd = { "Browse" },
init = function()
vim.g.netrw_nogx = 1
@@ -41,21 +42,23 @@ return {
},
{ -- Auto-save
"Pocco81/auto-save.nvim",
event = "InsertEnter",
config = function()
require("auto-save").setup({})
end,
},
{ -- User is bored
"mikesmithgh/ugbi",
event = "VeryLazy",
event = "InsertEnter",
},
{ -- Ripgrep substitute
"chrisgrieser/nvim-rip-substitute",
event = "InsertEnter",
cmd = "RipSubstitute",
},
{ -- Gist Tools
"Rawnly/gist.nvim",
event = "VeryLazy",
event = "InsertEnter",
cmd = { "GistCreate", "GistCreateFromFile", "GistsList" },
config = true,
},
@@ -114,6 +117,7 @@ return {
},
{ -- Thanks/github-stars
"jsongerber/thanks.nvim",
event = "VeryLazy",
config = {
star_on_install = false,
},
@@ -134,6 +138,7 @@ return {
},
{ -- GitLinker
"linrongbin16/gitlinker.nvim",
lazy = true,
cmd = "GitLink",
opts = {},
keys = {