0

I have this problem that I would really like to get to the bottom of.

If I open a file on neovim it will display like the broken syntax highlighting, see image below. Now, If I run :Telescope current_buffer_fuzzy_find - it gives me a better syntax highlighting on the preview

Sometimes, it kinda fixes the syntax highlighting on the file itself. Sometimes, I can only see the better highlighting on the preview

I know that I can have a better syntax highlighting as it is what is displayed on the preview. Any ideas of what could be the issue? Telescope improves syntax highlighting 100%, but not sure what the real error here is.

Some plugins I have installed:

Plugin 'nvim-telescope/telescope.nvim'
Plugin 'nvim-treesitter/nvim-treesitter'
Plugin 'nvim-treesitter/playground'

Broken:

broken syntax

Fixed:

fixed syntax

4
  • do you have the lua require 'treesitter'.setup(... line(s) in your init.vim? Sep 15 at 10:10
  • Possibly just missing a :redraw[!]/<C-L>
    – D. Ben Knoble
    Sep 15 at 19:13
  • @pVCaecidiosporeadduced I had something there about playground, removed, but still the same issue.
    – filype
    Sep 15 at 23:29
  • It must be something in vim. I tried inside and outside tmux, in other terminals and the same issue happens. running :redraw didn't fix it
    – filype
    Sep 15 at 23:30
0

This was fixed by adding this in my vimrc, which is described in https://github.com/nvim-treesitter/nvim-treesitter#highlight

lua <<EOF
require'nvim-treesitter.configs'.setup {
  highlight = {
    enable = true,
    custom_captures = {
      -- Highlight the @foo.bar capture group with the "Identifier" highlight group.
      ["foo.bar"] = "Identifier",
    },
    -- Setting this to true will run `:h syntax` and tree-sitter at the same time.
    -- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
    -- Using this option may slow down your editor, and you may see some duplicate highlights.
    -- Instead of true it can also be a list of languages
    additional_vim_regex_highlighting = false,
  },
}
EOF
2
  • You can accept your own answer to mark this as resolved.
    – D. Ben Knoble
    22 hours ago
  • @D.BenKnoble I needed to wait a day. That's done now
    – filype
    16 hours ago

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.