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

Telescope lsp_workspace_symbols not functioning #568

Closed
jacksonludwig opened this issue Feb 27, 2021 · 10 comments · Fixed by #554
Closed

Telescope lsp_workspace_symbols not functioning #568

jacksonludwig opened this issue Feb 27, 2021 · 10 comments · Fixed by #554
Labels
bug Something isn't working

Comments

@jacksonludwig
Copy link

jacksonludwig commented Feb 27, 2021

Description

:Telescope lsp_workspace_symbols not functioning.
Expected Behavior

:Telescope lsp_workspace_symbols launches the finder and displays the workspace symbols sent from the LSP.
Actual Behavior

:Telescope lsp_workspace_symbols has no effect; it is as if :Telescope lsp_workspace_symbols is an unrecognized command. This is the case even when the LSP supports workspace symbols, e.g. :lua vim.lsp.buf.workspace_symbol()<CR> works.

Details

Reproduce

1.) Use simple test.vim config
2.) Go to a python project (or any other language/LSP if you prefer)
3.) Run :Telescope lsp_workspace_symbols

Environment
  • nvim --version output:
NVIM v0.5.0-dev
Build type: Release
LuaJIT 2.1.0-beta3
Compilation:
Compiled by nixbld

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "
/nix/store/nn2wx8i57jqqsd4qaajfg66i83vyia1y-neovim-nightly-master/share/nvim"

Run :checkhealth for more info
  • Operating system: Ubuntu (+ nix/home-manager)
  • Telescope commit: 84732d1
Configuration

set nocompatible hidden laststatus=2

if !filereadable('/tmp/plug.vim')
  silent !curl --insecure -fLo /tmp/plug.vim
    \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
endif

source /tmp/plug.vim
call plug#begin('/tmp/plugged')
Plug 'nvim-lua/popup.nvim'
Plug 'nvim-lua/plenary.nvim'
Plug 'nvim-telescope/telescope.nvim'
Plug 'neovim/nvim-lspconfig'
call plug#end()

autocmd VimEnter * PlugClean! | PlugUpdate --sync | close
lua << EOF

require('telescope').setup{
  defaults = {
    vimgrep_arguments = {
      'rg',
      '--color=never',
      '--no-heading',
      '--with-filename',
      '--line-number',
      '--column',
      '--smart-case'
    },
    prompt_position = "bottom",
    prompt_prefix = ">",
    selection_strategy = "reset",
    sorting_strategy = "descending",
    layout_strategy = "horizontal",
    layout_defaults = {},
    file_ignore_patterns = {},
    shorten_path = true,
    winblend = 0,
    width = 0.75,
    preview_cutoff = 120,
    results_height = 1,
    results_width = 0.8,
    border = {},
    borderchars = { '', '', '', '', '', '', '', ''},
    color_devicons = true,
    use_less = true,
  }
}

require'lspconfig'.pyright.setup{}
EOF
@jacksonludwig jacksonludwig added the bug Something isn't working label Feb 27, 2021
@Conni2461
Copy link
Member

Thanks for reporting. pyright expects a query. I have already a PR ready that prints a message in that case. I am about to merge that PR :)

For now: Telescope lsp_workspace_symbols query=something should work. We just use a empty string as query and most servers will show all workspace symbols in that case but pyright and clangd don't

@jacksonludwig
Copy link
Author

Alright, that would make sense. However, in three LSPs I've used (tsserver, gopls, and pyright) I still get this issue even with query=something, just to be clear. @Conni2461

In the past I called vim.lsp.buf.workspace_symbol() with an empty string and it worked just fine with telescope set as the handler.

@jacksonludwig
Copy link
Author

Welp... regardless your PR fixed the issue XD, thanks and ignore my last comment

@Conni2461
Copy link
Member

Can't comment for tsserver and gopls but pyright just worked for me. I tested that 🤣
I don't know what the specification says for an empty string.

Good to hear that this fixes your issue :)

@ranjithshegde
Copy link

btw the issue still exists for ccls. Same error as above

@Conni2461
Copy link
Member

@ranjithshegde yeah because this issue isn't fixable from our side. ccls, clangd and probably more are not returning results for an empty query.
So what i am doing is i have this mapped:

lua require'telescope.builtin'.lsp_workspace_symbols({ query = vim.fn.input("Query >") })

So if i know that my lsp accepts an empty query like sumneko i just press enter again and if not i can type in my query

@Conni2461
Copy link
Member

I am thinking about a live grep version of workspace_symbols lately. Maybe something like this could solve that problem.

Maybe @oberblastmeister async PR can make a live_workspace_symbols possible. Just thinking out load

@ranjithshegde
Copy link

ranjithshegde commented Mar 9, 2021

lua require'telescope.builtin'.lsp_workspace_symbols({ query = vim.fn.input("Query >") })

Thanks. that worked like a charm. I just changed it to query = vim.fn.expandd ('<cword>') to get symbol under cursor

Live grep sounds nice!

@eulertour
Copy link

I am thinking about a live grep version of workspace_symbols lately. Maybe something like this could solve that problem.

Please do, this is one of the major advantages of coc.nvim

@oberblastmeister
Copy link
Contributor

@ranjithshegde @eulertour live_workspace_symbols is here! #705

Gelio added a commit to Gelio/ubuntu-dotfiles that referenced this issue Apr 23, 2021
It turns out most language servers return an empry list of symbols for
an empty query (which tsserver was doing).

See nvim-telescope/telescope.nvim#568
Fixed by nvim-telescope/telescope.nvim#705
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.

5 participants