Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…nvim into fix/oldfile_duplicated_list
  • Loading branch information
Jaehaks committed Jul 6, 2024
2 parents 0f4b8c9 + bfcc7d5 commit 267a819
Show file tree
Hide file tree
Showing 27 changed files with 662 additions and 284 deletions.
2 changes: 1 addition & 1 deletion .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
github: [tjdevries, Conni2461, fdschmidt93]
github: [tjdevries, Conni2461, fdschmidt93, jamestrew]
81 changes: 41 additions & 40 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,45 +75,46 @@ body:
required: true
- type: textarea
attributes:
label: "Minimal config"
description: "Minimal(!) configuration necessary to reproduce the issue. Save this as `minimal.lua`. If _absolutely_ necessary, add plugins and config options from your `init.lua` at the indicated lines."
render: Lua
value: |
vim.cmd [[set runtimepath=$VIMRUNTIME]]
vim.cmd [[set packpath=/tmp/nvim/site]]
local package_root = '/tmp/nvim/site/pack'
local install_path = package_root .. '/packer/start/packer.nvim'
local function load_plugins()
require('packer').startup {
{
'wbthomason/packer.nvim',
{
'nvim-telescope/telescope.nvim',
requires = {
'nvim-lua/plenary.nvim',
{ 'nvim-telescope/telescope-fzf-native.nvim', run = 'make' },
},
},
-- ADD PLUGINS THAT ARE _NECESSARY_ FOR REPRODUCING THE ISSUE
},
config = {
package_root = package_root,
compile_path = install_path .. '/plugin/packer_compiled.lua',
display = { non_interactive = true },
},
}
end
_G.load_config = function()
require('telescope').setup()
require('telescope').load_extension('fzf')
-- ADD INIT.LUA SETTINGS THAT ARE _NECESSARY_ FOR REPRODUCING THE ISSUE
end
if vim.fn.isdirectory(install_path) == 0 then
print("Installing Telescope and dependencies.")
vim.fn.system { 'git', 'clone', '--depth=1', 'https://github.com/wbthomason/packer.nvim', install_path }
end
load_plugins()
require('packer').sync()
vim.cmd [[autocmd User PackerComplete ++once echo "Ready!" | lua load_config()]]
label: "Minimal config"
description: "Minimal(!) configuration necessary to reproduce the issue. Save this as `minimal.lua` and run with `nvim -nu minimal.lua`. If _absolutely_ necessary, add plugins and config options from your `init.lua` at the indicated lines."
render: Lua
value: |
local root = vim.fn.fnamemodify("./.repro", ":p")
-- set stdpaths to use .repro
for _, name in ipairs { "config", "data", "state", "cache" } do
vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end
-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.uv.fs_stat(lazypath) then
vim.fn.system {
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
lazypath,
}
end
vim.opt.runtimepath:prepend(lazypath)
-- install plugins
local plugins = {
{
"nvim-telescope/telescope.nvim",
dependencies = {
"nvim-lua/plenary.nvim",
},
config = function()
-- ADD INIT.LUA SETTINGS THAT ARE _NECESSARY_ FOR REPRODUCING THE ISSUE
require("telescope").setup {}
end,
},
}
require("lazy").setup(plugins, {
root = root .. "/plugins",
})
validations:
required: true
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-22.04, macos-12, windows-2022]
rev: [nightly, v0.9.0]
rev: [nightly, v0.9.5, v0.10.0]
include:
- os: ubuntu-22.04
install-rg: sudo apt-get update && sudo apt-get install -y ripgrep
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docgen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:
branches-ignore:
- master
pull_request:
pull_request_target:
branches:
- master

Expand Down
13 changes: 8 additions & 5 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.6' }
Plug 'nvim-telescope/telescope.nvim', { 'tag': '0.1.8' }
" 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.6' })
call dein#add('nvim-telescope/telescope.nvim', { 'rev': '0.1.8' })
" or , { 'rev': '0.1.x' })
```

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

```lua
use {
'nvim-telescope/telescope.nvim', tag = '0.1.6',
'nvim-telescope/telescope.nvim', tag = '0.1.8',
-- 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.6',
'nvim-telescope/telescope.nvim', tag = '0.1.8',
-- or , branch = '0.1.x',
dependencies = { 'nvim-lua/plenary.nvim' }
}

-- plugins/telescope.lua:
return {
'nvim-telescope/telescope.nvim', tag = '0.1.6',
'nvim-telescope/telescope.nvim', tag = '0.1.8',
-- or , branch = '0.1.x',
dependencies = { 'nvim-lua/plenary.nvim' }
}
Expand Down Expand Up @@ -263,6 +263,9 @@ Many familiar mapping patterns are set up as defaults.
| `<C-q>` | Send all items not filtered to quickfixlist (qflist) |
| `<M-q>` | Send all selected items to qflist |
| `<C-r><C-w>` | Insert cword in original window into prompt (insert mode) |
| `<C-r><C-a>` | Insert cWORD in original window into prompt (insert mode) |
| `<C-r><C-f>` | Insert cfile in original window into prompt (insert mode) |
| `<C-r><C-l>` | Insert cline in original window into prompt (insert mode) |

To see the full list of mappings, check out `lua/telescope/mappings.lua` and the
`default_mappings` table.
Expand Down
2 changes: 1 addition & 1 deletion developers.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ more interesting. We will end up with the following new code for `finders.new_ta
```

With the new snippet, we no longer have an array of strings but an array of
tables. Each table has a color, name, and the color's hex value.
tables. Each table has a color name and the color's hex value.

`entry_maker` is a function that will receive each table and then we can set the
values we need. It's best practice to have a `value` reference to the
Expand Down
52 changes: 48 additions & 4 deletions doc/telescope.txt
Original file line number Diff line number Diff line change
Expand Up @@ -970,6 +970,8 @@ builtin.treesitter() *telescope.builtin.treesitter()*
{bufnr} (number) specify the buffer number where
treesitter should run. (default:
current buffer)
{symbol_width} (number) defines the width of the symbol
section (default: 25)
{symbols} (string|table) filter results by symbol kind(s)
{ignore_symbols} (string|table) list of symbols to ignore
{symbol_highlights} (table) string -> string. Matches symbol
Expand Down Expand Up @@ -1432,6 +1434,8 @@ builtin.reloader({opts}) *telescope.builtin.reloader()*
builtin.buffers({opts}) *telescope.builtin.buffers()*
Lists open buffers in current neovim instance, opens selected buffer on
`<cr>`
- Default keymaps:
- `<M-d>`: delete the currently selected buffer


Parameters: ~
Expand Down Expand Up @@ -1476,10 +1480,12 @@ 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
{colors} (table) a list of additional colorschemes to
explicitly make available to telescope
(default: {})
{enable_preview} (boolean) if true, will preview the selected color
{ignore_builtins} (boolean) if true, builtin colorschemes are not
listed


builtin.marks({opts}) *telescope.builtin.marks()*
Expand Down Expand Up @@ -1605,6 +1611,8 @@ builtin.lsp_references({opts}) *telescope.builtin.lsp_references()*
"vsplit", "never"
{show_line} (boolean) show results text (default: true)
{trim_text} (boolean) trim results text (default: false)
{reuse_win} (boolean) jump to existing window if buffer is
already opened (default: false)
{file_encoding} (string) file encoding for the previewer


Expand Down Expand Up @@ -2222,6 +2230,9 @@ layout_strategies.horizontal() *telescope.layout.horizontal()*
- anchor:
- Which edge/corner to pin the picker to
- See |resolver.resolve_anchor_pos()|
- anchor_padding:
- Specifies an amount of additional padding around the anchor
- Values should be a positive integer
- height:
- How tall to make Telescope's entire layout
- See |resolver.resolve_height()|
Expand Down Expand Up @@ -2275,6 +2286,9 @@ layout_strategies.center() *telescope.layout.center()*
- anchor:
- Which edge/corner to pin the picker to
- See |resolver.resolve_anchor_pos()|
- anchor_padding:
- Specifies an amount of additional padding around the anchor
- Values should be a positive integer
- height:
- How tall to make Telescope's entire layout
- See |resolver.resolve_height()|
Expand Down Expand Up @@ -2353,6 +2367,9 @@ layout_strategies.vertical() *telescope.layout.vertical()*
- anchor:
- Which edge/corner to pin the picker to
- See |resolver.resolve_anchor_pos()|
- anchor_padding:
- Specifies an amount of additional padding around the anchor
- Values should be a positive integer
- height:
- How tall to make Telescope's entire layout
- See |resolver.resolve_height()|
Expand Down Expand Up @@ -2383,6 +2400,9 @@ layout_strategies.flex() *telescope.layout.flex()*
- anchor:
- Which edge/corner to pin the picker to
- See |resolver.resolve_anchor_pos()|
- anchor_padding:
- Specifies an amount of additional padding around the anchor
- Values should be a positive integer
- height:
- How tall to make Telescope's entire layout
- See |resolver.resolve_height()|
Expand Down Expand Up @@ -3391,6 +3411,30 @@ actions.insert_original_cword({prompt_bufnr}) *telescope.actions.insert_original
{prompt_bufnr} (number) The prompt bufnr


actions.insert_original_cWORD({prompt_bufnr}) *telescope.actions.insert_original_cWORD()*
Insert the WORD under the cursor of the original (pre-Telescope) window


Parameters: ~
{prompt_bufnr} (number) The prompt bufnr


actions.insert_original_cfile({prompt_bufnr}) *telescope.actions.insert_original_cfile()*
Insert the file under the cursor of the original (pre-Telescope) window


Parameters: ~
{prompt_bufnr} (number) The prompt bufnr


actions.insert_original_cline({prompt_bufnr}) *telescope.actions.insert_original_cline()*
Insert the line under the cursor of the original (pre-Telescope) window


Parameters: ~
{prompt_bufnr} (number) The prompt bufnr



================================================================================
ACTIONS_STATE *telescope.actions.state*
Expand Down
50 changes: 49 additions & 1 deletion lua/telescope/actions/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,6 @@ actions.edit_register = function(prompt_bufnr)
v.content = updated_value
end
end
-- print(vim.inspect(picker.finder.results))
end

--- Paste the selected register into the buffer
Expand Down Expand Up @@ -1176,9 +1175,37 @@ end
---@param prompt_bufnr number: The prompt bufnr
actions.delete_buffer = function(prompt_bufnr)
local current_picker = action_state.get_current_picker(prompt_bufnr)

current_picker:delete_selection(function(selection)
local force = vim.api.nvim_buf_get_option(selection.bufnr, "buftype") == "terminal"
local ok = pcall(vim.api.nvim_buf_delete, selection.bufnr, { force = force })

-- If the current buffer is deleted, switch to the previous buffer
-- according to bdelete behavior
if ok and selection.bufnr == current_picker.original_bufnr then
if vim.api.nvim_win_is_valid(current_picker.original_win_id) then
local jumplist = vim.fn.getjumplist(current_picker.original_win_id)[1]
for i = #jumplist, 1, -1 do
if jumplist[i].bufnr ~= selection.bufnr and vim.fn.bufloaded(jumplist[i].bufnr) == 1 then
vim.api.nvim_win_set_buf(current_picker.original_win_id, jumplist[i].bufnr)
current_picker.original_bufnr = jumplist[i].bufnr
return ok
end
end

-- no more valid buffers in jumplist, create an empty buffer
local empty_buf = vim.api.nvim_create_buf(true, true)
vim.api.nvim_win_set_buf(current_picker.original_win_id, empty_buf)
current_picker.original_bufnr = empty_buf
vim.api.nvim_buf_delete(selection.bufnr, { force = true })
return ok
end

-- window of the selected buffer got wiped, switch to first valid window
local win_id = vim.fn.win_getid(1, current_picker.original_tabpage)
current_picker.original_win_id = win_id
current_picker.original_bufnr = vim.api.nvim_win_get_buf(win_id)
end
return ok
end)
end
Expand Down Expand Up @@ -1496,6 +1523,27 @@ actions.insert_original_cword = function(prompt_bufnr)
current_picker:set_prompt(current_picker.original_cword, false)
end

--- Insert the WORD under the cursor of the original (pre-Telescope) window
---@param prompt_bufnr number: The prompt bufnr
actions.insert_original_cWORD = function(prompt_bufnr)
local current_picker = action_state.get_current_picker(prompt_bufnr)
current_picker:set_prompt(current_picker.original_cWORD, false)
end

--- Insert the file under the cursor of the original (pre-Telescope) window
---@param prompt_bufnr number: The prompt bufnr
actions.insert_original_cfile = function(prompt_bufnr)
local current_picker = action_state.get_current_picker(prompt_bufnr)
current_picker:set_prompt(current_picker.original_cfile, false)
end

--- Insert the line under the cursor of the original (pre-Telescope) window
---@param prompt_bufnr number: The prompt bufnr
actions.insert_original_cline = function(prompt_bufnr)
local current_picker = action_state.get_current_picker(prompt_bufnr)
current_picker:set_prompt(current_picker.original_cline, false)
end

actions.nop = function(_) end

actions.mouse_click = function(prompt_bufnr)
Expand Down
7 changes: 3 additions & 4 deletions lua/telescope/builtin/__diagnostics.lua
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,12 @@ diagnostics.get = function(opts)
if opts.bufnr ~= 0 then
opts.bufnr = nil
end
if opts.bufnr == nil then
opts.path_display = vim.F.if_nil(opts.path_display, {})
end
if type(opts.bufnr) == "string" then
opts.bufnr = tonumber(opts.bufnr)
end
if opts.bufnr ~= nil then
opts.path_display = vim.F.if_nil(opts.path_display, "hidden")
end

local locations = diagnostics_to_tbl(opts)

Expand All @@ -157,7 +157,6 @@ diagnostics.get = function(opts)
return
end

opts.path_display = vim.F.if_nil(opts.path_display, "hidden")
pickers
.new(opts, {
prompt_title = opts.bufnr == nil and "Workspace Diagnostics" or "Document Diagnostics",
Expand Down
Loading

0 comments on commit 267a819

Please sign in to comment.