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 configmain
parent
4f46e4f1ba
commit
7890dadd6e
30
README.md
30
README.md
|
|
@ -1,3 +1,5 @@
|
||||||
|
<!-- panvimdoc-ignore-start -->
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<img src="https://user-images.githubusercontent.com/9512444/179085825-7c3bc1f7-c86b-4119-96e2-1a581e9bfffc.png" alt="Persisted.nvim" />
|
<img src="https://user-images.githubusercontent.com/9512444/179085825-7c3bc1f7-c86b-4119-96e2-1a581e9bfffc.png" alt="Persisted.nvim" />
|
||||||
</p>
|
</p>
|
||||||
|
|
@ -16,6 +18,8 @@
|
||||||
Forked from <a href="https://github.com/folke/persistence.nvim">Persistence.nvim</a> as active development had stopped
|
Forked from <a href="https://github.com/folke/persistence.nvim">Persistence.nvim</a> as active development had stopped
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<!-- panvimdoc-ignore-end -->
|
||||||
|
|
||||||
## :sparkles: Features
|
## :sparkles: Features
|
||||||
|
|
||||||
- Automatically saves the active session under `.local/share/nvim/sessions` on exiting Neovim
|
- Automatically saves the active session under `.local/share/nvim/sessions` on exiting Neovim
|
||||||
|
|
@ -80,6 +84,21 @@ Ensure that the telescope extension is loaded with:
|
||||||
require("telescope").load_extension("persisted")
|
require("telescope").load_extension("persisted")
|
||||||
```
|
```
|
||||||
|
|
||||||
|
The layout can then be customised from within Telescope:
|
||||||
|
|
||||||
|
```lua
|
||||||
|
require('telescope').setup({
|
||||||
|
defaults = {
|
||||||
|
…
|
||||||
|
},
|
||||||
|
extensions = {
|
||||||
|
persisted = {
|
||||||
|
layout_config = { width = 0.55, height = 0.55 }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
## :rocket: Usage
|
## :rocket: Usage
|
||||||
|
|
||||||
**Default commands**
|
**Default commands**
|
||||||
|
|
@ -100,8 +119,9 @@ The plugin comes with a number of commands:
|
||||||
The Telescope extension may be opened via `:Telescope persisted`.
|
The Telescope extension may be opened via `:Telescope persisted`.
|
||||||
|
|
||||||
Once opened, the available keymaps are:
|
Once opened, the available keymaps are:
|
||||||
* `<CR>` - Source the session file
|
|
||||||
* `<C-d>` - Delete the session file
|
- `<CR>` - Source the session file
|
||||||
|
- `<C-d>` - Delete the session file
|
||||||
|
|
||||||
**Statuslines**
|
**Statuslines**
|
||||||
|
|
||||||
|
|
@ -242,7 +262,7 @@ require("persisted").setup({
|
||||||
|
|
||||||
Specifying `~/Code` will autosave and autoload from that directory as well as all its sub-directories.
|
Specifying `~/Code` will autosave and autoload from that directory as well as all its sub-directories.
|
||||||
|
|
||||||
> **Note:** If `allowed_dirs` is left at its default value and `autosave` and/or `autoload` are set to `true`, then the plugin will autoload/autosave from *any* directory
|
> **Note:** If `allowed_dirs` is left at its default value and `autosave` and/or `autoload` are set to `true`, then the plugin will autoload/autosave from _any_ directory
|
||||||
|
|
||||||
### Ignored directories
|
### Ignored directories
|
||||||
|
|
||||||
|
|
@ -320,10 +340,14 @@ Finally, if you're using the excellent [Legendary.nvim](https://github.com/mrjon
|
||||||
|
|
||||||
### Telescope extension
|
### Telescope extension
|
||||||
|
|
||||||
|
<!-- panvimdoc-ignore-start -->
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<img src="https://user-images.githubusercontent.com/9512444/177375482-3bc9bd0d-42c8-4755-a36c-08ea5f954525.png" alt="Telescope">
|
<img src="https://user-images.githubusercontent.com/9512444/177375482-3bc9bd0d-42c8-4755-a36c-08ea5f954525.png" alt="Telescope">
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<!-- panvimdoc-ignore-end -->
|
||||||
|
|
||||||
The plugin contains an extension for [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim) which allows the user to list all of the saved session files and source them via `:Telescope persisted`.
|
The plugin contains an extension for [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim) which allows the user to list all of the saved session files and source them via `:Telescope persisted`.
|
||||||
|
|
||||||
## :page_with_curl: License
|
## :page_with_curl: License
|
||||||
|
|
|
||||||
|
|
@ -6,9 +6,11 @@ local action_state = require("telescope.actions.state")
|
||||||
local _actions = require("telescope._extensions.actions")
|
local _actions = require("telescope._extensions.actions")
|
||||||
local _finders = require("telescope._extensions.finders")
|
local _finders = require("telescope._extensions.finders")
|
||||||
|
|
||||||
|
local telescope_opts = {}
|
||||||
|
|
||||||
local function search_sessions(opts)
|
local function search_sessions(opts)
|
||||||
local utils = require("persisted.utils")
|
|
||||||
local config = require("persisted.config").options
|
local config = require("persisted.config").options
|
||||||
|
opts = vim.tbl_extend('force', telescope_opts, opts or {})
|
||||||
|
|
||||||
pickers
|
pickers
|
||||||
.new(opts, {
|
.new(opts, {
|
||||||
|
|
@ -39,6 +41,9 @@ local function search_sessions(opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
return require("telescope").register_extension({
|
return require("telescope").register_extension({
|
||||||
|
setup = function(topts)
|
||||||
|
telescope_opts = topts
|
||||||
|
end,
|
||||||
exports = {
|
exports = {
|
||||||
persisted = search_sessions,
|
persisted = search_sessions,
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue