* Update logic for autoload or starting sessions.
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: https://github.com/olimorris/persisted.nvim/discussions/93
* Fix comment, make comparisons more direct
* Update functions to be directory-aware
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.
* fix: unnecessary shell commands when autosave off
Problem: Shell programs aren't able to detect nvim exit.
Solution: Avoid running shell-commands unnecessarily on exit.
Programs that spawn nvim in-order to edit a file are unable to detect
nvim exit cleanly because of a race-condition that happens in
`VimLeavePre` and `get_current()` which runs shell commands during exit
even when `autosave` is off.
For example, using nvim nightly, run persisted.nvim with:
```lua
opts.should_autosave = function()
-- Do not autosave if git commit/rebase session.
return vim.env.GIT_EXEC_PATH == nil
end
```
And run `EDITOR=nvim git commit` from shell; git will fail waiting for
nvim to exit cleanly.
* fix: global variable in lowercase initial
When nvim is used as a man pager with `export MANPAGER='nvim +Man! '`, with autoload set to true, persisted.nvim still autoloads the current directory which is not desirable
Telescope extension folder structure is described here:
https://github.com/nvim-telescope/telescope.nvim/wiki/Extensions#extension-folder-structure
When `telescope.load_extension(<name>)` is done, the name is loaded from
path `telescope._extensions.<name>`. With the current structure, one
could do `telescope.load_extension('finders')` and then it will be
available to load through `Telescope finders` which will error
> Error executing Lua callback: ...share/nvim/lazy/telescope.nvim/lua/telescope/command.lua:193: attempt to call a nil value
> stack traceback:
> ...share/nvim/lazy/telescope.nvim/lua/telescope/command.lua:193: in function 'run_command'
> ...share/nvim/lazy/telescope.nvim/lua/telescope/command.lua:253: in function 'load_command'
> ...ocal/share/nvim/lazy/telescope.nvim/plugin/telescope.lua:108: in function <...ocal/share/nvim/lazy/telescope.nvim/plugin/telescope.lua:107>