Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error with which_key when telescope window width is narrow (no preview showing) #1667

Closed
prurph opened this issue Jan 9, 2022 · 0 comments · Fixed by #1668
Closed

Error with which_key when telescope window width is narrow (no preview showing) #1667

prurph opened this issue Jan 9, 2022 · 0 comments · Fixed by #1668
Labels
bug Something isn't working

Comments

@prurph
Copy link

prurph commented Jan 9, 2022

Description

If my terminal window is sufficiently narrow such that the preview isn't showing (i.e. it's below defaults.layout_config.horizontal.preview_cutoff), invoking telescope.actions.which_key results in the error below. Simply resizing the window such that the telescope preview is displayed makes everything work properly.

E5108: Error executing lua ...packer/opt/telescope.nvim/lua/telescope/actions/init.lua:962: Expected Lua number
stack traceback:
        [C]: in function 'nvim_win_get_position'
        ...packer/opt/telescope.nvim/lua/telescope/actions/init.lua:962: in function 'win_central_row'
        ...packer/opt/telescope.nvim/lua/telescope/actions/init.lua:968: in function 'run_replace_or_original'
        ...k/packer/opt/telescope.nvim/lua/telescope/actions/mt.lua:30: in function 'key_func'
        ...ack/packer/opt/telescope.nvim/lua/telescope/mappings.lua:236: in function 'execute_keymap'
        [string ":lua"]:1: in main chunk

Neovim version

NVIM v0.7.0-dev+855-ge41e8b3fd
Build type: Release
LuaJIT 2.1.0-beta3

Operating system and version

macOS 12.1

checkhealth telescope

2 telescope: require("telescope.health").check()
   3 ========================================================================
   4 ## Checking for required plugins
   5   - OK: plenary installed.
   6   - OK: nvim-treesitter installed.
   7
   8 ## Checking external dependencies
   9   - OK: rg: found ripgrep 13.0.0
  10   - OK: fd: found fd 8.3.1
  11
  12 ## ===== Installed extensions =====
  13
  14 ## Telescope Extension: `smart_history`
  15   - INFO: No healthcheck provided
  16
  17 ## Telescope Extension: `terms`
  18   - INFO: No healthcheck provided
  19
  20 ## Telescope Extension: `themes`
  21   - INFO: No healthcheck provided

Steps to reproduce

  1. Bind telescope which_key.
  2. Shrink terminal window width sufficiently such that telescope preview window is not shown
  3. Activate telescope and then activate which_key

Expected behavior

Key shortcuts are displayed

Actual behavior

An error occurs:

E5108: Error executing lua ...packer/opt/telescope.nvim/lua/telescope/actions/init.lua:962: Expected Lua number
stack traceback:
        [C]: in function 'nvim_win_get_position'
        ...packer/opt/telescope.nvim/lua/telescope/actions/init.lua:962: in function 'win_central_row'
        ...packer/opt/telescope.nvim/lua/telescope/actions/init.lua:968: in function 'run_replace_or_original'
        ...k/packer/opt/telescope.nvim/lua/telescope/actions/mt.lua:30: in function 'key_func'
        ...ack/packer/opt/telescope.nvim/lua/telescope/mappings.lua:236: in function 'execute_keymap'
        [string ":lua"]:1: in main chunk

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()]]
@prurph prurph added the bug Something isn't working label Jan 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant