-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
feat(startup): add v:argf for startup file arguments #35889
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Looks ok to me, but the verbosity indicates that this was AI generated. Always mention that, and also please prune the irrelevant details where possible. The PR, and its description, should be complete yet concise. And as the issue label indicates, I would prefer if I heard whether people actually want this feature, or if I missed some other possible way to achieve it already. |
Thank u for the feedback!
Yeah, keeping this as a draft |
Introduce the read-only Vim variable v:argf that stores the original file arguments passed at startup. Unlike v:argv, v:argf contains only raw file arguments and remains unchanged by :args commands or plugins. This is implemented via set_argf_var() called at startup, and documented in runtime/doc/vvars.txt. VV_ARGF is registered as a VAR_LIST and VAR_RO.
See |v:progpath| for the command with full path. | ||
|
||
*v:argf* *argf-variable* | ||
v:argf |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alphanumeric order. this should go before v:argv
VV(VV_VERSIONLONG, "versionlong", VAR_NUMBER, VV_RO), | ||
VV(VV_ECHOSPACE, "echospace", VAR_NUMBER, VV_RO), | ||
VV(VV_ARGV, "argv", VAR_LIST, VV_RO), | ||
VV(VV_ARGF, "argf", VAR_LIST, VV_RO), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should go before ARGV
VV_VERSIONLONG, | ||
VV_ECHOSPACE, | ||
VV_ARGV, | ||
VV_ARGF, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should go before ARGV
See |v:progpath| for the command with full path. | ||
]=], | ||
}, | ||
argf = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
before argv
list_T *list = tv_list_alloc(kListLenMayKnow); | ||
|
||
for (int i = 0; i < GARGCOUNT; i++) { | ||
char *fname = alist_name(&GARGLIST[i]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably should expand the filename to an absolute path, since CWD can change after startup, which would make v:argf
not very useful thereafter.
And need a test for that scenario.
Also need tests for the --
case:
nvim ... -- file1 file2
And need tests that check what happens if the user calls :argadd
in a -c
or --cmd
option:
nvim --cmd "argadd file1.txt" -c "argadd file2.txt"
Note: descriptions are AI-generated
Add
v:argf
to track original startup file arguments #35847Problem
:args
andargv()
can change after startup.v:arg
includes options/commands, not just files.Solution
v:argf
: snapshot of file/dir args at startup.:args
or plugins.v:argv
, excludes options/commands.Example
fix #35847