Skip to content
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

Update logic for autoload or starting sessions. #104

Merged
merged 3 commits into from
Dec 21, 2023

Conversation

neandrake
Copy link
Contributor

The logic to prevent autoloading/starting sessions when any arguments are supplied to neovim is to prevent session management from kicking in when editing a single file.

This updates the logic to allow a single argument passed to neovim as long as the argument is an existing directory. When neovim is launched in this way it behaves the same as opening neovim with no arguments but has changed the working directory.

This results in consistent behavior of the autoloading/starting of sessions when passing a directory argument to start neovim.

See: #93

The logic to prevent autoloading/starting sessions when any arguments
are supplied to neovim is to prevent session management from kicking in
when editing a single file.

This updates the logic to allow a single argument passed to neovim as
long as the argument is an existing directory. When neovim is launched
in this way it behaves the same as opening neovim with no arguments but
has changed the working directory.

This results in consistent behavior of the autoloading/starting of
sessions when passing a directory argument to start neovim.

See: olimorris#93
The main functionality in `init.lua` assumes using current working
directory in most cases. This refactors these functions to allow passing
in a directory instead.

The default behavior is to now use the current directory unless neovim
was started with a single directory argument, using that instead.

This also special-cases `.` as `vim.fn.expand()` does not resolve that
to the current working directory.
@neandrake
Copy link
Contributor Author

@Dioswilson I made some updates that I think will resolve most of the odd state you identified.

@olimorris
Copy link
Owner

This is a great PR. Thanks for your contribution.

I tried to rename the functions and update the comment blocks (mainly to aid myself when it comes to maintaining) but couldn't push it to the PR...something up with my Git config. So will merge and then and re-apply them.

@olimorris olimorris merged commit 7944b9a into olimorris:main Dec 21, 2023
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