diff --git a/nvim/init.lua b/nvim/init.lua index e075f24..23be4ab 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -1,12 +1,12 @@ vim.g.mapleader = vim.keycode("") -vim.g.maplocalleader = vim.keycode("") +vim.g.maplocalleader = vim.keycode("/") vim.o.langmap = "ø:" -- general options vim.o.shell = "/usr/bin/zsh" vim.g.BASH_Ctrl_j = "off" vim.g.BASH_Ctrl_l = "off" -vim.opt.clipboard = vim.opt.clipboard + { "unnamedplus" } +vim.opt.clipboard:append("unnamedplus") vim.o.guicursor = "n-v-c:block-CustomCursor,i:ver100-CustomICursor,n-v-c:blinkon0,i:blinkwait10" vim.o.cursorline = true vim.o.list = true @@ -18,11 +18,14 @@ vim.opt.shortmess:append({ W = true, I = true, c = true, C = true }) vim.o.cmdheight = 0 vim.o.showmode = false vim.o.sidescrolloff = 8 -vim.o.timeoutlen = 300 +vim.o.timeoutlen = 700 vim.o.virtualedit = "block" vim.o.wildmode = "longest:full,full" vim.o.wrap = false vim.opt.diffopt:append("linematch:60") -- second stage diff to align lines +vim.opt.diffopt:append("hiddenoff") +vim.opt.diffopt:append("vertical") +vim.opt.diffopt:append("algorithm:histogram") -- File History vim.o.undofile = true @@ -105,9 +108,6 @@ vim.diagnostic.config({ -- ---------------------------------------- local map = vim.keymap.set --- swap ;: -map({ "n", "v" }, ";", ":") -map({ "n", "v" }, ":", ";") -- better esc map({ "i", "n", "s" }, "", function() @@ -145,6 +145,15 @@ map("i", ",", ",u") map("i", ".", ".u") map("i", ";", ";u") +-- save file +map({ "i", "x", "n", "s" }, "ww", "w", { desc = "Save File" }) + +-- quit +map("n", "qq", "q", { desc = "Close Window" }) +map("n", "qQ", "qa", { desc = "Quit All" }) +map("n", "qw", "wq", { desc = "Write And Close Window" }) +map("n", "qW", "wqa", { desc = "Write And Quit All" }) + --keywordprg map("n", "K", "norm! K", { desc = "Keywordprg" }) @@ -195,7 +204,7 @@ map("n", "d", "tabclose", { desc = "Close Tab" }) map("n", "p", "tabprevious", { desc = "Previous Tab" }) -- other -map("n", "ww", [[:cd %:p:h]], { desc = "Set Workspace To Buffer Path" }) +map("n", "cw", [[:cd %:p:h]], { desc = "Set Workspace To Buffer Path" }) map("n", "o", "m`o``", { desc = "Insert Newline" }) map("n", "\\", "n.", { noremap = true, silent = true, desc = "Repeat And Goto Next" }) map("n", "", "Lazy", { desc = "Lazy" }) @@ -257,6 +266,7 @@ vim.api.nvim_create_autocmd("FileType", { "checkhealth", "floggraph", "fugitive", + "git", "gitsigns-blame", "grug-far", "help", @@ -320,6 +330,14 @@ local function makespecs_themes() return { "NLKNguyen/papercolor-theme", "junegunn/seoul256.vim", + { + "mcauley-penney/phobos-anomaly.nvim", + priority = 1000, + config = function() + vim.cmd("colorscheme phobos-anomaly") + vim.api.nvim_set_hl(0, "Visual", { bg = "#3c3f4e" }) + end, + }, { "mhartington/oceanic-next", config = function() @@ -344,7 +362,6 @@ local function makespecs_themes() lazy = false, name = "catppuccin", priority = 1000, - config = function() vim.cmd([[colorscheme catppuccin-mocha]]) end, }, { "Shatur/neovim-ayu", @@ -362,7 +379,7 @@ local function makespec_lspconfig() dependencies = { { "j-hui/fidget.nvim", opts = {} } }, event = { "BufReadPost", "BufNewFile" }, cmd = { "LspInfo", "LspRestart", "LspStart", "LspStop" }, - keys = { { "", "LspInfo", noremap = true } }, + keys = { { "", "LspInfo", noremap = true } }, config = function() local lspconfig = require("lspconfig") lspconfig.tinymist.setup({}) @@ -514,9 +531,7 @@ local function makespec_lualine() { "buffers", symbols = { alternate_file = "" }, - buffers_color = { - active = { bg = "goldenrod" }, - }, + buffers_color = { active = { bg = "goldenrod" } }, }, }, lualine_b = {}, @@ -527,9 +542,7 @@ local function makespec_lualine() { "tabs", mode = 2, - tabs_color = { - active = { bg = "goldenrod" }, - }, + tabs_color = { active = { bg = "goldenrod" } }, }, }, }, @@ -714,8 +727,8 @@ local function makespec_fugitive() end, keys = { { "gg", "vertical Git", desc = "Fugitive" }, - { "gp", "Git! push", desc = "Git Push" }, - { "gP", "Git! push -f", desc = "Git Force Push" }, + { "gp", "Git push", desc = "Git Push" }, + { "gP", "Git push -f", desc = "Git Force Push" }, }, } end @@ -747,25 +760,25 @@ local function makespec_gitsigns() bmap("n", "gb", function() gs.blame_line({ full = true }) end, "Blame Line") -- Hunk - bmap("n", "hp", gs.preview_hunk_inline, "Preview Hunk Inline") - bmap("n", "hi", gs.preview_hunk, "Preview Hunk") - bmap("n", "hq", gs.setqflist, "File Hunks to QuickFix") - bmap("n", "hQ", function() gs.setqflist("all") end, "All Hunks to QuickFix") - bmap("n", "hx", gs.reset_hunk, "Reset Hunk") - bmap("v", "hx", function() gs.reset_hunk({ vim.fn.line("."), vim.fn.line("v") }) end, "Reset Hunk") - bmap("n", "hR", gs.reset_buffer, "Reset Buffer") - bmap("n", "hs", gs.stage_hunk, "Stage Hunk") - bmap("v", "hs", function() gs.stage_hunk({ vim.fn.line("."), vim.fn.line("v") }) end, "Stage Hunk") - bmap("n", "hS", gs.stage_buffer, "Stage Buffer") - bmap("n", "hu", gs.undo_stage_hunk, "Undo Stage Hunk") - bmap({ "n", "v" }, "hv", gs.select_hunk, "Select Hunk") + bmap("n", "gI", gs.preview_hunk_inline, "Preview Hunk Inline") + bmap("n", "gi", gs.preview_hunk, "Preview Hunk") + bmap("n", "gq", gs.setqflist, "File Hunks to QuickFix") + bmap("n", "gQ", function() gs.setqflist("all") end, "All Hunks to QuickFix") + bmap("n", "gx", gs.reset_hunk, "Reset Hunk") + bmap("v", "gx", function() gs.reset_hunk({ vim.fn.line("."), vim.fn.line("v") }) end, "Reset Hunk") + bmap("n", "gR", gs.reset_buffer, "Reset Buffer") + bmap("n", "gs", gs.stage_hunk, "Stage Hunk") + bmap("v", "gs", function() gs.stage_hunk({ vim.fn.line("."), vim.fn.line("v") }) end, "Stage Hunk") + bmap("n", "gS", gs.stage_buffer, "Stage Buffer") + bmap("n", "gu", gs.undo_stage_hunk, "Undo Stage Hunk") + bmap({ "n", "v" }, "gv", gs.select_hunk, "Select Hunk") -- Toggles - bmap("n", "hd", gs.toggle_deleted, "Toggle Show Deleted Lines") - bmap("n", "hl", gs.toggle_linehl, "Toggle Diff Line Highlight") - bmap("n", "hb", gs.toggle_current_line_blame, "Toggle Line Blame") - bmap("n", "hh", gs.toggle_word_diff, "Toggle Diff Word Colors") - bmap("n", "hn", gs.toggle_numhl, "Toggle Diff Line Number Highlight") + bmap("n", "gtd", gs.toggle_deleted, "Toggle Show Deleted Lines") + bmap("n", "gtl", gs.toggle_linehl, "Toggle Diff Line Highlight") + bmap("n", "gtb", gs.toggle_current_line_blame, "Toggle Line Blame") + bmap("n", "gth", gs.toggle_word_diff, "Toggle Diff Word Colors") + bmap("n", "gtn", gs.toggle_numhl, "Toggle Diff Line Number Highlight") -- Text object, e.g. for dih to delete hunk bmap({ "o", "x" }, "ih", "Gitsigns select_hunk") @@ -812,9 +825,10 @@ local function makespec_whichkey() { "c", group = "code/content" }, { "f", group = "file/find" }, { "g", group = "git" }, - { "h", group = "hunks" }, + { "gt", group = "toggles" }, { "l", group = "logs" }, { "p", group = "autoformat" }, + { "q", group = "quit" }, { "s", group = "search" }, { "u", group = "ui", icon = { icon = "󰙵 ", color = "cyan" } }, { "[", group = "prev" }, @@ -912,7 +926,8 @@ local function makespec_snacks() -- stylua: ignore keys = { { "fr", function() Snacks.rename.rename_file() end, desc = "Rename File" }, - { "d", function() Snacks.bufdelete() end, desc = "Delete Buffer" }, + { "", function() Snacks.bufdelete() end, desc = "Delete Buffer" }, + { "qd", function() Snacks.bufdelete() end, desc = "Delete Buffer" }, { "gl", function() Snacks.lazygit() end, desc = "Launch Lazygit" }, { ".", function() Snacks.scratch.open() end, desc = "Scratch Buffer" }, -- find @@ -1107,7 +1122,24 @@ end local function makespec_flash() return { "folke/flash.nvim", - opts = {}, + event = "VeryLazy", + opts = { + label = { uppercase = false }, + jump = { autojump = true }, + modes = { + char = { + jump = { autojump = true }, + char_actions = function(motion) + return { + [";"] = "right", -- set to `right` to always go right + [","] = "left", -- set to `left` to always go left + [motion:lower()] = "next", + [motion:upper()] = "prev", + } + end, + }, + }, + }, -- stylua: ignore keys = { { "", mode = { "n", "o", "x" }, function() require("flash").jump() end, desc = "Flash" },