nvim-treesitter / nvim-treesitter-refactor

Refactor module for nvim-treesitter
Apache License 2.0
408 stars 25 forks source link

Definition highlight not right on cpp. #5

Open fgheng opened 4 years ago

fgheng commented 4 years ago

Describe the bug Hello, look at this code, if cursor on ::reused, the global value reused should be highlight, but the local value reused highlight.


  #include <iostream>

  int reused = 42;

  int main(int argc, char *argv[]) {
    int unique = 0;
    std::cout << reused << " " << unique << std::endl;
    int reused = 0;
    std::cout << reused << " " << unique << std::endl;
    std::cout << ::reused << " " << unique << std::endl;

    return 0;
  }

image image

Expected behavior the global value reused should be highlight.

Output of :checkhealth nvim_treesitter

health#nvim_treesitter#check ======================================================================== ## Installation - OK: `git` executable found. - OK: `cc` executable found. ## elm parser healthcheck - OK: elm parser found. - WARNING: No `highlights.scm` query found for elm - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter - WARNING: No `locals.scm` query found for elm - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter - WARNING: No `folds.scm` query found for elm - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter - WARNING: No `indents.scm` query found for elm - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter ## c parser healthcheck - OK: c parser found. - OK: `highlights.scm` found. - OK: `locals.scm` found. - OK: `folds.scm` found. - WARNING: No `indents.scm` query found for c - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter ## teal parser healthcheck - OK: teal parser found. - OK: `highlights.scm` found. - OK: `locals.scm` found. - OK: `folds.scm` found. - WARNING: No `indents.scm` query found for teal - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter ## java parser healthcheck - OK: java parser found. - OK: `highlights.scm` found. - OK: `locals.scm` found. - WARNING: No `folds.scm` query found for java - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter - WARNING: No `indents.scm` query found for java - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter ## python parser healthcheck - OK: python parser found. - OK: `highlights.scm` found. - OK: `locals.scm` found. - OK: `folds.scm` found. - WARNING: No `indents.scm` query found for python - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter ## dart parser healthcheck - OK: dart parser found. - OK: `highlights.scm` found. - OK: `locals.scm` found. - WARNING: No `folds.scm` query found for dart - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter - WARNING: No `indents.scm` query found for dart - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter ## lua parser healthcheck - OK: lua parser found. - OK: `highlights.scm` found. - OK: `locals.scm` found. - OK: `folds.scm` found. - OK: `indents.scm` found. ## ocaml parser healthcheck - OK: ocaml parser found. - OK: `highlights.scm` found. - OK: `locals.scm` found. - OK: `folds.scm` found. - WARNING: No `indents.scm` query found for ocaml - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter ## go parser healthcheck - OK: go parser found. - OK: `highlights.scm` found. - OK: `locals.scm` found. - WARNING: No `folds.scm` query found for go - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter - WARNING: No `indents.scm` query found for go - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter ## nix parser healthcheck - OK: nix parser found. - WARNING: No `highlights.scm` query found for nix - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter - WARNING: No `locals.scm` query found for nix - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter - WARNING: No `folds.scm` query found for nix - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter - WARNING: No `indents.scm` query found for nix - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter ## yaml parser healthcheck - OK: yaml parser found. - WARNING: No `highlights.scm` query found for yaml - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter - WARNING: No `locals.scm` query found for yaml - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter - WARNING: No `folds.scm` query found for yaml - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter - WARNING: No `indents.scm` query found for yaml - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter ## json parser healthcheck - OK: json parser found. - OK: `highlights.scm` found. - WARNING: No `locals.scm` query found for json - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter - WARNING: No `folds.scm` query found for json - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter - WARNING: No `indents.scm` query found for json - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter ## jsdoc parser healthcheck - OK: jsdoc parser found. - WARNING: No `highlights.scm` query found for jsdoc - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter - WARNING: No `locals.scm` query found for jsdoc - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter - WARNING: No `folds.scm` query found for jsdoc - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter - WARNING: No `indents.scm` query found for jsdoc - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter ## php parser healthcheck - OK: php parser found. - OK: `highlights.scm` found. - OK: `locals.scm` found. - OK: `folds.scm` found. - WARNING: No `indents.scm` query found for php - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter ## julia parser healthcheck - OK: julia parser found. - WARNING: No `highlights.scm` query found for julia - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter - WARNING: No `locals.scm` query found for julia - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter - WARNING: No `folds.scm` query found for julia - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter - WARNING: No `indents.scm` query found for julia - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter ## html parser healthcheck - OK: html parser found. - OK: `highlights.scm` found. - OK: `locals.scm` found. - WARNING: No `folds.scm` query found for html - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter - WARNING: No `indents.scm` query found for html - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter ## typescript parser healthcheck - OK: typescript parser found. - OK: `highlights.scm` found. - OK: `locals.scm` found. - OK: `folds.scm` found. - WARNING: No `indents.scm` query found for typescript - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter ## fennel parser healthcheck - OK: fennel parser found. - OK: `highlights.scm` found. - OK: `locals.scm` found. - WARNING: No `folds.scm` query found for fennel - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter - WARNING: No `indents.scm` query found for fennel - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter ## swift parser healthcheck - OK: swift parser found. - WARNING: No `highlights.scm` query found for swift - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter - WARNING: No `locals.scm` query found for swift - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter - WARNING: No `folds.scm` query found for swift - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter - WARNING: No `indents.scm` query found for swift - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter ## query parser healthcheck - OK: query parser found. - OK: `highlights.scm` found. - OK: `locals.scm` found. - WARNING: No `folds.scm` query found for query - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter - WARNING: No `indents.scm` query found for query - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter ## cpp parser healthcheck - OK: cpp parser found. - OK: `highlights.scm` found. - OK: `locals.scm` found. - OK: `folds.scm` found. - WARNING: No `indents.scm` query found for cpp - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter ## regex parser healthcheck - OK: regex parser found. - OK: `highlights.scm` found. - WARNING: No `locals.scm` query found for regex - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter - WARNING: No `folds.scm` query found for regex - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter - WARNING: No `indents.scm` query found for regex - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter ## verilog parser healthcheck - OK: verilog parser found. - OK: `highlights.scm` found. - WARNING: No `locals.scm` query found for verilog - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter - WARNING: No `folds.scm` query found for verilog - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter - WARNING: No `indents.scm` query found for verilog - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter ## ruby parser healthcheck - OK: ruby parser found. - OK: `highlights.scm` found. - OK: `locals.scm` found. - WARNING: No `folds.scm` query found for ruby - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter - WARNING: No `indents.scm` query found for ruby - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter ## vue parser healthcheck - OK: vue parser found. - WARNING: No `highlights.scm` query found for vue - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter - WARNING: No `locals.scm` query found for vue - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter - WARNING: No `folds.scm` query found for vue - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter - WARNING: No `indents.scm` query found for vue - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter ## ocamllex parser healthcheck - OK: ocamllex parser found. - OK: `highlights.scm` found. - WARNING: No `locals.scm` query found for ocamllex - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter - WARNING: No `folds.scm` query found for ocamllex - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter - WARNING: No `indents.scm` query found for ocamllex - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter ## scala parser healthcheck - OK: scala parser found. - WARNING: No `highlights.scm` query found for scala - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter - WARNING: No `locals.scm` query found for scala - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter - WARNING: No `folds.scm` query found for scala - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter - WARNING: No `indents.scm` query found for scala - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter ## ql parser healthcheck - OK: ql parser found. - OK: `highlights.scm` found. - OK: `locals.scm` found. - WARNING: No `folds.scm` query found for ql - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter - WARNING: No `indents.scm` query found for ql - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter ## rust parser healthcheck - OK: rust parser found. - OK: `highlights.scm` found. - OK: `locals.scm` found. - WARNING: No `folds.scm` query found for rust - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter - WARNING: No `indents.scm` query found for rust - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter ## toml parser healthcheck - OK: toml parser found. - OK: `highlights.scm` found. - OK: `locals.scm` found. - WARNING: No `folds.scm` query found for toml - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter - WARNING: No `indents.scm` query found for toml - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter ## bash parser healthcheck - OK: bash parser found. - OK: `highlights.scm` found. - OK: `locals.scm` found. - WARNING: No `folds.scm` query found for bash - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter - WARNING: No `indents.scm` query found for bash - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter ## rst parser healthcheck - OK: rst parser found. - OK: `highlights.scm` found. - OK: `locals.scm` found. - WARNING: No `folds.scm` query found for rst - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter - WARNING: No `indents.scm` query found for rst - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter ## css parser healthcheck - OK: css parser found. - OK: `highlights.scm` found. - WARNING: No `locals.scm` query found for css - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter - WARNING: No `folds.scm` query found for css - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter - WARNING: No `indents.scm` query found for css - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter ## ocaml_interface parser healthcheck - OK: ocaml_interface parser found. - OK: `highlights.scm` found. - OK: `locals.scm` found. - OK: `folds.scm` found. - WARNING: No `indents.scm` query found for ocaml_interface - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter ## javascript parser healthcheck - OK: javascript parser found. - OK: `highlights.scm` found. - OK: `locals.scm` found. - OK: `folds.scm` found. - WARNING: No `indents.scm` query found for javascript - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter ## c_sharp parser healthcheck - OK: c_sharp parser found. - OK: `highlights.scm` found. - WARNING: No `locals.scm` query found for c_sharp - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter - WARNING: No `folds.scm` query found for c_sharp - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter - WARNING: No `indents.scm` query found for c_sharp - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter ## haskell parser healthcheck - OK: haskell parser found. - WARNING: No `highlights.scm` query found for haskell - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter - WARNING: No `locals.scm` query found for haskell - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter - WARNING: No `folds.scm` query found for haskell - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter - WARNING: No `indents.scm` query found for haskell - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter ## tsx parser healthcheck - OK: tsx parser found. - OK: `highlights.scm` found. - OK: `locals.scm` found. - OK: `folds.scm` found. - WARNING: No `indents.scm` query found for tsx - ADVICE: - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter

Output of nvim --version

NVIM v0.5.0-781-ga22fe09b9
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/gcc-5 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/home/travis/build/neovim/bot-ci/build/neovim/build/config -I/home/travis/build/neovim/bot-ci/build/neovim/src -I/home/travis/build/neovim/bot-ci/build/neovim/.deps/usr/include -I/usr/include -I/home/travis/build/neovim/bot-ci/build/neovim/build/src/nvim/auto -I/home/travis/build/neovim/bot-ci/build/neovim/build/include
Compiled by travis@travis-job-cf8f8ff3-8560-4d24-8cbb-fea1921bfd23

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/share/nvim"

Run :checkhealth for more info

Additional context Add any other context about the problem here.

steelsojka commented 4 years ago

Currently this is expected by the implementation. Scopes are defined by their parent nodes and don't take into account where they are defined amongst their siblings. This will take some rework to fix.