Skip to content

Commit

Permalink
Use custom highlight group for hiding cursor. declancm#11
Browse files Browse the repository at this point in the history
  • Loading branch information
declancm committed Jul 7, 2022
1 parent bc9aeab commit 1716918
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
12 changes: 12 additions & 0 deletions lua/cinnamon/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,18 @@ M.setup = function(user_config)
Cinnamon = {}
Cinnamon.Scroll = Scroll

-- Create highlight group for hiding cursor:
if config.hide_cursor and vim.opt.termguicolors:get() then
vim.cmd([[
augroup cinnamon_highlight
autocmd!
autocmd ColorScheme * highlight CinnamonHideCursor gui=reverse blend=100
augroup END
highlight CinnamonHideCursor gui=reverse blend=100
]])
end

if config.default_keymaps then
-- Half-window movements:
utils.create_keymap({ 'n', 'x' }, '<C-u>', "<Cmd>lua Scroll('<C-u>', 1, 1)<CR>")
Expand Down
7 changes: 3 additions & 4 deletions lua/cinnamon/scroll.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ local utils = require('cinnamon.utils')
local fn = require('cinnamon.functions')
local motions = require('cinnamon.motions')

local saved_guicursor
local saved_guicursor = vim.opt.guicursor:get()
local warning_given = false

M.scroll = function(command, scroll_win, use_count, delay_length, deprecated_arg)
Expand Down Expand Up @@ -114,11 +114,10 @@ M.scroll = function(command, scroll_win, use_count, delay_length, deprecated_arg
-- Hide the cursor.
local cursor_hidden = false
if config.hide_cursor and vim.opt.termguicolors:get() then
if not saved_guicursor then
if vim.opt.guicursor:get() ~= 'a:CinnamonHideCursor' then
saved_guicursor = vim.opt.guicursor:get()
end
vim.cmd('highlight Cursor blend=100')
vim.opt.guicursor:append('a:Cursor/lCursor')
vim.opt.guicursor = 'a:CinnamonHideCursor'
cursor_hidden = true
end

Expand Down

0 comments on commit 1716918

Please sign in to comment.