playground icon indicating copy to clipboard operation
playground copied to clipboard

Query editor not working?

Open joshfrench opened this issue 2 years ago • 9 comments

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!

joshfrench avatar Aug 22 '22 22:08 joshfrench

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

theHamsta avatar Aug 22 '22 22:08 theHamsta

filetype is query

joshfrench avatar Aug 23 '22 00:08 joshfrench

make sure that you have the query parser installed @joshfrench

max397574 avatar Oct 12 '22 14:10 max397574

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

ashish10alex avatar Nov 07 '22 10:11 ashish10alex

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 avatar Dec 14 '22 05:12 antonok-edm

Much like https://github.com/nvim-treesitter/playground/issues/51#issuecomment-915715794, 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.

antonok-edm avatar Dec 22 '22 02:12 antonok-edm

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 avatar Jan 06 '23 01:01 teto

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

timtro avatar Jan 14 '23 04:01 timtro

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

teto avatar Jan 14 '23 11:01 teto