olimorris / onedarkpro.nvim

🎨 Atom's iconic One Dark theme. Cacheable, fully customisable, Tree-sitter and LSP semantic token support. Comes with variants
MIT License
821 stars 47 forks source link

[Bug]: `OnedarkproCache` occassionally hangs Neovim #112

Closed mrjones2014 closed 1 year ago

mrjones2014 commented 2 years ago

Your OneDarkPro config

return {
  'olimorris/onedarkpro.nvim',
  config = function()
    local onedarkpro = require('onedarkpro')
    local utils = require('onedarkpro.lib.color')
    local dark_gray = utils.lighten('#000000', 0.01, '#101010')
    local normal_fg = '#abb2bf'
    local buffer_inactive = '#434852'
    onedarkpro.setup({
      dark_theme = 'onedark_dark',
      caching = true,
      colors = {
        telescope_prompt = dark_gray,
        telescope_results = '#000000',
        comment = onedarkpro.get_colors('onedark_vivid').gray,
      },
      highlights = {
        CmdLine = {
          bg = dark_gray,
          fg = normal_fg,
        },
        LineNr = '${color_column}',
        SignColumn = '${color_column}',
        Search = {
          fg = '${black}',
          bg = '${highlight}',
        },
        TelescopeBorder = {
          fg = '${telescope_results}',
          bg = '${telescope_results}',
        },
        TelescopePromptBorder = {
          fg = '${telescope_prompt}',
          bg = '${telescope_prompt}',
        },
        TelescopePromptCounter = { fg = '${fg}' },
        TelescopePromptNormal = { fg = '${fg}', bg = '${telescope_prompt}' },
        TelescopePromptPrefix = {
          fg = '${green}',
          bg = '${telescope_prompt}',
        },
        TelescopePromptTitle = {
          fg = '${telescope_prompt}',
          bg = '${green}',
        },

        TelescopePreviewTitle = {
          fg = '${telescope_results}',
          bg = '${green}',
        },
        TelescopeResultsTitle = {
          fg = '${telescope_results}',
          bg = '${telescope_results}',
        },

        TelescopeMatching = { fg = '${green}' },
        TelescopeNormal = { bg = '${telescope_results}' },
        TelescopeSelection = { bg = '${telescope_prompt}' },

        -- barbar.nvim
        BufferCurrent = { fg = normal_fg, style = 'bold,italic' },
        BufferCurrentMod = { fg = normal_fg, style = 'bold,italic' },
        BufferInactiveSign = { fg = buffer_inactive },
      },
      plugins = {
        gitsigns = true,
        indentline = true,
        neotest = true,
        nvim_cmp = true,
        native_lsp = true,
        nvim_tree = true,
        nvim_ts_rainbow = true,
        op_nvim = true,
        packer = true,
        trouble = true,
      },
      options = {
        bold = true,
        italic = true,
        undercurl = true,
        window_unfocused_color = true,
      },
      styles = {
        comments = 'italic',
        keywords = 'italic',
      },
    })
    vim.cmd.colorscheme('onedarkpro')
  end,
}

Error messages

none

Describe the bug

What I expect to happen

It compiles cache

What actually happens

Not very often, but every once in a while, :OnedarkproCache will hang Neovim and I have to kill it with killall -KILL nvim

Reproduce the bug

I'm not sure any consistent way to reproduce, sorry. It happens maybe every 1 in 10-20 times if I had to estimate.

Run :OnedarkproCache a bunch of times until it reproduces.

Final checks

mmirus commented 2 years ago

I hit this a number of times, as well. Eventually it did begin responding again, so I didn't have to kill neovim. I don't have any more precise way to reproduce than you (and I'm not using the cache currently, since it doesn't support the legacy ft_highlights).

olimorris commented 2 years ago

I wonder if this is something to do with writing to file...

What I propose is that I'll add some debugging to the colorscheme in the coming days and we can see where it hangs based on what's logged.

mrjones2014 commented 2 years ago

Another somewhat related issue is that if there is an error in the cached file, then a lot of the rest of the theme fails to load, e.g. you cannot regenerate the cache because the :OnedarkproCache command doesn't get defined.

I think that bit should be basically wrapping the cache loading in pcall

olimorris commented 2 years ago

That's a really great spot!

olimorris commented 2 years ago

@mrjones2014 can you set log_level = "debug" in your configuration? A onedarkpro.log file should be generated in ~/.local/state/nvim/

mrjones2014 commented 2 years ago

Sure. I'll post back here if I notice the issue again.

olimorris commented 1 year ago

Closing this after the new merge. Please re-open if you notice any performance issues.