From 70b590bf6b83dcb8f142451951a0f54ec3308283 Mon Sep 17 00:00:00 2001 From: Arpit Chakladar <54011232+arpitchakladar@users.noreply.github.com> Date: Mon, 17 Mar 2025 23:53:38 +0530 Subject: Using nvim-ufo to have better folding for code blocks. --- .../editor/neovim/plugins/config/bufferline.lua | 0 .../tools/editor/neovim/plugins/config/default.nix | 2 ++ .../tools/editor/neovim/plugins/config/nvim-ufo.lua | 21 +++++++++++++++++++++ .../editor/neovim/plugins/config/which-key.lua | 5 +++++ 4 files changed, 28 insertions(+) delete mode 100644 modules/tools/editor/neovim/plugins/config/bufferline.lua create mode 100644 modules/tools/editor/neovim/plugins/config/nvim-ufo.lua create mode 100644 modules/tools/editor/neovim/plugins/config/which-key.lua (limited to 'modules/tools/editor/neovim/plugins/config') diff --git a/modules/tools/editor/neovim/plugins/config/bufferline.lua b/modules/tools/editor/neovim/plugins/config/bufferline.lua deleted file mode 100644 index e69de29..0000000 diff --git a/modules/tools/editor/neovim/plugins/config/default.nix b/modules/tools/editor/neovim/plugins/config/default.nix index cfc54cb..dcdb371 100644 --- a/modules/tools/editor/neovim/plugins/config/default.nix +++ b/modules/tools/editor/neovim/plugins/config/default.nix @@ -8,6 +8,8 @@ ${builtins.readFile ./dressing.lua} ${builtins.readFile (config.scheme { template = builtins.readFile ./noice.mustache.lua; })} +${builtins.readFile ./nvim-ufo.lua} +${builtins.readFile ./which-key.lua} '' else ""; in diff --git a/modules/tools/editor/neovim/plugins/config/nvim-ufo.lua b/modules/tools/editor/neovim/plugins/config/nvim-ufo.lua new file mode 100644 index 0000000..641373f --- /dev/null +++ b/modules/tools/editor/neovim/plugins/config/nvim-ufo.lua @@ -0,0 +1,21 @@ +require("ufo").setup { + provider_selector = function(bufnr, filetype, buftype) + return { + "treesitter", + "indent" + } + end, +}; + +vim.o.foldenable = true +vim.o.foldcolumn = '0' +vim.o.foldlevel = 99 -- Ensure all folds start open +vim.o.foldlevelstart = 99 + +-- press K or capslockK +vim.keymap.set("n", "", function() + local winid = ufo.peekFoldedLinesUnderCursor() + if not winid then + vim.lsp.buf.hover() + end +end) diff --git a/modules/tools/editor/neovim/plugins/config/which-key.lua b/modules/tools/editor/neovim/plugins/config/which-key.lua new file mode 100644 index 0000000..1290432 --- /dev/null +++ b/modules/tools/editor/neovim/plugins/config/which-key.lua @@ -0,0 +1,5 @@ +local wk = require("which-key"); + +vim.keymap.set("n", "h", function() + wk.show({ global = true }) +end, { silent = true }); -- cgit v1.2.3