mirror of
https://github.com/neovim/neovim.git
synced 2026-04-22 15:25:30 +00:00
feat(startup): provide v:argf for file arguments #35889
Problem:
- `:args` and `argv()` can change after startup.
- `v:arg` includes options/commands, not just files.
- Plugins (e.g. Oil) may rewrite directory args.
Solution:
- New read-only var `v:argf`: snapshot of file/dir args at startup.
- Unaffected by `:args` or plugins.
- Unlike `v:argv`, excludes options/commands.
- Paths are resolved to absolute paths when possible
Example:
nvim file1.txt dir1 file2.txt
:echo v:argf
" ['/home/user/project/file1.txt', '/home/user/project/dir1', '/home/user/project/file2.txt']
This commit is contained in:
15
runtime/lua/vim/_meta/vvars.lua
generated
15
runtime/lua/vim/_meta/vvars.lua
generated
@@ -6,6 +6,21 @@ error('Cannot require a meta file')
|
||||
--- @class vim.v
|
||||
vim.v = ...
|
||||
|
||||
--- The list of file arguments passed on the command line at startup.
|
||||
---
|
||||
--- Each filename is expanded to an absolute path, so that v:argf
|
||||
--- remains valid even if the current working directory changes later.
|
||||
---
|
||||
--- Unlike `v:argv`, this does not include option arguments
|
||||
--- such as `-u`, `--cmd`, or `+cmd`. Unlike `argv()`, it is not
|
||||
--- affected by later `:args`, `:argadd`, or plugin modifications.
|
||||
--- It also handles the `--` separator correctly, including only
|
||||
--- files specified after it.
|
||||
---
|
||||
--- This is a read-only snapshot of the original startup file arguments.
|
||||
--- @type string[]
|
||||
vim.v.argf = ...
|
||||
|
||||
--- The command line arguments Vim was invoked with. This is a
|
||||
--- list of strings. The first item is the Vim command.
|
||||
--- See `v:progpath` for the command with full path.
|
||||
|
||||
Reference in New Issue
Block a user