From 7a5bd54f16fa68bb27a2d84b651b0a46e4a18ff6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillaume=20Lam=C3=A9?= Date: Thu, 16 Jan 2025 11:17:34 +0100 Subject: [PATCH] FIX: desactivate if not in tmux --- lua/tmux-sync/init.lua | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lua/tmux-sync/init.lua b/lua/tmux-sync/init.lua index 95826a9..764afd8 100644 --- a/lua/tmux-sync/init.lua +++ b/lua/tmux-sync/init.lua @@ -23,7 +23,7 @@ end -- 📡 Synchroniser les couleurs avec Tmux selon le mode M.set_tmux_status = function(mode) if not (is_tmux_installed() and is_in_tmux()) then - return -- 🔒 Ne fait rien si tmux n'est pas dispo + return -- Ne fait rien si tmux n'est pas dispo end local mode_colors = { @@ -39,11 +39,16 @@ M.set_tmux_status = function(mode) local color = mode_colors[mode] or get_hl_color("MiniStatuslineModeNormal", "bg") -- 🛠️ Commande silencieuse pour changer la couleur de Tmux - vim.fn.system({ "tmux", "set-option", "-g", "status-bg", color }) + os.execute(string.format("tmux set-option -g status-bg '%s'", color)) end --- 🔄 Détecte les changements de mode -if is_tmux_installed() and is_in_tmux() then +-- Initialisation sécurisée : Ne rien lancer si Tmux est absent +M.setup = function() + if not (is_tmux_installed() and is_in_tmux()) then + return -- Tmux absent ➔ on quitte + end + + -- Détecte les changements de mode vim.api.nvim_create_autocmd("ModeChanged", { pattern = "*", callback = function()