diff options
| -rw-r--r-- | .config/nvim/lua/user/mods.lua | 12 | ||||
| -rw-r--r-- | .config/wezterm/wezterm.lua | 79 |
2 files changed, 85 insertions, 6 deletions
diff --git a/.config/nvim/lua/user/mods.lua b/.config/nvim/lua/user/mods.lua index 64e90a7..150af29 100644 --- a/.config/nvim/lua/user/mods.lua +++ b/.config/nvim/lua/user/mods.lua @@ -240,14 +240,24 @@ function M.update_tmux_status() vim.cmd("silent !tmux refresh-client -S") end +-- Add autocmd for <esc> +-- Add autocmd to check when tmux switches panes/windows vim.cmd([[ augroup TmuxStatus autocmd! - "autocmd CursorHold * lua require("user.mods").update_tmux_status() + autocmd InsertLeave,InsertEnter * lua require("user.mods").update_tmux_status() autocmd VimEnter * lua require("user.mods").update_tmux_status() autocmd ModeChanged * lua require("user.mods").update_tmux_status() augroup END ]]) + --autocmd InsertLeave,InsertEnter * lua require("user.mods").update_tmux_status() + + --autocmd BufEnter * lua require("user.mods").update_tmux_status() + --autocmd VimResized * lua require("user.mods").update_tmux_status() + --autocmd FocusGained * lua require("user.mods").update_tmux_status() + --autocmd FocusLost * lua require("user.mods").update_tmux_status() + --autocmd WinEnter,WinLeave * lua require("user.mods").update_tmux_status() + --autocmd CmdwinEnter,CmdwinLeave * lua require("user.mods").update_tmux_status() -------------------------------------------------- return M diff --git a/.config/wezterm/wezterm.lua b/.config/wezterm/wezterm.lua index 544b04f..de48ad6 100644 --- a/.config/wezterm/wezterm.lua +++ b/.config/wezterm/wezterm.lua @@ -1,5 +1,57 @@ local wezterm = require 'wezterm' +---- Function to unset Ctrl+C keybinding +--local function unsetCtrlCKeybinding(window) +-- local keys = window:get_config().keys +-- for i, key in ipairs(keys) do +-- if key.key == 'c' and key.mods == 'CTRL' then +-- table.remove(keys, i) +-- break +-- end +-- end +-- window:set_config({ keys = keys }) +--end +-- +---- Event handler to unset Ctrl+C keybinding when using nvim +--wezterm.on("spawn_command", function(window, pane) +-- local cmd = pane:get_command() +-- if cmd and cmd[1] == "nvim" then +-- unsetCtrlCKeybinding(window) +-- end +--end) + +--local function isNvimRunning(window) +-- local pane = window.active_pane +-- local cmd = pane:get_command() +-- return cmd and cmd[1] == "nvim" +--end +-- +---- Function to modify keybindings based on the current program +--local function updateKeybindings(window) +-- local isNvim = isNvimRunning(window) +-- +-- local keys = {} +-- if not isNvim then +-- -- Add the default Ctrl+C keybinding +-- keys = { +-- { +-- key = "c", +-- mods = "CTRL", +-- action = wezterm.action{CopyTo = "ClipboardAndPrimarySelection"} +-- } +-- } +-- end +-- +-- window:set_config({ +-- keys = keys +-- }) +--end +-- +---- Event handler to update keybindings when the active program changes +--wezterm.on("update-right-status", function(window) +-- updateKeybindings(window) +--end) + wezterm.on("toggle-opacity", function(window) local overrides = window:get_config_overrides() or {} if not overrides.window_background_opacity then @@ -72,11 +124,28 @@ return { mods = "CTRL", action = wezterm.action({ PasteFrom = "Clipboard" }), }, - { - key = "c", - mods = "CTRL", - action = wezterm.action({ CopyTo = "ClipboardAndPrimarySelection" }), - }, + --{ + -- key = "c", + -- mods = "CTRL", + -- action = wezterm.action({ CopyTo = "ClipboardAndPrimarySelection" }), + --}, + { + key="c", + mods="CTRL", + action = wezterm.action_callback(function(window, pane) + local has_selection = window:get_selection_text_for_pane(pane) ~= "" + if has_selection then + window:perform_action( + wezterm.action{CopyTo="ClipboardAndPrimarySelection"}, + pane) + window:perform_action("ClearSelection", pane) + else + window:perform_action( + wezterm.action{SendKey={key="c", mods="CTRL"}}, + pane) + end + end) + } }, -- Aesthetic Night Colorscheme --bold_brightens_ansi_colors = true, |
