diff --git a/nvim/lazy-lock.json b/nvim/lazy-lock.json index 76b6bae..492bb30 100644 --- a/nvim/lazy-lock.json +++ b/nvim/lazy-lock.json @@ -27,6 +27,7 @@ "nvim-cokeline": { "branch": "main", "commit": "9fbed130683b7b6f73198c09e35ba4b33f547c08" }, "nvim-colorizer.lua": { "branch": "master", "commit": "517df88cf2afb36652830df2c655df2da416a0ae" }, "nvim-lspconfig": { "branch": "master", "commit": "463b16bd6a347a129367a7fd00ebcdd9442d9a96" }, + "nvim-origami": { "branch": "main", "commit": "359cb2f5d28cc54a18a3a7fa40292a21f6c9e1a8" }, "nvim-spectre": { "branch": "master", "commit": "72f56f7585903cd7bf92c665351aa585e150af0f" }, "nvim-spider": { "branch": "main", "commit": "d4bdc45eac425e77108f068bd0706ff3ac20be7f" }, "nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" }, diff --git a/nvim/lua/config/keys.lua b/nvim/lua/config/keys.lua index ae7ce76..2e38706 100644 --- a/nvim/lua/config/keys.lua +++ b/nvim/lua/config/keys.lua @@ -11,7 +11,6 @@ map('n', '<]b>', 'bn', opts) map('n', 'w', 'bd', opts) map('n', 's', 'w', opts) map('n', 'S', 'w!', opts) -map('n', '', 'za', opts) map('n', 't', "Switch", opts) map('n', 'r', "Spectre", opts) map('n', '', "", opts) diff --git a/nvim/lua/plugins/folding.lua b/nvim/lua/plugins/folding.lua index 16cdc7e..ed92c0d 100644 --- a/nvim/lua/plugins/folding.lua +++ b/nvim/lua/plugins/folding.lua @@ -1,43 +1,32 @@ -return {} --- local handler = function(virtText, lnum, endLnum, width, truncate) --- local newVirtText = {} --- local suffix = (' 󰁂 %d '):format(endLnum - lnum) --- local sufWidth = vim.fn.strdisplaywidth(suffix) --- local targetWidth = width - sufWidth --- local curWidth = 0 --- for _, chunk in ipairs(virtText) do --- local chunkText = chunk[1] --- local chunkWidth = vim.fn.strdisplaywidth(chunkText) --- if targetWidth > curWidth + chunkWidth then --- table.insert(newVirtText, chunk) --- else --- chunkText = truncate(chunkText, targetWidth - curWidth) --- local hlGroup = chunk[2] --- table.insert(newVirtText, { chunkText, hlGroup }) --- chunkWidth = vim.fn.strdisplaywidth(chunkText) --- -- str width returned from truncate() may less than 2nd argument, need padding --- if curWidth + chunkWidth < targetWidth then --- suffix = suffix .. (' '):rep(targetWidth - curWidth - chunkWidth) --- end --- break --- end --- curWidth = curWidth + chunkWidth --- end --- table.insert(newVirtText, { suffix, 'MoreMsg' }) --- return newVirtText --- end --- --- return { --- "kevinhwang91/nvim-ufo", --- dependencies = { --- "kevinhwang91/promise-async", --- }, --- config = function() --- require('ufo').setup({ --- fold_virt_text_handler = handler, --- provider_selector = function(_bufnr, _filetype, _buftype) --- return { 'treesitter', 'indent' } --- end --- }) --- end, --- } +return { + "chrisgrieser/nvim-origami", + event = "VeryLazy", + opts = { + useLspFoldsWithTreesitterFallback = true, -- required for `autoFold` + pauseFoldsOnSearch = true, + foldtext = { + enabled = true, + padding = 3, + lineCount = { + template = "%d lines", -- `%d` is replaced with the number of folded lines + hlgroup = "Comment", + }, + diagnosticsCount = true, -- uses hlgroups and icons from `vim.diagnostic.config().signs` + gitsignsCount = true, -- requires `gitsigns.nvim` + }, + autoFold = { + enabled = true, + kinds = { "comment", "imports" }, ---@type lsp.FoldingRangeKind[] + }, + foldKeymaps = { + setup = true, -- modifies `h` and `l` + hOnlyOpensOnFirstColumn = false, + }, + }, + + -- recommended: disable vim's auto-folding + init = function() + vim.opt.foldlevel = 99 + vim.opt.foldlevelstart = 99 + end, +}