antoinemadec / coc-fzf

fzf :heart: coc.nvim
390 stars 28 forks source link

Symbols list fails to resolve python3 path on linux #118

Closed thisisrandy closed 2 years ago

thisisrandy commented 2 years ago

Environment

Describe the Bug

Whenever :CocFzfList symbols is run, the following error issues:

Error detected while processing function <SNR>153_echo_cb:
line    2:
E15: Invalid expression: ~/.pyenv/versions/neovim/bin/python' is not executable.' | echohl None

This is the command issued in s:echo_core. I'm not well-versed in vimscript, so it isn't clear to me why the expression is invalid. However, the root cause is more obvious. For reference,

  let python3 = get(g:, 'python3_host_prog', 'python3')
  if !executable(python3)
    call coc_fzf#common#echom_error(string(python3) . ' is not executable.')

g:python3_host_prog resolves to ~/.pyenv/versions/neovim/bin/python on my machine. executable apparently doesn't understand the tilde, so executable(python3) results in 0. Technically this is executable's fault, not coc-fzf's, but a possible patch would be to add something like the following:

  if has('unix')
    let python3 = substitute(python3, '\~', $HOME, "")
  endif
  if !executable(python3) ...

That may be a bad solution for a variety of reasons that aren't apparent to me, but I'll submit a PR for review.

To Reproduce

Minimal vimrc

let g:python3_host_prog = '~/.pyenv/versions/neovim/bin/python'

call plug#begin('~/.local/share/nvim/plugged')

Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'antoinemadec/coc-fzf', {'branch': 'release'}

call plug#end()

for key in keys(g:plugs)
  if ! isdirectory(g:plugs[key].dir)
    autocmd VimEnter * PlugInstall
    break
  endif
endfor

nnoremap <silent> <space>s       :<C-u>CocFzfList symbols<CR>

Steps to Reproduce

  1. nvim -u minimal_vimrc
  2. :e myfile.py
  3. <space>s

Expected Behavior

python3 is found to be executable and the symbols list is displayed.