Commit Graph

202 Commits (main)

Author SHA1 Message Date
olimorris e2ae8b321e refactor(utils): directory formatting 2024-08-09 13:31:14 +01:00
olimorris 12de2ac0cf refactor(utils): update `in_table` function 2024-08-09 08:59:48 +01:00
olimorris 98cd3de512 fix: #146 allowed_dirs and ignored_dirs 2024-08-09 08:56:18 +01:00
Oli 22e17b07fb
refactor!: #145 restore simplicity to the plugin
Announcement in #145
2024-08-08 18:25:16 +01:00
olimorris 0446fd0217 refactor: better git branch checking 2024-08-06 22:05:43 +01:00
olimorris 4df3f8a036 chore: add logging 2024-07-02 19:32:36 +01:00
olimorris a9138468f9 chore: handle null parameters on `ignore_branch` 2024-07-02 19:32:12 +01:00
Anurag 0a9eebf5cc
fix: missing autocmd data when no branch (#137) 2024-06-15 21:50:38 +01:00
Jurek Olden e50e0b65b0
fix: properly start a session from Telescope (#134)
Properly starts sessions loaded from another directory using Telescope.
Crucially, this version compares the working directory of the session, not
the working directory at the time of the session load, to the lists
of allowed and ignored directories.

Co-authored-by: Oli <olimorris@users.noreply.github.com>
2024-06-03 07:29:47 -07:00
Zheng PiaoDan 2b4f192aca
fix: follow_cwd option (#132)
* fix: TestFollowCwd

* fix: follow_cwd not actually working

cause: `follow_cwd and nil or session` always use `session` because the
`true and nil` expression is evaluated to false
2024-05-31 09:47:52 +01:00
Rémi Labeyrie 1e9fd63e25
fix: remove unused last_modified property (#126) 2024-05-07 19:31:21 +01:00
Oli 9c5fc98a4c
fix: #120 session loading for branches with slashes 2024-05-03 10:09:50 +01:00
PostCyberPunk 96bf597778
fix: use stat to last modified date (#121) 2024-04-26 09:23:21 +01:00
Rémi Labeyrie 8fc97b6182
feat: add icons and colors to telescope picker (#119)
* feat: add icons and colors to telescope picker

* feat: add configuration options for telescope icons

* fix: remove highlight group for telescope normal selection
2024-04-22 21:36:41 +01:00
Matthias Bilger ca9900c31e
fix: error message outside of git repo (#116)
in case ignored branches have been set and the current dir is not a
git directory no more error messages will be thrown
2024-04-04 13:42:31 +01:00
olimorris a192a0a11a chore(formatting): updates 2024-03-12 21:46:14 +00:00
Matthias Bilger ce9d621683
feat: Add ability to ignore branches (#114) 2024-03-12 21:44:36 +00:00
jyuan0 18fda8136f
feat: configurable telescope mappings (#113) 2024-03-06 14:16:41 +00:00
anhoder b4e09a639a
fix: force save (#112) 2024-02-29 09:04:48 +00:00
Mike Iversen edd8aa41cd
chore: use vim.notify (#108)
* Updated warnings and info to print with vim.notify

* Updated formatting
2024-01-06 09:40:32 +00:00
olimorris 284d714b8d fix: #107 corrected remove warning message 2024-01-05 22:56:04 +00:00
olimorris 9545fc0b85 fix: #107 remove warning message 2024-01-05 22:53:47 +00:00
Christopher Speck 97bc6260fb
fix: properly resolve directories (#105)
* fix: properly resolve directories

The `vim.loop.fs_realpath()` function can be used to properly resolve
both the `.` shortcut as well as relative paths. This corrects scenarios
when opening nvim to a subdirectory of the working directory. With this
change doing so will properly resolve the session file to the directory
that was specified on the command line.

```console
$ pwd
/Users/username/.config

$ ls
fish    iterm2    nvim

$ nvim nvim
```

This will result in using the path `/Users/username/.config/nvim` for
the session. The behavior will be the same as running plain `nvim` from
within the `/Users/username/.config/nvim` directory itself.

This change also quotes the path passed to `git` to properly handle
paths containing spaces.

This change also corrects some typos in the readme.

* fix: isdirectory is not necessary

The fs_realpath function will return nil if the path doesn't exist.

* fix: typos in comments

* fix: isdirectory is still necessary

Oops, the isdirectory check is necessary to confirm it's a directory and
not a file.
2023-12-22 15:53:31 +00:00
olimorris dfb79ffa75 feat: make more data available when firing events 2023-12-21 16:52:30 +00:00
olimorris 15096138b0 chore: update comment block 2023-12-21 13:45:03 +00:00
olimorris 548b43aec4 refactor: function names and comment blocks 2023-12-21 13:26:48 +00:00
Christopher Speck 7944b9afe3
refactor: update logic for autoload or starting sessions (#104)
* 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.
2023-12-21 11:15:05 +00:00
olimorris 66d540f949 refactor!: do not append `main` to non-git repo sessions
https://github.com/olimorris/persisted.nvim/discussions/103
2023-12-20 12:47:51 +00:00
olimorris ff261c2d22 feat: add copy session to Telescope actions 2023-12-20 12:45:11 +00:00
olimorris a1cc308580 feat: telescope add/update branch name 2023-12-18 23:46:57 +00:00
olimorris bcdada28d2 fix: prevent double running of git command
Should improve loading times significantly
2023-12-18 23:22:10 +00:00
olimorris 86ce6f14ae refactor!: telescope reset_prompt api 2023-12-18 23:21:04 +00:00
Mike Iversen fc9f398393
feat: Added exact ignored_dirs support (#100) 2023-11-26 10:38:57 +00:00
olimorris 3ebc5d77ae refactor: `override` to `force` for SessionSave 2023-11-18 16:07:38 +00:00
olimorris 0ea44f1586 feat: add global var for if session exists in cwd 2023-11-18 15:38:16 +00:00
olimorris d90f9adb04 fix: #96 improve startup time
For those who do not use the git branching feature, this may improve their Neovim startup time significantly
2023-11-16 09:50:09 +00:00
olimorris 71352aa7dc chore(formatting) 2023-11-06 12:16:35 +00:00
Rafael Bodill 315cd1a8a5
fix: unnecessary shell commands when autosave off (#85)
* 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
2023-08-11 14:07:50 +01:00
olimorris 2de1fe69e7 feat: add event for `PersistedToggled` 2023-08-11 10:33:54 +01:00
olimorris c1c4bbff8a feat: add global variable for last loaded session 2023-07-26 16:17:42 +01:00
olimorris 06946ed12d feat: allow session to be saved from telescope 2023-07-25 21:12:30 +01:00
olimorris b03c863731 Revert "fix: prevent autoloading when there are extra command line arguments passed to nvim (#76)"
This reverts commit 975cd4cd06.
2023-06-30 05:09:55 +01:00
Beartama 975cd4cd06
fix: prevent autoloading when there are extra command line arguments passed to nvim (#76)
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
2023-06-27 17:07:11 -07:00
olimorris c384aa6706 chore: active session mark in telescope 2023-06-12 09:04:37 +01:00
Dhruv Manilawala 0cdbc8a3fe
feat: mark active session in telescope, use `vim.fn.confirm` 2023-06-12 08:36:05 +01:00
Dhruv Manilawala f5d84ea6e1
fix: update telescope extension structure (#72)
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>
2023-06-11 21:51:26 +01:00
olimorris 2e6946c1ad refactor: clean up `mks` command 2023-06-02 10:22:04 +01:00
Oli 304a3c5551
feat: load the session from the main branch if no branch session (#66) 2023-04-24 17:44:57 +01:00
olimorris e053ff3348 fix: #61 `SessionSave` command 2023-03-13 19:45:24 +00:00
olimorris 7d91c60135 fix: #60 autosave ignoring vim.fn.argc 2023-03-09 09:57:27 +00:00
olimorris 0a6be5db0e refactor: remove deprecations 2023-03-09 09:41:22 +00:00
olimorris 88f27dcab2 fix: PersistedSavePre called when autosave = false 2023-02-28 23:21:54 +00:00
olimorris bcd99ed00c chore: rename functions 2023-02-28 22:28:44 +00:00
Demaro Stanberry 433e6d6808
fix: improve displayed session names
* fix: sanitize string before passing to `string.gsub(...)`

fix: improve displayed paths on windows os

* chore: improve scripting for review
2023-02-28 20:55:55 +00:00
olimorris e3647c1087 refactor: clean up session loading 2023-02-28 18:54:33 +00:00
Oli 03f11b519f
fix: autosaving (#56)
* fix: autosaving

* chore: newline

* feat: allow autosave override
2023-02-28 17:28:45 +00:00
Rafael Bodill 7890dadd6e
feat: allow options to be set in `telescope` setup (#55)
* feat: Allow options to be set in Telescope setup
* docs: update readme.md for telescope config
2023-02-28 16:16:37 +00:00
olimorris 4c960a99d7 feat: add data to state change and delete events 2023-02-25 10:39:41 +00:00
olimorris 4866194140 feat: add additional events 2023-02-23 20:44:47 +00:00
olimorris 383b5ba6b5 feat: delete a session in a schedule.wrap func 2023-02-23 20:44:26 +00:00
olimorris 029ba65f39 fix: config.setup deprecation checks 2023-02-23 10:41:21 +00:00
olimorris a0196d5c51 fix: make session data available via callback 2023-02-23 10:11:29 +00:00
olimorris e594ede825 fix: schedule loading session from telescope 2023-02-23 10:04:11 +00:00
olimorris fc3df75cd5 refactor!: #51 replace callbacks with user events 2023-02-22 20:24:27 +00:00
olimorris 65c5c07bf9 chore: remove redundant param 2023-02-22 18:11:01 +00:00
Oli 774e4d70e9
fix: #46 autoload sessions 2023-02-22 15:02:33 +00:00
Oli dfbd039fe1
feat: load session by path (#48) (#47)
* feat: load session by path

* chore: change order of commands

* tests: fix

* docs: tweak readme wording
2023-02-21 21:09:01 +00:00
olimorris 675744d835 chore: fixup error message 2023-02-21 16:40:54 +00:00
olimorris 898ddcdd46 chore: remove annotations 2023-02-21 16:03:52 +00:00
olimorris f99ad40198 refactor: move commands to vim file 2023-02-21 16:01:27 +00:00
olimorris 452c36a3f9 chore: clean up config file 2023-02-21 16:01:15 +00:00
olimorris 43805b40a6 refactor: autocmds 2023-02-21 15:47:56 +00:00
olimorris 769c130831 chore: cleanup utils file 2022-11-16 13:43:29 +00:00
ADoyle 53a39a0447
feat: add config option "telescope.reset_prompt_after_deletion"
User can decide whether to reset the prompt or not, after deleting a session
2022-11-03 14:14:36 +00:00
olimorris e39170f571 refactor!: change default branch separator 2022-11-02 17:38:41 +00:00
Cedric M'Passi 2e61c9fb92
fix: check for nil opts in setup 2022-10-27 08:18:14 +01:00
olimorris 5347c83ee4 refactor!: warn of future branch_separator change 2022-10-26 17:41:44 +01:00
olimorris cf3b9a45fe chore: formatting 2022-10-26 17:39:28 +01:00
olimorris 2105556a1a chore: rename autocmd group 2022-10-26 17:24:18 +01:00
olimorris df231232c7 fix: #38 reinstate on_autoload_no_session 2022-10-26 17:14:40 +01:00
olimorris 5c5c4ae949 fix: autocmd namings 2022-10-26 13:55:16 +01:00
olimorris 226db9219f fix: clear diagnostics 2022-10-26 13:49:43 +01:00
olimorris 26d82d6876 refactor: use neovim autocmd api 2022-10-26 13:41:13 +01:00
ADoyle 80c898a6c9
fix: #34 support width = { val, min, max } and show branch
- Use telescope builtin resolver to calculate width.
- The branch is missing. Fixed.
- If session file stores without git branch, `session.branch` should be nil. And do not show branch in list.
- `make test` will fail because plenary.nvim is old.

close #34
2022-10-25 13:44:54 +01:00
Connor Robertson 38b36fc5fd
feat: allow session name to be fixed on load
* Add follow_cwd option to allow fixing session name on load

* Update readme to reflect new follow_cwd command and explain use

* Add tests for follow_cwd

* Update README.md

* Adjust wording in README for follow_cwd to clarify use case

Co-authored-by: Oli M <olimorris@users.noreply.github.com>
2022-10-14 10:08:12 +01:00
olimorris df435cee43 feat: #31 should_autosave callback 2022-10-07 12:46:58 +01:00
Latif Sulistyo b54b72dbde
feat: add `silent` config option 2022-09-13 08:28:36 +01:00
Mat Jones 321ba42367
feat: #27 add `on_autoload_no_session` hook
* Add `on_autoload_no_session` hook

* Update README.md
2022-08-23 22:02:30 +01:00
HumblePresent e994852d86
feat: add configurable git branch separator string (#25) 2022-08-22 21:36:22 +01:00
olimorris 2379b3dfe8 test: fix branch test 2022-08-22 21:33:16 +01:00
olimorris dafb7a9e43 chore: misc updates 2022-08-16 08:25:11 +01:00
HumblePresent 7d2a0ac661
fix: #18 escape pattern matching characters in directory names 2022-08-16 08:22:44 +01:00
HumblePresent 17ee9ed4e0
fix: #21 accurately detect git-enabled parent directories 2022-08-15 07:58:37 +01:00
HumblePresent 6ce6823643
fix: #18 Replace directory pattern match with exact match
* fix: #18 replace directory pattern match with exact match

* fix: #18 properly expand directory name
2022-08-13 10:58:03 +01:00
olimorris b70eb5317d feat: add before_source callback 2022-08-13 10:53:59 +01:00
olimorris 9be6183f96 fix: after_source callback 2022-08-13 10:38:02 +01:00
olimorris 7d3f977ae5 feat: #7 remove .vim extension in telescope 2022-07-13 09:27:46 +01:00
olimorris 2b7ab49f36 refactor: telescope extension 2022-07-13 09:27:14 +01:00
olimorris 459adba9dd feat: improve deleting sessions via telescope 2022-07-07 23:08:04 +01:00
olimorris 0ad729ee38 fix: #15 callbacks being incorrectly detected 2022-06-30 19:53:28 +01:00