Skip to content

Commit 1716918

Browse files
committed
Use custom highlight group for hiding cursor. declancm#11
1 parent bc9aeab commit 1716918

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

lua/cinnamon/init.lua

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,18 @@ M.setup = function(user_config)
1818
Cinnamon = {}
1919
Cinnamon.Scroll = Scroll
2020

21+
-- Create highlight group for hiding cursor:
22+
if config.hide_cursor and vim.opt.termguicolors:get() then
23+
vim.cmd([[
24+
augroup cinnamon_highlight
25+
autocmd!
26+
autocmd ColorScheme * highlight CinnamonHideCursor gui=reverse blend=100
27+
augroup END
28+
29+
highlight CinnamonHideCursor gui=reverse blend=100
30+
]])
31+
end
32+
2133
if config.default_keymaps then
2234
-- Half-window movements:
2335
utils.create_keymap({ 'n', 'x' }, '<C-u>', "<Cmd>lua Scroll('<C-u>', 1, 1)<CR>")

lua/cinnamon/scroll.lua

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ local utils = require('cinnamon.utils')
55
local fn = require('cinnamon.functions')
66
local motions = require('cinnamon.motions')
77

8-
local saved_guicursor
8+
local saved_guicursor = vim.opt.guicursor:get()
99
local warning_given = false
1010

1111
M.scroll = function(command, scroll_win, use_count, delay_length, deprecated_arg)
@@ -114,11 +114,10 @@ M.scroll = function(command, scroll_win, use_count, delay_length, deprecated_arg
114114
-- Hide the cursor.
115115
local cursor_hidden = false
116116
if config.hide_cursor and vim.opt.termguicolors:get() then
117-
if not saved_guicursor then
117+
if vim.opt.guicursor:get() ~= 'a:CinnamonHideCursor' then
118118
saved_guicursor = vim.opt.guicursor:get()
119119
end
120-
vim.cmd('highlight Cursor blend=100')
121-
vim.opt.guicursor:append('a:Cursor/lCursor')
120+
vim.opt.guicursor = 'a:CinnamonHideCursor'
122121
cursor_hidden = true
123122
end
124123

0 commit comments

Comments
 (0)