diff options
| author | Thomas Vanbesien <tvanbesi@proton.me> | 2026-05-04 08:44:50 +0200 |
|---|---|---|
| committer | Thomas Vanbesien <tvanbesi@proton.me> | 2026-05-06 16:43:16 +0200 |
| commit | 34510ebc63ff65d51f6979a86169bfc52de6180c (patch) | |
| tree | 36c8b73c99a3c566ccee888818c60204398991fd /plugin/50-fold.lua | |
| download | nvim-config-34510ebc63ff65d51f6979a86169bfc52de6180c.tar.gz nvim-config-34510ebc63ff65d51f6979a86169bfc52de6180c.zip | |
feat: initial setup
- `dotfiles` (this project's CLI)
- foot configuration
- tmux configuration
- bash configuration
- nvim (as a git submodule) + configuration
- ranger configuration
- fzf configuration
- KDE global shortcuts
- Other miscellaneous dependencies
Diffstat (limited to 'plugin/50-fold.lua')
| -rw-r--r-- | plugin/50-fold.lua | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/plugin/50-fold.lua b/plugin/50-fold.lua new file mode 100644 index 0000000..c7013bb --- /dev/null +++ b/plugin/50-fold.lua @@ -0,0 +1,22 @@ +-- +-- fold plugin +-- + +-- Initialize folds with foldmethod = expr if a treesitter parser is available, then switch back to manual +-- This is to have the folds calculated and closed when editing the file initially, but with foldmethod set to manual +-- Without foldmethod set to manual folds are created while writing in insert mode which is annoying +-- +-- Skip floating windows, because they often are documentation (and thus should be visible by default) +vim.api.nvim_create_autocmd("FileType", { + desc = "Initialize folds", + group = vim.g.dotfiles.augroup, + callback = function(ev) + if vim.api.nvim_win_get_config(0).relative ~= "" or vim.treesitter.get_parser(0) == nil then + return + end + vim.opt_local.foldexpr = "v:lua.vim.treesitter.foldexpr()" + vim.opt_local.foldmethod = "expr" + vim.cmd.normal({ "zX", bang = true }) + vim.opt_local.foldmethod = "manual" + end, +}) |
