From 186752a734c87a1d92a75cf77ba7687c9a7c666a Mon Sep 17 00:00:00 2001 From: Martin Pander Date: Thu, 21 May 2026 07:46:55 +0200 Subject: [PATCH] Clean up nvim config --- .gitignore | 1 - .gitmodules | 3 - hosts/work/nixos/configuration.nix | 2 +- hosts/work/nixos/home.nix | 5 +- modules/home/nvim.nix | 3 - modules/nvim/lua/base.lua | 1 - modules/nvim/lua/keymaps.lua | 124 +++++++++++------------------ modules/overlays/opencode.nix | 2 +- 8 files changed, 48 insertions(+), 93 deletions(-) delete mode 100644 .gitignore delete mode 100644 .gitmodules diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 16873f6..0000000 --- a/.gitignore +++ /dev/null @@ -1 +0,0 @@ -plugins/ diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index aec4ca9..0000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "vim/bundle/Vundle.vim"] - path = vim/bundle/Vundle.vim - url = https://github.com/gmarik/Vundle.vim.git diff --git a/hosts/work/nixos/configuration.nix b/hosts/work/nixos/configuration.nix index fde0f0d..dc2cb02 100644 --- a/hosts/work/nixos/configuration.nix +++ b/hosts/work/nixos/configuration.nix @@ -21,7 +21,7 @@ fileSystems."/home/pan/pro" = { device = "/dev/disk/by-uuid/9a37862c-85db-4434-b06a-ec8c2713ecc9"; - fsType = "ext4"; # or xfs, etc. + fsType = "ext4"; options = [ "defaults" "nofail" "x-systemd.automount" ]; }; diff --git a/hosts/work/nixos/home.nix b/hosts/work/nixos/home.nix index 9d569d6..c6ae24a 100644 --- a/hosts/work/nixos/home.nix +++ b/hosts/work/nixos/home.nix @@ -11,7 +11,4 @@ # Home Manager release version home.stateVersion = "25.05"; - - # Disable version mismatch warning (intentionally using HM 25.11 with nixpkgs 25.05) - home.enableNixpkgsReleaseCheck = false; -} \ No newline at end of file +} diff --git a/modules/home/nvim.nix b/modules/home/nvim.nix index e094795..aa8afd8 100644 --- a/modules/home/nvim.nix +++ b/modules/home/nvim.nix @@ -57,9 +57,6 @@ in cmp-git nvim-lspconfig lspkind-nvim - # copilot-lua - # copilot-cmp - # CopilotChat-nvim # opencode-nvim bullets-vim nvim-dap diff --git a/modules/nvim/lua/base.lua b/modules/nvim/lua/base.lua index 01e41cc..8c6df21 100644 --- a/modules/nvim/lua/base.lua +++ b/modules/nvim/lua/base.lua @@ -67,7 +67,6 @@ vim.opt.directory = swapdir .. "," .. temp -------- CLIPBOARD --------- ---------------------------- -- Force Neovim to use the OSC 52 provider explicitly --- This often resolves the "waiting" hang by properly handling the sequence vim.g.clipboard = { name = 'OSC 52', copy = { diff --git a/modules/nvim/lua/keymaps.lua b/modules/nvim/lua/keymaps.lua index d424ee9..4498b74 100644 --- a/modules/nvim/lua/keymaps.lua +++ b/modules/nvim/lua/keymaps.lua @@ -1,17 +1,14 @@ vim.g.mapleader = " " +-- Convenience +vim.keymap.set('n', 'w', ':w', { silent = true }) +vim.keymap.set('n', 'F', ':NvimTreeToggle', { noremap = true, silent = true }) +vim.keymap.set('n', 'Y', 'y$', {}) + -- Navigation vim.keymap.set({'n', 'v'}, 'j', 'gj', {}) vim.keymap.set({'n', 'v'}, 'k', 'gk', {}) --- vim.keymap.set('n', '', 'h', {}) --- vim.keymap.set('n', '', 'j', {}) --- vim.keymap.set('n', '', 'k', {}) --- vim.keymap.set('n', '', 'l', {}) --- vim.keymap.set('t', '', 'h', {}) --- vim.keymap.set('t', '', 'j', {}) --- vim.keymap.set('t', '', 'k', {}) --- vim.keymap.set('t', '', 'l', {}) vim.keymap.set('n', 'zm', '_|', { noremap = true, silent = true }) vim.keymap.set('n', '', '5<', {}) vim.keymap.set('n', '', '5+', {}) @@ -24,10 +21,44 @@ vim.keymap.set('t', '', '5>', {}) vim.keymap.set('n', 's', ':call WindowSwap#EasyWindowSwap()', {}) --- Convenience -vim.keymap.set('n', 'w', ':w', { silent = true }) -vim.keymap.set('n', 'F', ':NvimTreeToggle', { noremap = true, silent = true }) -vim.keymap.set('n', 'Y', 'y$', {}) +-- tmux navigation +vim.g.tmux_navigator_no_mappings = 1 + +local function tmux_navigate(direction) + local old_win = vim.api.nvim_get_current_win() + vim.cmd('wincmd ' .. direction) + local new_win = vim.api.nvim_get_current_win() + + if old_win == new_win then + local tmux_cmd = "" + if direction == 'h' then + tmux_cmd = 'if -F "#{pane_at_left}" "previous-window" "select-pane -L"' + elseif direction == 'j' then + tmux_cmd = 'if -F "#{pane_at_bottom}" "switch-client -n" "select-pane -D"' + elseif direction == 'k' then + tmux_cmd = 'if -F "#{pane_at_top}" "switch-client -p" "select-pane -U"' + elseif direction == 'l' then + tmux_cmd = 'if -F "#{pane_at_right}" "next-window" "select-pane -R"' + end + + vim.fn.system('tmux ' .. tmux_cmd) + end +end + +vim.api.nvim_create_autocmd("CursorHold", { + callback = function() + vim.diagnostic.open_float(nil, { focusable = false }) + end, +}) + +vim.keymap.set('n', '', function() tmux_navigate('h') end) +vim.keymap.set('n', '', function() tmux_navigate('j') end) +vim.keymap.set('n', '', function() tmux_navigate('k') end) +vim.keymap.set('n', '', function() tmux_navigate('l') end) +vim.keymap.set('t', '', function() vim.cmd('stopinsert') tmux_navigate('h') end, { remap = true }) +vim.keymap.set('t', '', function() vim.cmd('stopinsert') tmux_navigate('j') end, { remap = true }) +vim.keymap.set('t', '', function() vim.cmd('stopinsert') tmux_navigate('k') end, { remap = true }) +vim.keymap.set('t', '', function() vim.cmd('stopinsert') tmux_navigate('l') end, { remap = true }) -- Telescope local telebuiltin = require('telescope.builtin') @@ -70,29 +101,6 @@ vim.keymap.set('v', 'cf', end ) --- Copilot --- local cop = require('copilot.panel') --- local cos = require('copilot.suggestion') --- --- vim.keymap.set('n', 'ap', cop.toggle) --- vim.keymap.set('n', 'apn', cop.jump_next) --- vim.keymap.set('n', 'app', cop.jump_prev) --- vim.keymap.set('n', 'apr', cop.refresh) --- --- vim.keymap.set('n', 'as', cos.accept) --- vim.keymap.set('n', 'ast', cos.toggle_auto_trigger) --- vim.keymap.set('n', 'asl', cos.accept_word) --- vim.keymap.set('n', 'asw', cos.accept_line) --- vim.keymap.set('n', 'asn', cos.next) --- vim.keymap.set('n', 'asp', cos.prev) --- vim.keymap.set('n', 'asd', cos.dismiss) - --- vim.keymap.set('n', 'ac', 'CopilotChatToggle') --- vim.keymap.set('n', 'acs', 'CopilotChatStop') --- vim.keymap.set('n', 'acr', 'CopilotChatReset') --- vim.keymap.set('n', 'acm', 'CopilotChatModels') --- vim.keymap.set('n', 'acp', 'CopilotChatPrompts') - -- Yanky vim.keymap.set({"n","x"}, "p", "(YankyPutAfter)") vim.keymap.set({"n","x"}, "P", "(YankyPutBefore)") @@ -126,51 +134,9 @@ vim.keymap.set('n', "dw", function() require("dap.ui.widgets").hover() e vim.keymap.set('n', "dv", function() require("dap-view").toggle() end) vim.keymap.set('n', "", function() require("dap").continue() end) -vim.keymap.set('n', "", function() require("dap").step_into() end) vim.keymap.set('n', "", function() require("dap").step_over() end) +vim.keymap.set('n', "", function() require("dap").step_into() end) vim.keymap.set('n', "", function() require("dap").step_out() end) +vim.keymap.set('n', "", function() require("dap").run_to_cursor() end) --- Tmux Navigator -vim.g.tmux_navigator_no_mappings = 1 - -local function tmux_navigate(direction) - local old_win = vim.api.nvim_get_current_win() - vim.cmd('wincmd ' .. direction) - local new_win = vim.api.nvim_get_current_win() - - if old_win == new_win then - -- We are at the edge, let tmux handle it - -- This requires the tmux config to be set up to handle these keys when not in vim, - -- BUT since we are IN vim, we need to explicitly trigger the tmux action. - -- However, simply sending the key to tmux might just send it back to vim if we aren't careful, - -- or we can just run the tmux command directly. - - local tmux_cmd = "" - if direction == 'h' then - tmux_cmd = 'if -F "#{pane_at_left}" "previous-window" "select-pane -L"' - elseif direction == 'j' then - tmux_cmd = 'if -F "#{pane_at_bottom}" "switch-client -n" "select-pane -D"' - elseif direction == 'k' then - tmux_cmd = 'if -F "#{pane_at_top}" "switch-client -p" "select-pane -U"' - elseif direction == 'l' then - tmux_cmd = 'if -F "#{pane_at_right}" "next-window" "select-pane -R"' - end - - -- We use vim.fn.system to execute the tmux command - -- We need to wrap the command in 'tmux' call - vim.fn.system('tmux ' .. tmux_cmd) - end -end - -vim.api.nvim_create_autocmd("CursorHold", { - callback = function() - vim.diagnostic.open_float(nil, { focusable = false }) - end, -}) - -vim.keymap.set('n', '', function() tmux_navigate('h') end) -vim.keymap.set('n', '', function() tmux_navigate('j') end) -vim.keymap.set('n', '', function() tmux_navigate('k') end) -vim.keymap.set('n', '', function() tmux_navigate('l') end) - diff --git a/modules/overlays/opencode.nix b/modules/overlays/opencode.nix index c9cd5d1..bdb90d5 100644 --- a/modules/overlays/opencode.nix +++ b/modules/overlays/opencode.nix @@ -1,6 +1,6 @@ # Overlay to provide a pinned version of opencode # This pins opencode to a specific nixpkgs commit to avoid issues -# with the latest unstable version (e.g., segfaults). +# with the latest unstable version (segfaults). # # Usage: Pass nixpkgs-opencode input when applying overlay: # overlays = [ (import ./modules/overlays/opencode.nix nixpkgs-opencode) ];