diff --git a/after/ftplugin/json.vim b/after/ftplugin/json.vim index 90db3ec..ab459da 100644 --- a/after/ftplugin/json.vim +++ b/after/ftplugin/json.vim @@ -1,6 +1,2 @@ " 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() +setlocal foldlevel=0 diff --git a/lua/config/ufo.lua b/lua/config/ufo.lua new file mode 100644 index 0000000..0f7ed82 --- /dev/null +++ b/lua/config/ufo.lua @@ -0,0 +1,14 @@ + -- disable foldcolumn, see https://github.com/kevinhwang91/nvim-ufo/issues/4 +vim.o.foldcolumn = '0' +vim.o.foldlevel = 99 -- Using ufo provider need a large value, feel free to decrease the value +vim.o.foldlevelstart = 99 +vim.o.foldenable = true + +-- treesitter as a main provider instead +-- Only depend on `nvim-treesitter/queries/filetype/folds.scm`, +-- performance and stability are better than `foldmethod=nvim_treesitter#foldexpr()` +require('ufo').setup({ + provider_selector = function(bufnr, filetype, buftype) + return {'treesitter', 'indent'} + end +}) diff --git a/lua/plugin_specs.lua b/lua/plugin_specs.lua index 8f9c4be..9a874c5 100644 --- a/lua/plugin_specs.lua +++ b/lua/plugin_specs.lua @@ -50,7 +50,7 @@ local plugin_specs = { { "nvim-treesitter/nvim-treesitter", enabled = function() - if vim.g.is_mac then + if vim.g.is_mac or vim.g.is_linux then return true end return false @@ -488,6 +488,14 @@ local plugin_specs = { require("config.fidget-nvim") end, }, + { + 'kevinhwang91/nvim-ufo', + dependencies = {'kevinhwang91/promise-async'}, + event = { "VeryLazy" }, + config = function() + require("config.ufo") + end + } } -- configuration for lazy itself.