diff --git a/modules/cli/tools/tmux.nix b/modules/cli/tools/tmux.nix index 562e02e..18da4ef 100644 --- a/modules/cli/tools/tmux.nix +++ b/modules/cli/tools/tmux.nix @@ -3,39 +3,55 @@ (pkgs.writeShellScriptBin "tmux-sessionizer" (builtins.readFile ./tmux-sessionizer.sh)) ]; - xdg.configFile."tmux/tmux.conf".text = '' - unbind C-b - set -g prefix C-t - bind -N "Send the prefix key through to the application" t send-prefix + programs.tmux = { + enable = true; + terminal = "tmux-256color"; - set -g mouse on - set -g status off - set -g set-clipboard on - set -g focus-events on + mouse = true; + focusEvents = true; + aggressiveResize = true; + clock24 = true; - set-window-option -g mode-keys vi - bind-key v copy-mode - bind-key -T copy-mode-vi i send -X cancel - bind-key -T copy-mode-vi v send -X begin-selection - bind-key -T copy-mode-vi V send -X select-line - bind-key -T copy-mode-vi y send -X copy-selection -x - bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-selection -x + historyLimit = 50000; + # default is 500 which makes vim's esc slow, we do not want 0 because it won't be able to read osc + escapeTime = 50; - bind-key [ copy-mode \; send-keys -X previous-prompt - bind-key ] copy-mode \; send-keys -X next-prompt - bind-key -T copy-mode-vi [ send-keys -X previous-prompt - bind-key -T copy-mode-vi ] send-keys -X next-prompt + keyMode = "vi"; + prefix = "C-t"; - bind-key f run-shell "tmux neww tmux-sessionizer" - bind-key C-h run-shell "tmux-sessionizer ~/projects/kyoo" - bind-key C-s run-shell "tmux-sessionizer ~/projects/flake" - bind-key C-n run-shell "tmux-sessionizer ~/projects/blog" + plugins = with pkgs.tmuxPlugins; [fzf-tmux-url]; - run-shell ${pkgs.tmuxPlugins.sensible.rtp} - run-shell ${pkgs.tmuxPlugins.fzf-tmux-url.rtp} + extraConfig = + #tmux + '' + set -g status off + set -s set-clipboard on - # https://github.com/tmux/tmux/issues/4162 - set -gu default-command - set -g default-shell "$SHELL" - ''; + # from tmux-sensible + set -g display-time 4000 + set -g status-interval 5 + + bind-key v copy-mode + bind-key -T copy-mode-vi i send -X cancel + bind-key -T copy-mode-vi v send -X begin-selection + bind-key -T copy-mode-vi V send -X select-line + bind-key -T copy-mode-vi y send -X copy-selection -x + bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-selection -x + bind-key -T copy-mode-vi p { refresh-client -l; run -d0.05; paste-buffer; send -X cancel } + + bind-key [ copy-mode \; send-keys -X previous-prompt + bind-key ] copy-mode \; send-keys -X next-prompt + bind-key -T copy-mode-vi [ send-keys -X previous-prompt + bind-key -T copy-mode-vi ] send-keys -X next-prompt + + bind-key f run-shell "tmux neww tmux-sessionizer" + bind-key C-h run-shell "tmux-sessionizer ~/projects/kyoo" + bind-key C-s run-shell "tmux-sessionizer ~/projects/flake" + bind-key C-n run-shell "tmux-sessionizer ~/projects/blog" + + # suspend inner tmux (to allow nested sessions) + bind -T root @ { set prefix None; set key-table off } + bind -T off C-@ { set -u prefix; set -u key-table } + ''; + }; } diff --git a/nvim/lua/settings.lua b/nvim/lua/settings.lua index 639dfe7..9ebf0bc 100644 --- a/nvim/lua/settings.lua +++ b/nvim/lua/settings.lua @@ -40,7 +40,7 @@ vim.opt.completeopt = { "menuone", "popup", "noinsert", "fuzzy" } vim.opt.pumheight = 15 vim.opt.spelloptions = { "camel", "noplainbuffer" } -vim.opt.spelllang = { "en", "cjk", } +vim.opt.spelllang = { "en", "programming", "cjk", } vim.opt.spell = true -- Can't specify this in wordmotion's config due to race conditions @@ -62,18 +62,25 @@ vim.keymap.set({ "n", "x" }, "y", '"+y', { desc = "Yank to system clipbo vim.keymap.set({ "n", "x" }, "Y", '"+y$', { desc = "Yank line to system clipboard" }) vim.keymap.set({ "n", "x" }, "p", '"+p', { desc = "Past from system clipboard" }) vim.keymap.set({ "n", "x" }, "P", '"+P', { desc = "Past line from system clipboard" }) + -- use osc52 so it works in ssh sessions -vim.g.clipboard = { - name = "OSC 52", - copy = { - ["+"] = require("vim.ui.clipboard.osc52").copy("+"), - ["*"] = require("vim.ui.clipboard.osc52").copy("*"), - }, - paste = { - ["+"] = require("vim.ui.clipboard.osc52").paste("+"), - ["*"] = require("vim.ui.clipboard.osc52").paste("*"), - }, -} +-- see https://github.com/tmux/tmux/issues/4048 for more info + +if vim.env.TMUX ~= nil then + -- tmux osc52 is lame, we need to run `tmux refresh-client -l` before copying + -- vim.g.clipboard = { + -- name = "tmux", + -- copy = { + -- ["+"] = { "tmux", "load-buffer", "-w", "-" }, + -- ["*"] = { "tmux", "load-buffer", "-w", "-" }, + -- }, + -- paste = { + -- ["+"] = { "bash", "-c", "tmux refresh-client -l && sleep 0.05 && tmux save-buffer -" }, + -- ["*"] = { "bash", "-c", "tmux refresh-client -l && sleep 0.05 && tmux save-buffer -" }, + -- }, + -- cache_enabled = 0, + -- } +end -- Quickfix list