treesitter: make foldenable configurable

This commit is contained in:
Tom Vincent 2026-03-19 12:36:51 +00:00
commit 68b7df5065
No known key found for this signature in database
GPG key ID: AB184CDBE6AEACDE
3 changed files with 10 additions and 7 deletions

View file

@ -22,7 +22,6 @@
``` ```
Some other settings and commands are now deprecated but are still supported. Some other settings and commands are now deprecated but are still supported.
- The `setupOpts.mappings` options were also removed. Use the built-in Neovim - The `setupOpts.mappings` options were also removed. Use the built-in Neovim
settings (nvf's {option}`vim.keymaps`) settings (nvf's {option}`vim.keymaps`)
@ -35,7 +34,6 @@
- "Correct `languages.go.treesitter` to contain all Go file types. - "Correct `languages.go.treesitter` to contain all Go file types.
`languages.go.treesitter.package` is now `languages.go.treesitter.goPackage`. `languages.go.treesitter.package` is now `languages.go.treesitter.goPackage`.
New are: New are:
- `languages.go.treesitter.goPackage`. - `languages.go.treesitter.goPackage`.
- `languages.go.treesitter.gomodPackage`. - `languages.go.treesitter.gomodPackage`.
@ -70,7 +68,7 @@
following: following:
```shell ```shell
(class: "nixos") cannot be imported into a module (class: "nixos") cannot be imported into a module
evaluation that expects class "darwin". evaluation that expects class "darwin".
``` ```
@ -165,7 +163,9 @@
- Mappings are now expected to be set using the built-in Neovim APIs, - Mappings are now expected to be set using the built-in Neovim APIs,
managed by `vim.keymaps` in nvf, instead of `mappings` options. managed by `vim.keymaps` in nvf, instead of `mappings` options.
- Some option defaults have changed. - Some option defaults have changed.
- And more. - And more.
- Automatically configure an enabled picker in the order mentioned above, if - Automatically configure an enabled picker in the order mentioned above, if
any are enabled. any are enabled.
- Add integration with `snacks.image` for rendering workspace/vault assets. - Add integration with `snacks.image` for rendering workspace/vault assets.
@ -318,4 +318,8 @@ https://github.com/gorbit99/codewindow.nvim
- Fix `vim.formatter.conform-nvim.setupOpts.formatters` type for correct merging - Fix `vim.formatter.conform-nvim.setupOpts.formatters` type for correct merging
[tlvince](https://github.com/tlvince):
- Added configuration option for `foldenable`
<!-- vim: set textwidth=80: --> <!-- vim: set textwidth=80: -->

View file

@ -6,6 +6,7 @@
inherit (lib.modules) mkIf; inherit (lib.modules) mkIf;
inherit (lib.lists) optionals; inherit (lib.lists) optionals;
inherit (lib.nvim.dag) entryAfter; inherit (lib.nvim.dag) entryAfter;
inherit (lib.trivial) boolToString;
cfg = config.vim.treesitter; cfg = config.vim.treesitter;
in { in {
@ -54,10 +55,7 @@ in {
callback = function() callback = function()
vim.wo[0][0].foldmethod = "expr" vim.wo[0][0].foldmethod = "expr"
vim.wo[0][0].foldexpr = "v:lua.vim.treesitter.foldexpr()" vim.wo[0][0].foldexpr = "v:lua.vim.treesitter.foldexpr()"
-- This is optional, but is set rather as a sane default. vim.o.foldenable = ${boolToString cfg.foldByDefault}
-- If unset, opened files will be folded by automatically as
-- the files are opened
vim.o.foldenable = false
end, end,
}) })
''} ''}

View file

@ -10,6 +10,7 @@ in {
enable = mkEnableOption "treesitter, also enabled automatically through language options"; enable = mkEnableOption "treesitter, also enabled automatically through language options";
fold = mkEnableOption "fold with treesitter"; fold = mkEnableOption "fold with treesitter";
foldByDefault = mkEnableOption "folding by default when a file is opened";
autotagHtml = mkEnableOption "autoclose and rename html tag"; autotagHtml = mkEnableOption "autoclose and rename html tag";
grammars = mkOption { grammars = mkOption {