nvim-treesitter/playground

Keybind for Query editor not working

dvdsk opened this issue · 9 comments

dvdsk commented

When pressing o while in the playground buffer the query editor will not open. If I run the command

:lua require "nvim-treesitter-playground.internal".toggle_query_editor(0)

it does open. I made sure

  • the tree-sitter setup runs as last item in my config.
  • the treesitter parsers are installed and up to date
  • I use the exact setup as in the README
  • the language was supported by treesitter playground (I used rust)

What else can I do to troubleshoot?

This is on NVIM v0.5.0 with the current master branch of treesitter playground

Hi, are you calling the setup function in your config as the shown on https://github.com/nvim-treesitter/playground#setup?

dvdsk commented

I copied the setup function directly from the readme. See the relevant functions in my config here:

@dskleingeld can you check on the playground buffer this? :verbose map o

BTW, If you don't want to change the defaults, you can just add playground = {enable = true}

dvdsk commented

The output was:

n  o            @:lua require "nvim-treesitter-playground.internal".toggle_query_editor(1)<CR>
        Last set from ~/.local/share/nvim/site/pack/packer/start/playground/plugin/nvim-treesitter-playground.vim

Or see the screenshot:
image

so, the query editor just doesn't show up or do you see any errors?

dvdsk commented

It doesn't show up, I do not see any errors. I click with my mouse in the playground window and press 'o'. Then nothing happens.

Does executing the same command from :map o works? this is :lua require "nvim-treesitter-playground.internal".toggle_query_editor(1) for the example you showed.

Also, try replicating this with a minimal init.vim, maybe another plugin is breaking this.

dvdsk commented

Okay..... so I went through my config disabling everything except this plugin and it worked! So then I started re-enabling my config bit by bit and found the cause.... It is the second of these two lines:

map('n', ';', ':', options)
map('n', ':', ';', options)

The map from : to ; in normal mode somehow blocks the query editor from opening when pressing o. 🤔🥴

Opening the query window using the command works btw.

I have the same problem. The issue is that mappings are being set as recursive on:
https://github.com/nvim-treesitter/playground/blob/master/lua/nvim-treesitter-playground/internal.lua#L215

To fix it, I just changed this line from:

{ silent = true }

to:

{ silent = true, noremap = true }