From 9d0e106178a14651f5290dd742761167c353631e Mon Sep 17 00:00:00 2001 From: pablu Date: Thu, 18 Jun 2026 10:16:47 +0200 Subject: [PATCH] dont use cmd+enter for fullscreen in ghostty, add unified vim + hyprland navigation --- dot_config/ghostty/config.tmpl | 1 + dot_config/hypr/config/binds.lua | 50 +++++++++++++++++++--- dot_config/nvim/init.lua | 31 +++++++++++--- dot_config/nvim/lazy-lock.json | 16 +++---- dot_config/nvim/lua/plugins/treesitter.lua | 2 +- 5 files changed, 79 insertions(+), 21 deletions(-) diff --git a/dot_config/ghostty/config.tmpl b/dot_config/ghostty/config.tmpl index dd966f5..b24728b 100644 --- a/dot_config/ghostty/config.tmpl +++ b/dot_config/ghostty/config.tmpl @@ -25,6 +25,7 @@ keybind = cmd+opt+left=unbind keybind = cmd+opt+right=unbind keybind = alt+left=unbind keybind = alt+right=unbind +keybind = ctrl+enter=ignore keybind = ctrl+v=paste_from_clipboard diff --git a/dot_config/hypr/config/binds.lua b/dot_config/hypr/config/binds.lua index 1180f1b..d0f8ba0 100644 --- a/dot_config/hypr/config/binds.lua +++ b/dot_config/hypr/config/binds.lua @@ -14,11 +14,48 @@ hl.bind(mainMod .. " + S", hl.dsp.exec_cmd("grim -o" .. MAIN_DISPLAY .. " \"${HOME}/screenshots/screenshot-$(date +%F-%T).png\"")) hl.bind(mainMod .. " + SHIFT + S", hl.dsp.exec_cmd("grim -g \"$(slurp)\" - | wl-copy")) --- Movement Keys -hl.bind(mainMod .. " + H", hl.dsp.focus({ direction = "left" })) -hl.bind(mainMod .. " + L", hl.dsp.focus({ direction = "right" })) -hl.bind(mainMod .. " + J", hl.dsp.focus({ direction = "down" })) -hl.bind(mainMod .. " + K", hl.dsp.focus({ direction = "up" })) +local synth = { + left = false, + right = false, + up = false, + down = false, +} + +local function smart_nav(direction) + return function() + if synth[direction] then + return + end + + local win = hl.get_active_window() + + if not win or win.class ~= "com.mitchellh.ghostty" or win.title ~= "vim" then + hl.dispatch(hl.dsp.focus({ direction = direction })) + return + end + + hl.dispatch(hl.dsp.pass({ window = "activewindow" })) + synth[direction] = true + end +end + +local function smart_nav_release(direction) + return function() + synth[direction] = false + end +end + +local movement_keys = { + H = "left", + L = "right", + J = "down", + K = "up" +} + +for key, dir in pairs(movement_keys) do + hl.bind(mainMod .. " + " .. key, smart_nav(dir)) + hl.bind(mainMod .. " + " .. key, smart_nav_release(dir), { release = true }) +end hl.bind(mainMod .. " + SHIFT + H", hl.dsp.window.move({ direction = "left" })) hl.bind(mainMod .. " + SHIFT + L", hl.dsp.window.move({ direction = "right" })) @@ -38,6 +75,7 @@ end -- Resize Keys hl.bind(mainMod .. " + F", hl.dsp.window.fullscreen({ action = "toggle" })) +hl.bind(mainMod .. " + v", hl.dsp.window.float()) hl.bind(mainMod .. " + mouse:272", hl.dsp.window.drag(), { mouse = true }) hl.bind(mainMod .. " + mouse:273", hl.dsp.window.resize(), { mouse = true }) @@ -51,4 +89,4 @@ hl.bind("XF86AudioPlay", hl.dsp.exec_cmd("playerctl play-pause"), { locked = tru hl.bind("XF86AudioNext", hl.dsp.exec_cmd("playerctl next"), { locked = true }) hl.bind("XF86AudioPrev", hl.dsp.exec_cmd("playerctl previous"), { locked = true }) -hl.bind("code:51", hl.dsp.pass({ window = "class:^([Dd]iscord)$" }), { non_consuming = true }) +-- hl.bind("code:51", hl.dsp.pass({ window = "class:^([Dd]iscord)$" }), { non_consuming = true }) diff --git a/dot_config/nvim/init.lua b/dot_config/nvim/init.lua index 11e3d28..b618040 100644 --- a/dot_config/nvim/init.lua +++ b/dot_config/nvim/init.lua @@ -38,10 +38,29 @@ vim.keymap.set("n", "-", function() vim.cmd.new() end, { desc = "Pane split down" }) --- vim.api.nvim_set_keymap('n', '', ':wincmd k', { noremap = true, silent = true, desc = "Move to up windows" }); --- vim.api.nvim_set_keymap('n', '', ':wincmd h', { noremap = true, silent = true, desc = "Move to left windows" }); --- vim.api.nvim_set_keymap('n', '', ':wincmd j', { noremap = true, silent = true, desc = "Move to down windows" }); --- vim.api.nvim_set_keymap('n', '', ':wincmd l', { noremap = true, silent = true, desc = "Move to right windows" }); +local function smart_move(direction, vim_cmd) + return function() + local before = vim.api.nvim_get_current_win() + + vim.cmd("wincmd " .. vim_cmd) + + if before == vim.api.nvim_get_current_win() then + vim.system({ + "hyprctl", + "dispatch", + string.format( + "hl.dsp.focus({direction = '%s' })", + direction + ) + }) + end + end +end + +vim.keymap.set('n', '', smart_move("left", "h"), { noremap = true, silent = false, desc = "Move to left windows" }); +vim.keymap.set('n', '', smart_move("right", "l"), { noremap = true, silent = false, desc = "Move to right windows" }); +vim.keymap.set('n', '', smart_move("down", "j"), { noremap = true, silent = false, desc = "Move to down window" }); +vim.keymap.set('n', '', smart_move("up", "k"), { noremap = true, silent = false, desc = "Move to up window" }); vim.api.nvim_set_keymap('n', 'gb', ':bnext', { noremap = true, silent = true, desc = "Go back last buffer" }); @@ -165,7 +184,7 @@ vim.keymap.set("n", "dps", function() local function start_debug(script_name, module, args_str) local package = module:match("^([^:]+)") - + -- Parse arguments string into table local args = {} if args_str and args_str ~= "" then @@ -205,7 +224,7 @@ vim.keymap.set("n", "dps", function() default = last_params[script_name] or "", completion = "file", }, function(args_str) - if args_str ~= nil then -- nil = cancelled, "" = empty input is OK + if args_str ~= nil then -- nil = cancelled, "" = empty input is OK start_debug(script_name, module, args_str) end end) diff --git a/dot_config/nvim/lazy-lock.json b/dot_config/nvim/lazy-lock.json index c5eaaa5..ec89ccb 100644 --- a/dot_config/nvim/lazy-lock.json +++ b/dot_config/nvim/lazy-lock.json @@ -2,16 +2,16 @@ "FixCursorHold.nvim": { "branch": "master", "commit": "1900f89dc17c603eec29960f57c00bd9ae696495" }, "autoclose.nvim": { "branch": "main", "commit": "bafd0368716216fa6a7bb2a43ecd889b44efdb46" }, "blink.cmp": { "branch": "main", "commit": "78336bc89ee5365633bcf754d93df01678b5c08f" }, - "catppuccin": { "branch": "main", "commit": "8edd468af4d63212b84d69b2ddb5ffc9023ef5eb" }, + "catppuccin": { "branch": "main", "commit": "0303a7208dba448c459767486a38a6ec05c4216b" }, "conform.nvim": { "branch": "master", "commit": "619363c30309d29ffa631e67c8183f2a72caa373" }, "fidget.nvim": { "branch": "main", "commit": "82404b196e73a00b1727a91903beef5ddc319d22" }, "flash.nvim": { "branch": "main", "commit": "fcea7ff883235d9024dc41e638f164a450c14ca2" }, "friendly-snippets": { "branch": "main", "commit": "6cd7280adead7f586db6fccbd15d2cac7e2188b9" }, "lazy.nvim": { "branch": "main", "commit": "306a05526ada86a7b30af95c5cc81ffba93fef97" }, "lazydev.nvim": { "branch": "main", "commit": "ff2cbcba459b637ec3fd165a2be59b7bbaeedf0d" }, - "lualine.nvim": { "branch": "master", "commit": "131a558e13f9f28b15cd235557150ccb23f89286" }, + "lualine.nvim": { "branch": "master", "commit": "221ce6b2d999187044529f49da6554a92f740a96" }, "mason-nvim-dap.nvim": { "branch": "main", "commit": "9a10e096703966335bd5c46c8c875d5b0690dade" }, - "mason.nvim": { "branch": "main", "commit": "bb639d4bf385a4d89f478b83af4d770be05ab7eb" }, + "mason.nvim": { "branch": "main", "commit": "16ba83bfc8a25f52bb545134f5bee082b195c460" }, "mini.icons": { "branch": "main", "commit": "520995f1d75da0e4cc901ee95080b1ff2bc46b94" }, "mini.indentscope": { "branch": "main", "commit": "ad19b1f02223391f3d40440f7ff10607f0043585" }, "neotest": { "branch": "master", "commit": "ad991822b7076b1d940b33a9d6d0d30416d5df81" }, @@ -21,17 +21,17 @@ "nvim-dap-ui": { "branch": "master", "commit": "1a66cabaa4a4da0be107d5eda6d57242f0fe7e49" }, "nvim-dap-virtual-text": { "branch": "master", "commit": "fbdb48c2ed45f4a8293d0d483f7730d24467ccb6" }, "nvim-lint": { "branch": "master", "commit": "d48f3a76189d03b2239f6df1b2f7e3fa8353743b" }, - "nvim-lspconfig": { "branch": "master", "commit": "a4ed4e761c400849e8c9f8bda33e5083f890268c" }, + "nvim-lspconfig": { "branch": "master", "commit": "229b79051b380377664edc4cbd534930154921a1" }, "nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" }, "nvim-tmux-navigation": { "branch": "main", "commit": "4898c98702954439233fdaf764c39636681e2861" }, "nvim-treesitter": { "branch": "main", "commit": "4916d6592ede8c07973490d9322f187e07dfefac" }, - "nvim-web-devicons": { "branch": "master", "commit": "0d7d35fa946837b8738b17c18d1faa1ac351e7f9" }, - "oil.nvim": { "branch": "master", "commit": "b91ee5a77a6a9605d9c1aaf4fda74b66082c8297" }, + "nvim-web-devicons": { "branch": "master", "commit": "dfbfaa967a6f7ec50789bead7ef87e336c1fa63c" }, + "oil.nvim": { "branch": "master", "commit": "b73018b75affd13fa38e2fc94ef753b465f770d7" }, "plenary.nvim": { "branch": "master", "commit": "74b06c6c75e4eeb3108ec01852001636d85a932b" }, - "ripgrep": { "branch": "master", "commit": "f0cec341ab95c25c691ad3d5754d4bd9eedde21f" }, + "ripgrep": { "branch": "master", "commit": "82313cf95849bfe425109ad9506a52154879b1b1" }, "telescope-fzf-native.nvim": { "branch": "main", "commit": "b25b749b9db64d375d782094e2b9dce53ad53a40" }, "telescope-ui-select.nvim": { "branch": "master", "commit": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2" }, "telescope.nvim": { "branch": "master", "commit": "7d324792b7943e4aa16ad007212e6acc6f9fe335" }, - "tiny-inline-diagnostic.nvim": { "branch": "main", "commit": "6bdbc9a2f5a846ff5fc55a998ff97c0e2968b7e5" }, + "tiny-inline-diagnostic.nvim": { "branch": "main", "commit": "680762989e8b05a72e90769959d0fb9a557e6917" }, "which-key.nvim": { "branch": "main", "commit": "3aab2147e74890957785941f0c1ad87d0a44c15a" } } diff --git a/dot_config/nvim/lua/plugins/treesitter.lua b/dot_config/nvim/lua/plugins/treesitter.lua index 5410dc0..1df588a 100644 --- a/dot_config/nvim/lua/plugins/treesitter.lua +++ b/dot_config/nvim/lua/plugins/treesitter.lua @@ -5,6 +5,6 @@ return { build = ":TSUpdate", config = function() local treesitter = require("nvim-treesitter") - treesitter.install({ "python", "go", "zig", "markdown", "json", "yaml", "javascript", "typescript", "bash", "python" }) + treesitter.install({ "python", "go", "zig", "markdown", "json", "yaml", "javascript", "typescript", "bash", "python", "lua" }) end }