aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/fs.lua
Commit message (Collapse)AuthorAge
* fix: resolve all remaining LuaLS diagnosticsLewis Russell2025-01-27
|
* feat(vim.fs): find(), dir() can "follow" symlinks #31551Mike2025-01-14
| | | | | | | | Problem: vim.fs.dir(), vim.fs.find() do not follow symlinks. Solution: - Add "follow" flag. - Enable it by default.
* feat: add vim.fs.relpathdundargoc2025-01-13
| | | | | This is needed to replace the nvim-lspconfig function is_descendant that some lspconfg configurations still use.
* fix(vim.fs.normalize): normalize case for windows drive letterdundargoc2025-01-04
| | | | | Also add tests for the current path casing behavior so it doesn't get accidentally changed.
* fix(vim.fs.abspath): correctly handle UNC pathsdundargoc2025-01-01
|
* docs: misc #31479Justin M. Keyes2025-01-01
|
* fix(vim.fs): joinpath() does not normalize slashes on Windows #31782Gustav Eikaas2024-12-31
|
* feat(lua): add `vim.fs.abspath`Famiu Haque2024-12-28
| | | | | | Problem: There is currently no way to check if a given path is absolute or convert a relative path to an absolute path through the Lua stdlib. `vim.fs.joinpath` does not work when the path is absolute. There is also currently no way to resolve `C:foo\bar` style paths in Windows. Solution: Add `vim.fs.abspath`, which allows converting any path to an absolute path. This also allows checking if current path is absolute by doing `vim.fs.abspath(path) == path`. It also has support for `C:foo\bar` style paths in Windows.
* docs: add tag `vim.fs.exists()` and document suggested replacementdundargoc2024-11-27
|
* feat(vim.validate): improve fast form and deprecate spec formLewis Russell2024-10-21
| | | | | | | | | | | | | | Problem: `vim.validate()` takes two forms when it only needs one. Solution: - Teach the fast form all the features of the spec form. - Deprecate the spec form. - General optimizations for both forms. - Add a `message` argument which can be used alongside or in place of the `optional` argument.
* perf(validate): use lighter versionLewis Russell2024-10-17
| | | | | - Also fix `vim.validate()` for PUC Lua when showing errors for values that aren't string or number.
* docs: more `@since` annotations #30660Justin M. Keyes2024-10-04
|
* fix(vim.fs): dirname() returns "." on mingw/msys2 #30480Justin M. Keyes2024-09-23
| | | | | | | | | | Problem: `vim.fs.dirname([[C:\User\XXX\AppData\Local]])` returns "." on mingw/msys2. Solution: - Check for "mingw" when deciding `iswin`. - Use `has("win32")` where possible, it works in "fast" contexts since b02eeb6a7281df0561a021d7ae595c84be9a01be.
* feat(fs.lua): add vim.fs.rm()Lewis Russell2024-09-22
| | | | Analogous to the shell `rm` command.
* fix(fs): make vim.fs.root work for relative paths and unnamed buffers (#28964)Gregory Anders2024-05-24
| | | | If a buffer does not have a backing file then fall back to the current working directory.
* perf(vim.fs.normalize): use iteratorLewis Russell2024-05-15
| | | | ~10% faster.
* perf(loader): use a quicker version of vim.fs.normalizeLewis Russell2024-05-15
| | | | | | | | | | | | | | | | Problem: vim.fs.normalize() normalizes too much vim.loader and is slow. Solution: Make it faster by doing less. This reduces the times spent in vim.fs.normalize in vim.loader from ~13ms -> 1-2ms. Numbers from a relative benchmark: - Skipping `vim.validate()`: 285ms -> 230ms - Skipping `path_resolve_dot()`: 285ms -> 60ms - Skipping `double_slash`: 60ms -> 35ms
* perf(fs): normalize path only once in fs.dirMathias Fussenegger2024-05-14
| | | | | | | | | | | | | | | | | | | | | | | Re-normalizing a path after a `joinpath` isn't necessary. Calling `normalize` on each child directory had quite a bit of impact when traversing a large directory. A simple test showed: Before: ~144ms After: ~80ms running the following logic against a dir with 4367 child folders and 25826 files: local files = {} local start = uv.hrtime() for name, type in vim.fs.dir(path, { depth = max_depth }) do table.insert(files, { name, type }) end local duration = uv.hrtime() - start Relates to https://github.com/neovim/neovim/issues/23291
* feat(fs): add vim.fs.root (#28477)Gregory Anders2024-04-24
| | | | | | vim.fs.root() is a function for finding a project root relative to a buffer using one or more "root markers". This is useful for LSP and could be useful for other "projects" designs, as well as for any plugins which work with a "projects" concept.
* feat(lua): vim.fs.normalize() resolves ".", ".." #28203Famiu Haque2024-04-16
| | | | | | | | | | | | | | | | | | | | | Problem: `vim.fs.normalize` does not resolve `.` and `..` components. This makes no sense as the entire point of normalization is to remove redundancy from the path. The path normalization functions in several other languages (Java, Python, C++, etc.) also resolve `.` and `..` components. Reference: - Python: https://docs.python.org/3/library/os.path.html#os.path.normpath - Java: https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html#normalize-- - C++: https://en.cppreference.com/w/cpp/filesystem/path/lexically_normal Solution: Resolve "." and ".." in `vim.fs.normalize`. Before: "~/foo/bar/../baz/./" => "~/foo/bar/../baz/." After: "~/foo/bar/../baz/./" => "~/foo/baz"
* fix: support UNC paths in vim.fs.normalizedundargoc2024-03-30
| | | | Closes https://github.com/neovim/neovim/issues/27068.
* fix(fs): allow backslash characters in unix pathsJames Trew2024-03-29
| | | | | | | Backslashes are valid characters in unix style paths. Fix the conversion of backslashes to forward slashes in several `vim.fs` functions when not on Windows. On Windows, backslashes will still be converted to forward slashes.
* fix(fs): use generics for better typingaltermo2024-03-06
|
* refactor(types): more fixesLewis Russell2024-03-06
|
* docs: improve/add documentation of Lua typesLewis Russell2024-03-01
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Added `@inlinedoc` so single use Lua types can be inlined into the functions docs. E.g. ```lua --- @class myopts --- @inlinedoc --- --- Documentation for some field --- @field somefield integer --- @param opts myOpts function foo(opts) end ``` Will be rendered as ``` foo(opts) Parameters: - {opts} (table) Object with the fields: - somefield (integer) Documentation for some field ``` - Marked many classes with with `@nodoc` or `(private)`. We can eventually introduce these when we want to.
* feat(docs): replace lua2dox.luaLewis Russell2024-02-27
| | | | | | | | | | | | | | | | | | | | | | | | | | Problem: The documentation flow (`gen_vimdoc.py`) has several issues: - it's not very versatile - depends on doxygen - doesn't work well with Lua code as it requires an awkward filter script to convert it into pseudo-C. - The intermediate XML files and filters makes it too much like a rube goldberg machine. Solution: Re-implement the flow using Lua, LPEG and treesitter. - `gen_vimdoc.py` is now replaced with `gen_vimdoc.lua` and replicates a portion of the logic. - `lua2dox.lua` is gone! - No more XML files. - Doxygen is now longer used and instead we now use: - LPEG for comment parsing (see `scripts/luacats_grammar.lua` and `scripts/cdoc_grammar.lua`). - LPEG for C parsing (see `scripts/cdoc_parser.lua`) - Lua patterns for Lua parsing (see `scripts/luacats_parser.lua`). - Treesitter for Markdown parsing (see `scripts/text_utils.lua`). - The generated `runtime/doc/*.mpack` files have been removed. - `scripts/gen_eval_files.lua` now instead uses `scripts/cdoc_parser.lua` directly. - Text wrapping is implemented in `scripts/text_utils.lua` and appears to produce more consistent results (the main contributer to the diff of this change).
* docs: replace <pre> with ``` (#25136)Gregory Anders2023-09-14
|
* fix(lua): vim.fs typing (#24608)Lewis Russell2023-08-08
|
* docs(lua): clarify fs.find() documentation #24394futsuuu2023-07-19
|
* docs(lua): more improvements (#24387)Lewis Russell2023-07-18
| | | | | | | | | | | | | | | | | * docs(lua): teach lua2dox how to table * docs(lua): teach gen_vimdoc.py about local functions No more need to mark local functions with @private * docs(lua): mention @nodoc and @meta in dev-lua-doc * fixup! Co-authored-by: Justin M. Keyes <justinkz@gmail.com> --------- Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
* fix(fs.lua): normalize slash truncation (#23753)Mike2023-07-18
| | | Preserve last slash in windows' root drive directories
* fix(lint): lint warnings #24226Raphael2023-07-10
|
* fix(fs): make `normalize()` work with '/' path (#24047)Evgeni Chasnovski2023-06-18
| | | | | | | Problem: Current implementation of "remove trailing /" doesn't account for the case of literal '/' as path. Solution: Remove trailing / only if it preceded by something else. Co-authored by: notomo <notomo.motono@gmail.com>
* docs: fix typos (#23917)Jonas Strittmatter2023-06-10
|
* feat(lua): rename vim.loop -> vim.uv (#22846)Lewis Russell2023-06-03
|
* feat(fs): expose join_paths as `vim.fs.joinpath` (#23685)Christian Clason2023-05-20
| | | This is a small function but used a lot in some plugins.
* feat(treesitter): improved logging (#23638)Lewis Russell2023-05-17
| | | | | | - Add bindings to Treesitter ts_parser_set_logger and ts_parser_logger - Add logfile with path STDPATH('log')/treesitter.c - Rework existing LanguageTree loggin to use logfile - Begin implementing log levels for vim.g.__ts_debug
* fix(windows): consistent normalization in fs.finddundargoc2023-04-04
| | | | | | | | | | | vim.fs.find(".luacheckrc") ``` c:\\projects\\neovim/.luacheckrc # before c:/projects/neovim/.luacheckrc # after ``` Co-authored-by: kylo252 <59826753+kylo252@users.noreply.github.com>
* feat(vim.fs): improve normalizeLewis Russell2023-03-26
| | | | | | - Add options argument with an option to expand env vars - Resolve '//' -> '/' - Use in vim.loader
* refactor(loader): use vim.fsLewis Russell2023-03-26
|
* feat(vim.fs): pass path to find() predicate, lazy evaluate #22378Mike2023-03-01
| | | | | | | | Problem: No easy way to find files under certain directories (ex: grab all files under `test/`) or exclude the content of certain paths (ex. `build/`, `.git/`) Solution: Pass the full `path` as an arg to the predicate.
* docs(vim.fs): normalize Windows example was incorrect (#21966)C.D. MacEachern2023-01-25
|
* fix(fs): duplicate path separator #21509Eric Haynes2023-01-03
| | | Fixes #21497
* feat(fs): add opts argument to vim.fs.dir()Lewis Russell2022-12-20
| | | | Added option depth to allow recursively searching a directory tree.
* Merge pull request #21154 from clason/vimdoc-injectionsChristian Clason2022-12-02
|\ | | | | feat(help): highlighted codeblocks
| * docs(gen): support language annotation in docstringsChristian Clason2022-12-02
| |
* | refactor(fs): replace vim.fn/vim.env in vim.fs (#20379)Mike2022-12-01
|/ | | | Avoid using vim.env and vim.fn in vim.fs functions so that they can be used in "fast" contexts.
* docs: fix typos (#21168)dundargoc2022-11-26
|
* docs(lua): add clarifications for fs.find() and fs.normalize() (#21132)AzerAfram2022-11-24
| | | | Co-Authored-By: Gregory Anders <8965202+gpanders@users.noreply.github.com> Co-Authored-By: zeertzjq <zeertzjq@outlook.com>
* feat(fs): extend fs.find to accept predicate (#20193)Mathias Fußenegger2022-09-13
| | | | | | | | | | | | | Makes it possible to use `vim.fs.find` to find files where only a substring is known. This is useful for `vim.lsp.start` to get the `root_dir` for languages where the project-file is only known by its extension, not by the full name. For example in .NET projects there is usually a `<projectname>.csproj` file in the project root. Example: vim.fs.find(function(x) return vim.endswith(x, '.csproj') end, { upward = true })