Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ require('github-theme').setup({
transparent = false, -- Disable setting bg (make neovim's background transparent)
terminal_colors = true, -- Set terminal colors (vim.g.terminal_color_*) used in `:terminal`
dim_inactive = false, -- Non focused panes set to alternative background
cursor = false, -- Set guicursor to use the theme's Cursor highlight groups
module_default = true, -- Default enable value for modules
styles = { -- Style to be applied to different syntax groups
comments = 'NONE', -- Value is any valid attr-list value `:help attr-list`
Expand Down
7 changes: 7 additions & 0 deletions Usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,13 @@ If set to `true`, it defines the terminal colors for the built-in `terminal` (vi

If set to `true`, it sets the background of non-current windows to be darker. Refer to `:h hl-NormalNC` for more information.

#### options.cursor {bool}

If set to `true`, it sets `guicursor` so that the cursor uses the colors of the theme's `Cursor`/`lCursor` highlight groups.
By default, Neovim renders the cursor with the host-terminal default colors and ignores the `Cursor` highlight group, which can
make the cursor hard to see on light themes. With this option enabled, e.g. on `github_light` the cursor becomes the theme's
foreground color (`#1F2328`) with a light glyph. The default value is `false`.

#### options.module_default {bool}

Specifies the default value of a module that has not been overridden in the modules table.
Expand Down
10 changes: 10 additions & 0 deletions doc/github-nvim-theme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,16 @@ If set to `true`, it sets the background of non-current windows to be darker.
Refer to `:h hl-NormalNC` for more information.


options.cursor {bool} *github-nvim-theme-options.cursor*

If set to `true`, it sets `guicursor` so that the cursor uses the colors of the
theme's `Cursor`/`lCursor` highlight groups. By default, Neovim renders the
cursor with the host-terminal default colors and ignores the `Cursor` highlight
group, which can make the cursor hard to see on light themes. With this option
enabled, e.g. on `github_light` the cursor becomes the theme's foreground color
(`#1F2328`) with a light glyph. The default value is `false`.


options.module_default {bool} *github-nvim-theme-options.module_default*

Specifies the default value of a module that has not been overridden in the
Expand Down
7 changes: 7 additions & 0 deletions lua/github-theme/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ local M = { theme = 'github_dark', has_options = false }
---@field transparent? boolean
---@field terminal_colors? boolean
---@field dim_inactive? boolean
---@field cursor? boolean
---@field module_default? boolean
---@field styles? GhTheme.Config.Options.Styles
---@field inverse? GhTheme.Config.Options.Inverse
Expand All @@ -37,6 +38,12 @@ local defaults = {
dim_inactive = false,
module_default = true,

---If set to `true`, `guicursor` is set so that the cursor uses the colors of
---the theme's `Cursor`/`lCursor` highlight groups, instead of the
---host-terminal default cursor colors.
---@field cursor? boolean
cursor = false,

---A table of syntax items/groups and their corresponding styles.
---@class (exact) GhTheme.Config.Options.Styles
---@field comments? GhTheme.HighlightGroup.Style
Expand Down
6 changes: 6 additions & 0 deletions lua/github-theme/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ function M.load(opts)

---@diagnostic disable-next-line: need-check-nil
compiled_theme()

if config.options.cursor then
vim.opt.guicursor =
'n-v-c-sm:block-Cursor/lCursor,i-ci-ve:ver25-Cursor,r-cr-o:hor20-Cursor,t:block-blinkon500-blinkoff500-TermCursor'
end

require('github-theme.autocmds').set_autocmds()
end

Expand Down
24 changes: 24 additions & 0 deletions test/github-theme/config/cursor_spec.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
if vim.fn.has('nvim-0.9.0') == 0 or vim.fn.has('nvim-0.9.0') == false then
return
end

describe('config > options > cursor', function()
before_each(function()
require('github-theme.util.reload')(true)
end)

it('should not set `guicursor` when disabled', function()
require('github-theme').setup()
vim.cmd.colorscheme({ args = { 'github_light' } })
assert.is_false(require('github-theme.config').options.cursor)
assert.is_not.match('%-Cursor', vim.o.guicursor)
end)

it('should reference the `Cursor` highlight groups when enabled', function()
require('github-theme').setup({ options = { cursor = true } })
vim.cmd.colorscheme({ args = { 'github_light' } })
assert.is_true(require('github-theme.config').options.cursor)
assert.is.match('block%-Cursor/lCursor', vim.o.guicursor)
assert.is.match('ver25%-Cursor', vim.o.guicursor)
end)
end)