Skip to content

jaredbarranco/json-nvim

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

json-nvim

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

Features

  • 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

⚠️ switching key cases is not supported on windows yet

Prerequisites

Installation

Using lazy.nvim:

{
    "jaredbarranco/json-nvim",
    ft = "json", -- only load for json filetype
}

Configuration

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,
}

Usage

These are all the available commands below with usage examples
Commands involving visual mode always should be used with valid json selection

  • :JsonFormatFile
    see example format_file
  • :JsonMinifyFile
    see example minify_file
  • :JsonFormatSelection
    see example format_selection
  • :JsonMinifySelection
    see example minify_selection
  • :JsonFormatNode
    see example format_node
  • :JsonMinifyNode
    see example minify_node
  • :JsonEscapeFile
    see example escape_file
  • :JsonUnescapeFile
    see example unescape_file
  • :JsonEscapeSelection
    see example escape_selection
  • :JsonUnescapeSelection
    see example unescape_selection
  • :JsonKeysToCamelCase
    see example to_camel
  • :JsonKeysToPascalCase
    see example to_pascal
  • :JsonKeysToSnakeCase
    see example to_snake

TODO

  • Implement windows support for case switching
  • Fix bug: Can't process long json buffers on windows due to cmd string limitation

About

Powerful Json processing capabilities in your Neovim buffer

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Lua 95.8%
  • jq 4.2%