docs: update README.md
parent
e2ae8b321e
commit
b0de69da63
24
README.md
24
README.md
|
|
@ -367,7 +367,7 @@ The plugin also comes with pre-defined highlight groups for the Telescope implem
|
||||||
|
|
||||||
The plugin has been designed to be fully extensible. All of the functions in the [init.lua](https://github.com/olimorris/persisted.nvim/blob/main/lua/persisted/init.lua) and [utils.lua](https://github.com/olimorris/persisted.nvim/blob/main/lua/persisted/utils.lua) file are public.
|
The plugin has been designed to be fully extensible. All of the functions in the [init.lua](https://github.com/olimorris/persisted.nvim/blob/main/lua/persisted/init.lua) and [utils.lua](https://github.com/olimorris/persisted.nvim/blob/main/lua/persisted/utils.lua) file are public.
|
||||||
|
|
||||||
Consider a user who wishes to autoload a session if arguments are passed to Neovim. A custom autocmd can be created which forces the autoload:
|
Consider a user who wishes to autoload a session if arguments are passed to Neovim. A custom autocmd can be created which forces the autoload (thanks to [neandrake](https://github.com/neandrake) for this solution):
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
local persisted = require("persisted")
|
local persisted = require("persisted")
|
||||||
|
|
@ -379,11 +379,25 @@ persisted.setup({
|
||||||
vim.api.nvim_create_autocmd("VimEnter", {
|
vim.api.nvim_create_autocmd("VimEnter", {
|
||||||
nested = true,
|
nested = true,
|
||||||
callback = function()
|
callback = function()
|
||||||
-- Add more complex logic here
|
if vim.g.started_with_stdin then
|
||||||
if vim.fn.argc() > 0 then
|
return
|
||||||
-- Leverage the plugin's ability to resolve allowed_dirs and ignored_dirs
|
|
||||||
require("persisted").autoload({ force = true })
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local forceload = false
|
||||||
|
if vim.fn.argc() == 0 then
|
||||||
|
forceload = true
|
||||||
|
elseif vim.fn.argc() == 1 then
|
||||||
|
local dir = vim.fn.expand(vim.fn.argv(0))
|
||||||
|
if dir == '.' then
|
||||||
|
dir = vim.fn.getcwd()
|
||||||
|
end
|
||||||
|
|
||||||
|
if vim.fn.isdirectory(dir) ~= 0 then
|
||||||
|
forceload = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
persisted.autoload({ force = forceload })
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
|
||||||
|
|
@ -388,7 +388,8 @@ and utils.lua
|
||||||
file are public.
|
file are public.
|
||||||
|
|
||||||
Consider a user who wishes to autoload a session if arguments are passed to
|
Consider a user who wishes to autoload a session if arguments are passed to
|
||||||
Neovim. A custom autocmd can be created which forces the autoload:
|
Neovim. A custom autocmd can be created which forces the autoload (thanks to
|
||||||
|
neandrake <https://github.com/neandrake> for this solution):
|
||||||
|
|
||||||
>lua
|
>lua
|
||||||
local persisted = require("persisted")
|
local persisted = require("persisted")
|
||||||
|
|
@ -400,11 +401,25 @@ Neovim. A custom autocmd can be created which forces the autoload:
|
||||||
vim.api.nvim_create_autocmd("VimEnter", {
|
vim.api.nvim_create_autocmd("VimEnter", {
|
||||||
nested = true,
|
nested = true,
|
||||||
callback = function()
|
callback = function()
|
||||||
-- Add more complex logic here
|
if vim.g.started_with_stdin then
|
||||||
if vim.fn.argc() > 0 then
|
return
|
||||||
-- Leverage the plugin's ability to resolve allowed_dirs and ignored_dirs
|
|
||||||
require("persisted").autoload({ force = true })
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local forceload = false
|
||||||
|
if vim.fn.argc() == 0 then
|
||||||
|
forceload = true
|
||||||
|
elseif vim.fn.argc() == 1 then
|
||||||
|
local dir = vim.fn.expand(vim.fn.argv(0))
|
||||||
|
if dir == '.' then
|
||||||
|
dir = vim.fn.getcwd()
|
||||||
|
end
|
||||||
|
|
||||||
|
if vim.fn.isdirectory(dir) ~= 0 then
|
||||||
|
forceload = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
persisted.autoload({ force = forceload })
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
<
|
<
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue