Skip to content

Commit

Permalink
Various previewer fixes (#260)
Browse files Browse the repository at this point in the history
- Set env vars for previewer with set_env({ key = value } fix #228)
- Set pager for git previewes (default is GIT_PAGER=less so users can scroll see #253)
- Use less for people who don't have bat but less installed
- Reset less env to only '-RS' because '-X' will break scrolling(fix #253, thanks @eth3lbert)
- Scrolling for buffer previewer(thanks @tami5 for helping)
  - Also new function to create buffer previewers (which has scrolling by default). Used for tags and help_tags previewer.
- Add new setting set_env to readme
  • Loading branch information
Conni2461 authored Nov 22, 2020
1 parent 5513f85 commit 874139e
Show file tree
Hide file tree
Showing 3 changed files with 129 additions and 53 deletions.
60 changes: 31 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ with advanced features. It is written in `lua` and is built on top of latest
awesome features from `neovim` core. `Telescope.nvim` is centered around
modularity so much so that each picker is its own world, (meaning it can be
configured in isolation from other pickers, such presentation, algorithm,
mappings ... etc).
mappings ... etc).

`Telescope.nvim` was built with the intention of becoming a library, but it has long grown to
be much bigger than that. In addition to
Expand All @@ -23,7 +23,7 @@ growing number of community driven [built-in pickers](#built-in-pickers),
covering a wide range of use cases and tools, and offers a customizable user
interface.


<!-- You can read this documentation from start to finish, or you can look at the -->
<!-- outline and directly jump to the section that interests you most. -->

Expand All @@ -44,7 +44,7 @@ This section should guide to run your first built-in pickers :smile:
[Neovim Nightly (0.5)](https://github.com/neovim/neovim/releases/tag/nightly)
is required for `telescope.nvim` to work.

#### Optional dependences
#### Optional dependences
- [sharkdp/bat](https://github.com/sharkdp/bat) (preview)
- [sharkdp/fd](https://github.com/sharkdp/fd) (finder)
- [BurntSushi/ripgrep](https://github.com/BurntSushi/ripgrep) (finder)
Expand Down Expand Up @@ -72,7 +72,7 @@ call dein#add('nvim-telescope/telescope.nvim')
```
Using [packer.nvim](https://github.com/wbthomason/packer.nvim)

```lua
```lua
use {
'nvim-telescope/telescope.nvim',
requires = {{'nvim-lua/popup.nvim'}, {'nvim-lua/plenary.nvim'}}
Expand Down Expand Up @@ -108,7 +108,7 @@ This section should help you explore available options to configure and
customize your `telescope.nvim`.

Unlike most vim plugins, `telescope.nvim` can be customized either by applying
customizations globally or individual pre picker.
customizations globally or individual pre picker.

- **Global Customization** affecting all pickers can be done through the
main `setup()` method (see defaults below)
Expand All @@ -125,12 +125,12 @@ As an example of using the `setup()` method, the following code configures
require('telescope').setup{
defaults = {
vimgrep_arguments = {
'rg',
'--color=never',
'--no-heading',
'--with-filename',
'--line-number',
'--column',
'rg',
'--color=never',
'--no-heading',
'--with-filename',
'--line-number',
'--column',
'--smart-case'
},
prompt_position = "bottom",
Expand All @@ -154,6 +154,7 @@ require('telescope').setup{
borderchars = { '', '', '', '', '', '', '', ''},
color_devicons = true,
use_less = true,
set_env = { ['COLORTERM'] = 'truecolor' }, -- default { }, currently unsupported for shells like cmd.exe / powershell.exe
}
}
```
Expand Down Expand Up @@ -186,9 +187,10 @@ EOF
| `preview_cutoff` | TODO | NUM |
| `results_height` | TODO | NUM |
| `results_width` | TODO | NUM |
| `borderchars` | The border chars, it gives border telescope window | dict |
| `borderchars` | The border chars, it gives border telescope window | dict |
| `color_devicons` | Whether to color devicons or not | boolean |
| `use_less` | Whether to use less of cat/bat | boolean |
| `use_less` | Whether to use less with bat or less/cat if bat not installed | boolean |
| `set_env` | Set environment variables for previewer | dict |
| `scroll_strategy` | How to behave when the when there are no more item next/prev | cycle, nil |

#### Options affecting Sorting
Expand All @@ -198,8 +200,8 @@ EOF
| `file_sorter` | The sorter for file lists. | [Sorters](#built-in-sorters) |
| `generic_sorter` | The sorter for everything else. | [Sorters](#built-in-sorters) |
| `vimgrep_arguments` | The command line argument for grep search ... TODO. | dict |
| `selection_strategy` | What happens to the selection if the list changes. | follow/reset/row |
| `file_ignore_patterns` | Pattern to be ignored `{ "scratch/.*", "%.env"}` | dict |
| `selection_strategy` | What happens to the selection if the list changes. | follow/reset/row |
| `file_ignore_patterns` | Pattern to be ignored `{ "scratch/.*", "%.env"}` | dict |
| `shorten_path` | Whether to shorten paths or not. | boolean |

#### Mappings
Expand All @@ -222,7 +224,7 @@ Many familiar mapping patterns are setup as defaults.
| `<Esc>` | close telescope (in normal mode) |

To see the full list of mappings, check out `lua/telescope/mappings.lua` and
the `default_mappings` table.
the `default_mappings` table.


Much like [built-in pickers](#built-in-pickers), there are a number of
Expand Down Expand Up @@ -273,7 +275,7 @@ require('telescope').setup{
For a [picker](#built-in-pickers) specific remapping, it can be done by setting
its `attach_mappings` key to a function, like this

```lua
```lua
local actions = require('telescope.actions')
-- Picker specific remapping
------------------------------
Expand Down Expand Up @@ -382,7 +384,7 @@ Built-in function ready to be bound to any key you like :smile:.
| .................................. | Your next awesome finder function here :D |


#### Built-in Sorters
#### Built-in Sorters

| Sorters | Description |
|------------------------------------|-----------------------------------------------------------------|
Expand All @@ -406,7 +408,7 @@ return a number, which is equivalent to the "distance" between the current
## Built-in Themes

Common groups of settings can be set up to allow for themes.
We have some built in themes but are looking for more cool options.
We have some built in themes but are looking for more cool options.

| Themes | Description |
|--------------------------|-----------------------------------------------------------------------|
Expand All @@ -425,7 +427,7 @@ Themes should work with every `telescope.builtin` function. If you wish to
make theme, check out `lua/telescope/themes.lua`. If you need more features,
make an issue :).

## API
## API
<!-- TODO: need to provide working examples for every api -->

#### Finders
Expand All @@ -441,9 +443,9 @@ Finder:new{
```

#### Picker
<!-- TODO: this section need some love, an in-depth explanation will be appreciated it need some in depth explanation -->
<!-- TODO: this section need some love, an in-depth explanation will be appreciated it need some in depth explanation -->
<!-- TODO what is pickers -->
This section is an overview of how custom pickers can be created any configured.
This section is an overview of how custom pickers can be created any configured.


```lua
Expand Down Expand Up @@ -508,19 +510,19 @@ All `telescope.nvim` functions are wrapped in `vim` commands for easy access, it
supports tab completions and settings options.

```viml
" Tab completion
:Telescope |<tab>
" Tab completion
:Telescope |<tab>
:Telescope find_files
" Setting options
:Telescope find_files prompt_prefix=🔍
:Telescope find_files prompt_prefix=🔍
" If option is table type in lua code ,you can use `,` connect each command string eg:
" find_command,vimgrep_arguments they are both table type. so config it in commandline like
:Telecope find_files find_command=rg,--ignore,--hidden,--files prompt_prefix=🔍
```

## Media
## Media

- [What is Telescope? (Video)](https://www.twitch.tv/teej_dv/clip/RichDistinctPlumberPastaThat)
- [More advanced configuration (Video)](https://www.twitch.tv/videos/756229115)
Expand All @@ -533,11 +535,11 @@ supports tab completions and settings options.

All options available from the setup function (see [Configuration options]()) and
some other functions can be easily changed in custom pickers or built-in
functions.
functions.
<!-- TODO: insert a list of available options like previewer and prompt prefix -->

```lua
-- Disable preview for find files
```lua
-- Disable preview for find files
nnoremap <leader>ff :lua require('telescope.builtin').find_files({previewer = false})<CR>

-- Change change prompt prefix for find_files builtin function:
Expand Down
4 changes: 3 additions & 1 deletion lua/telescope/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,12 @@ function config.set_defaults(defaults)
set("use_less", true)
set("color_devicons", true)

set("set_env", {})

-- TODO: Add motions to keybindings

-- To disable a keymap, put [map] = false
-- So, to not map "<C-n>", just put
-- So, to not map "<C-n>", just put
--
-- ...,
-- ["<C-n>"] = false,
Expand Down
Loading

0 comments on commit 874139e

Please sign in to comment.