json-nvim
is a NeoVim plugin that aims to vastly improve json editing and processing experience with help of jq and Neovim Treesitter
🚧 NOTE: This plugin is developed on linux environment and support for mac is not tested. Also some functionality won't work on windows
- Format whole file
- Format visual selection
- Format nearest json object/array under cursor
- Minify whole file
- Minify visual selection
- Minify nearest json object/array under cursor
- Escape whole file
- Unescape whole file
- Escape Selection
- Unescape Selection
- Switch keys to camelCase
- Switch keys to PascalCase
- Switch keys to snake_case
- jq installed and available on $PATH
- Neovim Treesitter with json module installed
- buffer filetype should be json :h filetype
Using lazy.nvim:
{
"VPavliashvili/json-nvim",
ft = "json", -- only load for json filetype
}
There is not much needed but I reccomend to use keymaps, otherwise you can ignore this section
For example setup with lazy.nvim like this
{
"VPavliashvili/json-nvim",
config = function()
vim.keymap.set("n", "<leader>jff", '<cmd>JsonFormatFile<cr>')
vim.keymap.set("n", "<leader>jmf", '<cmd>JsonMinifyFile<cr>')
end,
}
These are all the available commands below with usage examples
Commands involving visual mode always should be used with valid json selection
:JsonFormatFile
:JsonMinifyFile
:JsonFormatSelection
:JsonMinifySelection
:JsonFormatToken
:JsonMinifyToken
:JsonEscapeFile
:JsonUnescapeFile
:JsonEscapeSelection
:JsonUnescapeSelection
:JsonKeysToCamelCase
:JsonKeysToPascalCase
:JsonKeysToSnakeCase
- Implement windows support for case switching
- Fix bug: Can't process long json buffers on windows due to cmd string limitation