LinArcX / telescope-command-palette.nvim

Create key-bindings and watch them with telescope :telescope:
GNU General Public License v3.0
272 stars 8 forks source link

Command palette panel doesn't show anything #10

Open bryangeplant opened 2 years ago

bryangeplant commented 2 years ago
When I run the command palette command, no commands show up in the panel. When I press enter to select something, an ugly error message shows up, but could be expected given that, I pressed nothing. Still, not showing anything is weird.

lua << EOF
-- Setup variables

-- command-palette
command_palette = {
    {"File",
        { "entire selection (C-a)", ':call feedkeys("GVgg")' },
        { "save current file (C-s)", ':w' },
        { "save all files (C-A-s)", ':wa' },
        { "quit (C-q)", ':qa' },
        { "file browser (C-i)", ":lua require'telescope'.extensions.file_browser.file_browser()", 1 },
        { "search word (A-w)", ":lua require('telescope.builtin').live_grep()", 1 },
        { "git files (A-f)", ":lua require('telescope.builtin').git_files()", 1 },
        { "files (C-f)",     ":lua require('telescope.builtin').find_files()", 1 },
    },
    {"Help",
        { "tips", ":help tips" },
        { "cheatsheet", ":help index" },
        { "tutorial", ":help tutor" },
        { "summary", ":help summary" },
        { "quick reference", ":help quickref" },
        { "search help(F1)", ":lua require('telescope.builtin').help_tags()", 1 },
    },
    {"Vim",
        { "reload vimrc", ":source $MYVIMRC" },
        { 'check health', ":checkhealth" },
        { "jumps (Alt-j)", ":lua require('telescope.builtin').jumplist()" },
        { "commands", ":lua require('telescope.builtin').commands()" },
        { "command history", ":lua require('telescope.builtin').command_history()" },
        { "registers (A-e)", ":lua require('telescope.builtin').registers()" },
        { "colorshceme", ":lua require('telescope.builtin').colorscheme()", 1 },
        { "vim options", ":lua require('telescope.builtin').vim_options()" },
        { "keymaps", ":lua require('telescope.builtin').keymaps()" },
        { "buffers", ":Telescope buffers" },
        { "search history (C-h)", ":lua require('telescope.builtin').search_history()" },
        { "paste mode", ':set paste!' },
        { 'cursor line', ':set cursorline!' },
        { 'cursor column', ':set cursorcolumn!' },
        { "spell checker", ':set spell!' },
        { "relative number", ':set relativenumber!' },
        { "search highlighting (F12)", ':set hlsearch!' },
    }
}

telescope = require('telescope')

telescope.setup{
    extensions = {
        command_palette = command_pallete
    }
}

telescope.load_extension('command_palette')

EOF

" Telescope builtins
" TODO factor to use nvim functions. 
nnoremap <leader>ff <cmd>lua require('telescope.builtin').find_files()<cr>
nnoremap <leader>fg <cmd>lua require('telescope.builtin').live_grep()<cr>
nnoremap <leader>fb <cmd>lua require('telescope.builtin').buffers()<cr>
nnoremap <leader>fh <cmd>lua require('telescope.builtin').help_tags()<cr>
nnoremap <leader>fo <cmd>lua require('telescope.builtin').vim_options()<cr>
nnoremap <leader>fa <cmd>lua require('telescope.builtin').autocommands()<cr>
nnoremap <leader>fp <cmd>lua require('telescope.builtin').pickers()<cr>

" Telescope LSP builtins
nnoremap <leader>lr <cmd>lua require('telescope.builtin').lsp_references()<cr>
nnoremap <leader>ls <cmd>lua require('telescope.builtin').lsp_references()<cr>
nnoremap <leader>ld <cmd>lua require('telescope.builtin').lsp_definitions()<cr>
nnoremap <leader>lt <cmd>lua require('telescope.builtin').lsp_type_definitions()<cr>
nnoremap <leader>lr <cmd>lua require('telescope.builtin').lsp_references()<cr>

" Telescope git builtins
nnoremap <leader>gc <cmd> lua require('telescope.builtin').git_commits()<cr>
nnoremap <leader>gb <cmd> lua require('telescope.builtin').git_branches()<cr>
nnoremap <leader>gs <cmd> lua require('telescope.builtin').git_status()<cr>

"Telescope treesitter builtins
nnoremap <leader>ts <cmd> lua require('telescope.builtin').treesitter()<cr>

" Command Pallete
nnoremap <c-p> :Telescope command_palette<cr>

image

Pressing with no options selected gives me this error message:

search hit BOTTOM, continuing at TOP
E486: Pattern not found: ==
search hit TOP, continuing at BOTTOM
E486: Pattern not found: ==
E5108: Error executing lua ...lette.nvim/lua/telescope/_extensions/comman
d_palette.lua:155: attempt to index local 'selection' (a nil value)
stack traceback:
        ...lette.nvim/lua/telescope/_extensions/command_palette.lua:155:
in function 'run_replace_or_original'
        ...nvim/plugged/telescope.nvim/lua/telescope/actions/mt.lua:30: i
n function 'key_func'
        ...e/nvim/plugged/telescope.nvim/lua/telescope/mappings.lua:236:
in function 'execute_keymap'
        [string ":lua"]:1: in main chunk
E5108: Error executing lua ...lette.nvim/lua/telescope/_extensions/comman
d_palette.lua:155: attempt to index local 'selection' (a nil value)
stack traceback:
        ...lette.nvim/lua/telescope/_extensions/command_palette.lua:155:
in function 'run_replace_or_original'
        ...nvim/plugged/telescope.nvim/lua/telescope/actions/mt.lua:30: i
n function 'key_func'
        ...e/nvim/plugged/telescope.nvim/lua/telescope/mappings.lua:236:
in function 'execute_keymap'
        [string ":lua"]:1: in main chunk

Here are my installed plugins, yes I did run :PlugInstall

call plug#begin()

Plug 'neovim/nvim-lspconfig'
Plug 'williamboman/nvim-lsp-installer'
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
Plug 'gfanto/fzf-lsp.nvim'

" Visualize LSP and ctag symbols.
" Plug 'liuchengxu/vista.vim'

Plug 'nvim-lua/plenary.nvim'
Plug 'nvim-telescope/telescope.nvim'
Plug 'LinArcX/telescope-command-palette.nvim'
Plug 'nvim-lua/popup.nvim'
Plug 'nvim-lua/plenary.nvim'
Plug 'jvgrootveld/telescope-zoxide' 
" Discord Presence
Plug 'andweeb/presence.nvim'
"
" Plug 'https://gitlab.com/yorickpeterse/nvim-window.git'
" Plug 'beauwilliams/focus.nvim'
" Plug 'luukvbaal/stabilize.nvim'
"
" Plug 'windwp/nvim-ts-autotag'
" Plug 'windwp/nvim-autopairs'
"
" Plug 'Pocco81/TrueZen.nvim'
" Plug 'rktjmp/highlight-current-n.nvim'
"
" is0n/jaq-nvim
"
" Plug 'kyazdani42/nvim-web-devicons' " for file icons
" Plug 'kyazdani42/nvim-tree.lua'
"
" Plug 'ThePrimeagen/vim-be-good'
" Plug 'nvim-lualine/lualine.nvim'
" Plug 'michaeljsmith/vim-indent-object'
" Plug 'akinsho/toggleterm.nvim'
" Plug 'tpope/vim-surround'
" Plug 'folke/twilight.nvim'
" Plug 'khaveesh/vim-fish-syntax'

call plug#end()
LinArcX commented 2 years ago

Hello and thank you for reporting this issue.

My first guess was that:

The error happens because you defined commands outside of telescope setup section. If you follow the README file and define commands inside setup section of telescope, the error will be solved.

But i tried to use your approach that defined telescope variable first and call setup function on it. And surprisingly got same error message!

So please use the approach mentioned in README file.

require('telescope').setup({
  extensions = {
    command_palette = {
      -- your commands goes here
    }
  }
})
LinArcX commented 1 year ago

@bryangeplant

Can you please tell me if you still get the same errors?

JeanMertz commented 1 year ago

Note that the OP has a typo in it; command_pallete vs command_palette, which probably is the cause of the issue.