[audit] fix foldmethod: use 'expr' so treesitter foldexpr is consulted#143
[audit] fix foldmethod: use 'expr' so treesitter foldexpr is consulted#143stanfish06 wants to merge 1 commit into
Conversation
…ulted foldmethod='indent' silently ignores foldexpr; the treesitter fold expression is only evaluated when foldmethod='expr'. https://claude.ai/code/session_014eiycWG5KeoanDfLHDC825
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5c4e18ac60
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| -- folding | ||
| vim.o.foldlevel = 10 | ||
| vim.o.foldmethod = "indent" | ||
| vim.o.foldmethod = "expr" |
There was a problem hiding this comment.
Restore fallback folding for non-Tree-sitter filetypes
When a buffer has no Tree-sitter parser or vim.treesitter.start() fails, this global foldmethod=expr still leaves foldexpr as vim.treesitter.foldexpr(), which returns 0 without a parser, so those files have no folds at all. The repo only installs parsers for a limited set of languages in lua/config/treesitter.lua, and its FileType fallback only enables syntax on; it does not switch folding back from expr, so opening unsupported filetypes such as YAML/JSON or any parser install failure regresses from the previous indent-based folding to no usable folds.
Useful? React with 👍 / 👎.
What
lua/config/options.lua:100setsfoldmethod = "indent"whilefoldexpris pointed atvim.treesitter.foldexpr(). These two settings contradict each other.Where
lua/config/options.lualines 100–101:Why it matters
Neovim only calls
foldexprwhenfoldmethod = "expr". Withfoldmethod = "indent"the expression is set but never evaluated — all folding falls back to dumb indent-counting. This silently breaks every treesitter-aware fold boundary (e.g. multi-line if/match arms, docstrings, etc.).Change
One character change, no behaviour regression for any other option.
Generated by Claude Code