Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to disable highlighting of syntax errors? #119

Closed
pittcat opened this issue Jun 29, 2020 · 5 comments
Closed

How to disable highlighting of syntax errors? #119

pittcat opened this issue Jun 29, 2020 · 5 comments
Labels
bug Something isn't working

Comments

@pittcat
Copy link

pittcat commented Jun 29, 2020

Describe the bug
The treesitter highlighting is fast and awesome.But when syntax error occurs , the highlight groups will take effect, which is a hassle.

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

**Output of :checkhealth nvim_treesitter ***


health#nvim_treesitter#check
========================================================================
## Installation
  - OK: `git` executable found.
  - OK: `cc` executable found.

## html parser healthcheck
  - OK: html parser found.
  - WARNING: No `locals.scm` query found for html
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
  - OK: `highlights.scm` found.

## c parser healthcheck
  - OK: c parser found.
  - OK: `locals.scm` found.
  - OK: `highlights.scm` found.

## java parser healthcheck
  - OK: java parser found.
  - OK: `locals.scm` found.
  - OK: `highlights.scm` found.

## python parser healthcheck
  - OK: python parser found.
  - OK: `locals.scm` found.
  - OK: `highlights.scm` found.

## cpp parser healthcheck
  - OK: cpp parser found.
  - OK: `locals.scm` found.
  - OK: `highlights.scm` found.

## go parser healthcheck
  - OK: go parser found.
  - OK: `locals.scm` found.
  - OK: `highlights.scm` found.

## javascript parser healthcheck
  - OK: javascript parser found.
  - OK: `locals.scm` found.
  - OK: `highlights.scm` found.

## css parser healthcheck
  - OK: css parser found.
  - WARNING: No `locals.scm` query found for css
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
  - OK: `highlights.scm` found.

## Missing parsers
  - WARNING: Some parsers are not installed:
    typescript
    regex
    nix
    swift
    yaml
    elm
    vue
    toml
    lua
    ruby
    ocaml
    scala
    haskell
    rust
    json
    markdown
    julia
    php
    c_sharp
    bash
    tsx
    - ADVICE:
      - Install them using `:TSInstall language


Output of nvim --version

NVIM v0.5.0-576-g7efb302d2

Additional context
Add any other context about the problem here.

@pittcat pittcat added the bug Something isn't working label Jun 29, 2020
@pittcat pittcat changed the title How to diable highlighting of syntax errors? How to disable highlighting of syntax errors? Jun 29, 2020
@theHamsta
Copy link
Member

Should be solved by #117

The corresponding highlight is TSError. I don't know how to delete highlights without overwriting them so I use a hack:

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

    --Misc
    hlmap.error = nil

This table also contains the other highlights

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

    -- 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"

@vigoux knows more. Can you help me with #117

@vigoux
Copy link
Member

vigoux commented Jun 29, 2020

To disable this hihglight, adding the following will be enough:

highlight link TSError Normal

@theHamsta
Copy link
Member

theHamsta commented Jun 29, 2020

Did you try it? I also thought this would work but somehow my plug config executes the plugin code after my init.vim so that your line has no effect.
I would need to execute it manually after start up.

Edit: #121 solves this issue.

@vigoux
Copy link
Member

vigoux commented Jun 29, 2020

It should have been solved by #121

@pittcat
Copy link
Author

pittcat commented Jun 29, 2020

I have tried it.It works well to disable the highlighting of syntax errors. Thanks for your work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants