diff options
| author | jdhao <jdhao@hotmail.com> | 2023-06-13 22:24:31 +0200 |
|---|---|---|
| committer | jdhao <jdhao@hotmail.com> | 2023-06-13 22:25:25 +0200 |
| commit | ee38046ebc83b5dc91739a9c2a8d60cd9725e206 (patch) | |
| tree | 47758bfe7c4b3b09063b18283bba2f136489bffc | |
| parent | 6c873a32da5410b6accbe8da476e334e2918901f (diff) | |
Add folding support for JSON files
| -rw-r--r-- | after/ftplugin/json.vim | 6 | ||||
| -rw-r--r-- | lua/config/treesitter.lua | 2 | ||||
| -rw-r--r-- | plugin/command.vim | 3 |
3 files changed, 10 insertions, 1 deletions
diff --git a/after/ftplugin/json.vim b/after/ftplugin/json.vim new file mode 100644 index 0000000..90db3ec --- /dev/null +++ b/after/ftplugin/json.vim @@ -0,0 +1,6 @@ +" let the initial folding state be that all folds are closed. +set foldlevel=0 + +" Use nvim-treesitter for folding +set foldmethod=expr +set foldexpr=nvim_treesitter#foldexpr() diff --git a/lua/config/treesitter.lua b/lua/config/treesitter.lua index 92759d3..ee07b83 100644 --- a/lua/config/treesitter.lua +++ b/lua/config/treesitter.lua @@ -1,5 +1,5 @@ require("nvim-treesitter.configs").setup { - ensure_installed = { "python", "cpp", "lua", "vim" }, + ensure_installed = { "python", "cpp", "lua", "vim", "json" }, ignore_install = {}, -- List of parsers to ignore installing highlight = { enable = true, -- false will disable the whole extension diff --git a/plugin/command.vim b/plugin/command.vim index 5ed7b73..68b11f4 100644 --- a/plugin/command.vim +++ b/plugin/command.vim @@ -45,3 +45,6 @@ function! s:md_to_pdf() abort echoerr "Error running command" endif endfunction + +" json format +command! -range JSONFormat <line1>,<line2>!python -m json.tool |
