From cc0d6621a435ca6282d37682cb7cbe798d3dcedf Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 25 Jan 2024 14:27:55 +0530 Subject: [PATCH] Also document how to set user vars from nvim --- docs/mapping.rst | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/docs/mapping.rst b/docs/mapping.rst index 61371d4b8..b2fb37679 100644 --- a/docs/mapping.rst +++ b/docs/mapping.rst @@ -193,12 +193,37 @@ details. A more practical example unmaps the key when the focused window is runn map --when-focus-on var:in_editor -In order to make this work, you need the following lines in your :file:`.vimrc`:: +In order to make this work, you need to configure your editor as show below: - let &t_ti = &t_ti . "\\033]1337;SetUserVar=in_editor=MQo\\007" - let &t_te = &t_te . "\\033]1337;SetUserVar=in_editor\\007" +.. tab:: vim -These cause vim to set the :code:`in_editor` variable in kitty and unset it when leaving vim. + In :file:`~/.vimrc` add: + .. code-block:: vim + + let &t_ti = &t_ti . "\\033]1337;SetUserVar=in_editor=MQo\\007" + let &t_te = &t_te . "\\033]1337;SetUserVar=in_editor\\007" + +.. tab:: neovim + + In :file:`~/.config/nvim/init.lua` add: + + .. code-block:: lua + + vim.api.nvim_create_autocmd({ "VimEnter" }, { + group = vim.api.nvim_create_augroup("KittySetVarVimEnter", { clear = true }), + callback = function() + io.stdout:write("\x1b]1337;SetUserVar=in_editor=MQo\007") + end, + }) + + vim.api.nvim_create_autocmd({ "VimLeave" }, { + group = vim.api.nvim_create_augroup("KittyUnsetVarVimLeave", { clear = true }), + callback = function() + io.stdout:write("\x1b]1337;SetUserVar=in_editor\007") + end, + }) + +These cause the editor to set the :code:`in_editor` variable in kitty and unset it when exiting. Sending arbitrary text or keys to the program running in kitty --------------------------------------------------------------------------------