Skip to content

Instantly share code, notes, and snippets.

@Mr-Jack82
Created November 19, 2023 21:17
Show Gist options
  • Select an option

  • Save Mr-Jack82/3844ca116aae3474cfc6cbeefcd56c2d to your computer and use it in GitHub Desktop.

Select an option

Save Mr-Jack82/3844ca116aae3474cfc6cbeefcd56c2d to your computer and use it in GitHub Desktop.
-- 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