marko-cerovac / material.nvim

:trident: Material colorscheme for NeoVim written in Lua with built-in support for native LSP, TreeSitter and many more plugins
GNU General Public License v2.0
954 stars 121 forks source link

plugin breaks kitty protocol (existing workaround) #181

Open matu3ba opened 8 months ago

matu3ba commented 8 months ago

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 commented 8 months ago

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
marko-cerovac commented 8 months ago

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.