kevinhwang91 / nvim-ufo

Not UFO in the sky, but an ultra fold in Neovim.
BSD 3-Clause "New" or "Revised" License
2.23k stars 44 forks source link

Treesitter provider gets wrong highlights #54

Closed jaschenb closed 2 years ago

jaschenb commented 2 years ago

Neovim version (nvim -v | head -n1)

NVIM v0.7.2

Operating system/version

macOS 11.5

How to reproduce the issue

I use the Treesitter provider with my own highlight definitions and not a colour scheme. When I close the fold not all of the nodes seem to get recognised correctly.

Expected behavior

The colour of the folded text gets displayed correctly

Actual behavior

This is the unfolded text:

Captura de Tela 2022-07-16 às 23 07 18

and then here is the top line while folded:

Captura de Tela 2022-07-16 às 23 07 26
kevinhwang91 commented 2 years ago

use the Treesitter provider with my own highlight definitions and not a colour scheme.

Could you show me an example?

jaschenb commented 2 years ago

Could you show me an example?

for example the highlight groups in the screenshots I posted are:

hi Constant guifg=#5f875f hi Function guifg=#af8700 hi TSVariable guifg=#993300 hi TSField guifg=#808000

only the string, which links to Function seems to be displayed correctly.

kevinhwang91 commented 2 years ago

Please provide the line info by setting up ufo like

    require('ufo').setup({
        fold_virt_text_handler = function (virtText)
            print(vim.inspect(virtText))
            return virtText
        end
    })

and run TSCaptureUnderCursor (nvim-treesitter/playground) under each word for the line.

jaschenb commented 2 years ago

okay the line I get is: { { "vim.api.nvim_create_autocmd(", "UfoFoldedFg" }, { "'Filetype'", 735 }, { ", {", "UfoFoldedFg" } }

and the nodes are: vim: @variable -> luaTSVariable -> TSVariable

api: @variable -> luaTSVariable -> TSVariable
@field -> luaTSField -> TSField

nvim_create_autocommand: @variable -> luaTSVariable -> TSVariable
@field -> luaTSField -> TSField
@function -> luaTSFunction -> TSFunction

'Filetype': @string -> luaTSString -> TSString

kevinhwang91 commented 2 years ago

set termguicolors

jaschenb commented 2 years ago

I have that already and it isn't working with termguicolors on

jaschenb commented 2 years ago

okay your comment gave me an idea and now it works. I loaded ufo before I set termguicolors in my init files and then it doesn't work. I just moved it back now after I did that, now it works as inteded. Thanks for the help, but maybe it would help to mention that somewhere or maybe it's possible to check if termguicolors get used after ufo was loaded?

kevinhwang91 commented 2 years ago

I loaded ufo before I set termguicolors in my init files.

No idea why you are doing that, that's not a regular use case.

maybe it's possible to check if termguicolors get used after ufo was loaded?

Not worth doing this feature, this plugin is compatible with v0.6.1 Neovim which handling highlight groups is a little painful.