Skip to content

Commit

Permalink
fix: explicitly set colorscheme to vim (#106)
Browse files Browse the repository at this point in the history
closes #93
  • Loading branch information
mikesmithgh authored Dec 12, 2023
1 parent 8c36b74 commit 6e2bd60
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 23 deletions.
2 changes: 1 addition & 1 deletion lua/kitty-scrollback/footer_win.lua
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ M.open_footer_window = function(winopts, refresh_only)
vim.api.nvim_set_option_value(
'winhighlight',
'Normal:KittyScrollbackNvimPasteWinNormal,FloatBorder:KittyScrollbackNvimPasteWinFloatBorder,FloatTitle:KittyScrollbackNvimPasteWinFloatTitle',
{ win = p.footer_winid }
{ win = p.footer_winid, scope = 'local' }
)
end

Expand Down
5 changes: 3 additions & 2 deletions lua/kitty-scrollback/highlights.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---@mod kitty-scrollback.highlights
local ksb_api = require('kitty-scrollback.api')
local ksb_kitty_cmds = require('kitty-scrollback.kitty_commands')
local ksb_util = require('kitty-scrollback.util')

local M = {}
Expand Down Expand Up @@ -32,7 +31,9 @@ local function highlight_definitions()
end
local hl_as_normal_fn = opts.paste_window.highlight_as_normal_win
or function()
return vim.g.colors_name == nil or vim.g.colors_name == 'default'
return vim.g.colors_name == nil
or vim.g.colors_name == 'default'
or vim.g.colors_name == 'vim'
end
local hl_name = hl_as_normal_fn() and 'Normal' or 'NormalFloat'
local hl_def = vim.api.nvim_get_hl(0, { name = hl_name, link = false })
Expand Down
14 changes: 8 additions & 6 deletions lua/kitty-scrollback/launch.lua
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ local function set_options()
vim.o.termguicolors = true

-- preferred optional opts
vim.opt.shortmess:append('I') -- no intro message
vim.o.laststatus = 0
vim.o.scrolloff = 0
vim.o.cmdheight = 0
Expand Down Expand Up @@ -317,19 +318,21 @@ M.setup = function(kitty_data_str)
end
end

set_options()

ksb_util.setup(p, opts)
ksb_kitty_cmds.setup(p, opts)
ksb_win.setup(p, opts)
ksb_footer_win.setup(p, opts)
ksb_autocmds.setup(p, opts)
ksb_api.setup(p, opts)
ksb_keymaps.setup(p, opts)

local ok = ksb_hl.setup(p, opts)
if ok then
ksb_hl.set_highlights()
ksb_kitty_cmds.open_kitty_loading_window(ksb_hl.get_highlights_as_env()) -- must be after opts and set highlights
end
set_options()

if
opts.callbacks
Expand Down Expand Up @@ -396,11 +399,10 @@ M.launch = function()
local term_buf_name = vim.api.nvim_buf_get_name(p.bufid)
term_buf_name = term_buf_name:gsub('^(term://.-:).*', '%1kitty-scrollback.nvim')
vim.api.nvim_buf_set_name(p.bufid, term_buf_name)
vim.api.nvim_set_option_value(
'winhighlight',
'Visual:KittyScrollbackNvimVisual',
{ win = 0 }
)
vim.api.nvim_set_option_value('winhighlight', 'Visual:KittyScrollbackNvimVisual', {
scope = 'local',
win = 0,
})
vim.api.nvim_buf_delete(vim.fn.bufnr('#'), { force = true }) -- delete alt buffer after rename

if opts.restore_options then
Expand Down
3 changes: 2 additions & 1 deletion lua/kitty-scrollback/windows.lua
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ M.open_paste_window = function(start_insert)
vim.api.nvim_set_option_value(
'winhighlight',
'Normal:KittyScrollbackNvimPasteWinNormal,FloatBorder:KittyScrollbackNvimPasteWinFloatBorder,FloatTitle:KittyScrollbackNvimPasteWinFloatTitle',
{ win = p.paste_winid }
{ win = p.paste_winid, scope = 'local' }
)
vim.api.nvim_set_option_value('winblend', opts.paste_window.winblend or 0, {
win = p.paste_winid,
Expand Down Expand Up @@ -170,6 +170,7 @@ M.show_status_window = function()
)
vim.api.nvim_set_option_value('winhighlight', 'NormalFloat:KittyScrollbackNvimNormal', {
win = popup_winid,
scope = 'local',
})
local count = 0
local spinner = { '', '', '', '', '', '', '' }
Expand Down
24 changes: 11 additions & 13 deletions python/kitty_scrollback_nvim.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,7 @@ def nvim_err_cmd(err_file):
'nvim',
) + parse_nvim_args() + (
'-c',
'set laststatus=0',
'-c',
'set fillchars=eob:\\ ',
'-c',
'set filetype=checkhealth',
'lua vim.api.nvim_set_hl(0, [[Normal]], {})',
err_file,
)

Expand Down Expand Up @@ -190,14 +186,16 @@ def handle_result(args: List[str],

nvim_args = parse_nvim_args(args) + (
'--cmd',
' lua vim.api.nvim_create_autocmd([[VimEnter]], { '
' group = vim.api.nvim_create_augroup([[KittyScrollBackNvimVimEnter]], { clear = true }), '
' pattern = [[*]], '
' callback = function() '
f' vim.opt.runtimepath:append([[{ksb_dir}]])'
' vim.api.nvim_exec_autocmds([[User]], { pattern = [[KittyScrollbackLaunch]], modeline = false })'
f' require([[kitty-scrollback.launch]]).setup_and_launch([[{kitty_data}]])'
' end, '
' lua '
' vim.api.nvim_create_autocmd([[VimEnter]], {'
' group = vim.api.nvim_create_augroup([[KittyScrollBackNvimVimEnter]], { clear = true }),'
' pattern = [[*]],'
' callback = function()'
' vim.cmd.colorscheme({ args = {[[vim]]}, mods = { emsg_silent = true }})'
f' vim.opt.runtimepath:append([[{ksb_dir}]])'
' vim.api.nvim_exec_autocmds([[User]], { pattern = [[KittyScrollbackLaunch]], modeline = false })'
f' require([[kitty-scrollback.launch]]).setup_and_launch([[{kitty_data}]])'
' end,'
' })')

cmd = ('launch', ) + kitty_args + ('nvim', ) + nvim_args
Expand Down
1 change: 1 addition & 0 deletions scripts/breaking_change_config_file.txt
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,4 @@ https://github.com/mikesmithgh/kitty-scrollback.nvim/wiki
/_// ___/
\_)

vim:ft=checkhealth:laststatus=0:fillchars=eob\:\ :termguicolors
1 change: 1 addition & 0 deletions scripts/kitty_not_found.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ Failed to find kitty executable. Please check your environment variable `PATH`.
/_// ___/
\_)

vim:ft=checkhealth:laststatus=0:fillchars=eob\:\ :termguicolors

0 comments on commit 6e2bd60

Please sign in to comment.