- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 112
Not planned
Labels
bugSomething isn't workingSomething isn't working
Description
Problem
when i type a bracket in the last line of a function, an incorrect highlight happened.
before:

after:

Steps to reproduce
config file:
local lazypath = '/tmp/lazy/lazy.nvim'
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
'git',
'clone',
'--filter=blob:none',
'https://github.com/folke/lazy.nvim.git',
'--branch=stable',
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
vim.opt.termguicolors = true
require('lazy').setup({
{
'lukas-reineke/indent-blankline.nvim',
config = function()
local hooks = require('ibl.hooks')
-- create the highlight groups in the highlight setup hook, so they are reset
-- every time the colorscheme changes
hooks.register(hooks.type.HIGHLIGHT_SETUP, function()
vim.api.nvim_set_hl(0, 'IblIndent', { fg = '#d39aaa' })
vim.api.nvim_set_hl(0, 'IblScope', { fg = '#4f575e' })
end)
hooks.register(hooks.type.SCOPE_HIGHLIGHT, hooks.builtin.scope_highlight_from_extmark)
require('ibl').setup({})
end,
},
-- uncomment this if the problem is related to scope
{
'nvim-treesitter/nvim-treesitter',
build = ':TSUpdate',
config = function()
require('nvim-treesitter.configs').setup({
highlight = { enable = true },
ensure_installed = { 'cpp' }, -- change this to the language you use
})
end,
},
}, { root = '/tmp/lazy', lockfile = '/tmp/lazy/lazy-lock.json' })
test file:
void solve() {
}
int main() {
printf("hello world");
return 0;
}
steps:
1.nvim -u minimal.lua test.cpp
2.just type a bracket in the last line of the solve function
Expected behavior
when i type a bracket the highlight group of main function is IblScope,but it should be IblIndent
Neovim version (nvim -v)
v0.10.0-dev-2047+g8df374237
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working
Projects
Milestone
Relationships
Development
Select code repository

Activity
Danielkonge commentedon Jan 7, 2024
This highlighting problem seems to come from the way treesitter parses the code in your example when there is a missing
}at that spot. I am not sure ifiblcan do anything about this, since the scope highlighting depends on treesitter's parsing of the text. (#805 might make this slightly better by picking a different scope, but it won't fix the problem with the parsing.)lukas-reineke commentedon Jan 8, 2024
Yeah this is an issue in the treesitter parser. Nothing I can do to fix it, sorry.