2

Ok folks, I've tried all these duplicates:

But none of them work in for me in Neovim (0.8.2). And the plugin at https://github.com/benknoble/vim-synstax more helpfully reports "No syntax highlight groups under cursor".

I'm testing by putting my cursor in a word in a highlighted PHP doc and then firing the suggested command(s).

I just want my comments to be more readable (they're dark grey on black at the moment).

Is Neovim really different? Is it because I'm using Treesitter?

EDIT

Running without any plugins, the above answers work, it seems to be treesitter that causes the problem.

A minimal config is

use {
'nvim-treesitter/nvim-treesitter',
config = function()
  require('nvim-treesitter.configs').setup({
    highlight = { enable: true }
  })
  end,
}

Note that the problem only seems to occur when the treesitter's config specifies to enable highlight.

2
  • 1
    I suppose we will need a bit more information in order to reproduce the problem. Could you reproduce the problem on a minimal configuration (reduce at maximum the number of plugin that you install and limit the vimrc to the bare minimum). Let us know what you need to reproduce the problem. It will help us to reproduce and to help :-) Jan 13 at 15:20
  • Along with minimal configuration, commands necessary after running vim to reproduce would be helpful
    – D. Ben Knoble
    Jan 14 at 20:27

2 Answers 2

2

From 'nvim-treesitter/playground', there is the command

:TSHighlightCapturesUnderCursor

which does exactly this, presenting a nice popup at your cursor location. It works similarly to

:TSNodeUnderCursor

to get the tree-sitter node at your cursor location.

1

According to the closed issue at
https://github.com/nvim-treesitter/nvim-treesitter/issues/1654#issuecomment-893756730
Treesitter messes up synstack().

The only way to get a function to do something similar is through installing a 2nd plugin, nvim-treesitter/playground and writing a lua function, like the one at https://github.com/urbainvaes/vim-macaw/commit/be633f850fb54ed71cc6a1d46ee788380b7393b5

Manually, once you have playground installed you can start it up with :TSPlaygroundToggle then in the playground window press i to show highlight groups.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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