aboutsummaryrefslogtreecommitdiff
path: root/lua
diff options
context:
space:
mode:
authorsrdusr <trevorgray@srdusr.com>2023-05-27 21:49:15 +0200
committersrdusr <trevorgray@srdusr.com>2023-05-27 21:49:15 +0200
commit658e02ac77ed472745dbc327297fa619538ce646 (patch)
tree724742c600291958abb69e03b8b849ef774c693a /lua
parentb299640fb7c4cbca73d729951dbb592a38e29c20 (diff)
downloaddotfiles-658e02ac77ed472745dbc327297fa619538ce646.tar.gz
dotfiles-658e02ac77ed472745dbc327297fa619538ce646.zip
Add "Update Tmux Status Vi-mode" script
Diffstat (limited to 'lua')
-rw-r--r--lua/user/mods.lua34
1 files changed, 34 insertions, 0 deletions
diff --git a/lua/user/mods.lua b/lua/user/mods.lua
index e523eb7..08a3eb8 100644
--- a/lua/user/mods.lua
+++ b/lua/user/mods.lua
@@ -214,5 +214,39 @@ vim.cmd [[autocmd BufWritePre <buffer> lua vim.lsp.buf.format()]]
--------------------------------------------------
+--- Update Tmux Status Vi-mode
+function M.update_tmux_status()
+ local mode = vim.api.nvim_eval('mode()')
+ -- Determine the mode name based on the mode value
+ local mode_name
+ if mode == 'n' then
+ mode_name = '-- NORMAL --'
+ elseif mode == 'i' or mode == 'ic' then
+ mode_name = '-- INSERT --'
+ else
+ mode_name = '-- NORMAL --' --'-- COMMAND --'
+ end
+
+ -- Write the mode name to the file
+ local file = io.open(os.getenv('HOME') .. '/.vi-mode', 'w')
+ file:write(mode_name)
+ file:close()
+ if nvim_running then
+ -- Neovim is running, update the mode file and refresh tmux
+ VI_MODE = "" -- Clear VI_MODE to show Neovim mode
+ vim.cmd("silent !tmux refresh-client -S")
+ end
+ ---- Force tmux to update the status
+ vim.cmd("silent !tmux refresh-client -S")
+end
+vim.cmd([[
+ augroup TmuxStatus
+ autocmd!
+ autocmd CursorHold * 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
+]])
+--------------------------------------------------
return M