Created
November 19, 2023 21:17
-
-
Save Mr-Jack82/3844ca116aae3474cfc6cbeefcd56c2d to your computer and use it in GitHub Desktop.
Taken from here: https://github.com/amaanq/nvim-config/blob/1cf620498edba954ccf31030019dc9de6c77628f/lua/config/autocmds.lua#L7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- show cursor line only in active window | |
| vim.api.nvim_create_autocmd({ "InsertLeave", "WinEnter" }, { | |
| callback = function() | |
| local ok, cl = pcall(vim.api.nvim_win_get_var, 0, "auto-cursorline") | |
| if ok and cl then | |
| vim.wo.cursorline = true | |
| vim.api.nvim_win_del_var(0, "auto-cursorline") | |
| end | |
| end, | |
| }) | |
| vim.api.nvim_create_autocmd({ "InsertEnter", "WinLeave" }, { | |
| callback = function() | |
| local cl = vim.wo.cursorline | |
| if cl then | |
| vim.api.nvim_win_set_var(0, "auto-cursorline", cl) | |
| vim.wo.cursorline = false | |
| end | |
| end, | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment