Skip to content

Conversation

SanzharKuandyk
Copy link

@SanzharKuandyk SanzharKuandyk commented Sep 23, 2025

Note: descriptions are AI-generated

Add v:argf to track original startup file arguments #35847

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.

Example

nvim file1.txt dir1 file2.txt
echo v:argf
" ['file1.txt', 'dir1', 'file2.txt']

fix #35847

@justinmk
Copy link
Member

justinmk commented Sep 23, 2025

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.

@SanzharKuandyk
Copy link
Author

Thank u for the feedback!

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.

Yeah, keeping this as a draft

@SanzharKuandyk SanzharKuandyk force-pushed the 35847 branch 2 times, most recently from 9066485 to 5958d60 Compare October 7, 2025 07:55
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.
end)
end)

describe('v:argf', function()
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@justinmk could you check them plz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

v:argf gets file/directory args passed at startup
2 participants