fold options/hotkeys

This commit is contained in:
2026-08-05 06:39:52 +02:00
parent 4b066534d4
commit d584ef391a
2 changed files with 18 additions and 0 deletions
+10
View File
@@ -40,6 +40,16 @@ map("n", "<C-h>", "<cmd>Pick help<cr>", { desc = "Find: help tags" })
map("n", "<C-e>", "<cmd>Oil<cr>", { desc = "File explorer (Oil)" }) map("n", "<C-e>", "<cmd>Oil<cr>", { desc = "File explorer (Oil)" })
map("n", "<C-k>", "<cmd>Pick keymaps<cr>", { desc = "Find: keymaps" }) map("n", "<C-k>", "<cmd>Pick keymaps<cr>", { desc = "Find: keymaps" })
-- Folding (stock Vim fold keys, remapped to themselves just so they show up
-- with descriptions in the keymap picker <C-k>)
map("n", "za", "za", { desc = "Fold: toggle under cursor" })
map("n", "zc", "zc", { desc = "Fold: close under cursor" })
map("n", "zo", "zo", { desc = "Fold: open under cursor" })
map("n", "zR", "zR", { desc = "Fold: open all" })
map("n", "zM", "zM", { desc = "Fold: close all" })
map("n", "zj", "zj", { desc = "Fold: move to next fold start" })
map("n", "zk", "zk", { desc = "Fold: move to previous fold end" })
-- Spell -- Spell
map("n", "<leader>sc", function() map("n", "<leader>sc", function()
vim.wo.spell = not vim.wo.spell vim.wo.spell = not vim.wo.spell
+8
View File
@@ -12,6 +12,14 @@ o.winborder = "single"
o.termguicolors = true o.termguicolors = true
o.autoread = true o.autoread = true
-- Folding: native treesitter folds (function/class/block-aware), no plugin needed.
-- `foldmethod=diff` (used automatically in :diffthis / fugitive / diffview windows)
-- takes over on its own and isn't affected by this.
o.foldmethod = "expr"
o.foldexpr = "v:lua.vim.treesitter.foldexpr()"
o.foldlevel = 99 -- start with everything open
o.foldlevelstart = 99
vim.api.nvim_create_autocmd({ "FocusGained", "BufEnter", "CursorHold", "CursorHoldI" }, { vim.api.nvim_create_autocmd({ "FocusGained", "BufEnter", "CursorHold", "CursorHoldI" }, {
command = "if mode() != 'c' | checktime | endif", command = "if mode() != 'c' | checktime | endif",
}) })