|
1 | 1 | <p align="center"> |
2 | | -A simple Telescope extension to manage Terminal buffers |
| 2 | +A Telescope extension to manage toggleterm's terminal buffers |
3 | 3 | </p> |
4 | 4 |
|
5 | 5 | ## ✨ Features |
6 | 6 |
|
7 | | -- List and switch between all terminal buffers opened with `toggleterm.nvim`. |
8 | | -- Kill terminal buffers easily with keybindings. |
9 | | -- Open buffer picker with `:Telescope toggleterm` |
| 7 | +- List and switch between all terminal buffers opened with `toggleterm.nvim` |
| 8 | +- Easily customize the appearance of the Telescope window |
| 9 | +- Map pre-defined actions to keybindings |
| 10 | +- Open buffer picker with `:Telescope toggleterm_manager` |
10 | 11 | or `lua require('telescope-toggleterm').open()` |
11 | 12 |
|
12 | 13 | ## ⚡ Requirements |
13 | 14 |
|
14 | 15 | - [`telescope`](https://github.com/nvim-telescope/telescope.nvim) plugin. |
15 | 16 | - [`nvim-toggleterm`](https://github.com/akinsho/nvim-toggleterm.lua) plugin. |
16 | 17 |
|
17 | | -## 🛠️ Installation |
18 | | -Using [ `lazy.nvim` ](https://github.com/folke/lazy.nvim) in lua: |
| 18 | +## 🛠️ Quickstart |
| 19 | + |
| 20 | +Install using [ `lazy.nvim` ](https://github.com/folke/lazy.nvim) in lua: |
| 21 | + |
19 | 22 | ```lua |
20 | 23 | { |
21 | | - "ryanmsnyder/telescope-toggleterm.nvim", |
| 24 | + "ryanmsnyder/toggleterm-manager.nvim", |
22 | 25 | event = "TermOpen", |
23 | 26 | dependencies = { |
24 | 27 | "akinsho/nvim-toggleterm.lua", |
25 | 28 | "nvim-telescope/telescope.nvim", |
26 | 29 | "nvim-lua/popup.nvim", |
27 | 30 | "nvim-lua/plenary.nvim", |
28 | 31 | }, |
29 | | - config = function() |
30 | | - require("telescope").load_extension "toggleterm" |
31 | | - end, |
| 32 | + config = require("toggleterm-manager").setup() |
32 | 33 | } |
33 | 34 | ``` |
34 | 35 |
|
| 36 | +Open `toggleterm-manager` by either: |
| 37 | +- running the command `:Telescope toggleterm_manager` |
| 38 | +- calling `lua require('toggleterm-manager').open()` |
| 39 | + |
| 40 | +Keep reading if you want to change the default configuration. |
| 41 | + |
35 | 42 | ## ⚙️ Configuration |
36 | 43 |
|
| 44 | +### Defaults |
| 45 | + |
| 46 | +By default, the below table is passed to the `setup` function: |
| 47 | + |
37 | 48 | ```lua |
38 | | -require("telescope-toggleterm").setup { |
39 | | - mappings = { |
40 | | - -- <ctrl-c> : kill the terminal buffer (default) . |
41 | | - ["<C-c>"] = require("telescope-toggleterm").actions.exit_terminal, |
42 | | - }, |
| 49 | +{ |
| 50 | + mappings = {}, -- key mappings bound inside the telescope window |
| 51 | + telescope_titles = { |
| 52 | + preview = "Preview", -- title of the preview buffer in telescope |
| 53 | + prompt = " Pick Term", -- title of the prompt buffer in telescope |
| 54 | + results = "Results", -- title of the results buffer in telescope |
| 55 | + }, |
| 56 | + results = { |
| 57 | + fields = { |
| 58 | + "state", |
| 59 | + "space", |
| 60 | + "term_icon", |
| 61 | + "term_name", |
| 62 | + }, |
| 63 | + separator = " ", -- the character that will be used to separate each field provided in results_format |
| 64 | + term_icon = "", -- the icon that will be used for the term_icon in results_format |
| 65 | + |
| 66 | + }, |
| 67 | + search = { |
| 68 | + field = "term_name" -- the field that telescope fuzzy search will use |
| 69 | + }, |
| 70 | + sort = { |
| 71 | + field = "term_name", -- the field that will be used for sorting in the telesocpe results |
| 72 | + ascending = true, -- whether or not the field provided above will be sorted in ascending or descending order |
| 73 | + }, |
43 | 74 | } |
44 | 75 | ``` |
45 | 76 |
|
| 77 | +| Property | Type | Default Value | Description | |
| 78 | +|--------------------|--------------------------------|---------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| |
| 79 | +| **mappings** | `table` | | A table of key mappings for different modes. Each mode (like 'i' for insert mode, 'n' for normal mode) is a key in the table and maps to another table, where the key is the key combination (e.g., "<CR>") and the value is a table with the fields 'action' and 'exit_on_action'. The 'action' field is a function that will be called when the key combination is pressed, and 'exit_on_action' is a boolean that determines whether telescope should be exited after the action is performed. | |
| 80 | +| **telescope_titles.preview** | `string` | "Preview" | Title of the preview buffer in telescope. Any string. | |
| 81 | +| **telescope_titles.prompt** | `string` | " Pick Term" | Title of the prompt buffer in telescope. Any string. | |
| 82 | +| **telescope_titles.results** | `string` | "Results" | Title of the results buffer in telescope. Any string. | |
| 83 | +| **results.separator** | `string` | " " | The character used to separate each field in `results_format`. Any string, though a space character and a pipe character are the most commonly used. | |
| 84 | +| **results.fields** | `{string\|{string, string}}[]` | { "state", "space", "term_icon", "term_name", } | The format and order of the results displayed in the telescope buffer. This accepts a table where each element is either: an acceptable string a table of tuple-like tables where the first value in the tuple is one of the acceptable strings and the second is a valid NeoVim highlight group that the column should adhere to. The acceptable strings are: `bufname`, `bufnr`, `space`, `state`, `term_name`, `term_icon`. See results_format for more info. | |
| 85 | +| **results.term_icon** | `string` | "" | The icon used for `term_icon` in `results_format`. Any string. | |
| 86 | +| **search.field** | `string` | "term_name" | The field that telescope's fuzzy search will use. Doesn't need to be a value provided in `results_format`. Valid strings are: `bufname`, `bufnr`, `state`, `term_name`. | |
| 87 | +| **sort.field** | `table` | "term_name" | The field that will be used for sorting the results in telescope. Doesn't need to be a value provided in `results_format`. Valid strings are: `bufnr`, `recency`, `state`, `term_name`. | |
| 88 | +| **sort.ascending** | `boolean` | true | Determines the order used for sorting the telescope results. `true` = ascending, `false` = descending. | |
| 89 | + |
| 90 | + |
| 91 | +### `results_format` |
46 | 92 |
|
| 93 | +This propery allows for easy customization of how the terminal buffers appear in the telescope window. |
0 commit comments