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

Updated nvim_echo to instead use vim.notify #108

Merged
merged 2 commits into from
Jan 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 4 additions & 10 deletions doc/persisted.nvim.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ Table of Contents *persisted.nvim-table-of-contents*

FEATURES *persisted.nvim-features*


- Supports sessions across multiple git branches
- Telescope extension to work with saved sessions
- Custom events which users can hook into for tighter integration
Expand All @@ -23,7 +22,6 @@ FEATURES *persisted.nvim-features*

REQUIREMENTS *persisted.nvim-requirements*


- Neovim >= 0.8.0


Expand Down Expand Up @@ -60,7 +58,7 @@ Install the plugin with your preferred package manager:
>vim
" Vim Script
Plug 'olimorris/persisted.nvim'

lua << EOF
require("persisted").setup {
-- your configuration comes here
Expand Down Expand Up @@ -107,7 +105,6 @@ COMMANDS ~

The plugin comes with a number of commands:


- `:SessionToggle` - Determines whether to load, start or stop a session
- `:SessionStart` - Start recording a session. Useful if `autosave = false`
- `:SessionStop` - Stop recording a session
Expand All @@ -123,7 +120,6 @@ TELESCOPE EXTENSION ~
The Telescope extension may be opened via `:Telescope persisted`. The available
actions are:


- `<CR>` - Open/source the session file
- `<C-b>` - Add/update the git branch for the session file
- `<C-c>` - Copy the session file
Expand All @@ -134,7 +130,6 @@ GLOBAL VARIABLES ~

The plugin sets a number of global variables throughout its lifecycle:


- `vim.g.persisting` - (bool) Determines if the plugin is active for the current session
- `vim.g.persisted_exists` - (bool) Determines if a session exists for the current working directory
- `vim.g.persisted_loaded_session` - (string) The file path to the current session
Expand Down Expand Up @@ -171,7 +166,7 @@ WHAT IS SAVED IN THE SESSION? ~

As the plugin uses Vim’s `:mksession` command then you may change the
`vim.o.sessionoptions` value to determine what to write into the session.
Please see `:h sessionoptions` for more information.
Please see |sessionoptions| for more information.


**Note**The author uses: `vim.o.sessionoptions =
Expand Down Expand Up @@ -356,7 +351,6 @@ EVENTS / CALLBACKS ~

The plugin fires events at various points during its lifecycle:


- `PersistedLoadPre` - For _before_ a session is loaded
- `PersistedLoadPost` - For _after_ a session is loaded
- `PersistedTelescopeLoadPre` - For _before_ a session is loaded via Telescope
Expand All @@ -379,14 +373,14 @@ session, saving the current session before clearing all of the open buffers:

>lua
local group = vim.api.nvim_create_augroup("PersistedHooks", {})

vim.api.nvim_create_autocmd({ "User" }, {
pattern = "PersistedTelescopeLoadPre",
group = group,
callback = function(session)
-- Save the currently loaded session using a global variable
require("persisted").save({ session = vim.g.persisted_loaded_session })

-- Delete all of the open buffers
vim.api.nvim_input("<ESC>:%bd!<CR>")
end,
Expand Down
17 changes: 8 additions & 9 deletions lua/persisted/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,14 @@ function M.get_branch(dir)
if vim.fn.filereadable(branch_session) ~= 0 then
return branch
else
vim.api.nvim_echo({
{ "[Persisted.nvim]\n", "Question" },
{ "Could not load a session for branch " },
{ git_branch[1] .. "\n", "WarningMsg" },
{ "Trying to load a session for branch " },
{ config.options.default_branch, "Title" },
{ " ..." },
}, true, {})

vim.notify(
string.format("[Persisted.nvim]: Trying to load a session for branch %s", config.options.default_branch),
vim.log.levels.INFO
)
vim.notify(
string.format("[Persisted.nvim]: Could not load a session for branch %s.", git_branch[1]),
vim.log.levels.WARN
)
vim.g.persisted_branch_session = branch_session
return config.options.branch_separator .. config.options.default_branch
end
Expand Down
2 changes: 1 addition & 1 deletion lua/persisted/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ local fp_sep = vim.loop.os_uname().sysname:lower():match("windows") and "\\" or
--@return string
local function echoerr(msg, error)
vim.api.nvim_echo({
{ "[persisted.nvim]: ", "ErrorMsg" },
{ "[Persisted.nvim]: ", "ErrorMsg" },
{ msg, "WarningMsg" },
{ error, "Normal" },
}, true, {})
Expand Down
Loading