olimorris / onedarkpro.nvim

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

[Bug]: fixme/todos from comment parser overriden by semantic tokens in lua #190

Closed petobens closed 1 year ago

petobens commented 1 year ago

Your OneDarkPro config

local root = '/tmp/nvim-minimal'

-- Set stdpaths to use root dir
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',
        '--single-branch',
        'https://github.com/folke/lazy.nvim.git',
        lazypath,
    })
end
vim.opt.runtimepath:prepend(lazypath)

-- Install and configure plugins
local plugins = {
    {
        'nvim-treesitter/nvim-treesitter',
        build = ':TSUpdate',
        config = function()
            require('nvim-treesitter.configs').setup({
                ensure_installed = {
                    'lua',
                    'comment',
                },
                highlight = {
                    enable = true,
                },
            })
        end,
    },
    {
        'olimorris/onedarkpro.nvim',
        -- FIXME: not working when semantic tokens kick in
        config = function()
            require('onedarkpro').setup({
                theme = 'onedark',
                highlights = {
                    ['@lsp.type.comment.lua'] = {},
                },
            })
        end,
        priority = 1000, -- load first
    },
    -- LSP and completion
    {
        'williamboman/mason.nvim',
        dependencies = 'WhoIsSethDaniel/mason-tool-installer.nvim',
        config = function()
            require('mason').setup({})
            require('mason-tool-installer').setup({
                auto_update = true,
                ensure_installed = {
                    'lua-language-server',
                },
            })
        end,
    },
    { 'williamboman/mason-lspconfig.nvim' },
    {
        'neovim/nvim-lspconfig',
        config = function()
            require('mason-lspconfig').setup()
            require('lspconfig').lua_ls.setup({})
        end,
    },
}
require('lazy').setup(plugins, {
    root = root .. '/plugins',
})

vim.cmd('colorscheme onedark')

Error messages

-

Describe the bug

When the semantic token kicks in FIXME/TODOs messages highlight are overriden even when lsp semantic token is explicitly removed.

Reproduce the bug

As in the GIF do:

  1. Open nvim with the minimal config above
  2. Restart nvim once everything has loaded
  3. Edit the minimal.lua file and check in line 40 how the FIXME changes from red to gray

After 3. I expect the fixme to remain red. The :Inspect command shows:

Treesitter
  - @comment.lua links to Comment lua
  - @spell.lua links to @spell lua
  - @spell.comment links to @spell comment
  - @spell.comment links to @spell comment
  - @spell.comment links to @spell comment
  - @text.danger.comment links to @text.danger comment
  - @nospell.comment links to @nospell comment

Semantic Tokens
  - @lsp.type.comment.lua priority: 125

onedark

Final checks

olimorris commented 1 year ago

Ahhh good spot. It doesn't make sense to explicitly define that. I've removed the OneDarkPro semantic token for the Lua LSP but not sure that will fix the issue as you may need to disable semantic tokens or create some custom TS queries.

petobens commented 1 year ago

Mmm didn't fix it for me. Does it work in your case? Maybe I need to open an issue with the comment parser... Dunno why things are overriden though

olimorris commented 1 year ago

I get this too unless I install https://github.com/folke/todo-comments.nvim

petobens commented 1 year ago

Mmm but this used to work.. Isn't there a way to make it work without adding yet another plugin? Note that in my minimal config I'm indeed disabling the semantic token comment lsp and would thus expected the treesitter highlight to show:

   ['@lsp.type.comment.lua'] = {},
olimorris commented 1 year ago

Have you recently upgraded to Neovim 0.9?

There's no changes in the plugin that I can think would cause this at all. It looks purely related to LSP semantic tokens.

petobens commented 1 year ago

Roger that. I'll take a further look.

petobens commented 1 year ago

If I add vim.api.nvim_set_hl(0, '@lsp.type.comment.lua', {}) then the semantic token is correctly disabled. Whereas if I do

   ['@lsp.type.comment.lua'] = {},

as in the config above (i.e from the highlights section) then the problem returns.

petobens commented 1 year ago

Unfortunately no success.. sticking to the the vim.api call in the meantime.

olimorris commented 1 year ago

@petobens I've fixed this in the latest commit, you should now be able to do:

['@lsp.type.comment.lua'] = {},
petobens commented 1 year ago

Thanks!