From d062c91af6261781f9c2e9c1e6366da18b2426b4 Mon Sep 17 00:00:00 2001 From: Gustaf Rydholm Date: Fri, 13 Jan 2023 18:11:13 +0100 Subject: Add autocmd for showing cursor line only in active window --- fnl/settings/autocmds.fnl | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'fnl/settings') diff --git a/fnl/settings/autocmds.fnl b/fnl/settings/autocmds.fnl index cd3a27e..27d6c2d 100644 --- a/fnl/settings/autocmds.fnl +++ b/fnl/settings/autocmds.fnl @@ -31,7 +31,22 @@ (vim.keymap.set :t : "wincmd h" {}) (vim.keymap.set :t : "wincmd j" {}) (vim.keymap.set :t : "wincmd k" {}) - (vim.keymap.set :t : "wincmd l" {}))}]]) + (vim.keymap.set :t : "wincmd l" {}))}] + [[:InsertLeave :WinEnter] + {:callback (fn [] + (let [(ok cl) (pcall vim.api.nvim_win_get_var 0 + :auto-cursorline)] + (if (and ok cl) + (do + (set vim.wo.cursorline true) + (vim.api.nvim_win_del_var 0 :auto-cursorline)))))}] + [[:InsertEnter :WinLeave] + {:callback (fn [] + (let [cl vim.wo.cursorline] + (if cl + (do + (vim.api.nvim_win_set_var 0 :auto-cursorline cl) + (set vim.wo.cursorline false)))))}]]) (each [_ autocmd (ipairs autocmds)] (match autocmd -- cgit v1.2.3-70-g09d2