From d92d7b10f3abb3f4cb6baf2f15d907925ee8b592 Mon Sep 17 00:00:00 2001 From: Salar Rahmanian <code@softinio.com> Date: Sun, 23 Mar 2025 17:23:59 -0700 Subject: [PATCH] Improvements to kitty conf to support hyperlinks --- home.nix | 20 -------------------- programs/default.nix | 1 + programs/fish/default.nix | 1 + programs/kitty/default.nix | 32 ++++++++++++++++++++++++++++++++ programs/kitty/open-actions.conf | 10 ++++++++++ 5 files changed, 44 insertions(+), 20 deletions(-) create mode 100644 programs/kitty/default.nix create mode 100644 programs/kitty/open-actions.conf diff --git a/home.nix b/home.nix index 29494c0..0913ae7 100644 --- a/home.nix +++ b/home.nix @@ -192,26 +192,6 @@ enable = true; }; - programs.kitty = { - enable = true; - keybindings = { - "kitty_mod+enter" = "new_window_with_cwd"; - }; - themeFile = "Tango_Dark"; - font = { - name = "SF Mono"; - size = 13; - }; - settings = { - copy_on_select = true; - enabled_layouts = "*"; - macos_quit_when_last_window_closed = true; - scrollback_lines = 100000; - kitty_mod = "cmd+option"; - }; - shellIntegration.enableFishIntegration = true; - }; - programs.lazygit = { enable = true; }; diff --git a/programs/default.nix b/programs/default.nix index 5ea8a15..119bbd3 100644 --- a/programs/default.nix +++ b/programs/default.nix @@ -4,6 +4,7 @@ ./fish ./git ./jujutsu + ./kitty ./vscode ./zed ] diff --git a/programs/fish/default.nix b/programs/fish/default.nix index 6c068de..6227bc3 100644 --- a/programs/fish/default.nix +++ b/programs/fish/default.nix @@ -81,6 +81,7 @@ giscala = "gitignore scala,vim,java,sbt > .gitignore"; gforksync = "git fetch upstream && git merge upstream/master && git push origin master"; grep = "grep --color=auto"; + hg = "kitten hyperlinked-grep"; lg = "lazygit"; new-sbt = "sbt new scala/scala-seed.g8"; nixc = "cd ~/.config/nixpkgs"; diff --git a/programs/kitty/default.nix b/programs/kitty/default.nix new file mode 100644 index 0000000..9dbdb37 --- /dev/null +++ b/programs/kitty/default.nix @@ -0,0 +1,32 @@ +{ pkgs, ... }: + +let + actionsConfig = builtins.readFile ./open-actions.conf; +in +{ + programs.kitty = { + enable = true; + keybindings = { + "kitty_mod+enter" = "new_window_with_cwd"; + "f1" = "create_marker"; + "f2" = "remove_marker"; + "ctrl+p" = "scroll_to_mark prev"; + "ctrl+n" = "scroll_to_mark next"; + }; + themeFile = "Tango_Dark"; + font = { + name = "SF Mono"; + size = 13; + }; + settings = { + copy_on_select = true; + enabled_layouts = "*"; + kitty_mod = "cmd+option"; + macos_quit_when_last_window_closed = true; + scrollback_lines = 100000; + }; + shellIntegration.enableFishIntegration = true; + }; + + home.file.".config/kitty/open-actions.conf".text = actionsConfig; +} diff --git a/programs/kitty/open-actions.conf b/programs/kitty/open-actions.conf new file mode 100644 index 0000000..e8271b2 --- /dev/null +++ b/programs/kitty/open-actions.conf @@ -0,0 +1,10 @@ +# Open any file with a fragment in vim, fragments are generated +# by the hyperlink-grep kitten and nothing else so far. +protocol file +fragment_matches [0-9]+ +action launch --type=overlay --cwd=current vim +${FRAGMENT} -- ${FILE_PATH} + +# Open text files without fragments in the editor +protocol file +mime text/* +action launch --type=overlay --cwd=current -- ${EDITOR} -- ${FILE_PATH}