Giter VIP home page Giter VIP logo

Comments (15)

kyazdani42 avatar kyazdani42 commented on May 24, 2024 10

this is an issue with neovim's api. A refactoring was coming up but got delayed because the author is not available. We will try to fix that issue ourselves, we'll keep this issue updated in the meantime

from nvim-treesitter.

theHamsta avatar theHamsta commented on May 24, 2024 2

Hi, the ERROR highlight is easily fixable:

    require "nvim-treesitter".setup()
    require "nvim-treesitter.highlight"
    local hlmap = vim.treesitter.TSHighlighter.hl_map

    --Misc
    hlmap.error = nil

We probably should default to that. Then, @error is not highlighted for you. hlmap defines how the tree-sitter queries are translated to Vim hightlight groups. I maintain my own mapping:

    require "nvim-treesitter.highlight"
    local hlmap = vim.treesitter.TSHighlighter.hl_map

    --Misc
    hlmap.error = nil
    hlmap["punctuation.delimiter"] = "Delimiter"
    hlmap["punctuation.bracket"] = "Delimiter"

    -- Constants
    hlmap["constant"] = "Constant"
    hlmap["constant.builtin"] = "Type"
    hlmap["constant.macro"] = "Define"
    hlmap["string"] = "String"
    hlmap["string.regex"] = "String"
    hlmap["string.escape"] = "SpecialChar"
    hlmap["character"] = "Character"
    hlmap["number"] = "Number"
    hlmap["boolean"] = "Boolean"
    hlmap["float"] = "Float"

    -- Functions
    hlmap["function"] = "Function"
    hlmap["function.builtin"] = "Special"
    hlmap["function.macro"] = "Macro"
    hlmap["parameter"] = "Identifier"
    hlmap["method"] = "Function"
    hlmap["field"] = "Identifier"
    hlmap["property"] = "Identifier"
    hlmap["constructor"] = "Type"

    -- Keywords
    hlmap["conditional"] = "Conditional"
    hlmap["repeat"] = "Repeat"
    hlmap["label"] = "Label"
    hlmap["operator"] = "Operator"
    hlmap["keyword"] = "Repeat"
    hlmap["exception"] = "Exception"
    hlmap["include"] = "Include"
    hlmap["type"] = "Type"
    hlmap["type.builtin"] = "Type"
    hlmap["structure"] = "Structure"

The issues that you're observing are problems introduced by the last runtime update of Neovim built-in treesitter. Apparently, the code that's performing the regex queries still has some bugs.

from nvim-treesitter.

vigoux avatar vigoux commented on May 24, 2024 1

@glepnir

Treesitter highlighting is a completely different mechanism than standard highlighting. tbh they don't even share any single line of code (on the implementation side). Thus if you define syntax groups, treesitter will just not know that, you have to use queries to do so.

The colors changed and that's normal, treesitter highlighting tries to bring meaning together with colors, here for example, in red you find keywords, green are function calls and so on. So the colorscheme changed yes, but if you compare you go code and you typescript code, they look uniform and consistent on the highlighting side. To customize the behaviour though, you can customize the highlight groups nvim-treesitter uses using :highlight link {TSHlGroup} {TheGroupYouWant}.

from nvim-treesitter.

glepnir avatar glepnir commented on May 24, 2024 1

Ok. I got it. I will try to define them. Thanks .

from nvim-treesitter.

glepnir avatar glepnir commented on May 24, 2024 1

@PitcherTear22 It's my plugin spaceline.vim

from nvim-treesitter.

steelsojka avatar steelsojka commented on May 24, 2024

Would this be causing this issue I'm seeing?

Screen Shot 2020-07-09 at 7 23 29 AM

from nvim-treesitter.

vigoux avatar vigoux commented on May 24, 2024

Yep, both of them are related, the way you can help is tell us the edit you did to cause that. Because that's actually the tree getting out of sync.

from nvim-treesitter.

steelsojka avatar steelsojka commented on May 24, 2024

@vigoux Sounds good. I'm getting it a lot on typescript code. Seems to be on just inserting text. Is this something we can fix or does it need to be fixed upstream in nvim?

from nvim-treesitter.

vigoux avatar vigoux commented on May 24, 2024

It needs to be fixed upstream. And it is related to especially gnarly parts of neovim, thus it requires quite q bit of effort (at least for me...) to fix.

from nvim-treesitter.

glepnir avatar glepnir commented on May 24, 2024

Same issue here. I found it has some problems with syntax. I defined some syntax group in my colorscheme. when i install treesitter. It didn't follow syntax group,It even changed the color scheme.

before:
3

after:
1

With typescript. It works better than default regexengine2 ,But it looks like I didn't get more color schemes.

before:
4

after:
2

from nvim-treesitter.

glepnir avatar glepnir commented on May 24, 2024

@vigoux Aha thanks. About this highlight link {TSHlGroup} {TheGroupYouWant}. I think i know the {TheGroupYouWant} that the syntax group i defined in my colorscheme of ts or other language syntax group. This {TSHlGroup} mean these?

  require "nvim-treesitter.highlight"
    local hlmap = vim.treesitter.TSHighlighter.hl_map

    --Misc
    hlmap.error = nil
    hlmap["punctuation.delimiter"] = "Delimiter"
    hlmap["punctuation.bracket"] = "Delimiter"

    -- Constants
    hlmap["constant"] = "Constant"
    hlmap["constant.builtin"] = "Type"
    hlmap["constant.macro"] = "Define"
    hlmap["string"] = "String"
    hlmap["string.regex"] = "String"
    hlmap["string.escape"] = "SpecialChar"
    hlmap["character"] = "Character"
    hlmap["number"] = "Number"
    hlmap["boolean"] = "Boolean"
    hlmap["float"] = "Float"

    -- Functions
    hlmap["function"] = "Function"
    hlmap["function.builtin"] = "Special"
    hlmap["function.macro"] = "Macro"
    hlmap["parameter"] = "Identifier"
    hlmap["method"] = "Function"
    hlmap["field"] = "Identifier"
    hlmap["property"] = "Identifier"
    hlmap["constructor"] = "Type"

    -- Keywords
    hlmap["conditional"] = "Conditional"
    hlmap["repeat"] = "Repeat"
    hlmap["label"] = "Label"
    hlmap["operator"] = "Operator"
    hlmap["keyword"] = "Repeat"
    hlmap["exception"] = "Exception"
    hlmap["include"] = "Include"
    hlmap["type"] = "Type"
    hlmap["type.builtin"] = "Type"
    hlmap["structure"] = "Structure"

from nvim-treesitter.

vigoux avatar vigoux commented on May 24, 2024

Hmm you have a pretty old version of the plugin, I mean these. Update to latest master (on both neovim and the plugin) so that you can configure this how you like it.

from nvim-treesitter.

stsewd avatar stsewd commented on May 24, 2024

Just an update here, the only problem that isn't fixed is

When the using folds, some parts of the code doesn't get highlighted. This happens when I open a file where the text is folded (syntax is highlighted as normal), then go to the last line with G (syntax isn't highlighted, the whole text is white). This is fixed by forcing a redraw with .

I have updated the description

from nvim-treesitter.

stsewd avatar stsewd commented on May 24, 2024

I can't replicate this anymore with folding, but it still happens with other cases like #235. I'm closing this in favor of the other issue.

from nvim-treesitter.

jacobduncan00 avatar jacobduncan00 commented on May 24, 2024

Same issue here. I found it has some problems with syntax. I defined some syntax group in my colorscheme. when i install treesitter. It didn't follow syntax group,It even changed the color scheme.

before: 3

after: 1

With typescript. It works better than default regexengine2 ,But it looks like I didn't get more color schemes.

before: 4

after: 2

What colorscheme and font is this?

from nvim-treesitter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.