Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ziontee113/query-secretary
Neovim Plugin that assists you in writing Treesitter Queries
https://github.com/ziontee113/query-secretary
lua neovim queries query scheme tree-sitter
Last synced: 13 days ago
JSON representation
Neovim Plugin that assists you in writing Treesitter Queries
- Host: GitHub
- URL: https://github.com/ziontee113/query-secretary
- Owner: ziontee113
- License: mit
- Created: 2022-10-23T20:42:24.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2022-12-02T12:16:31.000Z (almost 2 years ago)
- Last Synced: 2024-10-10T23:30:06.966Z (about 1 month ago)
- Topics: lua, neovim, queries, query, scheme, tree-sitter
- Language: Lua
- Homepage:
- Size: 53.7 KB
- Stars: 65
- Watchers: 4
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## 📓 Query Secretary 🖊️
#### Neovim Plugin that *assists* you in writing Treesitter Queries 🌳
#### This plugin exists because *we don't want to manually write them queries ourselves* 🤓![query-secretary](https://user-images.githubusercontent.com/102876811/198027185-0af9abff-830d-464b-8016-bc7a5474b756.png)
## Demo 🎥
https://user-images.githubusercontent.com/102876811/198029879-dbb552de-05f5-41c0-baa4-eca3d718db98.mp4
## Developer's Message ✉️
This plugin is still in *Prototype Phase!* With features hasn't been developed yet!
Such as:
- End-user customizations (window location, highlight groups, etc...)
- Add / Manage **Children** and **Siblings** nodesAt this current state, this plugin is **useful** for ***simple queries that doesn't deal with
multi-layered children / sibling nodes***. These features will be gradually developed as
the demand of more complex queries increases.## Installation 💽
Packer:
```lua
use("ziontee113/query-secretary")
```## Setup 💻
By default, Query Window at the center of the editor.
If you want to change how the query window options:
```lua
require('query-secretary').setup({
open_win_opts = {
row = 0,
col = 9999,
width = 50,
height = 15,
},-- other options you can customize
buf_set_opts = {
tabstop = 2,
softtabstop = 2,
shiftwidth = 2,
}capture_group_names = { "cap", "second", "third" } -- when press "c"
predicates = { "eq", "any-of", "contains", "match", "lua-match" } -- when press "p"
visual_hl_group = "Visual" -- when moving cursor around-- here are the default keymaps
keymaps = {
close = { "q", "Esc" },
next_predicate = { "p" },
previous_predicate = { "P" },
remove_predicate = { "d" },
toggle_field_name = { "f" },
yank_query = { "y" },
next_capture_group = { "c" },
previous_capture_group = { "C" },
}
})
```The following `setup` will open Query Window at your cursor
with `width = 50` and `height = 15`
```lua
require('query-secretary').setup({
open_win_opts = {
relative = "cursor",
width = 50,
height = 15,
},
})
```Define your keymap:
```lua
vim.keymap.set("n", "your_keymap_here", function()
require("query-secretary").query_window_initiate()
end, {})
```## Usage & Keybindings ⌨️
After putting your cursor where you want your query to end, press `your_keymap`
to bring up the Query Window.Here are the default keymaps when you're in the Query Window (customizable with setup function):
- `q` / `Esc` close the Query Window
- `f` toggle current node's `field_name`
- `p` / `P` toggle current node's `predicate`
- `d` remove current node's `predicate`