aboutsummaryrefslogtreecommitdiff
path: root/test/functional/lua/glob_spec.lua
Commit message (Collapse)AuthorAge
* perf(watch): skip directories outside include glob prefixesLewis Russell2026-10-05
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: watchdirs() scans and watches every directory that is not excluded, even when a glob only matches files in one subtree. Some language servers register absolute dependency filenames separately. Neovim uses the workspace root for these string globs, so each extra registration can scan and allocate libuv handles across the whole tree. Solution: Keep each glob's literal directory prefix with its compiled matcher. A directory must be allowed by both the include filter and at least one watch rule. Skip unrelated subtrees, including new directories created later. Keep ancestors watched so matching directories can still be found. Report events only when they match the full patterns. For example, watching /project for /project/src/**/*.lua only needs the src tree and /project itself: /project/ watched |-- src/ watched | `-- lib/ watched |-- tests/ skipped | `-- fixtures/ skipped `-- vendor/ skipped `-- pkg/ skipped With no exclusions, this uses three watches instead of seven. The gain can be large, but depends on the server's patterns and the workspace layout. Separate watches for absolute dependency filenames can skip most directories. For example, a test workspace has 213 directories, including 201 under build/. The two dependency files in this example are under packages/ and styles/, so their watches can skip build/. Before this change, each watch starts at the workspace root, scans all 213 directories and creates 213 libuv handles. With this change: - Haskell Language Server: a separate watch for /project/packages/demo/demo.cabal watches four directories: the project root, packages/, demo/ and its src/ child. This cuts that watch's scans and handles by 98%. With one broad source watch and this dependency watch, the total falls by 49%. - Tailwind CSS v4: a separate watch for the imported /project/styles/themes/colors.css watches three directories: the project root, styles/ and themes/. This cuts that watch's scans and handles by 99%. With two broad watches and this dependency watch, the total falls by 33%. The broad watches still cover all 213 directories. The saving comes from avoiding repeated scans and extra handles for each dependency watch. Most servers with watch registrations in the survey do not benefit. Their patterns match throughout the watch root, or their watches already start at the relevant directory. In both cases, the glob prefix cannot exclude more directories. AI-assisted
* fix(glob): match leading hash characters literallyLewis Russell2026-10-05
| | | | | | | | | | | | Problem: Globs such as '#generated/*.lua' fail to match their literal paths. The parser consumes a leading '#' as its internal in-segment flag. Solution: Pass the flag as an LPeg match argument instead of inserting it into the glob text. Cover literal and braced patterns with leading hashes. AI-assisted
* test(harness): migrate away from magic globalsJustin M. Keyes2026-07-21
| | | | | | | | | | | | | | | | | | | | | Problem: The magic globals `it`, `describe`, etc., are more trouble than they are worth. - Hooking into `after_each` requires `getfenv()` hacks. - They confuse luals/emmylua, because the top-level `.luarc.json` isn't merged with `test/.luarc.json` (apparently a luals limitation?) - They totally defeat discoverability because the user just has to "know" about the various magic symbols. So they harm DX, which means they serve no purpose at all. Solution: - Expose the test API from `testutil`, so tests can call `t.it()`, `t.describe()`, etc., in the conventional way. - Drop `getfenv()` hacks. - Drop the `setfenv()` injection in `load_chunk`. - Drop `test/_meta.lua`.
* fix(glob): handle numeric literals in pattern matching (#37257)Tristan Knight2026-01-12
| | | | | | | | | | | | | | Problem: vim.glob.to_lpeg() errors when patterns contain numeric literals (like the '1' in '.ps*1') because LPeg interprets numeric strings as indexed grammar rule references. For example: vim.glob.to_lpeg('.ps*1') E5108: Lua: rule '1' undefined in given grammar Solution: Prefix all rule names with '_' in the end_seg() function to prevent literal numbers from being interpreted as LPeg indexed rules. This ensures pattern components like '1', '2', etc. are treated as regular rule names rather than special references.
* test: remove a few more redundant clear() calls (#35903)zeertzjq2025-09-24
|
* test: don't call clear() in both before_each() and after_each() (#35901)zeertzjq2025-09-24
|
* fix(glob): handling commas in letter pattern #34170Brynne Taylor2025-06-03
|
* feat(glob): new Glob implementation based on Peglob #33605Brynne Taylor2025-05-22
| | | | | | | |vim.glob.to_lpeg()| uses a new LPeg-based implementation (Peglob) that provides ~50% speedup for complex patterns. The implementation restores support for nested braces and follows LSP 3.17 specification with additional constraints for improved correctness and resistance to backtracking edge cases.
* test: support upvalues in exec_luaLewis Russell2024-09-21
|
* test: allow exec_lua to handle functionsLewis Russell2024-08-02
| | | | | | | | | | | Problem: Tests have lots of exec_lua calls which input blocks of code provided as unformatted strings. Solution: Teach exec_lua how to handle functions.
* fix(glob): avoid `subcapture nesting too deep` error (#29520)Zoltán Nyikos2024-07-06
| | | | Use Cmt to evaluate Cond and Elem during match to avoid building the nested capture structure later.
* fix(glob): handle overlapping `{}` condition elements #29236Jon Huhn2024-06-10
| | | | | | | | | | | | | | | | | | | | | | | | This change fixes an issue where glob patterns like `{a,ab}` would not match `ab` because the first option `a` matches, then the end of the string is expected but `b` is found, and LPeg does not backtrack to try the next option `ab` which would match. The fix here is to also append the rest of the pattern to the generated LPeg pattern for each option. This changes a glob `{a,ab}` from being parsed as ("a" or "ab") "end of string" to ("a" "end of string" or "ab" "end of string") Here, matching against `ab` would try the first option, fail to match, then proceed to the next option, and match. The sacrifice this change makes is dropping support for nested `{}` conditions, which VSCode doesn't seem to support or test AFAICT. Fixes #28931 Co-authored-by: Sergey Slipchenko <faergeek@gmail.com>
* test: improve test conventionsdundargoc2024-04-23
| | | | | | | | | Specifically, functions that are run in the context of the test runner are put in module `test/testutil.lua` while the functions that are run in the context of the test session are put in `test/functional/testnvim.lua`. Closes https://github.com/neovim/neovim/issues/27004.
* refactor(test): inject after_each differentlyLewis Russell2024-04-10
|
* test: improve test conventionsdundargoc2024-04-08
| | | | Work on https://github.com/neovim/neovim/issues/27004.
* refactor(lua): refactored globaltermo2024-01-19
|
* refactor: format test/*Justin M. Keyes2024-01-03
|
* refactor(lsp): move glob parsing to util (#26519)Steven Arcangeli2023-12-22
refactor(lsp): move glob parsing to vim.glob Moving the logic for using vim.lpeg to create a match pattern from a glob into `vim.glob`. There are several places in the LSP spec that use globs, and it's very useful to have glob matching as a generally-available utility.