Skip to content

Commit

Permalink
Merge branch 'master' into jump_type_function_for_lsp
Browse files Browse the repository at this point in the history
  • Loading branch information
Blackmorse authored May 22, 2024
2 parents c04d962 + 4aed639 commit 32d08ab
Show file tree
Hide file tree
Showing 37 changed files with 952 additions and 294 deletions.
49 changes: 17 additions & 32 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,48 +9,33 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04, macos-12, windows-2022]
rev: [nightly, v0.9.5, v0.10.0]
include:
- os: ubuntu-22.04
rev: nightly/nvim-linux64.tar.gz
manager: sudo apt-get
packages: -y ripgrep
- os: ubuntu-22.04
rev: v0.9.0/nvim-linux64.tar.gz
manager: sudo apt-get
packages: -y ripgrep
- os: macos-12
rev: nightly/nvim-macos.tar.gz
manager: brew
packages: ripgrep
install-rg: sudo apt-get update && sudo apt-get install -y ripgrep
- os: macos-12
rev: v0.9.0/nvim-macos.tar.gz
manager: brew
packages: ripgrep
install-rg: brew update && brew install ripgrep
- os: windows-2022
install-rg: choco install ripgrep

steps:
- uses: actions/checkout@v3
- run: date +%F > todays-date
- name: Restore from todays cache
uses: actions/cache@v3
- uses: actions/checkout@v4

- uses: rhysd/action-setup-vim@v1
with:
path: _neovim
key: ${{ runner.os }}-${{ matrix.rev }}-${{ hashFiles('todays-date') }}
neovim: true
version: ${{ matrix.rev }}

- name: Prepare
run: |
${{ matrix.manager }} update
${{ matrix.manager }} install ${{ matrix.packages }}
test -d _neovim || {
mkdir -p _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
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-tree/nvim-web-devicons ~/.local/share/nvim/site/pack/vendor/start/nvim-web-devicons
ln -s $(pwd) ~/.local/share/nvim/site/pack/vendor/start
${{ matrix.install-rg }}
rg --version
git clone --depth 1 https://github.com/nvim-lua/plenary.nvim ../plenary.nvim
git clone --depth 1 https://github.com/nvim-tree/nvim-web-devicons ../nvim-web-devicons
- name: Run tests
run: |
export PATH="${PWD}/_neovim/bin:${PATH}"
export VIM="${PWD}/_neovim/share/nvim/runtime"
nvim --version
make test
9 changes: 6 additions & 3 deletions .github/workflows/docgen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ on:
push:
branches-ignore:
- master
pull_request:
branches:
- master

jobs:
build-sources:
Expand All @@ -14,12 +17,12 @@ jobs:
matrix:
include:
- 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/v0.9.5/nvim-linux64.tar.gz
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- run: date +%F > todays-date
- name: Restore cache for today's nightly.
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: _neovim
key: ${{ runner.os }}-${{ matrix.url }}-${{ hashFiles('todays-date') }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
name: Luacheck
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Prepare
run: |
Expand All @@ -22,8 +22,8 @@ jobs:
name: stylua
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: JohnnyMorganz/stylua-action@v3
- uses: actions/checkout@v4
- uses: JohnnyMorganz/stylua-action@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
version: latest
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ jobs:
luarocks-upload:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: LuaRocks Upload
uses: nvim-neorocks/[email protected]
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.
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
Expand Down
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.PHONY: test lint docgen

test:
nvim --headless --noplugin -u scripts/minimal_init.vim -c "PlenaryBustedDirectory lua/tests/automated/ { minimal_init = './scripts/minimal_init.vim' }"

Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,23 +85,23 @@ Using [vim-plug](https://github.com/junegunn/vim-plug)

```viml
Plug 'nvim-lua/plenary.nvim'
Plug 'nvim-telescope/telescope.nvim', { 'tag': '0.1.5' }
Plug 'nvim-telescope/telescope.nvim', { 'tag': '0.1.6' }
" or , { 'branch': '0.1.x' }
```

Using [dein](https://github.com/Shougo/dein.vim)

```viml
call dein#add('nvim-lua/plenary.nvim')
call dein#add('nvim-telescope/telescope.nvim', { 'rev': '0.1.5' })
call dein#add('nvim-telescope/telescope.nvim', { 'rev': '0.1.6' })
" or , { 'rev': '0.1.x' })
```

Using [packer.nvim](https://github.com/wbthomason/packer.nvim)

```lua
use {
'nvim-telescope/telescope.nvim', tag = '0.1.5',
'nvim-telescope/telescope.nvim', tag = '0.1.6',
-- or , branch = '0.1.x',
requires = { {'nvim-lua/plenary.nvim'} }
}
Expand All @@ -112,14 +112,14 @@ Using [lazy.nvim](https://github.com/folke/lazy.nvim)
```lua
-- init.lua:
{
'nvim-telescope/telescope.nvim', tag = '0.1.5',
'nvim-telescope/telescope.nvim', tag = '0.1.6',
-- or , branch = '0.1.x',
dependencies = { 'nvim-lua/plenary.nvim' }
}

-- plugins/telescope.lua:
return {
'nvim-telescope/telescope.nvim', tag = '0.1.5',
'nvim-telescope/telescope.nvim', tag = '0.1.6',
-- or , branch = '0.1.x',
dependencies = { 'nvim-lua/plenary.nvim' }
}
Expand All @@ -135,7 +135,7 @@ to get an understanding of how to use Telescope and how to configure it.

## Usage

Try the command `:Telescope find_files<cr>`
Try the command `:Telescope find_files`
to see if `telescope.nvim` is installed correctly.

Using VimL:
Expand Down
106 changes: 89 additions & 17 deletions doc/telescope.txt
Original file line number Diff line number Diff line change
Expand Up @@ -270,18 +270,19 @@ telescope.setup({opts}) *telescope.setup()*
Determines how file paths are displayed.

path_display can be set to an array with a combination of:
- "hidden" hide file names
- "tail" only display the file name, and not the path
- "absolute" display absolute paths
- "smart" remove as much from the path as possible to only show
the difference between the displayed paths.
Warning: The nature of the algorithm might have a negative
performance impact!
- "shorten" only display the first character of each directory in
the path
- "truncate" truncates the start of the path when the whole path will
not fit. To increase the gap between the path and the edge,
set truncate to number `truncate = 3`
- "hidden" hide file names
- "tail" only display the file name, and not the path
- "absolute" display absolute paths
- "smart" remove as much from the path as possible to only show
the difference between the displayed paths.
Warning: The nature of the algorithm might have a negative
performance impact!
- "shorten" only display the first character of each directory in
the path
- "truncate" truncates the start of the path when the whole path will
not fit. To increase the gap between the path and the edge,
set truncate to number `truncate = 3`
- "filename_first" shows filenames first and then the directories

You can also specify the number of characters of each directory name
to keep by setting `path_display.shorten = num`.
Expand All @@ -306,17 +307,57 @@ telescope.setup({opts}) *telescope.setup()*
will give a path like:
`al/beta/gamma/de`

path_display can also be set to 'filename_first' to put the filename
in front.

path_display = {
"filename_first"
},

The directory structure can be reversed as follows:

path_display = {
filename_first = {
reverse_directories = true
}
},

path_display can also be set to 'hidden' string to hide file names

path_display can also be set to a function for custom formatting of
the path display. Example:
the path display with the following signature

Signature: fun(opts: table, path: string): string, table?

The optional table is an list of positions and highlight groups to
set the highlighting of the return path string.

Example:

-- Format path as "file.txt (path\to\file\)"
path_display = function(opts, path)
local tail = require("telescope.utils").path_tail(path)
return string.format("%s (%s)", tail, path)
end,

-- Format path and add custom highlighting
path_display = function(opts, path)
local tail = require("telescope.utils").path_tail(path)
path = string.format("%s (%s)", tail, path)

local highlights = {
{
{
0, -- highlight start position
#path, -- highlight end position
},
"Comment", -- highlight group name
},
}

return path, highlights
end

Default: {}

*telescope.defaults.borderchars*
Expand Down Expand Up @@ -1435,6 +1476,9 @@ builtin.colorscheme({opts}) *telescope.builtin.colorscheme()*
{opts} (table) options to pass to the picker

Options: ~
{colors} (table) a list of additional colorschemes to
explicitly make available to telescope
(default: {})
{enable_preview} (boolean) if true, will preview the selected color


Expand Down Expand Up @@ -2541,6 +2585,31 @@ UTILS *telescope.utils*

Utilities for writing telescope pickers

utils.path_expand({path}) *telescope.utils.path_expand()*
Hybrid of `vim.fn.expand()` and custom `vim.fs.normalize()`

Paths starting with '%', '#' or '<' are expanded with `vim.fn.expand()`.
Otherwise avoids using `vim.fn.expand()` due to its overly aggressive
expansion behavior which can sometimes lead to errors or the creation of
non-existent paths when dealing with valid absolute paths.

Other paths will have '~' and environment variables expanded. Unlike
`vim.fs.normalize()`, backslashes are preserved. This has better
compatibility with `plenary.path` and also avoids mangling valid Unix paths
with literal backslashes.

Trailing slashes are trimmed. With the exception of root paths. eg. `/` on
Unix or `C:\` on Windows



Parameters: ~
{path} (string)

Return: ~
string


utils.transform_path({opts}, {path}) *telescope.utils.transform_path()*
Transform path is a util function that formats a path based on path_display
found in `opts` or the default value from config. It is meant to be used in
Expand All @@ -2551,12 +2620,13 @@ utils.transform_path({opts}, {path}) *telescope.utils.transform_path()*


Parameters: ~
{opts} (table) The opts the users passed into the picker. Might
contains a path_display key
{path} (string) The path that should be formatted
{opts} (table) The opts the users passed into the picker. Might
contains a path_display key
{path} (string|nil) The path that should be formatted

Return: ~
string: The transformed path ready to be displayed
string: path to be displayed
table: The transformed path ready to be displayed with the styling


utils.has_ts_parser({lang}) *telescope.utils.has_ts_parser()*
Expand Down Expand Up @@ -3658,6 +3728,8 @@ action_generate.which_key({opts}) *telescope.actions.generate.which_key()*
"TelescopePromptBorder")
{winblend} (number) pseudo-transparency of keymap
hints floating window
{zindex} (number) z-index of keymap hints floating
window (default: 100)



Expand Down
3 changes: 2 additions & 1 deletion lua/telescope/_.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ local log = require "plenary.log"

local async = require "plenary.async"
local channel = require("plenary.async").control.channel
local utils = require "telescope.utils"

local M = {}

Expand All @@ -21,7 +22,7 @@ function AsyncJob.new(opts)
self.stderr = opts.stderr or M.NullPipe()

if opts.cwd and opts.cwd ~= "" then
self.uv_opts.cwd = vim.fn.expand(vim.fn.escape(opts.cwd, "$"))
self.uv_opts.cwd = utils.path_expand(opts.cwd)
-- 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
-- Because empty string is not allowed in libuv the job will not spawn. Solution is we just set it to opts.cwd
Expand Down
4 changes: 3 additions & 1 deletion lua/telescope/actions/generate.lua
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,12 @@ local action_generate = {}
---@field normal_hl string: winhl of "Normal" for keymap hints floating window (default: "TelescopePrompt")
---@field border_hl string: winhl of "Normal" for keymap borders (default: "TelescopePromptBorder")
---@field winblend number: pseudo-transparency of keymap hints floating window
---@field zindex number: z-index of keymap hints floating window (default: 100)
action_generate.which_key = function(opts)
return function(prompt_bufnr)
local which_key = function(prompt_bufnr)
actions.which_key(prompt_bufnr, opts)
end
return which_key
end

action_generate.refine = function(prompt_bufnr, opts)
Expand Down
2 changes: 1 addition & 1 deletion lua/telescope/actions/history.lua
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function histories.History:new(opts)
if conf.history.limit then
obj.limit = conf.history.limit
end
obj.path = vim.fn.expand(conf.history.path)
obj.path = utils.path_expand(conf.history.path)
obj.content = {}
obj.index = 1
obj.cycle_wrap = conf.history.cycle_wrap
Expand Down
Loading

0 comments on commit 32d08ab

Please sign in to comment.