telescope.nvim
telescope.nvim copied to clipboard
highlighter error when `preview` is a boolean
Description
:h telescope.setup()
says:
To disable previewing, set it to false. If you have disabled previewers
globally, but want to opt in to previewing for single pickers, you will have to
pass preview = true or preview = {...} (your config) to the opts of
your picker.
but then with an invocation like live_grep({ preview = true })
, telescope complains:
Error executing vim.schedule lua callback: ...lugged/telescope.nvim/lua/telescope/previewers/utils.lua:83: attempt to index field 'preview' (a boolean value)
stack traceback:
...lugged/telescope.nvim/lua/telescope/previewers/utils.lua:83: in function 'highlighter'
...scope.nvim/lua/telescope/previewers/buffer_previewer.lua:242: in function ''
vim/_editor.lua: in function <vim/_editor.lua:0>
from the referenced line at https://github.com/nvim-telescope/telescope.nvim/blob/master/lua/telescope/previewers/utils.lua#L82, it seems like extra handling is needed for the boolean case - something like return early if opts.preview
is false
, else create the object if opts.preview
is true?
opts.preview = opts.preview or {}
Neovim version
NVIM v0.7.2
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by runner@fv-az164-457
Features: +acl +iconv +tui
See ":help feature-compile"
system vimrc file: "$VIM/sysinit.vim"
fall-back for $VIM: "/share/nvim"
Run :checkhealth for more info
Operating system and version
Ubuntu 12
Telescope version / branch / rev
0.1.0
checkhealth telescope
N/A
Steps to reproduce
lua require('telescope.builtin').live_grep({ preview = true })
Expected behavior
No response
Actual behavior
error is raised
Minimal config
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()]]
Same here. preview
set to false
in defaults
, but set to true
for lsp_references
, and it fails to show references with the same error (attempt to index field 'preview' (a boolean value)
).
And, btw, explicitly setting preview = true
in defaults
makes nvim
issue this error on start: Error in packer_compiled: ...ack/packer/start/telescope.nvim/lua/telescope/config.lua:31: attempt to index local 'priority' (a boolean value)
Hi, I'm facing a similar issue. Did anyone find a solution yet? If I put:
find_files = {
theme="anything",
previewer=true
}
It breaks when I hit the keympat for find_files:
Error executing Lua callback: ...ck/packer/start/telescope.nvim/lua/telescope/pickers.lua:147: attempt to index field 'all_previewers' (a boolean value)
stack traceback:
...ck/packer/start/telescope.nvim/lua/telescope/pickers.lua:147: in function 'new'
...r/start/telescope.nvim/lua/telescope/builtin/__files.lua:299: in function 'v'
...r/start/telescope.nvim/lua/telescope/builtin/__files.lua:529: in function 'v'
...cker/start/telescope.nvim/lua/telescope/builtin/init.lua:515: in function <...cker/start/telescope.nvim/lua/telescope/builtin/init.lua:484>
...ck/packer/start/telescope.nvim/lua/telescope/command.lua:188: in function 'run_command'
...ck/packer/start/telescope.nvim/lua/telescope/command.lua:253: in function 'load_command'
...te/pack/packer/start/telescope.nvim/plugin/telescope.lua:109: in function <...te/pack/packer/start/telescope.nvim/plugin/telescope.lua:108>
Thanks for reporting and sorry for the late response.
#2168 should fix this issue. would be nice if anyone could confirm?
hmmm... updated the plugin, can see the latest commits, but still having the same issue if set preview = false
in defaults, and preview = true
for lsp_references.
Can you please share the full telescope.setup
configuration. Thanks
Sure, here it is:
require('telescope').setup {
defaults = {
preview = false, -- if set to true, nvim shows error on startup; if commented out, no error
file_ignore_patterns = {'%.jpeg', '%.pdf'},
layout_strategy = "vertical",
layout_config = { height = 0.95, width = 0.9 },
mappings = {
i = {
["<C-h>"] = "which_key",
["<C-j>"] = require('telescope.actions').move_selection_next,
["<C-k>"] = require('telescope.actions').move_selection_previous,
["<esc>"] = require('telescope.actions').close,
["<C-t>"] = require('telescope.actions.layout').toggle_preview,
}
},
vimgrep_arguments = {
'rg',
'--color=never',
'--no-heading',
'--with-filename',
'--line-number',
'--column',
'--smart-case'
},
prompt_prefix = "▶ ",
selection_caret = "| ",
entry_prefix = " ",
initial_mode = "insert",
selection_strategy = "reset",
sorting_strategy = "descending",
file_sorter = require'telescope.sorters'.get_fuzzy_file,
generic_sorter = require'telescope.sorters'.get_generic_fuzzy_sorter,
winblend = 0,
border = {},
borderchars = { '─', '│', '─', '│', '╭', '╮', '╯', '╰' },
color_devicons = true,
use_less = true,
path_display = {},
set_env = { ['COLORTERM'] = 'truecolor' },
file_previewer = require'telescope.previewers'.vim_buffer_cat.new,
grep_previewer = require'telescope.previewers'.vim_buffer_vimgrep.new,
qflist_previewer = require'telescope.previewers'.vim_buffer_qflist.new,
},
pickers = {
colorscheme = {
enable_preview = true
},
lsp_references = {
preview = true -- error on launchin lsp_references
},
},
extensions = {
}
}
Frankly, I don't remember where I copied some of the options from, or even what some of them mean (like use_less
; that was quite ago, when I moved to telescope from another plugin).
preview = false, -- if set to true, nvim shows error on startup; if commented out, no error
i pushed another commit to my branch that fixed this issue https://github.com/nvim-telescope/telescope.nvim/pull/2168
preview = true -- error on launchin lsp_references
this works with my branch make sure you have checked out commit d8817726f1073c5444698f478af24f7bf4802cbd
I am not sure I have this commit. If I go via your link, I see the warning "This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository."
I use packer.nvim
, and I have just updated and synced all packages. With that I tried three scenarios: 1) using master branch (no additional options to packer); and, as suggested in telescope installation instructions - 2) with tag = '0.1.0'
3) with branch = '0.1.x'
. None of these solved the issue.
The branch, I linked twice is obviously not merged, I am looking for testers prior to my merge. So obv is not part of the master tree, the 0.1.0 tag or the 0.1.x branch.
There are a couple of ways you could test it (without interacting with packer) but this is probably the easiest way for you. Just replace the current telescope block in packer with the following
use {
'conni2461/telescope.nvim', branch = 'fix/preview_true',
requires = { {'nvim-lua/plenary.nvim'} }
}
Once you confirm everything works, i am going to merge and it will be part of the master tree, after that i port it back to 0.1.x and plan to do a release of 0.1.1 soon
Sorry, somehow it wasn't obvious to me you were asking to confirm before you merge it to the regular branch...
I've followed your suggestion, and do confirm it works as expected. Thanks.
Thanks for testing :) Its merged and you can go back to master. I'll port it back to 0.1.x later today
I am on the 0.1.x
branch (through LunarVim) and doing :Telescope buffers
errors out very similarly like for @krshrimali:
Error executing Lua callback: ...e/pack/lazy/opt/telescope.nvim/lua/telescope/pickers.lua:147: attempt to index field 'all_previewers' (a boolean value)
stack traceback:
...e/pack/lazy/opt/telescope.nvim/lua/telescope/pickers.lua:147: in function 'new'
.../opt/telescope.nvim/lua/telescope/builtin/__internal.lua:905: in function 'v'
.../opt/telescope.nvim/lua/telescope/builtin/__internal.lua:1366: in function 'v'
...k/lazy/opt/telescope.nvim/lua/telescope/builtin/init.lua:515: in function <...k/lazy/opt/telescope.nvim/lua/telescope/builtin/init.lua:482>
...e/pack/lazy/opt/telescope.nvim/lua/telescope/command.lua:188: in function 'run_command'
...e/pack/lazy/opt/telescope.nvim/lua/telescope/command.lua:253: in function 'load_command'
...m/site/pack/lazy/opt/telescope.nvim/plugin/telescope.lua:108: in function <...m/site/pack/lazy/opt/telescope.nvim/plugin/telescope.lua:107>
I don't see how this is fixed. NOTE: invoking the keybind for showing buffers (SPC-b-f in LunarVim's case) does NOT error out (apparently it calls another function).
Here's what I have in my LunarVim config.lua
file:
lvim.builtin.telescope.pickers = {
buffers = {
previewer = true,
initial_mode = "insert",
mappings = {
i = {
["<C-d>"] = actions.delete_buffer,
},
n = {
["dd"] = actions.delete_buffer,
},
},
scroll_strategy = "limit",
},
}
I know this is not LunarVim's issue tracker but as far as I can tell all options are passed wherever they should (tested by changing configs for various pickers) and I seem to be on the right telescope
branch.
Anything else I can do?
@dimitarvp https://github.com/nvim-telescope/telescope.nvim/pull/2395 should fix your issue. could you test?
thanks for reporting :)
Can't test right away now but I will try it soon-ish, thanks for the quick reaction.
@Conni2461 Yes, it works! LGTM then!
thanks for testing, PR is merged and already backported to 0.1.x
I stopped using the GIT branch pointed at by you and got back to using the 0.1.x
branch, and can confirm that it is working there as well. Thank you!