From 6e2bd60d14fdfb9839a7ac6e352c880f463cc9ba Mon Sep 17 00:00:00 2001 From: Mike <10135646+mikesmithgh@users.noreply.github.com> Date: Tue, 12 Dec 2023 14:44:11 -0500 Subject: [PATCH] fix: explicitly set colorscheme to vim (#106) closes #93 --- lua/kitty-scrollback/footer_win.lua | 2 +- lua/kitty-scrollback/highlights.lua | 5 +++-- lua/kitty-scrollback/launch.lua | 14 ++++++++------ lua/kitty-scrollback/windows.lua | 3 ++- python/kitty_scrollback_nvim.py | 24 +++++++++++------------- scripts/breaking_change_config_file.txt | 1 + scripts/kitty_not_found.txt | 1 + 7 files changed, 27 insertions(+), 23 deletions(-) diff --git a/lua/kitty-scrollback/footer_win.lua b/lua/kitty-scrollback/footer_win.lua index 015f44e7..f4255df0 100644 --- a/lua/kitty-scrollback/footer_win.lua +++ b/lua/kitty-scrollback/footer_win.lua @@ -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 diff --git a/lua/kitty-scrollback/highlights.lua b/lua/kitty-scrollback/highlights.lua index 4735058c..4692f4f5 100644 --- a/lua/kitty-scrollback/highlights.lua +++ b/lua/kitty-scrollback/highlights.lua @@ -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 = {} @@ -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 }) diff --git a/lua/kitty-scrollback/launch.lua b/lua/kitty-scrollback/launch.lua index 3e0503d3..7c93fc27 100644 --- a/lua/kitty-scrollback/launch.lua +++ b/lua/kitty-scrollback/launch.lua @@ -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 @@ -317,6 +318,8 @@ 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) @@ -324,12 +327,12 @@ M.setup = function(kitty_data_str) 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 @@ -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 diff --git a/lua/kitty-scrollback/windows.lua b/lua/kitty-scrollback/windows.lua index 7be1beb5..2ba8aef1 100644 --- a/lua/kitty-scrollback/windows.lua +++ b/lua/kitty-scrollback/windows.lua @@ -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, @@ -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 = { '⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '✔' } diff --git a/python/kitty_scrollback_nvim.py b/python/kitty_scrollback_nvim.py index 34d30eb9..086ff483 100755 --- a/python/kitty_scrollback_nvim.py +++ b/python/kitty_scrollback_nvim.py @@ -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, ) @@ -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 diff --git a/scripts/breaking_change_config_file.txt b/scripts/breaking_change_config_file.txt index 0a185aa5..95a5bedf 100644 --- a/scripts/breaking_change_config_file.txt +++ b/scripts/breaking_change_config_file.txt @@ -94,3 +94,4 @@ https://github.com/mikesmithgh/kitty-scrollback.nvim/wiki /_// ___/ \_) +vim:ft=checkhealth:laststatus=0:fillchars=eob\:\ :termguicolors diff --git a/scripts/kitty_not_found.txt b/scripts/kitty_not_found.txt index 9133e4af..49f09dac 100644 --- a/scripts/kitty_not_found.txt +++ b/scripts/kitty_not_found.txt @@ -16,3 +16,4 @@ Failed to find kitty executable. Please check your environment variable `PATH`. /_// ___/ \_) +vim:ft=checkhealth:laststatus=0:fillchars=eob\:\ :termguicolors