From 39c2e5db8c6f108d0c1c2c93b0afeef475e49343 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Sat, 6 May 2023 18:17:16 +0100 Subject: [PATCH] home: vim: signtoggle: use lua autocommands A nice next step would be to use actual lua callbacks instead of the VimL command. --- home/vim/plugin/signtoggle.vim | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/home/vim/plugin/signtoggle.vim b/home/vim/plugin/signtoggle.vim index c2f0183..5cc2e8e 100644 --- a/home/vim/plugin/signtoggle.vim +++ b/home/vim/plugin/signtoggle.vim @@ -1,8 +1,22 @@ -augroup signtoggle - autocmd! - " Only show the sign column for the current focused buffer - autocmd BufEnter,FocusGained,WinEnter * set signcolumn=yes - autocmd BufLeave,FocusLost,WinLeave * set signcolumn=no - " Disable the sign column in terminal - autocmd TermOpen * setlocal signcolumn=no -augroup END +lua << EOF +local signtoggle = vim.api.nvim_create_augroup("signtoggle", { clear = true }) + +-- Only show sign column for the currently focused buffer +vim.api.nvim_create_autocmd({ "BufEnter", "FocusGained", "WinEnter" }, { + pattern = "*", + group = signtoggle, + command = "setlocal signcolumn=yes", +}) +vim.api.nvim_create_autocmd({ "BufLeave", "FocusLost", "WinLeave" }, { + pattern = "*", + group = signtoggle, + command = "setlocal signcolumn=yes", +}) + +-- Never show the sign column in a terminal buffer +vim.api.nvim_create_autocmd({ "TermOpen" }, { + pattern = "*", + group = signtoggle, + command = "setlocal signcolumn=no", +}) +EOF