Skip to content

Add support for multiple files, line number, -o -O -p cmd line arguemnt#87

Draft
lguarda wants to merge 10 commits intosamjwill:mainfrom
lguarda:main
Draft

Add support for multiple files, line number, -o -O -p cmd line arguemnt#87
lguarda wants to merge 10 commits intosamjwill:mainfrom
lguarda:main

Conversation

@lguarda
Copy link

@lguarda lguarda commented May 21, 2025

In This PR which add some cmd line option parsing capabilities

Added:

  • new config g.unception_multi_file_open_method that will control how successive file will be opened (default still argadd)
  • cmd line option -o -O -p is detected to overwrite config vim.g.unception_multi_file_open_method
    so for example by default the argadd method is used, so only one file will be visisble
    but if you type nvim file1 file2 -O both file will be open in a vsplit
  • cmd line option -d is detected this will open all file in a vsplit and mark them for diff using :diffthis
  • cmd line option +{number} is detected to open specified file at a given number (this currently doesn't work with argadd method)

Fixed:

  • when using --cmd to set global with viml like this nvim --cmd "let g:unception_disable=0" now 0 is set to false so lua code handle it properly
    all boolean config value can be set to 0 in viml this will be handled as false

Example usage

# type this
nvim file1 file2 +2 -o
nvim -d file1 file2 +2
# enjoy

What's remaining to do:

  • find better name for unception_multi_file_open_method
  • update the README
  • update doc
  • clean up/refacto code + better naming for config and functions
  • add better unit tests
  • check potential compatibility issue with vim.fn.rpcrequest vs vim.rpcrequest
    Actualy vim.fn.* will do this lua/viml translation, so it's seems better to use vim.rpcrequest/notify

@samjwill
Copy link
Owner

Hi lguarda! Thanks for the PR! I appreciate that you took some time to dedicate to looking into potential improvements for the plugin.

I want to be upfront that at the moment, I'm quite low on bandwidth, and may not be able to review for a while. I hope to get to it eventually, but it could take some time.

Regarding argadd, I believe I initially used it because it mimics how Neovim behaves when you give it multiple file arguments directly (without using any plugins). Neovim adds each file to the args list, and you can switch between them using :next and :prev. One of my goals was to have it integrate with the vanilla behavior as seamlessly as possible, and that's what I came up with.

@lguarda
Copy link
Author

lguarda commented May 22, 2025

Ok thanks it something that i never used so i didn't even think of next/prev, i will continue to update this PR and keep the default behavior with argadd + next/prev

lguarda added 7 commits May 23, 2025 17:56
Improvement:
- directory can be open
- multiple files are supported
- cmd line argument -o -O -p are supported to open in split vsplit or
  tab
- cmd line file option + is also supported so `nvim file +32` will i open
  file at the line 32
…ion in a dictionary

Also change unit test since the scope of unception_arg_parse as change
in lua number if number will always be asserted as true
```lua
if 0 then print("number is == true") end
```

And in viml boolean doesn't exit
So for example this:
nvim --cmd "let g:unception_disable=0"
will still disable unception since in lua `if 0` == `if true`

we could also do this instead
```
nvim --cmd "lua vim.g.unception_disable=false"
```
but i think it's better to also support viml
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.

2 participants