diff --git a/dotfiles/fish/config.fish b/dotfiles/fish/config.fish new file mode 100644 index 0000000..42699fd --- /dev/null +++ b/dotfiles/fish/config.fish @@ -0,0 +1,7 @@ +# Make normal mode the default +set vi_mode_default vi_mode_normal + +function vi_mode_user_key_bindings + echo "Added keybinds (hopefully)" + bind jj 'commandline -f backward-char; vi_mode_normal' +end diff --git a/dotfiles/tmux/tmux.conf b/dotfiles/tmux/tmux.conf index 84baaba..9d6bdd0 100644 --- a/dotfiles/tmux/tmux.conf +++ b/dotfiles/tmux/tmux.conf @@ -16,3 +16,20 @@ bind -n m-h select-pane -L bind -n m-l select-pane -R bind -n m-k select-pane -U bind -n m-j select-pane -D + +# Vim-mode +set-window-option -g mode-keys vi + +# Vim like keybinds for copying +bind -t vi-copy v begin-selection # begin selection +bind -t vi-copy V rectangle-toggle # square selection (?) + +bind -t vi-copy y copy-pipe 'xclip -in -set clipboard' # copy + +unbind p +bind p run "tmux set-buffer \"$(xclip -o -set clipboard)\"; tmux paste-buffer" # paste + +# Vim like mode for leaving insert mode +unbind [ # unbind the default way to copy text +bind Escape copy-mode # allow exiting insert mode with Escape +bind jj copy-mode # allow exiting insert mode with jj (?) diff --git a/flake.lock b/flake.lock index 6675fde..f749fdf 100644 --- a/flake.lock +++ b/flake.lock @@ -48,6 +48,22 @@ "type": "github" } }, + "fish-plugin-vi-mode": { + "flake": false, + "locked": { + "lastModified": 1613331590, + "narHash": "sha256-kRYWbTVT+eV5t5ZvV8abL2zIUnOZMbc2Gk+hDhX6hPM=", + "owner": "oh-my-fish", + "repo": "plugin-vi-mode", + "rev": "2655a7253077faefd2f0a57b799dee687344d4fb", + "type": "github" + }, + "original": { + "owner": "oh-my-fish", + "repo": "plugin-vi-mode", + "type": "github" + } + }, "flake-compat": { "flake": false, "locked": { @@ -261,6 +277,7 @@ "agnoster": "agnoster", "easy-dhall-nix": "easy-dhall-nix", "easy-purescript-nix": "easy-purescript-nix", + "fish-plugin-vi-mode": "fish-plugin-vi-mode", "githubNvimTheme": "githubNvimTheme", "home-manager": "home-manager", "neovim-nightly-overlay": "neovim-nightly-overlay", diff --git a/flake.nix b/flake.nix index 492c64d..b319137 100644 --- a/flake.nix +++ b/flake.nix @@ -35,6 +35,11 @@ flake = false; }; + fish-plugin-vi-mode = { + url = "github:oh-my-fish/plugin-vi-mode"; + flake = false; + }; + agnoster = { url = "github:oh-my-fish/theme-agnoster"; flake = false; diff --git a/modules/applications/shells/fish.nix b/modules/applications/shells/fish.nix index 882e5df..274fd98 100644 --- a/modules/applications/shells/fish.nix +++ b/modules/applications/shells/fish.nix @@ -2,11 +2,16 @@ let shellAliases = import ./aliases.nix; common = import ./common.nix; -in { +in +{ home-manager.users.adrielus.programs.fish = { inherit shellAliases; - shellInit = common.shellInit; - plugins = with pkgs; [ z agnoster ]; + + shellInit = '' + source ${../../../dotfiles/fish/fish.conf} + '' ++ common.shellInit; + + plugins = with pkgs; [ myFishPlugins.z myFishPlugins.vi-mode myFishPlugins.themes.agnoster ]; enable = true; }; diff --git a/modules/overlays/flakes.nix b/modules/overlays/flakes.nix index 519d474..fcc2251 100644 --- a/modules/overlays/flakes.nix +++ b/modules/overlays/flakes.nix @@ -6,6 +6,7 @@ , easy-purescript-nix , easy-dhall-nix , z +, fish-plugin-vi-mode , agnoster , githubNvimTheme , vim-extra-plugins @@ -28,15 +29,25 @@ in easy-purescript-nix = self.callPackage easy-purescript-nix { }; easy-dhall-nix = self.callPackage easy-dhall-nix { }; - z = { - src = z; - name = "z"; + myFishPlugins = { + z = { + src = z; + name = "z"; + }; + vi-mode = { + src = fish-plugin-vi-mode; + name = "vi-mode"; + }; + + themes = { + agnoster = { + src = agnoster; + name = "agnoster"; + }; + }; }; - agnoster = { - src = agnoster; - name = "agnoster"; - }; + githubNvimTheme = githubNvimTheme;