material.nvim icon indicating copy to clipboard operation
material.nvim copied to clipboard

plugin breaks kitty protocol (existing workaround)

Open matu3ba opened this issue 2 years ago • 2 comments

Minimal reproducible:

-- nvim --clean -u mini.lua -c quit
local root = vim.fn.fnamemodify("./.repro", ":p")
-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end
-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath, })
end
vim.opt.runtimepath:prepend(lazypath)
-- install plugins
local plugins = {
  "marko-cerovac/material.nvim",
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})
vim.cmd.colorscheme("material")

Yet unhelpful manifestation: Executing nvim --clean -u mini.lua -c quit breaks ghostty. I will update this issue with more information how to debug/inspect the underlying issue based on provided feedback.

matu3ba avatar Nov 13 '23 22:11 matu3ba

~~Still no feedback yet. :(~~ Got feedback, but it was unconclusive regarding how to debug the neovim behavior.

Anyhow, I have a more minimal reproducible and it looks like "Disable the colored cursor" fixes the problem:

require('material').setup({
    disable = {
        colored_cursor = true, -- Disable the colored cursor (enabled colored cursor breaks things)
    },
})

I could reduce some more functions and it looks like the cleanup is somehow messed up:

M.load = function()
    vim.g.colors_name     = "material"
    vim.opt.termguicolors = true
    vim.opt.background = "dark"

    vim.opt.guicursor = "n-v-c-sm:block,i-ci-ve:ver25,r-cr-o:hor20,a:Cursor/Cursor"
    local exit_group  = vim.api.nvim_create_augroup("MaterialExit", { clear = true })
    vim.api.nvim_create_autocmd("ExitPre", {
        command = "autocmd ExitPre * set guicursor=n-v-c-sm:block,i-ci-ve:ver25,r-cr-o:hor20",
        group   = exit_group
    })

    -- apply highlights one by one
    for _, highlights_fn in pairs(highlights.main_highlights) do
        for name, values in pairs(highlights_fn()) do
            vim.api.nvim_set_hl(0, name, values)
        end
    end
end

matu3ba avatar Nov 14 '23 19:11 matu3ba

Yes, I suspected that it would be the cursor. When the colorscheme changes the cursor color and you exit nvim, the cursor color stays the same. That autogrup is there to revert the cursor back to it's default color before nvim exits. For some reason Kitty just doesn't play nice with this option. I think it's an issue between neovim and kitty but I'll look into this in the next couple of days. The solution, for now, is to disable the colored cursor as you already found out. I'll keep you updated.

marko-cerovac avatar Nov 15 '23 17:11 marko-cerovac