nvim-treesitter / nvim-treesitter/nvim-treesitter
C/C++ variables in upper case marked as @constant instead of @variable
Open
Nobody has claimed this yet.
- #2256 by @NaincyKumariKnoldus — closed without merging
bug
- Dominant language
- Tree-sitter Query
- Stars
- 14.4k
- Forks
- 1.4k
- Avg merge
- 4h 35m
- Merged PRs (30d)
- 13
Description
Before reporting
- I have updated my neovim version to latest master
- I have updated my plugin to the latest version
- I have run
:TSUpdate - I have read the troubleshooting section
Describe the bug
In C/C++ a variable in upper case letters is marked as @constant.
To Reproduce
// OpenGL Vertex Buffer Object
unsigned int VBO;
glGenBuffers(1, &VBO);
Expected behavior
Upper case variables should be possible and marked as @variable.
Output of :checkhealth nvim-treesitter
nvim-treesitter: require("nvim-treesitter.health").check()
========================================================================
## Installation
- OK: `tree-sitter` found 0.19.5 (8d8690538ef0029885c7ef1f163b0e32f256a5aa) (parser generator, only needed for :TSInstallFromGrammar)
- OK: `node` found v16.13.2 (only needed for :TSInstallFromGrammar)
- OK: `git` executable found.
- OK: `cc` executable found. Selected from { vim.NIL, "cc", "gcc", "clang", "cl", "zig" }
Version: cc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
- OK: Neovim was compiled with tree-sitter runtime ABI version 13 (required >=13). Parsers must be compatible with runtime ABI.
## Parser/Features H L F I J
- teal ✓ ✓ ✓ ✓ ✓
- graphql ✓ . . ✓ ✓
- ql ✓ ✓ . ✓ ✓
- ruby ✓ ✓ ✓ ✓ ✓
- html ✓ ✓ ✓ ✓ ✓
- perl ✓ . . . .
- llvm ✓ . . . .
- bash ✓ ✓ ✓ . ✓
- http ✓ . . . ✓
- fish ✓ ✓ ✓ ✓ ✓
- comment ✓ . . . .
- go ✓ ✓ ✓ ✓ ✓
- jsdoc ✓ . . . .
- java ✓ ✓ . ✓ ✓
- rasi ✓ ✓ ✓ ✓ .
- sparql ✓ ✓ ✓ ✓ ✓
- kotlin ✓ ✓ ✓ . ✓
- gdscript ✓ ✓ . . ✓
- julia ✓ ✓ ✓ ✓ ✓
- godot_resource ✓ ✓ ✓ . .
- erlang . . . . .
- elixir ✓ ✓ ✓ ✓ ✓
- surface ✓ . ✓ ✓ ✓
- typescript ✓ ✓ ✓ ✓ ✓
- heex ✓ . ✓ ✓ ✓
- ocaml ✓ ✓ ✓ . ✓
- turtle ✓ ✓ ✓ ✓ ✓
- ocaml_interface✓ ✓ ✓ . ✓
- css ✓ . ✓ ✓ ✓
- scss ✓ . . ✓ .
- ocamllex ✓ . . . ✓
- c_sharp ✓ ✓ ✓ . ✓
- beancount ✓ . ✓ . .
- tsx ✓ ✓ ✓ ✓ ✓
- scala ✓ . ✓ . ✓
- javascript ✓ ✓ ✓ ✓ ✓
- supercollider ✓ ✓ ✓ ✓ ✓
- hcl ✓ . ✓ ✓ ✓
- php ✓ ✓ ✓ ✓ ✓
- tlaplus ✓ . ✓ . ✓
- make ✓ . . . ✓
- toml ✓ ✓ ✓ ✓ ✓
- prisma ✓ . . . .
- glimmer ✓ . . . .
- hjson ✓ ✓ ✓ ✓ ✓
- pioasm ✓ . . . ✓
- regex ✓ . . . .
- clojure ✓ ✓ ✓ . ✓
- json5 ✓ . . . ✓
- vim ✓ ✓ . . ✓
- commonlisp ✓ ✓ ✓ . .
- pug ✓ . . . ✓
- vue ✓ . ✓ ✓ ✓
- gomod ✓ . . . ✓
- dot ✓ . . . ✓
- jsonc ✓ ✓ ✓ ✓ ✓
- cuda ✓ ✓ ✓ ✓ ✓
- latex ✓ . ✓ . ✓
- c ✓ ✓ ✓ ✓ ✓
- yaml ✓ ✓ ✓ ✓ ✓
- glsl ✓ ✓ ✓ ✓ ✓
- yang ✓ . ✓ . .
- dockerfile ✓ . . . ✓
- svelte ✓ . ✓ ✓ ✓
- ninja ✓ . ✓ ✓ .
- devicetree ✓ ✓ ✓ ✓ ✓
- query ✓ ✓ ✓ ✓ ✓
- nix ✓ ✓ ✓ . ✓
- pascal ✓ ✓ ✓ ✓ ✓
- python ✓ ✓ ✓ ✓ ✓
- dart ✓ ✓ . ✓ ✓
- fusion ✓ ✓ ✓ ✓ .
- gowork ✓ . . . ✓
- json ✓ ✓ ✓ ✓ .
- ledger ✓ . ✓ ✓ ✓
- bibtex ✓ . ✓ ✓ .
- r ✓ ✓ . . .
- lua ✓ ✓ ✓ ✓ ✓
- zig ✓ . ✓ ✓ ✓
- rust ✓ ✓ ✓ ✓ ✓
- cpp ✓ ✓ ✓ ✓ ✓
- rst ✓ ✓ . . ✓
- cmake ✓ . ✓ . .
- fennel ✓ ✓ . . ✓
Legend: H[ighlight], L[ocals], F[olds], I[ndents], In[j]ections
+) multiple parsers found, only one will be used
x) errors found in the query, try to run :TSUpdate {lang}
Output of nvim --version
NVIM v0.6.1
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/cc -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_TS_HAS_SET_MATCH_LIMIT -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=always -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/home/mike/repos/github/neovim/build/config -I/home/mike/repos/github/neovim/src -I/home/mike/repos/github/neovim/.deps/usr/include -I/usr/include -I/home/mike/repos/github/neovim/build/src/nvim/auto -I/home/mike/repos/github/neovim/build/include
Übersetzt von mike@Nilar
Features: +acl +iconv +tui
See ":help feature-compile"
System-vimrc-Datei: "$VIM/sysinit.vim"
Voreinstellung für $VIM: "/usr/local/share/nvim"
Run :checkhealth for more info
Additional context
IMO this query is way to greedy:
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with queries/c/highlights.scm at the linked lines 140-141 and reproduce the behavior using the provided C++ VBO example in Neovim. Check that uppercase variables are highlighted as @variable rather than @constant, and review the linked pull request for prior work before proceeding.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, cpp
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100