mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-03-13 02:05:40 +08:00
chore(telescope): update telescope to 0.1.2
This commit is contained in:
parent
9be79c8e5a
commit
a7194fbafa
34
bundle/telescope.nvim/.github/workflows/ci.yml
vendored
34
bundle/telescope.nvim/.github/workflows/ci.yml
vendored
@ -10,30 +10,38 @@ jobs:
|
|||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- os: ubuntu-20.04
|
- os: ubuntu-22.04
|
||||||
url: https://github.com/neovim/neovim/releases/download/nightly/nvim-linux64.tar.gz
|
rev: nightly/nvim-linux64.tar.gz
|
||||||
manager: sudo apt-get
|
manager: sudo apt-get
|
||||||
packages: -y ripgrep
|
packages: -y ripgrep
|
||||||
- os: ubuntu-20.04
|
- os: ubuntu-22.04
|
||||||
url: https://github.com/neovim/neovim/releases/download/v0.7.0/nvim-linux64.tar.gz
|
rev: v0.7.2/nvim-linux64.tar.gz
|
||||||
manager: sudo apt-get
|
manager: sudo apt-get
|
||||||
packages: -y ripgrep
|
packages: -y ripgrep
|
||||||
- os: macos-10.15
|
- os: ubuntu-22.04
|
||||||
url: https://github.com/neovim/neovim/releases/download/nightly/nvim-macos.tar.gz
|
rev: v0.8.1/nvim-linux64.tar.gz
|
||||||
|
manager: sudo apt-get
|
||||||
|
packages: -y ripgrep
|
||||||
|
- os: macos-12
|
||||||
|
rev: nightly/nvim-macos.tar.gz
|
||||||
manager: brew
|
manager: brew
|
||||||
packages: ripgrep
|
packages: ripgrep
|
||||||
- os: macos-10.15
|
- os: macos-12
|
||||||
url: https://github.com/neovim/neovim/releases/download/v0.7.0/nvim-macos.tar.gz
|
rev: v0.7.2/nvim-macos.tar.gz
|
||||||
|
manager: brew
|
||||||
|
packages: ripgrep
|
||||||
|
- os: macos-12
|
||||||
|
rev: v0.8.1/nvim-macos.tar.gz
|
||||||
manager: brew
|
manager: brew
|
||||||
packages: ripgrep
|
packages: ripgrep
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- run: date +%F > todays-date
|
- run: date +%F > todays-date
|
||||||
- name: Restore from todays cache
|
- name: Restore from todays cache
|
||||||
uses: actions/cache@v2
|
uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
path: _neovim
|
path: _neovim
|
||||||
key: ${{ runner.os }}-${{ matrix.url }}-${{ hashFiles('todays-date') }}
|
key: ${{ runner.os }}-${{ matrix.rev }}-${{ hashFiles('todays-date') }}
|
||||||
|
|
||||||
- name: Prepare
|
- name: Prepare
|
||||||
run: |
|
run: |
|
||||||
@ -41,11 +49,11 @@ jobs:
|
|||||||
${{ matrix.manager }} install ${{ matrix.packages }}
|
${{ matrix.manager }} install ${{ matrix.packages }}
|
||||||
test -d _neovim || {
|
test -d _neovim || {
|
||||||
mkdir -p _neovim
|
mkdir -p _neovim
|
||||||
curl -sL ${{ matrix.url }} | tar xzf - --strip-components=1 -C "${PWD}/_neovim"
|
curl -sL "https://github.com/neovim/neovim/releases/download/${{ matrix.rev }}" | tar xzf - --strip-components=1 -C "${PWD}/_neovim"
|
||||||
}
|
}
|
||||||
mkdir -p ~/.local/share/nvim/site/pack/vendor/start
|
mkdir -p ~/.local/share/nvim/site/pack/vendor/start
|
||||||
git clone --depth 1 https://github.com/nvim-lua/plenary.nvim ~/.local/share/nvim/site/pack/vendor/start/plenary.nvim
|
git clone --depth 1 https://github.com/nvim-lua/plenary.nvim ~/.local/share/nvim/site/pack/vendor/start/plenary.nvim
|
||||||
git clone --depth 1 https://github.com/kyazdani42/nvim-web-devicons ~/.local/share/nvim/site/pack/vendor/start/nvim-web-devicons
|
git clone --depth 1 https://github.com/nvim-tree/nvim-web-devicons ~/.local/share/nvim/site/pack/vendor/start/nvim-web-devicons
|
||||||
ln -s $(pwd) ~/.local/share/nvim/site/pack/vendor/start
|
ln -s $(pwd) ~/.local/share/nvim/site/pack/vendor/start
|
||||||
|
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
|
@ -13,13 +13,13 @@ jobs:
|
|||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- os: ubuntu-20.04
|
- os: ubuntu-22.04
|
||||||
url: https://github.com/neovim/neovim/releases/download/nightly/nvim-linux64.tar.gz
|
url: https://github.com/neovim/neovim/releases/download/nightly/nvim-linux64.tar.gz
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- run: date +%F > todays-date
|
- run: date +%F > todays-date
|
||||||
- name: Restore cache for today's nightly.
|
- name: Restore cache for today's nightly.
|
||||||
uses: actions/cache@v2
|
uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
path: _neovim
|
path: _neovim
|
||||||
key: ${{ runner.os }}-${{ matrix.url }}-${{ hashFiles('todays-date') }}
|
key: ${{ runner.os }}-${{ matrix.url }}-${{ hashFiles('todays-date') }}
|
||||||
@ -32,13 +32,14 @@ jobs:
|
|||||||
}
|
}
|
||||||
mkdir -p ~/.local/share/nvim/site/pack/vendor/start
|
mkdir -p ~/.local/share/nvim/site/pack/vendor/start
|
||||||
git clone --depth 1 https://github.com/nvim-lua/plenary.nvim ~/.local/share/nvim/site/pack/vendor/start/plenary.nvim
|
git clone --depth 1 https://github.com/nvim-lua/plenary.nvim ~/.local/share/nvim/site/pack/vendor/start/plenary.nvim
|
||||||
git clone --depth 1 https://github.com/tjdevries/tree-sitter-lua ~/.local/share/nvim/site/pack/vendor/start/tree-sitter-lua
|
git clone https://github.com/tjdevries/tree-sitter-lua ~/.local/share/nvim/site/pack/vendor/start/tree-sitter-lua
|
||||||
ln -s $(pwd) ~/.local/share/nvim/site/pack/vendor/start
|
ln -s $(pwd) ~/.local/share/nvim/site/pack/vendor/start
|
||||||
|
|
||||||
- name: Build parser
|
- name: Build parser
|
||||||
run: |
|
run: |
|
||||||
# We have to build the parser every single time to keep up with parser changes
|
# We have to build the parser every single time to keep up with parser changes
|
||||||
cd ~/.local/share/nvim/site/pack/vendor/start/tree-sitter-lua
|
cd ~/.local/share/nvim/site/pack/vendor/start/tree-sitter-lua
|
||||||
|
git checkout 86f74dfb69c570f0749b241f8f5489f8f50adbea
|
||||||
make dist
|
make dist
|
||||||
cd -
|
cd -
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ jobs:
|
|||||||
name: Luacheck
|
name: Luacheck
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-20.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Prepare
|
- name: Prepare
|
||||||
run: |
|
run: |
|
||||||
@ -22,9 +22,10 @@ jobs:
|
|||||||
name: stylua
|
name: stylua
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-20.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- uses: JohnnyMorganz/stylua-action@v1
|
- uses: JohnnyMorganz/stylua-action@v3
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
version: latest
|
||||||
# CLI arguments
|
# CLI arguments
|
||||||
args: --color always --check lua/
|
args: --color always --check lua/
|
||||||
|
29
bundle/telescope.nvim/.github/workflows/release.yml
vendored
Normal file
29
bundle/telescope.nvim/.github/workflows/release.yml
vendored
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
name: "release"
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- '*'
|
||||||
|
jobs:
|
||||||
|
luarocks-upload:
|
||||||
|
runs-on: ubuntu-22.04
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: LuaRocks Upload
|
||||||
|
uses: nvim-neorocks/luarocks-tag-release@v1.0.2
|
||||||
|
env:
|
||||||
|
LUAROCKS_API_KEY: ${{ secrets.LUAROCKS_API_KEY }}
|
||||||
|
with:
|
||||||
|
summary: "Find, Filter, Preview, Pick. All lua, all the time."
|
||||||
|
detailed_description: |
|
||||||
|
A highly extendable fuzzy finder over lists.
|
||||||
|
Built on the latest awesome features from neovim core.
|
||||||
|
Telescope is centered around modularity, allowing for easy customization.
|
||||||
|
dependencies: |
|
||||||
|
plenary.nvim
|
||||||
|
copy_directories: |
|
||||||
|
doc
|
||||||
|
ftplugin
|
||||||
|
plugin
|
||||||
|
scripts
|
||||||
|
autoload
|
||||||
|
data
|
9
bundle/telescope.nvim/.luacheckrc
vendored
9
bundle/telescope.nvim/.luacheckrc
vendored
@ -17,10 +17,17 @@ globals = {
|
|||||||
"TelescopeGlobalState",
|
"TelescopeGlobalState",
|
||||||
"_TelescopeConfigurationValues",
|
"_TelescopeConfigurationValues",
|
||||||
"_TelescopeConfigurationPickers",
|
"_TelescopeConfigurationPickers",
|
||||||
"__TelescopeKeymapStore",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Global objects defined by the C code
|
-- Global objects defined by the C code
|
||||||
read_globals = {
|
read_globals = {
|
||||||
"vim",
|
"vim",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
files = {
|
||||||
|
["lua/telescope/builtin/init.lua"] = {
|
||||||
|
ignore = {
|
||||||
|
"631", -- allow line len > 120
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
45
bundle/telescope.nvim/README.md
vendored
45
bundle/telescope.nvim/README.md
vendored
@ -1,6 +1,7 @@
|
|||||||
# telescope.nvim
|
# telescope.nvim
|
||||||
|
|
||||||
[](https://gitter.im/nvim-telescope/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
|
[](https://gitter.im/nvim-telescope/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
|
||||||
|
[](https://luarocks.org/modules/Conni2461/telescope.nvim)
|
||||||
|
|
||||||
Gaze deeply into unknown regions using the power of the moon.
|
Gaze deeply into unknown regions using the power of the moon.
|
||||||
|
|
||||||
@ -51,7 +52,7 @@ latest neovim nightly commit is required for `telescope.nvim` to work.
|
|||||||
### Suggested dependencies
|
### Suggested dependencies
|
||||||
|
|
||||||
- [BurntSushi/ripgrep](https://github.com/BurntSushi/ripgrep) is required for
|
- [BurntSushi/ripgrep](https://github.com/BurntSushi/ripgrep) is required for
|
||||||
`live_grep` and `grep_string` and is the first priority for `find_files`.
|
`live_grep` and `grep_string`
|
||||||
|
|
||||||
We also suggest you install one native telescope sorter to significantly improve
|
We also suggest you install one native telescope sorter to significantly improve
|
||||||
sorting performance. Take a look at either
|
sorting performance. Take a look at either
|
||||||
@ -67,7 +68,7 @@ wiki.
|
|||||||
- [sharkdp/fd](https://github.com/sharkdp/fd) (finder)
|
- [sharkdp/fd](https://github.com/sharkdp/fd) (finder)
|
||||||
- [nvim-treesitter/nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter) (finder/preview)
|
- [nvim-treesitter/nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter) (finder/preview)
|
||||||
- [neovim LSP]( https://neovim.io/doc/user/lsp.html) (picker)
|
- [neovim LSP]( https://neovim.io/doc/user/lsp.html) (picker)
|
||||||
- [devicons](https://github.com/kyazdani42/nvim-web-devicons) (icons)
|
- [devicons](https://github.com/nvim-tree/nvim-web-devicons) (icons)
|
||||||
|
|
||||||
### Installation
|
### Installation
|
||||||
|
|
||||||
@ -82,7 +83,7 @@ Using [vim-plug](https://github.com/junegunn/vim-plug)
|
|||||||
|
|
||||||
```viml
|
```viml
|
||||||
Plug 'nvim-lua/plenary.nvim'
|
Plug 'nvim-lua/plenary.nvim'
|
||||||
Plug 'nvim-telescope/telescope.nvim', { 'tag': '0.1.0' }
|
Plug 'nvim-telescope/telescope.nvim', { 'tag': '0.1.1' }
|
||||||
" or , { 'branch': '0.1.x' }
|
" or , { 'branch': '0.1.x' }
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -90,19 +91,37 @@ Using [dein](https://github.com/Shougo/dein.vim)
|
|||||||
|
|
||||||
```viml
|
```viml
|
||||||
call dein#add('nvim-lua/plenary.nvim')
|
call dein#add('nvim-lua/plenary.nvim')
|
||||||
call dein#add('nvim-telescope/telescope.nvim', { 'rev': '0.1.0' })
|
call dein#add('nvim-telescope/telescope.nvim', { 'rev': '0.1.1' })
|
||||||
" or , { 'rev': '0.1.x' })
|
" or , { 'rev': '0.1.x' })
|
||||||
```
|
```
|
||||||
Using [packer.nvim](https://github.com/wbthomason/packer.nvim)
|
Using [packer.nvim](https://github.com/wbthomason/packer.nvim)
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
use {
|
use {
|
||||||
'nvim-telescope/telescope.nvim', tag = '0.1.0',
|
'nvim-telescope/telescope.nvim', tag = '0.1.1',
|
||||||
-- or , branch = '0.1.x',
|
-- or , branch = '0.1.x',
|
||||||
requires = { {'nvim-lua/plenary.nvim'} }
|
requires = { {'nvim-lua/plenary.nvim'} }
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Using [lazy.nvim](https://github.com/folke/lazy.nvim)
|
||||||
|
|
||||||
|
```lua
|
||||||
|
-- init.lua:
|
||||||
|
{
|
||||||
|
'nvim-telescope/telescope.nvim', tag = '0.1.1',
|
||||||
|
-- or , branch = '0.1.1',
|
||||||
|
dependencies = { 'nvim-lua/plenary.nvim' }
|
||||||
|
}
|
||||||
|
|
||||||
|
-- plugins/telescope.lua:
|
||||||
|
return {
|
||||||
|
'nvim-telescope/telescope.nvim', tag = '0.1.1',
|
||||||
|
-- or , branch = '0.1.1',
|
||||||
|
dependencies = { 'nvim-lua/plenary.nvim' }
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
### checkhealth
|
### checkhealth
|
||||||
|
|
||||||
Make sure you call `:checkhealth telescope` after installing telescope to ensure
|
Make sure you call `:checkhealth telescope` after installing telescope to ensure
|
||||||
@ -279,12 +298,12 @@ Built-in functions. Ready to be bound to any key you like.
|
|||||||
|
|
||||||
### File Pickers
|
### File Pickers
|
||||||
|
|
||||||
| Functions | Description |
|
| Functions | Description |
|
||||||
|-------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------|
|
|-------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||||
| `builtin.find_files` | Lists files in your current working directory, respects .gitignore |
|
| `builtin.find_files` | Lists files in your current working directory, respects .gitignore |
|
||||||
| `builtin.git_files` | Fuzzy search through the output of `git ls-files` command, respects .gitignore |
|
| `builtin.git_files` | Fuzzy search through the output of `git ls-files` command, respects .gitignore |
|
||||||
| `builtin.grep_string` | Searches for the string under your cursor in your current working directory |
|
| `builtin.grep_string` | Searches for the string under your cursor in your current working directory |
|
||||||
| `builtin.live_grep` | Search for a string in your current working directory and get results live as you type, respects .gitignore |
|
| `builtin.live_grep` | Search for a string in your current working directory and get results live as you type, respects .gitignore. (Requires [ripgrep](https://github.com/BurntSushi/ripgrep)) |
|
||||||
|
|
||||||
### Vim Pickers
|
### Vim Pickers
|
||||||
|
|
||||||
@ -338,7 +357,7 @@ Built-in functions. Ready to be bound to any key you like.
|
|||||||
|-------------------------------------|------------------------------------------------------------------------------------------------------------|
|
|-------------------------------------|------------------------------------------------------------------------------------------------------------|
|
||||||
| `builtin.git_commits` | Lists git commits with diff preview, checkout action `<cr>`, reset mixed `<C-r>m`, reset soft `<C-r>s` and reset hard `<C-r>h` |
|
| `builtin.git_commits` | Lists git commits with diff preview, checkout action `<cr>`, reset mixed `<C-r>m`, reset soft `<C-r>s` and reset hard `<C-r>h` |
|
||||||
| `builtin.git_bcommits` | Lists buffer's git commits with diff preview and checks them out on `<cr>` |
|
| `builtin.git_bcommits` | Lists buffer's git commits with diff preview and checks them out on `<cr>` |
|
||||||
| `builtin.git_branches` | Lists all branches with log preview, checkout action `<cr>`, track action `<C-t>` and rebase action`<C-r>` |
|
| `builtin.git_branches` | Lists all branches with log preview, checkout action `<cr>`, track action `<C-t>`, rebase action`<C-r>`, create action `<C-a>`, switch action `<C-s>`, delete action `<C-d>` and merge action `<C-y>` |
|
||||||
| `builtin.git_status` | Lists current changes per file with diff preview and add action. (Multi-selection still WIP) |
|
| `builtin.git_status` | Lists current changes per file with diff preview and add action. (Multi-selection still WIP) |
|
||||||
| `builtin.git_stash` | Lists stash items in current repository with ability to apply them on `<cr>` |
|
| `builtin.git_stash` | Lists stash items in current repository with ability to apply them on `<cr>` |
|
||||||
|
|
||||||
@ -524,7 +543,7 @@ Telescope user autocmds:
|
|||||||
## Extensions
|
## Extensions
|
||||||
|
|
||||||
Telescope provides the capabilities to create & register extensions, which
|
Telescope provides the capabilities to create & register extensions, which
|
||||||
improve telescope in a variety of ways.
|
improves telescope in a variety of ways.
|
||||||
|
|
||||||
Some extensions provide integration with external tools, outside of the scope of
|
Some extensions provide integration with external tools, outside of the scope of
|
||||||
`builtins`. Others provide performance enhancements by using compiled C and
|
`builtins`. Others provide performance enhancements by using compiled C and
|
||||||
|
2
bundle/telescope.nvim/developers.md
vendored
2
bundle/telescope.nvim/developers.md
vendored
@ -264,7 +264,7 @@ find results and call `entry_maker` for each entry. An example usage would be
|
|||||||
`find`.
|
`find`.
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
finder = finders.new_oneshot_job({ "find" }, opts ),
|
finder = finders.new_oneshot_job { "find", opts },
|
||||||
```
|
```
|
||||||
|
|
||||||
### More examples
|
### More examples
|
||||||
|
354
bundle/telescope.nvim/doc/telescope.txt
vendored
354
bundle/telescope.nvim/doc/telescope.txt
vendored
@ -6,9 +6,9 @@ filter, find and pick things in Lua.
|
|||||||
|
|
||||||
Getting started with telescope:
|
Getting started with telescope:
|
||||||
1. Run `:checkhealth telescope` to make sure everything is installed.
|
1. Run `:checkhealth telescope` to make sure everything is installed.
|
||||||
2. Evaluate it working with `:Telescope find_files` or `:lua
|
2. Evaluate it is working with `:Telescope find_files` or `:lua
|
||||||
require("telescope.builtin").find_files()`
|
require("telescope.builtin").find_files()`
|
||||||
3. Put a `require("telescope").setup() call somewhere in your neovim config.
|
3. Put a `require("telescope").setup()` call somewhere in your neovim config.
|
||||||
4. Read |telescope.setup| to check what config keys are available and what
|
4. Read |telescope.setup| to check what config keys are available and what
|
||||||
you can put inside the setup call
|
you can put inside the setup call
|
||||||
5. Read |telescope.builtin| to check which builtin pickers are offered and
|
5. Read |telescope.builtin| to check which builtin pickers are offered and
|
||||||
@ -24,14 +24,14 @@ The below flow chart illustrates a simplified telescope architecture:
|
|||||||
│ │ ┌───│Manager│────│ Sorter │┐ └───┬───* │
|
│ │ ┌───│Manager│────│ Sorter │┐ └───┬───* │
|
||||||
│ ▼ ▼ └───────* └────────┘│ │ │
|
│ ▼ ▼ └───────* └────────┘│ │ │
|
||||||
│ 1────────┐ 2───┴──┐ │ │
|
│ 1────────┐ 2───┴──┐ │ │
|
||||||
│ ┌─────│ Picker │ │Finder│◄────┘ │
|
│ ┌─────│ Picker │ │Finder│◀────┘ │
|
||||||
│ ▼ └───┬────┘ └──────* │
|
│ ▼ └───┬────┘ └──────* │
|
||||||
│ ┌────────┐ │ 3────────+ ▲ │
|
│ ┌────────┐ │ 3────────+ ▲ │
|
||||||
│ │Selected│ └───────│ Prompt │─────────┘ │
|
│ │Selected│ └───────│ Prompt │─────────┘ │
|
||||||
│ │ Entry │ └───┬────┘ │
|
│ │ Entry │ └───┬────┘ │
|
||||||
│ └────────* ┌───┴────┐ ┌────────┐ ┌────────┐ │
|
│ └────────* ┌───┴────┐ ┌────────┐ ┌────────┐ │
|
||||||
│ │ ▲ 4─────────┐│ Prompt │ │(Attach)│ │Actions │ │
|
│ │ ▲ 4─────────┐│ Prompt │ │(Attach)│ │Actions │ │
|
||||||
│ ▼ └──► │ Results ││ Buffer │◄─┤Mappings│◄─┤User Fn │ │
|
│ ▼ └──▶ │ Results ││ Buffer │◀─┤Mappings│◀─┤User Fn │ │
|
||||||
│5─────────┐ └─────────┘└────────┘ └────────┘ └────────┘ │
|
│5─────────┐ └─────────┘└────────┘ └────────┘ └────────┘ │
|
||||||
││Previewer│ │
|
││Previewer│ │
|
||||||
│└─────────┘ telescope.nvim architecture │
|
│└─────────┘ telescope.nvim architecture │
|
||||||
@ -192,13 +192,13 @@ telescope.setup({opts}) *telescope.setup()*
|
|||||||
|
|
||||||
*telescope.defaults.cycle_layout_list*
|
*telescope.defaults.cycle_layout_list*
|
||||||
cycle_layout_list: ~
|
cycle_layout_list: ~
|
||||||
Determines the layouts to cycle through when using `actions.cycle_layout_next`
|
Determines the layouts to cycle through when using `actions.layout.cycle_layout_next`
|
||||||
and `actions.cycle_layout_prev`.
|
and `actions.layout.cycle_layout_prev`.
|
||||||
Should be a list of "layout setups".
|
Should be a list of "layout setups".
|
||||||
Each "layout setup" can take one of two forms:
|
Each "layout setup" can take one of two forms:
|
||||||
1. string <br>
|
1. string
|
||||||
This is interpreted as the name of a `layout_strategy`
|
This is interpreted as the name of a `layout_strategy`
|
||||||
2. table <br>
|
2. table
|
||||||
A table with possible keys `layout_strategy`, `layout_config` and `previewer`
|
A table with possible keys `layout_strategy`, `layout_config` and `previewer`
|
||||||
|
|
||||||
Default: { "horizontal", "vertical" }
|
Default: { "horizontal", "vertical" }
|
||||||
@ -227,7 +227,6 @@ telescope.setup({opts}) *telescope.setup()*
|
|||||||
selection_caret: ~
|
selection_caret: ~
|
||||||
The character(s) that will be shown in front of the current selection.
|
The character(s) that will be shown in front of the current selection.
|
||||||
|
|
||||||
|
|
||||||
Default: '> '
|
Default: '> '
|
||||||
|
|
||||||
*telescope.defaults.entry_prefix*
|
*telescope.defaults.entry_prefix*
|
||||||
@ -260,7 +259,7 @@ telescope.setup({opts}) *telescope.setup()*
|
|||||||
|
|
||||||
*telescope.defaults.path_display*
|
*telescope.defaults.path_display*
|
||||||
path_display: ~
|
path_display: ~
|
||||||
Determines how file paths are displayed
|
Determines how file paths are displayed.
|
||||||
|
|
||||||
path_display can be set to an array with a combination of:
|
path_display can be set to an array with a combination of:
|
||||||
- "hidden" hide file names
|
- "hidden" hide file names
|
||||||
@ -273,7 +272,7 @@ telescope.setup({opts}) *telescope.setup()*
|
|||||||
- "shorten" only display the first character of each directory in
|
- "shorten" only display the first character of each directory in
|
||||||
the path
|
the path
|
||||||
- "truncate" truncates the start of the path when the whole path will
|
- "truncate" truncates the start of the path when the whole path will
|
||||||
not fit. To increase the the gap between the path and the edge.
|
not fit. To increase the gap between the path and the edge,
|
||||||
set truncate to number `truncate = 3`
|
set truncate to number `truncate = 3`
|
||||||
|
|
||||||
You can also specify the number of characters of each directory name
|
You can also specify the number of characters of each directory name
|
||||||
@ -352,7 +351,7 @@ telescope.setup({opts}) *telescope.setup()*
|
|||||||
prompt_title: ~
|
prompt_title: ~
|
||||||
Defines the default title of the prompt window. A false value
|
Defines the default title of the prompt window. A false value
|
||||||
can be used to hide the title altogether. Most of the times builtins
|
can be used to hide the title altogether. Most of the times builtins
|
||||||
define a prompt_title which will be prefered over this default.
|
define a prompt_title which will be preferred over this default.
|
||||||
|
|
||||||
Default: "Prompt"
|
Default: "Prompt"
|
||||||
|
|
||||||
@ -371,6 +370,8 @@ telescope.setup({opts}) *telescope.setup()*
|
|||||||
Will allow you to completely remove all of telescope's default maps
|
Will allow you to completely remove all of telescope's default maps
|
||||||
and use your own.
|
and use your own.
|
||||||
|
|
||||||
|
Default: nil
|
||||||
|
|
||||||
|
|
||||||
*telescope.defaults.history*
|
*telescope.defaults.history*
|
||||||
history: ~
|
history: ~
|
||||||
@ -388,11 +389,11 @@ telescope.setup({opts}) *telescope.setup()*
|
|||||||
|
|
||||||
Fields:
|
Fields:
|
||||||
- path: The path to the telescope history as string.
|
- path: The path to the telescope history as string.
|
||||||
default: stdpath("data")/telescope_history
|
Default: stdpath("data")/telescope_history
|
||||||
- limit: The amount of entries that will be written in the
|
- limit: The amount of entries that will be written in the
|
||||||
history.
|
history.
|
||||||
Warning: If limit is set to nil it will grow unbound.
|
Warning: If limit is set to nil it will grow unbound.
|
||||||
default: 100
|
Default: 100
|
||||||
- handler: A lua function that implements the history.
|
- handler: A lua function that implements the history.
|
||||||
This is meant as a developer setting for extensions to
|
This is meant as a developer setting for extensions to
|
||||||
override the history handling, e.g.,
|
override the history handling, e.g.,
|
||||||
@ -420,7 +421,8 @@ telescope.setup({opts}) *telescope.setup()*
|
|||||||
indices larger than `cache_picker.num_pickers` will
|
indices larger than `cache_picker.num_pickers` will
|
||||||
be cleared.
|
be cleared.
|
||||||
Default: 1
|
Default: 1
|
||||||
- limit_entries: The amount of entries that will be written in the
|
- limit_entries: The amount of entries that will be saved for each
|
||||||
|
picker.
|
||||||
Default: 1000
|
Default: 1000
|
||||||
|
|
||||||
|
|
||||||
@ -514,7 +516,7 @@ telescope.setup({opts}) *telescope.setup()*
|
|||||||
- msg_bg_fillchar: Character to fill background of unpreviewable buffers with
|
- msg_bg_fillchar: Character to fill background of unpreviewable buffers with
|
||||||
Default: "╱"
|
Default: "╱"
|
||||||
- hide_on_startup: Hide previewer when picker starts. Previewer can be toggled
|
- hide_on_startup: Hide previewer when picker starts. Previewer can be toggled
|
||||||
with actions.toggle_preview.
|
with actions.layout.toggle_preview.
|
||||||
Default: false
|
Default: false
|
||||||
|
|
||||||
|
|
||||||
@ -565,7 +567,7 @@ telescope.setup({opts}) *telescope.setup()*
|
|||||||
file_sorter: ~
|
file_sorter: ~
|
||||||
A function pointer that specifies the file_sorter. This sorter will
|
A function pointer that specifies the file_sorter. This sorter will
|
||||||
be used for find_files, git_files and similar.
|
be used for find_files, git_files and similar.
|
||||||
Hint: If you load a native sorter, you dont need to change this value,
|
Hint: If you load a native sorter, you don't need to change this value,
|
||||||
the native sorter will override it anyway.
|
the native sorter will override it anyway.
|
||||||
|
|
||||||
Default: require("telescope.sorters").get_fzy_sorter
|
Default: require("telescope.sorters").get_fzy_sorter
|
||||||
@ -574,7 +576,7 @@ telescope.setup({opts}) *telescope.setup()*
|
|||||||
generic_sorter: ~
|
generic_sorter: ~
|
||||||
A function pointer to the generic sorter. The sorter that should be
|
A function pointer to the generic sorter. The sorter that should be
|
||||||
used for everything that is not a file.
|
used for everything that is not a file.
|
||||||
Hint: If you load a native sorter, you dont need to change this value,
|
Hint: If you load a native sorter, you don't need to change this value,
|
||||||
the native sorter will override it anyway.
|
the native sorter will override it anyway.
|
||||||
|
|
||||||
Default: require("telescope.sorters").get_fzy_sorter
|
Default: require("telescope.sorters").get_fzy_sorter
|
||||||
@ -583,7 +585,7 @@ telescope.setup({opts}) *telescope.setup()*
|
|||||||
prefilter_sorter: ~
|
prefilter_sorter: ~
|
||||||
This points to a wrapper sorter around the generic_sorter that is able
|
This points to a wrapper sorter around the generic_sorter that is able
|
||||||
to do prefiltering.
|
to do prefiltering.
|
||||||
Its usually used for lsp_*_symbols and lsp_*_diagnostics
|
It's usually used for lsp_*_symbols and lsp_*_diagnostics
|
||||||
|
|
||||||
Default: require("telescope.sorters").prefilter
|
Default: require("telescope.sorters").prefilter
|
||||||
|
|
||||||
@ -794,6 +796,8 @@ builtin.live_grep({opts}) *telescope.builtin.live_grep()*
|
|||||||
{max_results} (number) define a upper result value
|
{max_results} (number) define a upper result value
|
||||||
{disable_coordinates} (boolean) don't show the line & row
|
{disable_coordinates} (boolean) don't show the line & row
|
||||||
numbers (default: false)
|
numbers (default: false)
|
||||||
|
{file_encoding} (string) file encoding for the entry &
|
||||||
|
previewer
|
||||||
|
|
||||||
|
|
||||||
builtin.grep_string({opts}) *telescope.builtin.grep_string()*
|
builtin.grep_string({opts}) *telescope.builtin.grep_string()*
|
||||||
@ -828,6 +832,8 @@ builtin.grep_string({opts}) *telescope.builtin.grep_string()*
|
|||||||
{only_sort_text} (boolean) only sort the text, not the
|
{only_sort_text} (boolean) only sort the text, not the
|
||||||
file, line or row (default:
|
file, line or row (default:
|
||||||
false)
|
false)
|
||||||
|
{file_encoding} (string) file encoding for the entry &
|
||||||
|
previewer
|
||||||
|
|
||||||
|
|
||||||
builtin.find_files({opts}) *telescope.builtin.find_files()*
|
builtin.find_files({opts}) *telescope.builtin.find_files()*
|
||||||
@ -857,6 +863,7 @@ builtin.find_files({opts}) *telescope.builtin.find_files()*
|
|||||||
{search_dirs} (table) directory/directories/files to
|
{search_dirs} (table) directory/directories/files to
|
||||||
search
|
search
|
||||||
{search_file} (string) specify a filename to search for
|
{search_file} (string) specify a filename to search for
|
||||||
|
{file_encoding} (string) file encoding for the previewer
|
||||||
|
|
||||||
|
|
||||||
builtin.fd() *telescope.builtin.fd()*
|
builtin.fd() *telescope.builtin.fd()*
|
||||||
@ -879,6 +886,7 @@ builtin.treesitter() *telescope.builtin.treesitter()*
|
|||||||
current buffer)
|
current buffer)
|
||||||
{symbol_highlights} (table) string -> string. Matches symbol with
|
{symbol_highlights} (table) string -> string. Matches symbol with
|
||||||
hl_group
|
hl_group
|
||||||
|
{file_encoding} (string) file encoding for the previewer
|
||||||
|
|
||||||
|
|
||||||
builtin.current_buffer_fuzzy_find({opts}) *telescope.builtin.current_buffer_fuzzy_find()*
|
builtin.current_buffer_fuzzy_find({opts}) *telescope.builtin.current_buffer_fuzzy_find()*
|
||||||
@ -889,8 +897,9 @@ builtin.current_buffer_fuzzy_find({opts}) *telescope.builtin.current_buffer_fuzz
|
|||||||
{opts} (table) options to pass to the picker
|
{opts} (table) options to pass to the picker
|
||||||
|
|
||||||
Options: ~
|
Options: ~
|
||||||
{skip_empty_lines} (boolean) if true we dont display empty lines
|
{skip_empty_lines} (boolean) if true we don't display empty lines
|
||||||
(default: false)
|
(default: false)
|
||||||
|
{file_encoding} (string) file encoding for the previewer
|
||||||
|
|
||||||
|
|
||||||
builtin.tags({opts}) *telescope.builtin.tags()*
|
builtin.tags({opts}) *telescope.builtin.tags()*
|
||||||
@ -958,8 +967,9 @@ builtin.git_files({opts}) *telescope.builtin.git_files()*
|
|||||||
{recurse_submodules} (boolean) if true, adds the
|
{recurse_submodules} (boolean) if true, adds the
|
||||||
`--recurse-submodules` flag to command
|
`--recurse-submodules` flag to command
|
||||||
(default: false)
|
(default: false)
|
||||||
{git_command} (table) command that will be exectued.
|
{git_command} (table) command that will be executed.
|
||||||
{"git","ls-files","--exclude-standard","--cached"}
|
{"git","ls-files","--exclude-standard","--cached"}
|
||||||
|
{file_encoding} (string) file encoding for the previewer
|
||||||
|
|
||||||
|
|
||||||
builtin.git_commits({opts}) *telescope.builtin.git_commits()*
|
builtin.git_commits({opts}) *telescope.builtin.git_commits()*
|
||||||
@ -978,13 +988,13 @@ builtin.git_commits({opts}) *telescope.builtin.git_commits()*
|
|||||||
{cwd} (string) specify the path of the repo
|
{cwd} (string) specify the path of the repo
|
||||||
{use_git_root} (boolean) if we should use git root as cwd or the cwd
|
{use_git_root} (boolean) if we should use git root as cwd or the cwd
|
||||||
(important for submodule) (default: true)
|
(important for submodule) (default: true)
|
||||||
{git_command} (table) command that will be exectued.
|
{git_command} (table) command that will be executed.
|
||||||
{"git","log","--pretty=oneline","--abbrev-commit","--","."}
|
{"git","log","--pretty=oneline","--abbrev-commit","--","."}
|
||||||
|
|
||||||
|
|
||||||
builtin.git_bcommits({opts}) *telescope.builtin.git_bcommits()*
|
builtin.git_bcommits({opts}) *telescope.builtin.git_bcommits()*
|
||||||
Lists commits for current buffer with diff preview
|
Lists commits for current buffer with diff preview
|
||||||
- Default keymaps or your overriden `select_` keys:
|
- Default keymaps or your overridden `select_` keys:
|
||||||
- `<cr>`: checks out the currently selected commit
|
- `<cr>`: checks out the currently selected commit
|
||||||
- `<c-v>`: opens a diff in a vertical split
|
- `<c-v>`: opens a diff in a vertical split
|
||||||
- `<c-x>`: opens a diff in a horizontal split
|
- `<c-x>`: opens a diff in a horizontal split
|
||||||
@ -1000,7 +1010,7 @@ builtin.git_bcommits({opts}) *telescope.builtin.git_bcommits()*
|
|||||||
(important for submodule) (default: true)
|
(important for submodule) (default: true)
|
||||||
{current_file} (string) specify the current file that should be used
|
{current_file} (string) specify the current file that should be used
|
||||||
for bcommits (default: current buffer)
|
for bcommits (default: current buffer)
|
||||||
{git_command} (table) command that will be exectued.
|
{git_command} (table) command that will be executed.
|
||||||
{"git","log","--pretty=oneline","--abbrev-commit"}
|
{"git","log","--pretty=oneline","--abbrev-commit"}
|
||||||
|
|
||||||
|
|
||||||
@ -1115,9 +1125,9 @@ builtin.planets({opts}) *telescope.builtin.planets()*
|
|||||||
{opts} (table) options to pass to the picker
|
{opts} (table) options to pass to the picker
|
||||||
|
|
||||||
Options: ~
|
Options: ~
|
||||||
{show_pluto} (boolean) we love pluto (default: false, because its a
|
{show_pluto} (boolean) we love Pluto (default: false, because its a
|
||||||
hidden feature)
|
hidden feature)
|
||||||
{show_moon} (boolean) we love the moon (default: false, because its
|
{show_moon} (boolean) we love the Moon (default: false, because its
|
||||||
a hidden feature)
|
a hidden feature)
|
||||||
|
|
||||||
|
|
||||||
@ -1199,8 +1209,9 @@ builtin.oldfiles({opts}) *telescope.builtin.oldfiles()*
|
|||||||
{opts} (table) options to pass to the picker
|
{opts} (table) options to pass to the picker
|
||||||
|
|
||||||
Options: ~
|
Options: ~
|
||||||
{only_cwd} (boolean) show only files in the cwd (default: false)
|
{only_cwd} (boolean) show only files in the cwd (default: false)
|
||||||
{cwd_only} (boolean) alias for only_cwd
|
{cwd_only} (boolean) alias for only_cwd
|
||||||
|
{file_encoding} (string) file encoding for the previewer
|
||||||
|
|
||||||
|
|
||||||
builtin.command_history({opts}) *telescope.builtin.command_history()*
|
builtin.command_history({opts}) *telescope.builtin.command_history()*
|
||||||
@ -1300,6 +1311,7 @@ builtin.buffers({opts}) *telescope.builtin.buffers()*
|
|||||||
{bufnr_width} (number) Defines the width of the buffer
|
{bufnr_width} (number) Defines the width of the buffer
|
||||||
numbers in front of the filenames
|
numbers in front of the filenames
|
||||||
(default: dynamic)
|
(default: dynamic)
|
||||||
|
{file_encoding} (string) file encoding for the previewer
|
||||||
|
|
||||||
|
|
||||||
builtin.colorscheme({opts}) *telescope.builtin.colorscheme()*
|
builtin.colorscheme({opts}) *telescope.builtin.colorscheme()*
|
||||||
@ -1320,6 +1332,9 @@ builtin.marks({opts}) *telescope.builtin.marks()*
|
|||||||
Parameters: ~
|
Parameters: ~
|
||||||
{opts} (table) options to pass to the picker
|
{opts} (table) options to pass to the picker
|
||||||
|
|
||||||
|
Options: ~
|
||||||
|
{file_encoding} (string) file encoding for the previewer
|
||||||
|
|
||||||
|
|
||||||
builtin.registers({opts}) *telescope.builtin.registers()*
|
builtin.registers({opts}) *telescope.builtin.registers()*
|
||||||
Lists vim registers, pastes the contents of the register on `<cr>`
|
Lists vim registers, pastes the contents of the register on `<cr>`
|
||||||
@ -1424,6 +1439,7 @@ builtin.lsp_references({opts}) *telescope.builtin.lsp_references()*
|
|||||||
section (default: 30)
|
section (default: 30)
|
||||||
{show_line} (boolean) show results text (default: true)
|
{show_line} (boolean) show results text (default: true)
|
||||||
{trim_text} (boolean) trim results text (default: false)
|
{trim_text} (boolean) trim results text (default: false)
|
||||||
|
{file_encoding} (string) file encoding for the previewer
|
||||||
|
|
||||||
|
|
||||||
builtin.lsp_incoming_calls({opts}) *telescope.builtin.lsp_incoming_calls()*
|
builtin.lsp_incoming_calls({opts}) *telescope.builtin.lsp_incoming_calls()*
|
||||||
@ -1435,10 +1451,11 @@ builtin.lsp_incoming_calls({opts}) *telescope.builtin.lsp_incoming_calls()*
|
|||||||
{opts} (table) options to pass to the picker
|
{opts} (table) options to pass to the picker
|
||||||
|
|
||||||
Options: ~
|
Options: ~
|
||||||
{fname_width} (number) defines the width of the filename section
|
{fname_width} (number) defines the width of the filename section
|
||||||
(default: 30)
|
(default: 30)
|
||||||
{show_line} (boolean) show results text (default: true)
|
{show_line} (boolean) show results text (default: true)
|
||||||
{trim_text} (boolean) trim results text (default: false)
|
{trim_text} (boolean) trim results text (default: false)
|
||||||
|
{file_encoding} (string) file encoding for the previewer
|
||||||
|
|
||||||
|
|
||||||
builtin.lsp_outgoing_calls({opts}) *telescope.builtin.lsp_outgoing_calls()*
|
builtin.lsp_outgoing_calls({opts}) *telescope.builtin.lsp_outgoing_calls()*
|
||||||
@ -1450,10 +1467,11 @@ builtin.lsp_outgoing_calls({opts}) *telescope.builtin.lsp_outgoing_calls()*
|
|||||||
{opts} (table) options to pass to the picker
|
{opts} (table) options to pass to the picker
|
||||||
|
|
||||||
Options: ~
|
Options: ~
|
||||||
{fname_width} (number) defines the width of the filename section
|
{fname_width} (number) defines the width of the filename section
|
||||||
(default: 30)
|
(default: 30)
|
||||||
{show_line} (boolean) show results text (default: true)
|
{show_line} (boolean) show results text (default: true)
|
||||||
{trim_text} (boolean) trim results text (default: false)
|
{trim_text} (boolean) trim results text (default: false)
|
||||||
|
{file_encoding} (string) file encoding for the previewer
|
||||||
|
|
||||||
|
|
||||||
builtin.lsp_definitions({opts}) *telescope.builtin.lsp_definitions()*
|
builtin.lsp_definitions({opts}) *telescope.builtin.lsp_definitions()*
|
||||||
@ -1465,12 +1483,15 @@ builtin.lsp_definitions({opts}) *telescope.builtin.lsp_definitions()*
|
|||||||
{opts} (table) options to pass to the picker
|
{opts} (table) options to pass to the picker
|
||||||
|
|
||||||
Options: ~
|
Options: ~
|
||||||
{jump_type} (string) how to goto definition if there is only one,
|
{jump_type} (string) how to goto definition if there is only one
|
||||||
values: "tab", "split", "vsplit", "never"
|
and the definition file is different from
|
||||||
{fname_width} (number) defines the width of the filename section
|
the current file, values: "tab", "split",
|
||||||
(default: 30)
|
"vsplit", "never"
|
||||||
{show_line} (boolean) show results text (default: true)
|
{fname_width} (number) defines the width of the filename section
|
||||||
{trim_text} (boolean) trim results text (default: false)
|
(default: 30)
|
||||||
|
{show_line} (boolean) show results text (default: true)
|
||||||
|
{trim_text} (boolean) trim results text (default: false)
|
||||||
|
{file_encoding} (string) file encoding for the previewer
|
||||||
|
|
||||||
|
|
||||||
builtin.lsp_type_definitions({opts}) *telescope.builtin.lsp_type_definitions()*
|
builtin.lsp_type_definitions({opts}) *telescope.builtin.lsp_type_definitions()*
|
||||||
@ -1482,12 +1503,15 @@ builtin.lsp_type_definitions({opts}) *telescope.builtin.lsp_type_definitions()*
|
|||||||
{opts} (table) options to pass to the picker
|
{opts} (table) options to pass to the picker
|
||||||
|
|
||||||
Options: ~
|
Options: ~
|
||||||
{jump_type} (string) how to goto definition if there is only one,
|
{jump_type} (string) how to goto definition if there is only one
|
||||||
values: "tab", "split", "vsplit", "never"
|
and the definition file is different from
|
||||||
{fname_width} (number) defines the width of the filename section
|
the current file, values: "tab", "split",
|
||||||
(default: 30)
|
"vsplit", "never"
|
||||||
{show_line} (boolean) show results text (default: true)
|
{fname_width} (number) defines the width of the filename section
|
||||||
{trim_text} (boolean) trim results text (default: false)
|
(default: 30)
|
||||||
|
{show_line} (boolean) show results text (default: true)
|
||||||
|
{trim_text} (boolean) trim results text (default: false)
|
||||||
|
{file_encoding} (string) file encoding for the previewer
|
||||||
|
|
||||||
|
|
||||||
builtin.lsp_implementations({opts}) *telescope.builtin.lsp_implementations()*
|
builtin.lsp_implementations({opts}) *telescope.builtin.lsp_implementations()*
|
||||||
@ -1499,13 +1523,15 @@ builtin.lsp_implementations({opts}) *telescope.builtin.lsp_implementations()*
|
|||||||
{opts} (table) options to pass to the picker
|
{opts} (table) options to pass to the picker
|
||||||
|
|
||||||
Options: ~
|
Options: ~
|
||||||
{jump_type} (string) how to goto implementation if there is only
|
{jump_type} (string) how to goto implementation if there is only
|
||||||
one, values: "tab", "split", "vsplit",
|
one and the definition file is different
|
||||||
"never"
|
from the current file, values: "tab",
|
||||||
{fname_width} (number) defines the width of the filename section
|
"split", "vsplit", "never"
|
||||||
(default: 30)
|
{fname_width} (number) defines the width of the filename section
|
||||||
{show_line} (boolean) show results text (default: true)
|
(default: 30)
|
||||||
{trim_text} (boolean) trim results text (default: false)
|
{show_line} (boolean) show results text (default: true)
|
||||||
|
{trim_text} (boolean) trim results text (default: false)
|
||||||
|
{file_encoding} (string) file encoding for the previewer
|
||||||
|
|
||||||
|
|
||||||
builtin.lsp_document_symbols({opts}) *telescope.builtin.lsp_document_symbols()*
|
builtin.lsp_document_symbols({opts}) *telescope.builtin.lsp_document_symbols()*
|
||||||
@ -1521,6 +1547,10 @@ builtin.lsp_document_symbols({opts}) *telescope.builtin.lsp_document_symbols()*
|
|||||||
Options: ~
|
Options: ~
|
||||||
{fname_width} (number) defines the width of the filename
|
{fname_width} (number) defines the width of the filename
|
||||||
section (default: 30)
|
section (default: 30)
|
||||||
|
{symbol_width} (number) defines the width of the symbol
|
||||||
|
section (default: 25)
|
||||||
|
{symbol_type_width} (number) defines the width of the symbol
|
||||||
|
type section (default: 8)
|
||||||
{show_line} (boolean) if true, shows the content of the
|
{show_line} (boolean) if true, shows the content of the
|
||||||
line the tag is found on (default:
|
line the tag is found on (default:
|
||||||
false)
|
false)
|
||||||
@ -1528,6 +1558,7 @@ builtin.lsp_document_symbols({opts}) *telescope.builtin.lsp_document_symbols()*
|
|||||||
{ignore_symbols} (string|table) list of symbols to ignore
|
{ignore_symbols} (string|table) list of symbols to ignore
|
||||||
{symbol_highlights} (table) string -> string. Matches symbol
|
{symbol_highlights} (table) string -> string. Matches symbol
|
||||||
with hl_group
|
with hl_group
|
||||||
|
{file_encoding} (string) file encoding for the previewer
|
||||||
|
|
||||||
|
|
||||||
builtin.lsp_workspace_symbols({opts}) *telescope.builtin.lsp_workspace_symbols()*
|
builtin.lsp_workspace_symbols({opts}) *telescope.builtin.lsp_workspace_symbols()*
|
||||||
@ -1545,6 +1576,10 @@ builtin.lsp_workspace_symbols({opts}) *telescope.builtin.lsp_workspace_symbols()
|
|||||||
(default: "")
|
(default: "")
|
||||||
{fname_width} (number) defines the width of the filename
|
{fname_width} (number) defines the width of the filename
|
||||||
section (default: 30)
|
section (default: 30)
|
||||||
|
{symbol_width} (number) defines the width of the symbol
|
||||||
|
section (default: 25)
|
||||||
|
{symbol_type_width} (number) defines the width of the symbol
|
||||||
|
type section (default: 8)
|
||||||
{show_line} (boolean) if true, shows the content of the
|
{show_line} (boolean) if true, shows the content of the
|
||||||
line the tag is found on (default:
|
line the tag is found on (default:
|
||||||
false)
|
false)
|
||||||
@ -1552,6 +1587,7 @@ builtin.lsp_workspace_symbols({opts}) *telescope.builtin.lsp_workspace_symbols()
|
|||||||
{ignore_symbols} (string|table) list of symbols to ignore
|
{ignore_symbols} (string|table) list of symbols to ignore
|
||||||
{symbol_highlights} (table) string -> string. Matches symbol
|
{symbol_highlights} (table) string -> string. Matches symbol
|
||||||
with hl_group
|
with hl_group
|
||||||
|
{file_encoding} (string) file encoding for the previewer
|
||||||
|
|
||||||
|
|
||||||
builtin.lsp_dynamic_workspace_symbols({opts}) *telescope.builtin.lsp_dynamic_workspace_symbols()*
|
builtin.lsp_dynamic_workspace_symbols({opts}) *telescope.builtin.lsp_dynamic_workspace_symbols()*
|
||||||
@ -1574,6 +1610,7 @@ builtin.lsp_dynamic_workspace_symbols({opts}) *telescope.builtin.lsp_dynamic_wor
|
|||||||
{ignore_symbols} (string|table) list of symbols to ignore
|
{ignore_symbols} (string|table) list of symbols to ignore
|
||||||
{symbol_highlights} (table) string -> string. Matches symbol
|
{symbol_highlights} (table) string -> string. Matches symbol
|
||||||
with hl_group
|
with hl_group
|
||||||
|
{file_encoding} (string) file encoding for the previewer
|
||||||
|
|
||||||
|
|
||||||
builtin.diagnostics({opts}) *telescope.builtin.diagnostics()*
|
builtin.diagnostics({opts}) *telescope.builtin.diagnostics()*
|
||||||
@ -1628,9 +1665,10 @@ themes.get_dropdown() *telescope.themes.get_dropdown()*
|
|||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
>
|
>
|
||||||
`local builtin = require('telescope.builtin')`
|
local opts = {...} -- picker options
|
||||||
`local themes = require('telescope.themes')`
|
local builtin = require('telescope.builtin')
|
||||||
`builtin.find_files(themes.get_dropdown())`
|
local themes = require('telescope.themes')
|
||||||
|
builtin.find_files(themes.get_dropdown(opts))
|
||||||
<
|
<
|
||||||
|
|
||||||
|
|
||||||
@ -1640,10 +1678,10 @@ themes.get_cursor() *telescope.themes.get_cursor()*
|
|||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
>
|
>
|
||||||
|
local opts = {...} -- picker options
|
||||||
`local builtin = require('telescope.builtin')`
|
local builtin = require('telescope.builtin')
|
||||||
`local themes = require('telescope.themes')`
|
local themes = require('telescope.themes')
|
||||||
`builtin.lsp_references(themes.get_cursor())`
|
builtin.find_files(themes.get_cursor(opts))
|
||||||
<
|
<
|
||||||
|
|
||||||
|
|
||||||
@ -1653,9 +1691,10 @@ themes.get_ivy() *telescope.themes.get_ivy()*
|
|||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
>
|
>
|
||||||
`local builtin = require('telescope.builtin')`
|
local opts = {...} -- picker options
|
||||||
`local themes = require('telescope.themes')`
|
local builtin = require('telescope.builtin')
|
||||||
`builtin.find_files(themes.get_ivy())`
|
local themes = require('telescope.themes')
|
||||||
|
builtin.find_files(themes.get_ivy(opts))
|
||||||
<
|
<
|
||||||
|
|
||||||
|
|
||||||
@ -1665,12 +1704,11 @@ themes.get_ivy() *telescope.themes.get_ivy()*
|
|||||||
MAPPINGS *telescope.mappings*
|
MAPPINGS *telescope.mappings*
|
||||||
|
|
||||||
|telescope.mappings| is used to configure the keybindings within a telescope
|
|telescope.mappings| is used to configure the keybindings within a telescope
|
||||||
picker. These keybinds are only local to the picker window and will be cleared
|
picker. These key binds are only local to the picker window and will be cleared
|
||||||
once you exit the picker.
|
once you exit the picker.
|
||||||
|
|
||||||
We provide multiple different ways of configuring, as described below, to
|
We provide multiple configuration options to make it easy for you to adjust
|
||||||
provide an easy to use experience for changing the default behavior of
|
telescope's default key bindings and create your own custom key binds.
|
||||||
telescope or extending for your own purposes.
|
|
||||||
|
|
||||||
To see many of the builtin actions that you can use as values for this table,
|
To see many of the builtin actions that you can use as values for this table,
|
||||||
see |telescope.actions|
|
see |telescope.actions|
|
||||||
@ -1703,7 +1741,6 @@ For example:
|
|||||||
...,
|
...,
|
||||||
}
|
}
|
||||||
<
|
<
|
||||||
Into your config.
|
|
||||||
|
|
||||||
To override behavior of a key, simply set the value to be a function (either by
|
To override behavior of a key, simply set the value to be a function (either by
|
||||||
requiring an action or by writing your own function)
|
requiring an action or by writing your own function)
|
||||||
@ -1716,7 +1753,8 @@ requiring an action or by writing your own function)
|
|||||||
<
|
<
|
||||||
|
|
||||||
If the function you want is part of `telescope.actions`, then you can simply
|
If the function you want is part of `telescope.actions`, then you can simply
|
||||||
give a string. For example, the previous option is equivalent to:
|
supply the function name as a string. For example, the previous option is
|
||||||
|
equivalent to:
|
||||||
>
|
>
|
||||||
{
|
{
|
||||||
...,
|
...,
|
||||||
@ -1775,6 +1813,11 @@ ordered from the lowest priority to the highest priority.
|
|||||||
map("i", "asdf", function(_prompt_bufnr)
|
map("i", "asdf", function(_prompt_bufnr)
|
||||||
print "You typed asdf"
|
print "You typed asdf"
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
map({"i", "n"}, "<C-r>", function(_prompt_bufnr)
|
||||||
|
print "You typed <C-r>"
|
||||||
|
end)
|
||||||
|
|
||||||
-- needs to return true if you want to map default_mappings and
|
-- needs to return true if you want to map default_mappings and
|
||||||
-- false if not
|
-- false if not
|
||||||
return true
|
return true
|
||||||
@ -1823,7 +1866,6 @@ All layout strategies are functions with the following signature:
|
|||||||
- lines : (number) Lines in the vim window
|
- lines : (number) Lines in the vim window
|
||||||
- layout_config : (table) The configuration values specific to the picker.
|
- layout_config : (table) The configuration values specific to the picker.
|
||||||
|
|
||||||
|
|
||||||
This means you can create your own layout strategy if you want! Just be aware
|
This means you can create your own layout strategy if you want! Just be aware
|
||||||
for now that we may change some APIs or interfaces, so they may break if you
|
for now that we may change some APIs or interfaces, so they may break if you
|
||||||
create your own.
|
create your own.
|
||||||
@ -1892,14 +1934,14 @@ layout_strategies.center() *telescope.layout.center()*
|
|||||||
|
|
||||||
┌──────────────────────────────────────────────────┐
|
┌──────────────────────────────────────────────────┐
|
||||||
│ ┌────────────────────────────────────────┐ │
|
│ ┌────────────────────────────────────────┐ │
|
||||||
│ | Preview | │
|
│ │ Preview │ │
|
||||||
│ | Preview | │
|
│ │ Preview │ │
|
||||||
│ └────────────────────────────────────────┘ │
|
│ └────────────────────────────────────────┘ │
|
||||||
│ ┌────────────────────────────────────────┐ │
|
│ ┌────────────────────────────────────────┐ │
|
||||||
│ | Prompt | │
|
│ │ Prompt │ │
|
||||||
│ ├────────────────────────────────────────┤ │
|
│ ├────────────────────────────────────────┤ │
|
||||||
│ | Result | │
|
│ │ Result │ │
|
||||||
│ | Result | │
|
│ │ Result │ │
|
||||||
│ └────────────────────────────────────────┘ │
|
│ └────────────────────────────────────────┘ │
|
||||||
│ │
|
│ │
|
||||||
│ │
|
│ │
|
||||||
@ -1948,6 +1990,20 @@ layout_strategies.cursor() *telescope.layout.cursor()*
|
|||||||
│ │
|
│ │
|
||||||
└──────────────────────────────────────────────────┘
|
└──────────────────────────────────────────────────┘
|
||||||
|
|
||||||
|
`picker.layout_config` shared options:
|
||||||
|
- height:
|
||||||
|
- How tall to make Telescope's entire layout
|
||||||
|
- See |resolver.resolve_height()|
|
||||||
|
- scroll_speed: The number of lines to scroll through the previewer
|
||||||
|
- width:
|
||||||
|
- How wide to make Telescope's entire layout
|
||||||
|
- See |resolver.resolve_width()|
|
||||||
|
|
||||||
|
`picker.layout_config` unique options:
|
||||||
|
- preview_cutoff: When columns are less than this value, the preview will be disabled
|
||||||
|
- preview_width:
|
||||||
|
- Change the width of Telescope's preview window
|
||||||
|
- See |resolver.resolve_width()|
|
||||||
|
|
||||||
|
|
||||||
layout_strategies.vertical() *telescope.layout.vertical()*
|
layout_strategies.vertical() *telescope.layout.vertical()*
|
||||||
@ -1957,16 +2013,16 @@ layout_strategies.vertical() *telescope.layout.vertical()*
|
|||||||
┌──────────────────────────────────────────────────┐
|
┌──────────────────────────────────────────────────┐
|
||||||
│ │
|
│ │
|
||||||
│ ┌────────────────────────────────────────┐ │
|
│ ┌────────────────────────────────────────┐ │
|
||||||
│ | Preview | │
|
│ │ Preview │ │
|
||||||
│ | Preview | │
|
│ │ Preview │ │
|
||||||
│ | Preview | │
|
│ │ Preview │ │
|
||||||
│ └────────────────────────────────────────┘ │
|
│ └────────────────────────────────────────┘ │
|
||||||
│ ┌────────────────────────────────────────┐ │
|
│ ┌────────────────────────────────────────┐ │
|
||||||
│ | Result | │
|
│ │ Result │ │
|
||||||
│ | Result | │
|
│ │ Result │ │
|
||||||
│ └────────────────────────────────────────┘ │
|
│ └────────────────────────────────────────┘ │
|
||||||
│ ┌────────────────────────────────────────┐ │
|
│ ┌────────────────────────────────────────┐ │
|
||||||
│ | Prompt | │
|
│ │ Prompt │ │
|
||||||
│ └────────────────────────────────────────┘ │
|
│ └────────────────────────────────────────┘ │
|
||||||
│ │
|
│ │
|
||||||
└──────────────────────────────────────────────────┘
|
└──────────────────────────────────────────────────┘
|
||||||
@ -2103,33 +2159,33 @@ MAKE_ENTRY *telescope.make_entry*
|
|||||||
|
|
||||||
Each picker has a finder made up of two parts, the results which are the data
|
Each picker has a finder made up of two parts, the results which are the data
|
||||||
to be displayed, and the entry_maker. These entry_makers are functions returned
|
to be displayed, and the entry_maker. These entry_makers are functions returned
|
||||||
from make_entry functions. These will be referrd to as entry_makers in the
|
from make_entry functions. These will be referred to as entry_makers in the
|
||||||
following documentation.
|
following documentation.
|
||||||
|
|
||||||
Every entry maker returns a function which accepts the data to be used for an
|
Every entry maker returns a function that accepts the data to be used for an
|
||||||
entry. This function will return an entry table (or nil, meaning skip this
|
entry. This function will return an entry table (or nil, meaning skip this
|
||||||
entry) which contains of the - following important keys:
|
entry) which contains the following important keys:
|
||||||
- value any: value key can be anything but still required
|
- value any: value key can be anything but still required
|
||||||
- valid bool: is an optional key because it defaults to true but if the key is
|
- valid bool (optional): is an optional key because it defaults to true but if
|
||||||
set to false it will not be displayed by the picker. (optional)
|
the key is set to false it will not be displayed by the picker
|
||||||
- ordinal string: is the text that is used for filtering (required)
|
- ordinal string: is the text that is used for filtering
|
||||||
- display string|function: is either a string of the text that is being
|
- display string|function: is either a string of the text that is being
|
||||||
displayed or a function receiving the entry at a later stage, when the entry
|
displayed or a function receiving the entry at a later stage, when the entry
|
||||||
is actually being displayed. A function can be useful here if complex
|
is actually being displayed. A function can be useful here if a complex
|
||||||
calculation have to be done. `make_entry` can also return a second value a
|
calculation has to be done. `make_entry` can also return a second value - a
|
||||||
highlight array which will then apply to the line. Highlight entry in this
|
highlight array which will then apply to the line. Highlight entry in this
|
||||||
array has the following signature `{ { start_col, end_col }, hl_group }`
|
array has the following signature `{ { start_col, end_col }, hl_group }`
|
||||||
(required).
|
- filename string (optional): will be interpreted by the default `<cr>` action
|
||||||
- filename string: will be interpreted by the default `<cr>` action as open
|
as open this file
|
||||||
this file (optional)
|
- bufnr number (optional): will be interpreted by the default `<cr>` action as
|
||||||
- bufnr number: will be interpreted by the default `<cr>` action as open this
|
open this buffer
|
||||||
buffer (optional)
|
- lnum number (optional): lnum value which will be interpreted by the default
|
||||||
- lnum number: lnum value which will be interpreted by the default `<cr>`
|
`<cr>` action as a jump to this line
|
||||||
action as a jump to this line (optional)
|
- col number (optional): col value which will be interpreted by the default
|
||||||
- col number: col value which will be interpreted by the default `<cr>` action
|
`<cr>` action as a jump to this column
|
||||||
as a jump to this column (optional)
|
|
||||||
|
|
||||||
More information on easier displaying, see |telescope.pickers.entry_display|
|
For more information on easier displaying, see
|
||||||
|
|telescope.pickers.entry_display|
|
||||||
|
|
||||||
TODO: Document something we call `entry_index`
|
TODO: Document something we call `entry_index`
|
||||||
|
|
||||||
@ -2148,11 +2204,11 @@ every single entry. So it is suggested to do this outside of `make_display` for
|
|||||||
the best performance.
|
the best performance.
|
||||||
|
|
||||||
The create function will use the column widths passed to it in
|
The create function will use the column widths passed to it in
|
||||||
configaration.items. Each item in that table is the number of characters in the
|
configuration.items. Each item in that table is the number of characters in the
|
||||||
column. It's also possible for the final column to not have a fixed width, this
|
column. It's also possible for the final column to not have a fixed width, this
|
||||||
will be shown in the configuartion as 'remaining = true'.
|
will be shown in the configuration as 'remaining = true'.
|
||||||
|
|
||||||
An example of this configuration is shown for the buffers picker
|
An example of this configuration is shown for the buffers picker:
|
||||||
>
|
>
|
||||||
local displayer = entry_display.create {
|
local displayer = entry_display.create {
|
||||||
separator = " ",
|
separator = " ",
|
||||||
@ -2166,10 +2222,10 @@ local displayer = entry_display.create {
|
|||||||
<
|
<
|
||||||
|
|
||||||
This shows 4 columns, the first is defined in the opts as the width we'll use
|
This shows 4 columns, the first is defined in the opts as the width we'll use
|
||||||
when display_string the number of the buffer. The second has a fixed width of 4
|
when display_string is the number of the buffer. The second has a fixed width
|
||||||
and the 3rd column's widht will be decided by the width of the icons we use.
|
of 4 and the third column's width will be decided by the width of the icons we
|
||||||
The fourth column will use the remaining space. Finally we have also defined
|
use. The fourth column will use the remaining space. Finally, we have also
|
||||||
the seperator between each column will be the space " ".
|
defined the separator between each column will be the space " ".
|
||||||
|
|
||||||
An example of how the display reference will be used is shown, again for the
|
An example of how the display reference will be used is shown, again for the
|
||||||
buffers picker:
|
buffers picker:
|
||||||
@ -2185,11 +2241,12 @@ return displayer {
|
|||||||
There are two types of values each column can have. Either a simple String or a
|
There are two types of values each column can have. Either a simple String or a
|
||||||
table containing the String as well as the hl_group.
|
table containing the String as well as the hl_group.
|
||||||
|
|
||||||
The displayer can return values, string and an optional highlights. String is
|
The displayer can return values, string and an optional highlights. The string
|
||||||
all the text to be displayed for this entry as a single string. If parts of the
|
is all the text to be displayed for this entry as a single string. If parts of
|
||||||
string are to be highlighted they will be described in the highlights table.
|
the string are to be highlighted they will be described in the highlights
|
||||||
|
table.
|
||||||
|
|
||||||
For better understanding of how create() and displayer are used it's best to
|
For a better understanding of how create() and displayer are used it's best to
|
||||||
look at the code in make_entry.lua.
|
look at the code in make_entry.lua.
|
||||||
|
|
||||||
|
|
||||||
@ -2210,7 +2267,7 @@ utils.transform_path({opts}, {path}) *telescope.utils.transform_path()*
|
|||||||
Parameters: ~
|
Parameters: ~
|
||||||
{opts} (table) The opts the users passed into the picker. Might
|
{opts} (table) The opts the users passed into the picker. Might
|
||||||
contains a path_display key
|
contains a path_display key
|
||||||
{path} (string) The path that should be formated
|
{path} (string) The path that should be formatted
|
||||||
|
|
||||||
Return: ~
|
Return: ~
|
||||||
string: The transformed path ready to be displayed
|
string: The transformed path ready to be displayed
|
||||||
@ -2229,9 +2286,9 @@ utils.notify({funname}, {opts}) *telescope.utils.notify()*
|
|||||||
================================================================================
|
================================================================================
|
||||||
ACTIONS *telescope.actions*
|
ACTIONS *telescope.actions*
|
||||||
|
|
||||||
Actions functions that are useful for people creating their own mappings.
|
These functions are useful for people creating their own mappings.
|
||||||
|
|
||||||
Actions can be either normal functions that expect the prompt_bufnr as first
|
Actions can be either normal functions that expect the `prompt_bufnr` as first
|
||||||
argument (1) or they can be a custom telescope type called "action" (2).
|
argument (1) or they can be a custom telescope type called "action" (2).
|
||||||
|
|
||||||
(1) The `prompt_bufnr` of a normal function denotes the identifier of your
|
(1) The `prompt_bufnr` of a normal function denotes the identifier of your
|
||||||
@ -2272,8 +2329,8 @@ do the following:
|
|||||||
action(bufnr)
|
action(bufnr)
|
||||||
<
|
<
|
||||||
|
|
||||||
Another interesing thing to do is that these actions now have functions you can
|
Another interesting thing to do is that these actions now have functions you
|
||||||
call. These functions include `:replace(f)`, `:replace_if(f, c)`,
|
can call. These functions include `:replace(f)`, `:replace_if(f, c)`,
|
||||||
`replace_map(tbl)` and `enhance(tbl)`. More information on these functions can
|
`replace_map(tbl)` and `enhance(tbl)`. More information on these functions can
|
||||||
be found in the `developers.md` and `lua/tests/automated/action_spec.lua` file.
|
be found in the `developers.md` and `lua/tests/automated/action_spec.lua` file.
|
||||||
|
|
||||||
@ -2359,8 +2416,8 @@ actions.toggle_selection({prompt_bufnr}) *telescope.actions.toggle_selection()*
|
|||||||
|
|
||||||
actions.select_all({prompt_bufnr}) *telescope.actions.select_all()*
|
actions.select_all({prompt_bufnr}) *telescope.actions.select_all()*
|
||||||
Multi select all entries.
|
Multi select all entries.
|
||||||
- Note: selected entries may include results not visible in the results
|
- Note: selected entries may include results not visible in the results pop
|
||||||
popup.
|
up.
|
||||||
|
|
||||||
|
|
||||||
Parameters: ~
|
Parameters: ~
|
||||||
@ -2377,8 +2434,8 @@ actions.drop_all({prompt_bufnr}) *telescope.actions.drop_all()*
|
|||||||
|
|
||||||
actions.toggle_all({prompt_bufnr}) *telescope.actions.toggle_all()*
|
actions.toggle_all({prompt_bufnr}) *telescope.actions.toggle_all()*
|
||||||
Toggle multi selection for all entries.
|
Toggle multi selection for all entries.
|
||||||
- Note: toggled entries may include results not visible in the results
|
- Note: toggled entries may include results not visible in the results pop
|
||||||
popup.
|
up.
|
||||||
|
|
||||||
|
|
||||||
Parameters: ~
|
Parameters: ~
|
||||||
@ -2470,28 +2527,6 @@ actions.select_tab({prompt_bufnr}) *telescope.actions.select_tab()*
|
|||||||
{prompt_bufnr} (number) The prompt bufnr
|
{prompt_bufnr} (number) The prompt bufnr
|
||||||
|
|
||||||
|
|
||||||
actions.select_drop({prompt_bufnr}) *telescope.actions.select_drop()*
|
|
||||||
Perform 'drop' action on selection, usually something like
|
|
||||||
`:drop <selection>`
|
|
||||||
|
|
||||||
i.e. open the selection in a window
|
|
||||||
|
|
||||||
|
|
||||||
Parameters: ~
|
|
||||||
{prompt_bufnr} (number) The prompt bufnr
|
|
||||||
|
|
||||||
|
|
||||||
actions.select_tab_drop({prompt_bufnr}) *telescope.actions.select_tab_drop()*
|
|
||||||
Perform 'tab drop' action on selection, usually something like
|
|
||||||
`:tab drop <selection>`
|
|
||||||
|
|
||||||
i.e. open the selection in a new tab
|
|
||||||
|
|
||||||
|
|
||||||
Parameters: ~
|
|
||||||
{prompt_bufnr} (number) The prompt bufnr
|
|
||||||
|
|
||||||
|
|
||||||
actions.file_edit({prompt_bufnr}) *telescope.actions.file_edit()*
|
actions.file_edit({prompt_bufnr}) *telescope.actions.file_edit()*
|
||||||
Perform file edit on selection, usually something like
|
Perform file edit on selection, usually something like
|
||||||
`:edit <selection>`
|
`:edit <selection>`
|
||||||
@ -2547,7 +2582,7 @@ actions._close({prompt_bufnr}) *telescope.actions._close()*
|
|||||||
|
|
||||||
|
|
||||||
actions.edit_command_line({prompt_bufnr}) *telescope.actions.edit_command_line()*
|
actions.edit_command_line({prompt_bufnr}) *telescope.actions.edit_command_line()*
|
||||||
Set a value in the command line and dont run it, making it editable.
|
Set a value in the command line and don't run it, making it editable.
|
||||||
|
|
||||||
|
|
||||||
Parameters: ~
|
Parameters: ~
|
||||||
@ -2563,7 +2598,7 @@ actions.set_command_line({prompt_bufnr}) *telescope.actions.set_command_line()*
|
|||||||
|
|
||||||
|
|
||||||
actions.edit_search_line({prompt_bufnr}) *telescope.actions.edit_search_line()*
|
actions.edit_search_line({prompt_bufnr}) *telescope.actions.edit_search_line()*
|
||||||
Set a value in the search line and dont search for it, making it editable.
|
Set a value in the search line and don't search for it, making it editable.
|
||||||
|
|
||||||
|
|
||||||
Parameters: ~
|
Parameters: ~
|
||||||
@ -3087,7 +3122,7 @@ utils.map_entries({prompt_bufnr}, {f}) *telescope.actions.utils.map_entries()*
|
|||||||
Apply `f` to the entries of the current picker.
|
Apply `f` to the entries of the current picker.
|
||||||
- Notes:
|
- Notes:
|
||||||
- Mapped entries include all currently filtered results, not just the
|
- Mapped entries include all currently filtered results, not just the
|
||||||
visible onces.
|
visible ones.
|
||||||
- Indices are 1-indexed, whereas rows are 0-indexed.
|
- Indices are 1-indexed, whereas rows are 0-indexed.
|
||||||
- Warning: `map_entries` has no return value.
|
- Warning: `map_entries` has no return value.
|
||||||
- The below example showcases how to collect results
|
- The below example showcases how to collect results
|
||||||
@ -3100,7 +3135,7 @@ utils.map_entries({prompt_bufnr}, {f}) *telescope.actions.utils.map_entries()*
|
|||||||
local prompt_bufnr = vim.api.nvim_get_current_buf()
|
local prompt_bufnr = vim.api.nvim_get_current_buf()
|
||||||
local current_picker = action_state.get_current_picker(prompt_bufnr)
|
local current_picker = action_state.get_current_picker(prompt_bufnr)
|
||||||
local results = {}
|
local results = {}
|
||||||
action_utils.map_entries(prompt_bufnr, function(entry, index, row)
|
action_utils.map_entries(prompt_bufnr, function(entry, index, row)
|
||||||
results[row] = entry.value
|
results[row] = entry.value
|
||||||
end)
|
end)
|
||||||
return results
|
return results
|
||||||
@ -3119,7 +3154,8 @@ utils.map_selections({prompt_bufnr}, {f}) *telescope.actions.utils.map_selection
|
|||||||
Apply `f` to the multi selections of the current picker and return a table
|
Apply `f` to the multi selections of the current picker and return a table
|
||||||
of mapped selections.
|
of mapped selections.
|
||||||
- Notes:
|
- Notes:
|
||||||
- Mapped selections may include results not visible in the results popup.
|
- Mapped selections may include results not visible in the results pop
|
||||||
|
up.
|
||||||
- Selected entries are returned in order of their selection.
|
- Selected entries are returned in order of their selection.
|
||||||
- Warning: `map_selections` has no return value.
|
- Warning: `map_selections` has no return value.
|
||||||
- The below example showcases how to collect results
|
- The below example showcases how to collect results
|
||||||
@ -3132,7 +3168,7 @@ utils.map_selections({prompt_bufnr}, {f}) *telescope.actions.utils.map_selection
|
|||||||
local prompt_bufnr = vim.api.nvim_get_current_buf()
|
local prompt_bufnr = vim.api.nvim_get_current_buf()
|
||||||
local current_picker = action_state.get_current_picker(prompt_bufnr)
|
local current_picker = action_state.get_current_picker(prompt_bufnr)
|
||||||
local results = {}
|
local results = {}
|
||||||
action_utils.map_selections(prompt_bufnr, function(entry, index)
|
action_utils.map_selections(prompt_bufnr, function(entry, index)
|
||||||
results[index] = entry.value
|
results[index] = entry.value
|
||||||
end)
|
end)
|
||||||
return results
|
return results
|
||||||
@ -3239,7 +3275,7 @@ PREVIEWERS *telescope.previewers*
|
|||||||
|
|
||||||
Provides a Previewer table that has to be implemented by each previewer. To
|
Provides a Previewer table that has to be implemented by each previewer. To
|
||||||
achieve this, this module also provides two wrappers that abstract most of the
|
achieve this, this module also provides two wrappers that abstract most of the
|
||||||
work and make it really easy create new previewers.
|
work and make it really easy to create new previewers.
|
||||||
- `previewers.new_termopen_previewer`
|
- `previewers.new_termopen_previewer`
|
||||||
- `previewers.new_buffer_previewer`
|
- `previewers.new_buffer_previewer`
|
||||||
|
|
||||||
@ -3268,7 +3304,7 @@ previewers.Previewer() *telescope.previewers.Previewer()*
|
|||||||
|
|
||||||
What `:new` expects is listed below
|
What `:new` expects is listed below
|
||||||
|
|
||||||
The interface provides following set of functions. All of them, besides
|
The interface provides the following set of functions. All of them, besides
|
||||||
`new`, will be handled by telescope pickers.
|
`new`, will be handled by telescope pickers.
|
||||||
- `:new(opts)`
|
- `:new(opts)`
|
||||||
- `:preview(entry, status)`
|
- `:preview(entry, status)`
|
||||||
@ -3279,7 +3315,7 @@ previewers.Previewer() *telescope.previewers.Previewer()*
|
|||||||
`Previewer:new()` expects a table as input with following keys:
|
`Previewer:new()` expects a table as input with following keys:
|
||||||
- `setup` function(self): Will be called the first time preview will be
|
- `setup` function(self): Will be called the first time preview will be
|
||||||
called.
|
called.
|
||||||
- `teardown` function(self): Will be called on cleanup.
|
- `teardown` function(self): Will be called on clean up.
|
||||||
- `preview_fn` function(self, entry, status): Will be called each time a
|
- `preview_fn` function(self, entry, status): Will be called each time a
|
||||||
new entry was selected.
|
new entry was selected.
|
||||||
- `title` function(self): Will return the static title of the previewer.
|
- `title` function(self): Will return the static title of the previewer.
|
||||||
@ -3389,9 +3425,9 @@ previewers.new_buffer_previewer() *telescope.previewers.new_buffer_previewer()*
|
|||||||
table of vars that will be available in `self.state` in each
|
table of vars that will be available in `self.state` in each
|
||||||
`define_preview` call.
|
`define_preview` call.
|
||||||
- `teardown = function(self)` (optional) Will be called at the end, when
|
- `teardown = function(self)` (optional) Will be called at the end, when
|
||||||
the picker is being closed and is meant to cleanup everything that was
|
the picker is being closed and is meant to clean up everything that was
|
||||||
allocated by the previewer. The `buffer_previewer` will automatically
|
allocated by the previewer. The `buffer_previewer` will automatically
|
||||||
cleanup all created buffers. So you only need to handle things that
|
clean up all created buffers. So you only need to handle things that
|
||||||
were introduced by you.
|
were introduced by you.
|
||||||
- `keep_last_buf = true` (optional) Will not delete the last selected
|
- `keep_last_buf = true` (optional) Will not delete the last selected
|
||||||
buffer. This would allow you to reuse that buffer in the select action.
|
buffer. This would allow you to reuse that buffer in the select action.
|
||||||
@ -3399,7 +3435,7 @@ previewers.new_buffer_previewer() *telescope.previewers.new_buffer_previewer()*
|
|||||||
recreating that buffer in an action. To access the last buffer number:
|
recreating that buffer in an action. To access the last buffer number:
|
||||||
`require('telescope.state').get_global_key("last_preview_bufnr")`
|
`require('telescope.state').get_global_key("last_preview_bufnr")`
|
||||||
- `get_buffer_by_name = function(self, entry)` Allows you to set a unique
|
- `get_buffer_by_name = function(self, entry)` Allows you to set a unique
|
||||||
name for each buffer. This is used for caching purpose.
|
name for each buffer. This is used for caching purposes.
|
||||||
`self.state.bufname` will be nil if the entry was never loaded or the
|
`self.state.bufname` will be nil if the entry was never loaded or the
|
||||||
unique name when it was loaded once. For example, useful if you have
|
unique name when it was loaded once. For example, useful if you have
|
||||||
one file but multiple entries. This happens for grep and lsp builtins.
|
one file but multiple entries. This happens for grep and lsp builtins.
|
||||||
@ -3450,8 +3486,8 @@ previewers.new_buffer_previewer() *telescope.previewers.new_buffer_previewer()*
|
|||||||
vim.api.nvim_buf_call(bufnr, function()
|
vim.api.nvim_buf_call(bufnr, function()
|
||||||
-- for example `search` and `matchadd`
|
-- for example `search` and `matchadd`
|
||||||
end)
|
end)
|
||||||
to achieve that.
|
|
||||||
<
|
<
|
||||||
|
to achieve that.
|
||||||
- If you want to read a file into the buffer it's best to use
|
- If you want to read a file into the buffer it's best to use
|
||||||
`buffer_previewer_maker`. But access this function with
|
`buffer_previewer_maker`. But access this function with
|
||||||
`require('telescope.config').values.buffer_previewer_maker` because it
|
`require('telescope.config').values.buffer_previewer_maker` because it
|
||||||
@ -3495,7 +3531,7 @@ previewers.vim_buffer_vimgrep() *telescope.previewers.vim_buffer_vimgrep()*
|
|||||||
|
|
||||||
|
|
||||||
previewers.vim_buffer_qflist() *telescope.previewers.vim_buffer_qflist()*
|
previewers.vim_buffer_qflist() *telescope.previewers.vim_buffer_qflist()*
|
||||||
Is the same as `vim_buffer_vimgrep` and only exist for consistency with
|
Is the same as `vim_buffer_vimgrep` and only exists for consistency with
|
||||||
`term_previewers`.
|
`term_previewers`.
|
||||||
|
|
||||||
The preferred way of using this previewer is like this
|
The preferred way of using this previewer is like this
|
||||||
@ -3566,7 +3602,7 @@ HISTORY *telescope.actions.history*
|
|||||||
A base implementation of a prompt history that provides a simple history and
|
A base implementation of a prompt history that provides a simple history and
|
||||||
can be replaced with a custom implementation.
|
can be replaced with a custom implementation.
|
||||||
|
|
||||||
For example: We provide a extension for a smart history that uses sql.nvim to
|
For example: We provide an extension for a smart history that uses sql.nvim to
|
||||||
map histories to metadata, like the calling picker or cwd.
|
map histories to metadata, like the calling picker or cwd.
|
||||||
|
|
||||||
So you have a history for:
|
So you have a history for:
|
||||||
|
2
bundle/telescope.nvim/lua/telescope/_.lua
vendored
2
bundle/telescope.nvim/lua/telescope/_.lua
vendored
@ -21,7 +21,7 @@ function AsyncJob.new(opts)
|
|||||||
self.stderr = opts.stderr or M.NullPipe()
|
self.stderr = opts.stderr or M.NullPipe()
|
||||||
|
|
||||||
if opts.cwd and opts.cwd ~= "" then
|
if opts.cwd and opts.cwd ~= "" then
|
||||||
self.uv_opts.cwd = vim.fn.expand(opts.cwd)
|
self.uv_opts.cwd = vim.fn.expand(vim.fn.escape(opts.cwd, "$"))
|
||||||
-- this is a "illegal" hack for windows. E.g. If the git command returns `/` rather than `\` as delimiter,
|
-- this is a "illegal" hack for windows. E.g. If the git command returns `/` rather than `\` as delimiter,
|
||||||
-- vim.fn.expand might just end up returning an empty string. Weird
|
-- vim.fn.expand might just end up returning an empty string. Weird
|
||||||
-- Because empty string is not allowed in libuv the job will not spawn. Solution is we just set it to opts.cwd
|
-- Because empty string is not allowed in libuv the job will not spawn. Solution is we just set it to opts.cwd
|
||||||
|
@ -62,7 +62,7 @@ action_generate.refine = function(prompt_bufnr, opts)
|
|||||||
opts = opts or {}
|
opts = opts or {}
|
||||||
opts.prompt_to_prefix = vim.F.if_nil(opts.prompt_to_prefix, false)
|
opts.prompt_to_prefix = vim.F.if_nil(opts.prompt_to_prefix, false)
|
||||||
opts.prefix_hl_group = vim.F.if_nil(opts.prompt_hl_group, "TelescopePromptPrefix")
|
opts.prefix_hl_group = vim.F.if_nil(opts.prompt_hl_group, "TelescopePromptPrefix")
|
||||||
opts.prompt_prefix = vim.F.if_nil(opts.promt_prefix, config.values.prompt_prefix)
|
opts.prompt_prefix = vim.F.if_nil(opts.prompt_prefix, config.values.prompt_prefix)
|
||||||
opts.reset_multi_selection = vim.F.if_nil(opts.reset_multi_selection, false)
|
opts.reset_multi_selection = vim.F.if_nil(opts.reset_multi_selection, false)
|
||||||
opts.reset_prompt = vim.F.if_nil(opts.reset_prompt, true)
|
opts.reset_prompt = vim.F.if_nil(opts.reset_prompt, true)
|
||||||
opts.sorter = vim.F.if_nil(opts.sorter, config.values.generic_sorter {})
|
opts.sorter = vim.F.if_nil(opts.sorter, config.values.generic_sorter {})
|
||||||
@ -75,11 +75,11 @@ action_generate.refine = function(prompt_bufnr, opts)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- title
|
-- title
|
||||||
if opts.prompt_title then
|
if opts.prompt_title and current_picker.prompt_border then
|
||||||
current_picker.prompt_border:change_title(opts.prompt_title)
|
current_picker.prompt_border:change_title(opts.prompt_title)
|
||||||
end
|
end
|
||||||
|
|
||||||
if opts.results_title then
|
if opts.results_title and current_picker.results_border then
|
||||||
current_picker.results_border:change_title(opts.results_title)
|
current_picker.results_border:change_title(opts.results_title)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ local uv = vim.loop
|
|||||||
--- A base implementation of a prompt history that provides a simple history
|
--- A base implementation of a prompt history that provides a simple history
|
||||||
--- and can be replaced with a custom implementation.
|
--- and can be replaced with a custom implementation.
|
||||||
---
|
---
|
||||||
--- For example: We provide a extension for a smart history that uses sql.nvim
|
--- For example: We provide an extension for a smart history that uses sql.nvim
|
||||||
--- to map histories to metadata, like the calling picker or cwd.
|
--- to map histories to metadata, like the calling picker or cwd.
|
||||||
---
|
---
|
||||||
--- So you have a history for:
|
--- So you have a history for:
|
||||||
|
224
bundle/telescope.nvim/lua/telescope/actions/init.lua
vendored
224
bundle/telescope.nvim/lua/telescope/actions/init.lua
vendored
@ -2,9 +2,9 @@
|
|||||||
---@config { ["module"] = "telescope.actions" }
|
---@config { ["module"] = "telescope.actions" }
|
||||||
|
|
||||||
---@brief [[
|
---@brief [[
|
||||||
--- Actions functions that are useful for people creating their own mappings.
|
--- These functions are useful for people creating their own mappings.
|
||||||
---
|
---
|
||||||
--- Actions can be either normal functions that expect the prompt_bufnr as
|
--- Actions can be either normal functions that expect the `prompt_bufnr` as
|
||||||
--- first argument (1) or they can be a custom telescope type called "action" (2).
|
--- first argument (1) or they can be a custom telescope type called "action" (2).
|
||||||
---
|
---
|
||||||
--- (1) The `prompt_bufnr` of a normal function denotes the identifier of your
|
--- (1) The `prompt_bufnr` of a normal function denotes the identifier of your
|
||||||
@ -45,7 +45,7 @@
|
|||||||
--- action(bufnr)
|
--- action(bufnr)
|
||||||
--- </code>
|
--- </code>
|
||||||
---
|
---
|
||||||
--- Another interesing thing to do is that these actions now have functions you
|
--- Another interesting thing to do is that these actions now have functions you
|
||||||
--- can call. These functions include `:replace(f)`, `:replace_if(f, c)`,
|
--- can call. These functions include `:replace(f)`, `:replace_if(f, c)`,
|
||||||
--- `replace_map(tbl)` and `enhance(tbl)`. More information on these functions
|
--- `replace_map(tbl)` and `enhance(tbl)`. More information on these functions
|
||||||
--- can be found in the `developers.md` and `lua/tests/automated/action_spec.lua`
|
--- can be found in the `developers.md` and `lua/tests/automated/action_spec.lua`
|
||||||
@ -75,6 +75,12 @@ local actions = setmetatable({}, {
|
|||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
local append_to_history = function(prompt_bufnr)
|
||||||
|
action_state
|
||||||
|
.get_current_history()
|
||||||
|
:append(action_state.get_current_line(), action_state.get_current_picker(prompt_bufnr))
|
||||||
|
end
|
||||||
|
|
||||||
--- Move the selection to the next entry
|
--- Move the selection to the next entry
|
||||||
---@param prompt_bufnr number: The prompt bufnr
|
---@param prompt_bufnr number: The prompt bufnr
|
||||||
actions.move_selection_next = function(prompt_bufnr)
|
actions.move_selection_next = function(prompt_bufnr)
|
||||||
@ -150,7 +156,7 @@ actions.toggle_selection = function(prompt_bufnr)
|
|||||||
end
|
end
|
||||||
|
|
||||||
--- Multi select all entries.
|
--- Multi select all entries.
|
||||||
--- - Note: selected entries may include results not visible in the results popup.
|
--- - Note: selected entries may include results not visible in the results pop up.
|
||||||
---@param prompt_bufnr number: The prompt bufnr
|
---@param prompt_bufnr number: The prompt bufnr
|
||||||
actions.select_all = function(prompt_bufnr)
|
actions.select_all = function(prompt_bufnr)
|
||||||
local current_picker = action_state.get_current_picker(prompt_bufnr)
|
local current_picker = action_state.get_current_picker(prompt_bufnr)
|
||||||
@ -187,7 +193,7 @@ actions.drop_all = function(prompt_bufnr)
|
|||||||
end
|
end
|
||||||
|
|
||||||
--- Toggle multi selection for all entries.
|
--- Toggle multi selection for all entries.
|
||||||
--- - Note: toggled entries may include results not visible in the results popup.
|
--- - Note: toggled entries may include results not visible in the results pop up.
|
||||||
---@param prompt_bufnr number: The prompt bufnr
|
---@param prompt_bufnr number: The prompt bufnr
|
||||||
actions.toggle_all = function(prompt_bufnr)
|
actions.toggle_all = function(prompt_bufnr)
|
||||||
local current_picker = action_state.get_current_picker(prompt_bufnr)
|
local current_picker = action_state.get_current_picker(prompt_bufnr)
|
||||||
@ -241,11 +247,7 @@ end
|
|||||||
--- i.e. open the selection in the current buffer
|
--- i.e. open the selection in the current buffer
|
||||||
---@param prompt_bufnr number: The prompt bufnr
|
---@param prompt_bufnr number: The prompt bufnr
|
||||||
actions.select_default = {
|
actions.select_default = {
|
||||||
pre = function(prompt_bufnr)
|
pre = append_to_history,
|
||||||
action_state
|
|
||||||
.get_current_history()
|
|
||||||
:append(action_state.get_current_line(), action_state.get_current_picker(prompt_bufnr))
|
|
||||||
end,
|
|
||||||
action = function(prompt_bufnr)
|
action = function(prompt_bufnr)
|
||||||
return action_set.select(prompt_bufnr, "default")
|
return action_set.select(prompt_bufnr, "default")
|
||||||
end,
|
end,
|
||||||
@ -257,11 +259,7 @@ actions.select_default = {
|
|||||||
--- i.e. open the selection in a new horizontal split
|
--- i.e. open the selection in a new horizontal split
|
||||||
---@param prompt_bufnr number: The prompt bufnr
|
---@param prompt_bufnr number: The prompt bufnr
|
||||||
actions.select_horizontal = {
|
actions.select_horizontal = {
|
||||||
pre = function(prompt_bufnr)
|
pre = append_to_history,
|
||||||
action_state
|
|
||||||
.get_current_history()
|
|
||||||
:append(action_state.get_current_line(), action_state.get_current_picker(prompt_bufnr))
|
|
||||||
end,
|
|
||||||
action = function(prompt_bufnr)
|
action = function(prompt_bufnr)
|
||||||
return action_set.select(prompt_bufnr, "horizontal")
|
return action_set.select(prompt_bufnr, "horizontal")
|
||||||
end,
|
end,
|
||||||
@ -273,11 +271,7 @@ actions.select_horizontal = {
|
|||||||
--- i.e. open the selection in a new vertical split
|
--- i.e. open the selection in a new vertical split
|
||||||
---@param prompt_bufnr number: The prompt bufnr
|
---@param prompt_bufnr number: The prompt bufnr
|
||||||
actions.select_vertical = {
|
actions.select_vertical = {
|
||||||
pre = function(prompt_bufnr)
|
pre = append_to_history,
|
||||||
action_state
|
|
||||||
.get_current_history()
|
|
||||||
:append(action_state.get_current_line(), action_state.get_current_picker(prompt_bufnr))
|
|
||||||
end,
|
|
||||||
action = function(prompt_bufnr)
|
action = function(prompt_bufnr)
|
||||||
return action_set.select(prompt_bufnr, "vertical")
|
return action_set.select(prompt_bufnr, "vertical")
|
||||||
end,
|
end,
|
||||||
@ -289,48 +283,12 @@ actions.select_vertical = {
|
|||||||
--- i.e. open the selection in a new tab
|
--- i.e. open the selection in a new tab
|
||||||
---@param prompt_bufnr number: The prompt bufnr
|
---@param prompt_bufnr number: The prompt bufnr
|
||||||
actions.select_tab = {
|
actions.select_tab = {
|
||||||
pre = function(prompt_bufnr)
|
pre = append_to_history,
|
||||||
action_state
|
|
||||||
.get_current_history()
|
|
||||||
:append(action_state.get_current_line(), action_state.get_current_picker(prompt_bufnr))
|
|
||||||
end,
|
|
||||||
action = function(prompt_bufnr)
|
action = function(prompt_bufnr)
|
||||||
return action_set.select(prompt_bufnr, "tab")
|
return action_set.select(prompt_bufnr, "tab")
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
--- Perform 'drop' action on selection, usually something like<br>
|
|
||||||
---`:drop <selection>`
|
|
||||||
---
|
|
||||||
--- i.e. open the selection in a window
|
|
||||||
---@param prompt_bufnr number: The prompt bufnr
|
|
||||||
actions.select_drop = {
|
|
||||||
pre = function(prompt_bufnr)
|
|
||||||
action_state
|
|
||||||
.get_current_history()
|
|
||||||
:append(action_state.get_current_line(), action_state.get_current_picker(prompt_bufnr))
|
|
||||||
end,
|
|
||||||
action = function(prompt_bufnr)
|
|
||||||
return action_set.select(prompt_bufnr, "drop")
|
|
||||||
end,
|
|
||||||
}
|
|
||||||
|
|
||||||
--- Perform 'tab drop' action on selection, usually something like<br>
|
|
||||||
---`:tab drop <selection>`
|
|
||||||
---
|
|
||||||
--- i.e. open the selection in a new tab
|
|
||||||
---@param prompt_bufnr number: The prompt bufnr
|
|
||||||
actions.select_tab_drop = {
|
|
||||||
pre = function(prompt_bufnr)
|
|
||||||
action_state
|
|
||||||
.get_current_history()
|
|
||||||
:append(action_state.get_current_line(), action_state.get_current_picker(prompt_bufnr))
|
|
||||||
end,
|
|
||||||
action = function(prompt_bufnr)
|
|
||||||
return action_set.select(prompt_bufnr, "tab drop")
|
|
||||||
end,
|
|
||||||
}
|
|
||||||
|
|
||||||
-- TODO: consider adding float!
|
-- TODO: consider adding float!
|
||||||
-- https://github.com/nvim-telescope/telescope.nvim/issues/365
|
-- https://github.com/nvim-telescope/telescope.nvim/issues/365
|
||||||
|
|
||||||
@ -394,16 +352,17 @@ end
|
|||||||
|
|
||||||
local set_edit_line = function(prompt_bufnr, fname, prefix, postfix)
|
local set_edit_line = function(prompt_bufnr, fname, prefix, postfix)
|
||||||
postfix = vim.F.if_nil(postfix, "")
|
postfix = vim.F.if_nil(postfix, "")
|
||||||
|
postfix = a.nvim_replace_termcodes(postfix, true, false, true)
|
||||||
local selection = action_state.get_selected_entry()
|
local selection = action_state.get_selected_entry()
|
||||||
if selection == nil then
|
if selection == nil then
|
||||||
utils.__warn_no_selection(fname)
|
utils.__warn_no_selection(fname)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
actions.close(prompt_bufnr)
|
actions.close(prompt_bufnr)
|
||||||
a.nvim_feedkeys(a.nvim_replace_termcodes(prefix .. selection.value .. postfix, true, false, true), "t", true)
|
a.nvim_feedkeys(prefix .. selection.value .. postfix, "n", true)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Set a value in the command line and dont run it, making it editable.
|
--- Set a value in the command line and don't run it, making it editable.
|
||||||
---@param prompt_bufnr number: The prompt bufnr
|
---@param prompt_bufnr number: The prompt bufnr
|
||||||
actions.edit_command_line = function(prompt_bufnr)
|
actions.edit_command_line = function(prompt_bufnr)
|
||||||
set_edit_line(prompt_bufnr, "actions.edit_command_line", ":")
|
set_edit_line(prompt_bufnr, "actions.edit_command_line", ":")
|
||||||
@ -422,7 +381,7 @@ actions.set_command_line = function(prompt_bufnr)
|
|||||||
vim.cmd(selection.value)
|
vim.cmd(selection.value)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Set a value in the search line and dont search for it, making it editable.
|
--- Set a value in the search line and don't search for it, making it editable.
|
||||||
---@param prompt_bufnr number: The prompt bufnr
|
---@param prompt_bufnr number: The prompt bufnr
|
||||||
actions.edit_search_line = function(prompt_bufnr)
|
actions.edit_search_line = function(prompt_bufnr)
|
||||||
set_edit_line(prompt_bufnr, "actions.edit_search_line", "/")
|
set_edit_line(prompt_bufnr, "actions.edit_search_line", "/")
|
||||||
@ -781,7 +740,7 @@ actions.git_checkout_current_buffer = function(prompt_bufnr)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
actions.close(prompt_bufnr)
|
actions.close(prompt_bufnr)
|
||||||
utils.get_os_command_output({ "git", "checkout", selection.value, "--", selection.file }, cwd)
|
utils.get_os_command_output({ "git", "checkout", selection.value, "--", selection.current_file }, cwd)
|
||||||
vim.cmd "checktime"
|
vim.cmd "checktime"
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -864,51 +823,68 @@ end
|
|||||||
|
|
||||||
--- Sends the selected entries to the quickfix list, replacing the previous entries.
|
--- Sends the selected entries to the quickfix list, replacing the previous entries.
|
||||||
---@param prompt_bufnr number: The prompt bufnr
|
---@param prompt_bufnr number: The prompt bufnr
|
||||||
actions.send_selected_to_qflist = function(prompt_bufnr)
|
actions.send_selected_to_qflist = {
|
||||||
send_selected_to_qf(prompt_bufnr, " ")
|
pre = append_to_history,
|
||||||
end
|
action = function(prompt_bufnr)
|
||||||
|
send_selected_to_qf(prompt_bufnr, " ")
|
||||||
|
end,
|
||||||
|
}
|
||||||
--- Adds the selected entries to the quickfix list, keeping the previous entries.
|
--- Adds the selected entries to the quickfix list, keeping the previous entries.
|
||||||
---@param prompt_bufnr number: The prompt bufnr
|
---@param prompt_bufnr number: The prompt bufnr
|
||||||
actions.add_selected_to_qflist = function(prompt_bufnr)
|
actions.add_selected_to_qflist = {
|
||||||
send_selected_to_qf(prompt_bufnr, "a")
|
pre = append_to_history,
|
||||||
end
|
action = function(prompt_bufnr)
|
||||||
|
send_selected_to_qf(prompt_bufnr, "a")
|
||||||
|
end,
|
||||||
|
}
|
||||||
--- Sends all entries to the quickfix list, replacing the previous entries.
|
--- Sends all entries to the quickfix list, replacing the previous entries.
|
||||||
---@param prompt_bufnr number: The prompt bufnr
|
---@param prompt_bufnr number: The prompt bufnr
|
||||||
actions.send_to_qflist = function(prompt_bufnr)
|
actions.send_to_qflist = {
|
||||||
send_all_to_qf(prompt_bufnr, " ")
|
pre = append_to_history,
|
||||||
end
|
action = function(prompt_bufnr)
|
||||||
|
send_all_to_qf(prompt_bufnr, " ")
|
||||||
|
end,
|
||||||
|
}
|
||||||
--- Adds all entries to the quickfix list, keeping the previous entries.
|
--- Adds all entries to the quickfix list, keeping the previous entries.
|
||||||
---@param prompt_bufnr number: The prompt bufnr
|
---@param prompt_bufnr number: The prompt bufnr
|
||||||
actions.add_to_qflist = function(prompt_bufnr)
|
actions.add_to_qflist = {
|
||||||
send_all_to_qf(prompt_bufnr, "a")
|
pre = append_to_history,
|
||||||
end
|
action = function(prompt_bufnr)
|
||||||
|
send_all_to_qf(prompt_bufnr, "a")
|
||||||
|
end,
|
||||||
|
}
|
||||||
--- Sends the selected entries to the location list, replacing the previous entries.
|
--- Sends the selected entries to the location list, replacing the previous entries.
|
||||||
---@param prompt_bufnr number: The prompt bufnr
|
---@param prompt_bufnr number: The prompt bufnr
|
||||||
actions.send_selected_to_loclist = function(prompt_bufnr)
|
actions.send_selected_to_loclist = {
|
||||||
send_selected_to_qf(prompt_bufnr, " ", "loclist")
|
pre = append_to_history,
|
||||||
end
|
action = function(prompt_bufnr)
|
||||||
|
send_selected_to_qf(prompt_bufnr, " ", "loclist")
|
||||||
|
end,
|
||||||
|
}
|
||||||
--- Adds the selected entries to the location list, keeping the previous entries.
|
--- Adds the selected entries to the location list, keeping the previous entries.
|
||||||
---@param prompt_bufnr number: The prompt bufnr
|
---@param prompt_bufnr number: The prompt bufnr
|
||||||
actions.add_selected_to_loclist = function(prompt_bufnr)
|
actions.add_selected_to_loclist = {
|
||||||
send_selected_to_qf(prompt_bufnr, "a", "loclist")
|
pre = append_to_history,
|
||||||
end
|
action = function(prompt_bufnr)
|
||||||
|
send_selected_to_qf(prompt_bufnr, "a", "loclist")
|
||||||
|
end,
|
||||||
|
}
|
||||||
--- Sends all entries to the location list, replacing the previous entries.
|
--- Sends all entries to the location list, replacing the previous entries.
|
||||||
---@param prompt_bufnr number: The prompt bufnr
|
---@param prompt_bufnr number: The prompt bufnr
|
||||||
actions.send_to_loclist = function(prompt_bufnr)
|
actions.send_to_loclist = {
|
||||||
send_all_to_qf(prompt_bufnr, " ", "loclist")
|
pre = append_to_history,
|
||||||
end
|
action = function(prompt_bufnr)
|
||||||
|
send_all_to_qf(prompt_bufnr, " ", "loclist")
|
||||||
|
end,
|
||||||
|
}
|
||||||
--- Adds all entries to the location list, keeping the previous entries.
|
--- Adds all entries to the location list, keeping the previous entries.
|
||||||
---@param prompt_bufnr number: The prompt bufnr
|
---@param prompt_bufnr number: The prompt bufnr
|
||||||
actions.add_to_loclist = function(prompt_bufnr)
|
actions.add_to_loclist = {
|
||||||
send_all_to_qf(prompt_bufnr, "a", "loclist")
|
pre = append_to_history,
|
||||||
end
|
action = function(prompt_bufnr)
|
||||||
|
send_all_to_qf(prompt_bufnr, "a", "loclist")
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
|
||||||
local smart_send = function(prompt_bufnr, mode, target)
|
local smart_send = function(prompt_bufnr, mode, target)
|
||||||
local picker = action_state.get_current_picker(prompt_bufnr)
|
local picker = action_state.get_current_picker(prompt_bufnr)
|
||||||
@ -922,31 +898,39 @@ end
|
|||||||
--- Sends the selected entries to the quickfix list, replacing the previous entries.
|
--- Sends the selected entries to the quickfix list, replacing the previous entries.
|
||||||
--- If no entry was selected, sends all entries.
|
--- If no entry was selected, sends all entries.
|
||||||
---@param prompt_bufnr number: The prompt bufnr
|
---@param prompt_bufnr number: The prompt bufnr
|
||||||
actions.smart_send_to_qflist = function(prompt_bufnr)
|
actions.smart_send_to_qflist = {
|
||||||
smart_send(prompt_bufnr, " ")
|
pre = append_to_history,
|
||||||
end
|
action = function(prompt_bufnr)
|
||||||
|
smart_send(prompt_bufnr, " ")
|
||||||
|
end,
|
||||||
|
}
|
||||||
--- Adds the selected entries to the quickfix list, keeping the previous entries.
|
--- Adds the selected entries to the quickfix list, keeping the previous entries.
|
||||||
--- If no entry was selected, adds all entries.
|
--- If no entry was selected, adds all entries.
|
||||||
---@param prompt_bufnr number: The prompt bufnr
|
---@param prompt_bufnr number: The prompt bufnr
|
||||||
actions.smart_add_to_qflist = function(prompt_bufnr)
|
actions.smart_add_to_qflist = {
|
||||||
smart_send(prompt_bufnr, "a")
|
pre = append_to_history,
|
||||||
end
|
action = function(prompt_bufnr)
|
||||||
|
smart_send(prompt_bufnr, "a")
|
||||||
|
end,
|
||||||
|
}
|
||||||
--- Sends the selected entries to the location list, replacing the previous entries.
|
--- Sends the selected entries to the location list, replacing the previous entries.
|
||||||
--- If no entry was selected, sends all entries.
|
--- If no entry was selected, sends all entries.
|
||||||
---@param prompt_bufnr number: The prompt bufnr
|
---@param prompt_bufnr number: The prompt bufnr
|
||||||
actions.smart_send_to_loclist = function(prompt_bufnr)
|
actions.smart_send_to_loclist = {
|
||||||
smart_send(prompt_bufnr, " ", "loclist")
|
pre = append_to_history,
|
||||||
end
|
action = function(prompt_bufnr)
|
||||||
|
smart_send(prompt_bufnr, " ", "loclist")
|
||||||
|
end,
|
||||||
|
}
|
||||||
--- Adds the selected entries to the location list, keeping the previous entries.
|
--- Adds the selected entries to the location list, keeping the previous entries.
|
||||||
--- If no entry was selected, adds all entries.
|
--- If no entry was selected, adds all entries.
|
||||||
---@param prompt_bufnr number: The prompt bufnr
|
---@param prompt_bufnr number: The prompt bufnr
|
||||||
actions.smart_add_to_loclist = function(prompt_bufnr)
|
actions.smart_add_to_loclist = {
|
||||||
smart_send(prompt_bufnr, "a", "loclist")
|
pre = append_to_history,
|
||||||
end
|
action = function(prompt_bufnr)
|
||||||
|
smart_send(prompt_bufnr, "a", "loclist")
|
||||||
|
end,
|
||||||
|
}
|
||||||
--- Open completion menu containing the tags which can be used to filter the results in a faster way
|
--- Open completion menu containing the tags which can be used to filter the results in a faster way
|
||||||
---@param prompt_bufnr number: The prompt bufnr
|
---@param prompt_bufnr number: The prompt bufnr
|
||||||
actions.complete_tag = function(prompt_bufnr)
|
actions.complete_tag = function(prompt_bufnr)
|
||||||
@ -1037,7 +1021,7 @@ end
|
|||||||
--- `actions.smart_send_to_qflist + actions.open_qflist`
|
--- `actions.smart_send_to_qflist + actions.open_qflist`
|
||||||
---@param prompt_bufnr number: The prompt bufnr
|
---@param prompt_bufnr number: The prompt bufnr
|
||||||
actions.open_qflist = function(prompt_bufnr)
|
actions.open_qflist = function(prompt_bufnr)
|
||||||
vim.cmd [[copen]]
|
vim.cmd [[botright copen]]
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Open the location list. It makes sense to use this in combination with one of the send_to_loclist actions
|
--- Open the location list. It makes sense to use this in combination with one of the send_to_loclist actions
|
||||||
@ -1154,26 +1138,10 @@ actions.which_key = function(prompt_bufnr, opts)
|
|||||||
local mappings = {}
|
local mappings = {}
|
||||||
local mode = a.nvim_get_mode().mode
|
local mode = a.nvim_get_mode().mode
|
||||||
for _, v in pairs(action_utils.get_registered_mappings(prompt_bufnr)) do
|
for _, v in pairs(action_utils.get_registered_mappings(prompt_bufnr)) do
|
||||||
-- holds true for registered keymaps
|
if v.desc and v.desc ~= "which_key" and v.desc ~= "nop" then
|
||||||
if type(v.func) == "table" then
|
|
||||||
local name = ""
|
|
||||||
for _, action in ipairs(v.func) do
|
|
||||||
if type(action) == "string" then
|
|
||||||
name = name == "" and action or name .. " + " .. action
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if name and name ~= "which_key" and name ~= "nop" then
|
|
||||||
if not opts.only_show_current_mode or mode == v.mode then
|
|
||||||
table.insert(mappings, { mode = v.mode, keybind = v.keybind, name = name })
|
|
||||||
end
|
|
||||||
end
|
|
||||||
elseif type(v.func) == "function" then
|
|
||||||
if not opts.only_show_current_mode or mode == v.mode then
|
if not opts.only_show_current_mode or mode == v.mode then
|
||||||
local fname = action_utils._get_anon_function_name(v.func)
|
table.insert(mappings, { mode = v.mode, keybind = v.keybind, name = v.desc })
|
||||||
-- telescope.setup mappings might result in function names that reflect the keys
|
if v.desc == "<anonymous>" then
|
||||||
fname = fname:lower() == v.keybind:lower() and "<anonymous>" or fname
|
|
||||||
table.insert(mappings, { mode = v.mode, keybind = v.keybind, name = fname })
|
|
||||||
if fname == "<anonymous>" then
|
|
||||||
utils.notify("actions.which_key", {
|
utils.notify("actions.which_key", {
|
||||||
msg = "No name available for anonymous functions.",
|
msg = "No name available for anonymous functions.",
|
||||||
level = "INFO",
|
level = "INFO",
|
||||||
|
@ -67,8 +67,6 @@ end
|
|||||||
local edit_buffer
|
local edit_buffer
|
||||||
do
|
do
|
||||||
local map = {
|
local map = {
|
||||||
drop = "drop",
|
|
||||||
["tab drop"] = "tab drop",
|
|
||||||
edit = "buffer",
|
edit = "buffer",
|
||||||
new = "sbuffer",
|
new = "sbuffer",
|
||||||
vnew = "vert sbuffer",
|
vnew = "vert sbuffer",
|
||||||
@ -80,11 +78,7 @@ do
|
|||||||
if command == nil then
|
if command == nil then
|
||||||
error "There was no associated buffer command"
|
error "There was no associated buffer command"
|
||||||
end
|
end
|
||||||
if command ~= "drop" and command ~= "tab drop" then
|
vim.cmd(string.format("%s %d", command, bufnr))
|
||||||
vim.cmd(string.format("%s %d", command, bufnr))
|
|
||||||
else
|
|
||||||
vim.cmd(string.format("%s %s", command, vim.api.nvim_buf_get_name(bufnr)))
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -110,7 +104,7 @@ action_set.edit = function(prompt_bufnr, command)
|
|||||||
|
|
||||||
-- TODO: Check for off-by-one
|
-- TODO: Check for off-by-one
|
||||||
row = entry.row or entry.lnum
|
row = entry.row or entry.lnum
|
||||||
col = vim.F.if_nil(entry.col, 1)
|
col = entry.col
|
||||||
elseif not entry.bufnr then
|
elseif not entry.bufnr then
|
||||||
-- TODO: Might want to remove this and force people
|
-- TODO: Might want to remove this and force people
|
||||||
-- to put stuff into `filename`
|
-- to put stuff into `filename`
|
||||||
@ -164,8 +158,19 @@ action_set.edit = function(prompt_bufnr, command)
|
|||||||
-- check if we didn't pick a different buffer
|
-- check if we didn't pick a different buffer
|
||||||
-- prevents restarting lsp server
|
-- prevents restarting lsp server
|
||||||
if vim.api.nvim_buf_get_name(0) ~= filename or command ~= "edit" then
|
if vim.api.nvim_buf_get_name(0) ~= filename or command ~= "edit" then
|
||||||
filename = Path:new(vim.fn.fnameescape(filename)):normalize(vim.loop.cwd())
|
filename = Path:new(filename):normalize(vim.loop.cwd())
|
||||||
pcall(vim.cmd, string.format("%s %s", command, filename))
|
pcall(vim.cmd, string.format("%s %s", command, vim.fn.fnameescape(filename)))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local pos = vim.api.nvim_win_get_cursor(0)
|
||||||
|
if col == nil then
|
||||||
|
if row == pos[1] then
|
||||||
|
col = pos[2] + 1
|
||||||
|
elseif row == nil then
|
||||||
|
row, col = pos[1], pos[2] + 1
|
||||||
|
else
|
||||||
|
col = 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -33,8 +33,6 @@ local select_to_edit_map = {
|
|||||||
horizontal = "new",
|
horizontal = "new",
|
||||||
vertical = "vnew",
|
vertical = "vnew",
|
||||||
tab = "tabedit",
|
tab = "tabedit",
|
||||||
drop = "drop",
|
|
||||||
["tab drop"] = "tab drop",
|
|
||||||
}
|
}
|
||||||
function action_state.select_key_to_edit_key(type)
|
function action_state.select_key_to_edit_key(type)
|
||||||
return select_to_edit_map[type]
|
return select_to_edit_map[type]
|
||||||
|
@ -13,7 +13,7 @@ local utils = {}
|
|||||||
|
|
||||||
--- Apply `f` to the entries of the current picker.
|
--- Apply `f` to the entries of the current picker.
|
||||||
--- - Notes:
|
--- - Notes:
|
||||||
--- - Mapped entries include all currently filtered results, not just the visible onces.
|
--- - Mapped entries include all currently filtered results, not just the visible ones.
|
||||||
--- - Indices are 1-indexed, whereas rows are 0-indexed.
|
--- - Indices are 1-indexed, whereas rows are 0-indexed.
|
||||||
--- - Warning: `map_entries` has no return value.
|
--- - Warning: `map_entries` has no return value.
|
||||||
--- - The below example showcases how to collect results
|
--- - The below example showcases how to collect results
|
||||||
@ -26,7 +26,7 @@ local utils = {}
|
|||||||
--- local prompt_bufnr = vim.api.nvim_get_current_buf()
|
--- local prompt_bufnr = vim.api.nvim_get_current_buf()
|
||||||
--- local current_picker = action_state.get_current_picker(prompt_bufnr)
|
--- local current_picker = action_state.get_current_picker(prompt_bufnr)
|
||||||
--- local results = {}
|
--- local results = {}
|
||||||
--- action_utils.map_entries(prompt_bufnr, function(entry, index, row)
|
--- action_utils.map_entries(prompt_bufnr, function(entry, index, row)
|
||||||
--- results[row] = entry.value
|
--- results[row] = entry.value
|
||||||
--- end)
|
--- end)
|
||||||
--- return results
|
--- return results
|
||||||
@ -50,7 +50,7 @@ end
|
|||||||
|
|
||||||
--- Apply `f` to the multi selections of the current picker and return a table of mapped selections.
|
--- Apply `f` to the multi selections of the current picker and return a table of mapped selections.
|
||||||
--- - Notes:
|
--- - Notes:
|
||||||
--- - Mapped selections may include results not visible in the results popup.
|
--- - Mapped selections may include results not visible in the results pop up.
|
||||||
--- - Selected entries are returned in order of their selection.
|
--- - Selected entries are returned in order of their selection.
|
||||||
--- - Warning: `map_selections` has no return value.
|
--- - Warning: `map_selections` has no return value.
|
||||||
--- - The below example showcases how to collect results
|
--- - The below example showcases how to collect results
|
||||||
@ -63,7 +63,7 @@ end
|
|||||||
--- local prompt_bufnr = vim.api.nvim_get_current_buf()
|
--- local prompt_bufnr = vim.api.nvim_get_current_buf()
|
||||||
--- local current_picker = action_state.get_current_picker(prompt_bufnr)
|
--- local current_picker = action_state.get_current_picker(prompt_bufnr)
|
||||||
--- local results = {}
|
--- local results = {}
|
||||||
--- action_utils.map_selections(prompt_bufnr, function(entry, index)
|
--- action_utils.map_selections(prompt_bufnr, function(entry, index)
|
||||||
--- results[index] = entry.value
|
--- results[index] = entry.value
|
||||||
--- end)
|
--- end)
|
||||||
--- return results
|
--- return results
|
||||||
@ -81,25 +81,25 @@ function utils.map_selections(prompt_bufnr, f)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local findnth = function(str, nth)
|
|
||||||
local array = {}
|
|
||||||
for i in string.gmatch(str, "%d+") do
|
|
||||||
table.insert(array, tonumber(i))
|
|
||||||
end
|
|
||||||
return array[nth]
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Utility to collect mappings of prompt buffer in array of `{mode, keybind, name}`.
|
--- Utility to collect mappings of prompt buffer in array of `{mode, keybind, name}`.
|
||||||
---@param prompt_bufnr number: The prompt bufnr
|
---@param prompt_bufnr number: The prompt bufnr
|
||||||
function utils.get_registered_mappings(prompt_bufnr)
|
function utils.get_registered_mappings(prompt_bufnr)
|
||||||
local ret = {}
|
local ret = {}
|
||||||
for _, mode in ipairs { "n", "i" } do
|
for _, mode in ipairs { "n", "i" } do
|
||||||
local mode_mappings = vim.api.nvim_buf_get_keymap(prompt_bufnr, mode)
|
for _, mapping in ipairs(vim.api.nvim_buf_get_keymap(prompt_bufnr, mode)) do
|
||||||
for _, mapping in ipairs(mode_mappings) do
|
|
||||||
-- ensure only telescope mappings
|
-- ensure only telescope mappings
|
||||||
if mapping.rhs and string.find(mapping.rhs, [[require%('telescope.mappings'%).execute_keymap]]) then
|
if mapping.desc then
|
||||||
local funcid = findnth(mapping.rhs, 2)
|
if mapping.desc:sub(1, 10) == "telescope|" then
|
||||||
table.insert(ret, { mode = mode, keybind = mapping.lhs, func = __TelescopeKeymapStore[prompt_bufnr][funcid] })
|
table.insert(ret, { mode = mode, keybind = mapping.lhs, desc = mapping.desc:sub(11) })
|
||||||
|
elseif mapping.desc:sub(1, 11) == "telescopej|" then
|
||||||
|
local fname = utils._get_anon_function_name(vim.json.decode(mapping.desc:sub(12)))
|
||||||
|
fname = fname:lower() == mapping.lhs:lower() and "<anonymous>" or fname
|
||||||
|
table.insert(ret, {
|
||||||
|
mode = mode,
|
||||||
|
keybind = mapping.lhs,
|
||||||
|
desc = fname,
|
||||||
|
})
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -107,9 +107,8 @@ function utils.get_registered_mappings(prompt_bufnr)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Best effort to infer function names for actions.which_key
|
-- Best effort to infer function names for actions.which_key
|
||||||
function utils._get_anon_function_name(func_ref)
|
function utils._get_anon_function_name(info)
|
||||||
local Path = require "plenary.path"
|
local Path = require "plenary.path"
|
||||||
local info = debug.getinfo(func_ref)
|
|
||||||
local fname
|
local fname
|
||||||
-- if fn defined in string (ie loadstring) source is string
|
-- if fn defined in string (ie loadstring) source is string
|
||||||
-- if fn defined in file, source is file name prefixed with a `@´
|
-- if fn defined in file, source is file name prefixed with a `@´
|
||||||
|
@ -59,6 +59,36 @@ local get_open_filelist = function(grep_open_files, cwd)
|
|||||||
return filelist
|
return filelist
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local opts_contain_invert = function(args)
|
||||||
|
local invert = false
|
||||||
|
local files_with_matches = false
|
||||||
|
|
||||||
|
for _, v in ipairs(args) do
|
||||||
|
if v == "--invert-match" then
|
||||||
|
invert = true
|
||||||
|
elseif v == "--files-with-matches" or v == "--files-without-match" then
|
||||||
|
files_with_matches = true
|
||||||
|
end
|
||||||
|
|
||||||
|
if #v >= 2 and v:sub(1, 1) == "-" and v:sub(2, 2) ~= "-" then
|
||||||
|
local non_option = false
|
||||||
|
for i = 2, #v do
|
||||||
|
local vi = v:sub(i, i)
|
||||||
|
if vi == "=" then -- ignore option -g=xxx
|
||||||
|
break
|
||||||
|
elseif vi == "g" or vi == "f" or vi == "m" or vi == "e" or vi == "r" or vi == "t" or vi == "T" then
|
||||||
|
non_option = true
|
||||||
|
elseif non_option == false and vi == "v" then
|
||||||
|
invert = true
|
||||||
|
elseif non_option == false and vi == "l" then
|
||||||
|
files_with_matches = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return invert, files_with_matches
|
||||||
|
end
|
||||||
|
|
||||||
-- Special keys:
|
-- Special keys:
|
||||||
-- opts.search_dirs -- list of directory to search in
|
-- opts.search_dirs -- list of directory to search in
|
||||||
-- opts.grep_open_files -- boolean to restrict search to open files
|
-- opts.grep_open_files -- boolean to restrict search to open files
|
||||||
@ -96,9 +126,10 @@ files.live_grep = function(opts)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local live_grepper = finders.new_job(function(prompt)
|
local args = flatten { vimgrep_arguments, additional_args }
|
||||||
-- TODO: Probably could add some options for smart case and whatever else rg offers.
|
opts.__inverted, opts.__matches = opts_contain_invert(args)
|
||||||
|
|
||||||
|
local live_grepper = finders.new_job(function(prompt)
|
||||||
if not prompt or prompt == "" then
|
if not prompt or prompt == "" then
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
@ -111,7 +142,7 @@ files.live_grep = function(opts)
|
|||||||
search_list = search_dirs
|
search_list = search_dirs
|
||||||
end
|
end
|
||||||
|
|
||||||
return flatten { vimgrep_arguments, additional_args, "--", prompt, search_list }
|
return flatten { args, "--", prompt, search_list }
|
||||||
end, opts.entry_maker or make_entry.gen_from_vimgrep(opts), opts.max_results, opts.cwd)
|
end, opts.entry_maker or make_entry.gen_from_vimgrep(opts), opts.max_results, opts.cwd)
|
||||||
|
|
||||||
pickers
|
pickers
|
||||||
@ -148,7 +179,6 @@ files.grep_string = function(opts)
|
|||||||
|
|
||||||
if search == "" then
|
if search == "" then
|
||||||
search = { "-v", "--", "^[[:space:]]*$" }
|
search = { "-v", "--", "^[[:space:]]*$" }
|
||||||
opts.__inverted = true
|
|
||||||
else
|
else
|
||||||
search = { "--", search }
|
search = { "--", search }
|
||||||
end
|
end
|
||||||
@ -159,6 +189,7 @@ files.grep_string = function(opts)
|
|||||||
opts.word_match,
|
opts.word_match,
|
||||||
search,
|
search,
|
||||||
}
|
}
|
||||||
|
opts.__inverted, opts.__matches = opts_contain_invert(args)
|
||||||
|
|
||||||
if opts.grep_open_files then
|
if opts.grep_open_files then
|
||||||
for _, file in ipairs(get_open_filelist(opts.grep_open_files, opts.cwd)) do
|
for _, file in ipairs(get_open_filelist(opts.grep_open_files, opts.cwd)) do
|
||||||
@ -401,13 +432,11 @@ files.current_buffer_fuzzy_find = function(opts)
|
|||||||
local _, ts_configs = pcall(require, "nvim-treesitter.configs")
|
local _, ts_configs = pcall(require, "nvim-treesitter.configs")
|
||||||
|
|
||||||
local parser_ok, parser = pcall(vim.treesitter.get_parser, opts.bufnr, filetype)
|
local parser_ok, parser = pcall(vim.treesitter.get_parser, opts.bufnr, filetype)
|
||||||
local query_ok, query = pcall(vim.treesitter.get_query, filetype, "highlights")
|
local get_query = vim.treesitter.query.get or vim.treesitter.get_query
|
||||||
|
local query_ok, query = pcall(get_query, filetype, "highlights")
|
||||||
if parser_ok and query_ok and ts_ok and ts_configs.is_enabled("highlight", filetype, opts.bufnr) then
|
if parser_ok and query_ok and ts_ok and ts_configs.is_enabled("highlight", filetype, opts.bufnr) then
|
||||||
local root = parser:parse()[1]:root()
|
local root = parser:parse()[1]:root()
|
||||||
|
|
||||||
local highlighter = vim.treesitter.highlighter.new(parser)
|
|
||||||
local highlighter_query = highlighter:get_query(filetype)
|
|
||||||
|
|
||||||
local line_highlights = setmetatable({}, {
|
local line_highlights = setmetatable({}, {
|
||||||
__index = function(t, k)
|
__index = function(t, k)
|
||||||
local obj = {}
|
local obj = {}
|
||||||
@ -418,9 +447,23 @@ files.current_buffer_fuzzy_find = function(opts)
|
|||||||
|
|
||||||
-- update to changes on Neovim master, see https://github.com/neovim/neovim/pull/19931
|
-- update to changes on Neovim master, see https://github.com/neovim/neovim/pull/19931
|
||||||
-- TODO(clason): remove when dropping support for Neovim 0.7
|
-- TODO(clason): remove when dropping support for Neovim 0.7
|
||||||
local on_nvim_master = vim.fn.has "nvim-0.8" == 1
|
local get_hl_from_capture = (function()
|
||||||
|
if vim.fn.has "nvim-0.8" == 1 then
|
||||||
|
return function(q, id)
|
||||||
|
return "@" .. q.captures[id]
|
||||||
|
end
|
||||||
|
else
|
||||||
|
local highlighter = vim.treesitter.highlighter.new(parser)
|
||||||
|
local highlighter_query = highlighter:get_query(filetype)
|
||||||
|
|
||||||
|
return function(_, id)
|
||||||
|
return highlighter_query:_get_hl_from_capture(id)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)()
|
||||||
|
|
||||||
for id, node in query:iter_captures(root, opts.bufnr, 0, -1) do
|
for id, node in query:iter_captures(root, opts.bufnr, 0, -1) do
|
||||||
local hl = on_nvim_master and query.captures[id] or highlighter_query:_get_hl_from_capture(id)
|
local hl = get_hl_from_capture(query, id)
|
||||||
if hl and type(hl) ~= "number" then
|
if hl and type(hl) ~= "number" then
|
||||||
local row1, col1, row2, col2 = node:range()
|
local row1, col1, row2, col2 = node:range()
|
||||||
|
|
||||||
@ -469,6 +512,7 @@ files.current_buffer_fuzzy_find = function(opts)
|
|||||||
|
|
||||||
return true
|
return true
|
||||||
end,
|
end,
|
||||||
|
push_cursor_on_edit = true,
|
||||||
})
|
})
|
||||||
:find()
|
:find()
|
||||||
end
|
end
|
||||||
|
@ -71,12 +71,9 @@ git.commits = function(opts)
|
|||||||
sorter = conf.file_sorter(opts),
|
sorter = conf.file_sorter(opts),
|
||||||
attach_mappings = function(_, map)
|
attach_mappings = function(_, map)
|
||||||
actions.select_default:replace(actions.git_checkout)
|
actions.select_default:replace(actions.git_checkout)
|
||||||
map("i", "<c-r>m", actions.git_reset_mixed)
|
map({ "i", "n" }, "<c-r>m", actions.git_reset_mixed)
|
||||||
map("n", "<c-r>m", actions.git_reset_mixed)
|
map({ "i", "n" }, "<c-r>s", actions.git_reset_soft)
|
||||||
map("i", "<c-r>s", actions.git_reset_soft)
|
map({ "i", "n" }, "<c-r>h", actions.git_reset_hard)
|
||||||
map("n", "<c-r>s", actions.git_reset_soft)
|
|
||||||
map("i", "<c-r>h", actions.git_reset_hard)
|
|
||||||
map("n", "<c-r>h", actions.git_reset_hard)
|
|
||||||
return true
|
return true
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
@ -293,23 +290,12 @@ git.branches = function(opts)
|
|||||||
sorter = conf.file_sorter(opts),
|
sorter = conf.file_sorter(opts),
|
||||||
attach_mappings = function(_, map)
|
attach_mappings = function(_, map)
|
||||||
actions.select_default:replace(actions.git_checkout)
|
actions.select_default:replace(actions.git_checkout)
|
||||||
map("i", "<c-t>", actions.git_track_branch)
|
map({ "i", "n" }, "<c-t>", actions.git_track_branch)
|
||||||
map("n", "<c-t>", actions.git_track_branch)
|
map({ "i", "n" }, "<c-r>", actions.git_rebase_branch)
|
||||||
|
map({ "i", "n" }, "<c-a>", actions.git_create_branch)
|
||||||
map("i", "<c-r>", actions.git_rebase_branch)
|
map({ "i", "n" }, "<c-s>", actions.git_switch_branch)
|
||||||
map("n", "<c-r>", actions.git_rebase_branch)
|
map({ "i", "n" }, "<c-d>", actions.git_delete_branch)
|
||||||
|
map({ "i", "n" }, "<c-y>", actions.git_merge_branch)
|
||||||
map("i", "<c-a>", actions.git_create_branch)
|
|
||||||
map("n", "<c-a>", actions.git_create_branch)
|
|
||||||
|
|
||||||
map("i", "<c-s>", actions.git_switch_branch)
|
|
||||||
map("n", "<c-s>", actions.git_switch_branch)
|
|
||||||
|
|
||||||
map("i", "<c-d>", actions.git_delete_branch)
|
|
||||||
map("n", "<c-d>", actions.git_delete_branch)
|
|
||||||
|
|
||||||
map("i", "<c-y>", actions.git_merge_branch)
|
|
||||||
map("n", "<c-y>", actions.git_merge_branch)
|
|
||||||
return true
|
return true
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
@ -327,7 +313,7 @@ git.status = function(opts)
|
|||||||
|
|
||||||
local gen_new_finder = function()
|
local gen_new_finder = function()
|
||||||
local expand_dir = vim.F.if_nil(opts.expand_dir, true)
|
local expand_dir = vim.F.if_nil(opts.expand_dir, true)
|
||||||
local git_cmd = { "git", "status", "-s", "--", "." }
|
local git_cmd = { "git", "status", "-z", "--", "." }
|
||||||
|
|
||||||
if expand_dir then
|
if expand_dir then
|
||||||
table.insert(git_cmd, #git_cmd - 1, "-u")
|
table.insert(git_cmd, #git_cmd - 1, "-u")
|
||||||
@ -345,7 +331,7 @@ git.status = function(opts)
|
|||||||
end
|
end
|
||||||
|
|
||||||
return finders.new_table {
|
return finders.new_table {
|
||||||
results = output,
|
results = vim.split(output[1], " |