A simple, kulala.nvim-inspired filter buffer for interactively filtering JSON and YAML data using jq and yq in Neovim.
- Simple filter buffer interface inspired by kulala.nvim
- Automatic detection of JSON/YAML files
- Filter entire files or visual selections
- Real-time filtering with jq/yq
- Easy keybindings: press Enter to apply filter
- Quick yank results to clipboard
{
"your-username/filter.nvim",
dependencies = {
"nvim-lua/plenary.nvim",
},
config = function()
require("filter").setup()
end,
}The plugin works out of the box with sensible defaults:
require("filter").setup({
setup_keybindings = true, -- Automatically set up <leader>j keybinding (default: true)
keymap = "<leader>j", -- The keymap to use (default: "<leader>j")
debounce = 200, -- Debounce time in ms (default: 200)
})If you prefer to set up keybindings manually, disable automatic setup:
require("filter").setup({
setup_keybindings = false,
})
-- Then set up your own keybindings
vim.keymap.set("n", "<leader>j", function()
require("filter").open_filter()
end, { desc = "Open JQ/YQ Filter" })
vim.keymap.set("v", "<leader>j", function()
require("filter").open_filter()
end, { desc = "Filter selected JSON/YAML" })- Open a JSON or YAML file
- Press
<leader>j(or your custom keymap) - A split buffer opens with a filter line at the top:
JQ Filter: .orYQ Filter: . - Edit the filter query and press
<CR>(Enter) to apply - Results appear below the filter line
- Select JSON/YAML text in visual mode (v, V, or Ctrl-v)
- Press
<leader>j - The selected text will be filtered in the new buffer
When the filter buffer is open:
<CR>(Enter) - Apply the filter (when cursor is on filter line)q- Close the filter buffery- Yank results to clipboard
For JSON files (uses jq):
JQ Filter: .users[0].name
JQ Filter: .[] | select(.age > 25)
JQ Filter: .items | map(.price)
JQ Filter: keys
For YAML files (uses yq):
YQ Filter: .metadata.name
YQ Filter: .spec.containers[0].image
YQ Filter: .data
- The plugin automatically detects the filetype (JSON or YAML)
- For JSON files, it uses
jqfor filtering - For YAML files, it uses
yqfor filtering - Results are updated in real-time as you modify the filter
- The filter buffer shows both the filter input and results in a single view
- Cursor automatically positions after the
.for easy editing
- Neovim 0.8+
jqcommand-line tool for JSON filteringyqcommand-line tool for YAML filtering (optional, only needed for YAML files)- plenary.nvim
This plugin is inspired by kulala.nvim's filter response feature, which provides a clean and simple way to filter API responses. filter.nvim brings that same simplicity to filtering JSON and YAML files.
MIT