Skip to content
This repository has been archived by the owner on Jan 17, 2024. It is now read-only.

Query editor not working? #88

Open
joshfrench opened this issue Aug 22, 2022 · 9 comments
Open

Query editor not working? #88

joshfrench opened this issue Aug 22, 2022 · 9 comments

Comments

@joshfrench
Copy link

The query editor doesn't seem to highlight anything:
Screen Shot 2022-08-22 at 18 06 31

I did see this other issue, which suggested making sure the query grammar is installed, but I've already done that. Any other ideas?

Thanks!

@theHamsta
Copy link
Member

Hi! It works for me... Can you execute :echo &ft on the query buffer?

@joshfrench
Copy link
Author

filetype is query

@max397574
Copy link

make sure that you have the query parser installed @joshfrench

@ashish10alex
Copy link

I am having this same issue. I have the query parser installed too.
CleanShot 2022-11-07 at 10 58 56@2x

@antonok-edm
Copy link

Same issue here too. query parser is installed; ft is query. Is there any other information that would be helpful for diagnosing the issue?

@antonok-edm
Copy link

Much like #51 (comment), the issue just magically resolved itself for me as well. I did poke some related config slightly, but I wasn't specifcally attempting to fix the issue.

In particular:

  • I've been using packer.nvim, with the following treesitter configs:
    use {
      'nvim-treesitter/nvim-treesitter',
      run = function()
        local ts_update = require('nvim-treesitter.install').update({ with_sync = true })
        ts_update()
      end,
    }
    use {
      'nvim-treesitter/playground',
      config = function()
        local ts = require('nvim-treesitter.configs')
        ts.setup {
          highlight = {
            enable = true,
          },
          indent = { enable = true },
          playground = {
            enable = true,
            disable = {},
            updatetime = 25,
            persist_queries = false,
            keybindings = {
              -- probably not relevant
            },
          },
        }
      end,
    }
  • Particularly note highlighting was enabled, but I hadn't been seeing any highlighting changes either. I assumed it just changed the highlighting algorithm without affecting visuals, but I see now that it simply wasn't working.
  • I just added a new, unrelated plugin to the list of installed plugins
  • I ran PackerInstall and then PackerCompile
  • I noticed that the status line printed something about the treesitter query parser already being installed, as part of the above packer commands
  • Shortly afterwards, I opened a C++ file (I also had the cpp parser installed from before). I noticed the syntax highlighting was very different from what I was used to.
  • I suspected something happened to treesitter, so I opened a Rust file (again, already installed the rust parser previously). The syntax highlighting was suddenly different there too.
  • Suspecting this issue was fixed too, I opened the playground next and wrote a simple query ((identifier) @capture). Hovering over @capture highlighted all the identifiers in the source code.

TL;DR

I think PackerInstall/PackerCompile happened to fix it, but I'd definitely done those commands previously with no luck. That, plus the number of others with this issue, makes me believe there is something else going on behind the scenes.

The general syntax highlighting (outside of playground) issue I saw might be related? If you're still struggling with this issue I definitely recommend setting highlight = { enable = true } in your config, as it'll be immediately obvious if that starts working. Without the syntax highlighting change I'm not sure I would have noticed that the playground started working.

@teto
Copy link

teto commented Jan 6, 2023

I just spent 30mn trying to understand why this didn't work when the solution was as simple as installing the "query" grammar: let's add it to requirements https://github.com/nvim-treesitter/playground#requirements . I've fixed the nix package so that installing playground installs the "query" grammar as well.

teto added a commit to teto/nixpkgs that referenced this issue Jan 6, 2023
I just spent too much time trying to understand why the query editor woudn't work when the solution was just to install the query grammar, see nvim-treesitter/playground#88 (comment)
@timtro
Copy link

timtro commented Jan 14, 2023

I use Packer. Removing ~/.local/share/nvim/site/pack/packer/start/playground, reinstalling and recompiling fixed it for me.

@teto
Copy link

teto commented Jan 14, 2023

also note that in neovim master's you can now do :lua vim.treesitter.show_tree()

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants