From dcbbacf638a6cb520421f2f5adece090f882908b Mon Sep 17 00:00:00 2001 From: Santos Gallegos Date: Mon, 5 Jul 2021 13:27:25 -0500 Subject: [PATCH] Hint how to use the query editor Ref https://github.com/nvim-treesitter/playground/issues/23 --- README.md | 12 +++++++++++- lua/nvim-treesitter-playground/internal.lua | 5 +++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f13d083..769cf05 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,17 @@ The tree can be toggled using the command `:TSPlaygroundToggle`. - `F`: Unfocuses the currently focused language. - ``: Go to current node in code buffer +## Query Editor + +Press `o` to show the query editor. +Write your query like `(node) @capture`, +put the cursor under the capture to highlight the matches. + +## Completions + +When you are on a `query` buffer, you can get a list of suggestions with +Ctrl-X Ctrl-O-. See `:h 'omnifunc'`. + ## Query Linter The playground can lint query files for you. For that, you need to activate the `query_linter` module: @@ -87,4 +98,3 @@ The playground comes with `:TSHighlightCapturesUnderCursor` that shows any trees ![image](https://user-images.githubusercontent.com/292349/119982982-6665ef00-bf74-11eb-93d5-9b214928c3a9.png) ![image](https://user-images.githubusercontent.com/292349/119983093-8c8b8f00-bf74-11eb-9fa2-3670a8253fbd.png) - diff --git a/lua/nvim-treesitter-playground/internal.lua b/lua/nvim-treesitter-playground/internal.lua index a714e0c..0dc6e47 100644 --- a/lua/nvim-treesitter-playground/internal.lua +++ b/lua/nvim-treesitter-playground/internal.lua @@ -285,6 +285,11 @@ local function setup_query_editor(bufnr) api.nvim_buf_set_lines(buf, 0, -1, false, lines) end end)) + else + api.nvim_buf_set_lines(buf, 0, -1, false, { + ";; Write your query here like `(node) @capture`,", + ";; put the cursor under the capture to highlight the matches.", + }) end return buf