From d55dd987b2c691af61d15e5ac3babe1ae5d9f049 Mon Sep 17 00:00:00 2001 From: LordMZTE Date: Mon, 24 Oct 2022 22:52:58 +0200 Subject: [PATCH] add nvim-ufo --- .config/nvim/lua/pluginconf/lspconf.lua | 5 ++++ .config/nvim/lua/pluginconf/nvim_ufo.lua | 30 ++++++++++++++++++++++++ .config/nvim/lua/plugins.lua | 7 ++++++ 3 files changed, 42 insertions(+) create mode 100644 .config/nvim/lua/pluginconf/nvim_ufo.lua diff --git a/.config/nvim/lua/pluginconf/lspconf.lua b/.config/nvim/lua/pluginconf/lspconf.lua index 6acf706..a883790 100644 --- a/.config/nvim/lua/pluginconf/lspconf.lua +++ b/.config/nvim/lua/pluginconf/lspconf.lua @@ -1,6 +1,11 @@ local lspc = require "lspconfig" local caps = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities()) +caps.textDocument.foldingRange = { + dynamicRegistration = false, + lineFoldingOnly = true, +} + local lua_runtime_path = vim.split(package.path, ";") table.insert(lua_runtime_path, "lua/?.lua") table.insert(lua_runtime_path, "lua/?/init.lua") diff --git a/.config/nvim/lua/pluginconf/nvim_ufo.lua b/.config/nvim/lua/pluginconf/nvim_ufo.lua new file mode 100644 index 0000000..15f20ad --- /dev/null +++ b/.config/nvim/lua/pluginconf/nvim_ufo.lua @@ -0,0 +1,30 @@ +local ufo = require "ufo" +local ts_parsers = require "nvim-treesitter.parsers" +local map = vim.api.nvim_set_keymap + +ufo.setup { + open_fold_hl_timeout = 0, -- disable blinky thingy when opening fold + provider_selector = function(_, ft, _) + if ts_parsers.has_parser(ft) then + return { "lsp", "treesitter" } + else + return { "lsp", "indent" } + end + end, +} + +vim.o.foldcolumn = "1" +-- https://github.com/neovim/neovim/pull/17446 +vim.o.fillchars = [[eob: ,fold: ,foldopen:,foldsep: ,foldclose:]] +vim.o.foldlevel = 256 +vim.o.foldlevelstart = 256 +vim.o.foldenable = true + +local map_opts = { + noremap = true, + silent = true, +} + +map("n", "t", "za", map_opts) -- toggle fold +map("n", "zO", [[lua require("ufo").openAllFolds()]], map_opts) +map("n", "zC", [[lua require("ufo").closeAllFolds()]], map_opts) diff --git a/.config/nvim/lua/plugins.lua b/.config/nvim/lua/plugins.lua index b7384d8..b0802be 100644 --- a/.config/nvim/lua/plugins.lua +++ b/.config/nvim/lua/plugins.lua @@ -164,5 +164,12 @@ return require("packer").startup(function(use) use "mfussenegger/nvim-jdtls" + use { + "kevinhwang91/nvim-ufo", + requires = "kevinhwang91/promise-async", + after = "nvim-lspconfig", + config = pconf "nvim_ufo", + } + cmp_plugins(use) end)