diff --git a/dotfiles/neovim/README.md b/dotfiles/neovim/README.md index c478532..6db540c 100644 --- a/dotfiles/neovim/README.md +++ b/dotfiles/neovim/README.md @@ -221,7 +221,7 @@ The following keybinds are available only when running inside firenvim: | \p | [P]aste imge from clipboard | clipboard-image.nvim | | \L | [L]azy ui | lazy.nvim | | C-h/j/k/l | Navigate panes | vim-tmux-navigator | -| \h | Add file to harpoon | harpoon | +| \H | Add file to harpoon | harpoon | | C-a | Harpoon quick menu | harpoon | | C-s q/w/e/r/a/s/d/f/z | Open harpoon file with index 0-9 | harpoon | | lc | Open [l]ocal [c]argo.toml | rust-tools | @@ -235,3 +235,7 @@ Iron.nvim commands rest in the `i` namespace. There is a lot of them, an #### Magma Magma commands live under the namespace `M`. I barely use this plugin, so I won't document my keybinds just yet. + +#### Gitsigns + +I use a slightly modified version of the default keybinds, and I've been too lazy to document everything. diff --git a/dotfiles/neovim/lazy-lock.json b/dotfiles/neovim/lazy-lock.json index eeb39b8..c89aea3 100644 --- a/dotfiles/neovim/lazy-lock.json +++ b/dotfiles/neovim/lazy-lock.json @@ -17,6 +17,7 @@ "formatter.nvim": { "branch": "master", "commit": "44c89f09dcc220dc2a9b056e93c3a87c86e79804" }, "github-actions-yaml.vim": { "branch": "master", "commit": "f2f16243447cea174daa6b4a9ffd3ff9213814ef" }, "gitlinker.nvim": { "branch": "master", "commit": "cc59f732f3d043b626c8702cb725c82e54d35c25" }, + "gitsigns.nvim": { "branch": "main", "commit": "af0f583cd35286dd6f0e3ed52622728703237e50" }, "harpoon": { "branch": "master", "commit": "21f4c47c6803d64ddb934a5b314dcb1b8e7365dc" }, "haskell-tools.nvim": { "branch": "master", "commit": "b19df600da8ef5fb4fb280815415ebd2a4228f0f" }, "hydra.nvim": { "branch": "master", "commit": "3ced42c0b6a6c85583ff0f221635a7f4c1ab0dd0" }, diff --git a/dotfiles/neovim/lua/my/plugins/gitsigns.lua b/dotfiles/neovim/lua/my/plugins/gitsigns.lua new file mode 100644 index 0000000..776d8cd --- /dev/null +++ b/dotfiles/neovim/lua/my/plugins/gitsigns.lua @@ -0,0 +1,100 @@ +local env = require("my.helpers.env") + +local M = { + "lewis6991/gitsigns.nvim", + event = "BufReadPost", + cond = env.firenvim.not_active() and env.vscode.not_active(), + config = function() + require("gitsigns").setup({ + on_attach = function(bufnr) + local wk = require("which-key") + local gs = package.loaded.gitsigns + + -- {{{ Helpers + local function map(mode, from, to, desc, expr) + vim.keymap.set( + mode, + from, + to, + { expr = expr, silent = true, buffer = bufnr, desc = desc } + ) + end + + local function exprmap(from, to, desc) + map("n", from, to, desc, true) + end + -- }}} + -- {{{ Navigation + exprmap("]c", function() + if vim.wo.diff then + return "]c" + end + + vim.schedule(function() + gs.next_hunk() + end) + + return "" + end, "Navigate to next hunk") + + exprmap("[c", function() + if vim.wo.diff then + return "[c" + end + + vim.schedule(function() + gs.prev_hunk() + end) + + return "" + end, "Navigate to previous hunk") + -- }}} + -- {{{ Actions + local prefix = "h" + + wk.register({ + [prefix] = { name = "gitsigns" }, + }) + + -- {{{ Normal mode + map("n", prefix .. "s", gs.stage_hunk, "[s]tage hunk") + map("n", prefix .. "r", gs.reset_hunk, "[r]eset hunk") + map("n", prefix .. "S", gs.stage_buffer, "[s]tage buffer") + map("n", prefix .. "u", gs.undo_stage_hunk, "[u]ndo hunk staging") + map("n", prefix .. "R", gs.reset_buffer, "[r]eset buffer") + map("n", prefix .. "p", gs.preview_hunk, "[p]review hunk") + map("n", prefix .. "b", function() + gs.blame_line({ full = true }) + end, "[b]lame line") + map("n", prefix .. "d", gs.diffthis, "[d]iff this") + map("n", prefix .. "D", function() + gs.diffthis("~") + end, "[d]iff file (?)") + -- }}} + -- {{{ Toggles + map( + "n", + prefix .. "tb", + gs.toggle_current_line_blame, + "[t]oggle line [b]laming" + ) + map("n", prefix .. "td", gs.toggle_deleted, "[t]oggle [d]eleted") + -- }}} + -- {{{ Visual + map("v", prefix .. "s", function() + gs.stage_hunk({ vim.fn.line("."), vim.fn.line("v") }) + end, "stage visual hunk") + map("v", prefix .. "r", function() + gs.reset_hunk({ vim.fn.line("."), vim.fn.line("v") }) + end, "reset visual hunk") + -- }}} + -- }}} + -- {{{ Text objects + map({ "o", "x" }, "ih", ":Gitsigns select_hunk", "Inside hunk") + -- }}} + end, + }) + end, +} + +return M diff --git a/dotfiles/neovim/lua/my/plugins/harpoon.lua b/dotfiles/neovim/lua/my/plugins/harpoon.lua index c5b8412..94fdb67 100644 --- a/dotfiles/neovim/lua/my/plugins/harpoon.lua +++ b/dotfiles/neovim/lua/my/plugins/harpoon.lua @@ -9,7 +9,7 @@ local function bindHarpoon(key, index) end function M.init() - vim.keymap.set("n", "h", function() + vim.keymap.set("n", "H", function() require("harpoon.mark").add_file() end, { desc = "Add file to [h]arpoon" }) vim.keymap.set("n", "", function() diff --git a/dotfiles/neovim/lua/my/plugins/treesitter.lua b/dotfiles/neovim/lua/my/plugins/treesitter.lua index 75c06d0..8e8f9de 100644 --- a/dotfiles/neovim/lua/my/plugins/treesitter.lua +++ b/dotfiles/neovim/lua/my/plugins/treesitter.lua @@ -66,19 +66,19 @@ local M = { set_jumps = true, -- whether to set jumps in the jumplist goto_next_start = { ["]f"] = "@function.outer", - ["]c"] = "@class.outer", + ["]t"] = "@class.outer", }, goto_next_end = { ["]F"] = "@function.outer", - ["]C"] = "@class.outer", + ["]T"] = "@class.outer", }, goto_previous_start = { ["[f"] = "@function.outer", - ["[c"] = "@class.outer", + ["[t"] = "@class.outer", }, goto_previous_end = { ["[F"] = "@function.outer", - ["[C"] = "@class.outer", + ["[T"] = "@class.outer", }, }, --}}} diff --git a/home/features/desktop/wezterm/wezterm.lua b/home/features/desktop/wezterm/wezterm.lua index f02dafc..04d95a6 100644 --- a/home/features/desktop/wezterm/wezterm.lua +++ b/home/features/desktop/wezterm/wezterm.lua @@ -51,19 +51,28 @@ config.colors.tab_bar = { }, } -- }}} --- {{{ Other visual things -config.window_background_opacity = 0.6; +-- {{{ Other visual things +config.window_background_opacity = 0.6 -- TODO: load from nix! -- }}} -- }}} -- {{{ Main config options -config.adjust_window_size_when_changing_font_size = false -- Makes it work with fixed window sizes. config.automatically_reload_config = true + +-- {{{ Fonts +config.adjust_window_size_when_changing_font_size = false -- Makes it work with fixed window sizes. config.font_size = font_size -config.use_fancy_tab_bar = false +-- }}} +-- {{{ Tab bar +config.use_fancy_tab_bar = true +-- config.enable_tab_bar = false +config.hide_tab_bar_if_only_one_tab = true +-- }}} +-- {{{ Keycodes config.disable_default_key_bindings = true -- config.enable_kitty_keyboard = true -- Let's apps recognise more distinct keys config.enable_csi_u_key_encoding = true -- For some reason I need this for all keybinds to work inside neovim. -- }}} +-- }}} -- {{{ Keybinds -- }}}