liuchengxu / space-vim

:four_leaf_clover: Lean & mean spacemacs-ish Vim distribution
https://liuchengxu.github.io/space-vim/
MIT License
2.85k stars 258 forks source link

Auto-installed FZF does not work out of the box #464

Open jyscao opened 3 years ago

jyscao commented 3 years ago

Environment

:version

NVIM v0.4.4
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/cc -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -g
record-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tab
les -fstack-clash-protection -fcf-protection -Wp,-U_FORTIFY_SOURCE -Wp,-D_FORTIFY_SOURCE=1 -O2 -g -DMIN_LOG_LEVEL=3 -Og -g -Wall -Wextra -pedantic -Wno-unused
-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagn
ostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -I/builddir/build/BUILD/neovim-0.4.4/bui
ld/config -I/builddir/build/BUILD/neovim-0.4.4/src -I/usr/include -I/usr/include/lua-5.1 -I/builddir/build/BUILD/neovim-0.4.4/build/src/nvim/auto -I/builddir/
build/BUILD/neovim-0.4.4/build/include
Compiled by mockbuild

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

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/share/nvim"

:SpaceInfo

    Current FileType: 
    Global Variables:
    let g:spacevim = {
        base = '/home/jyscao/.space-vim',
        excluded = [],
        gui = 0,
        info = '/home/jyscao/.space-vim/core/autoload/spacevim/info.vim',
        layers_base = '/layers',
        loaded = ['spacevim', 'fzf', 'better-defaults', 'which-key'],
        manifest = {'wasm': {'dir': '/home/jyscao/.space-vim/layers/+lang/wasm'}, 'spacevim': {'dir': '/home/jyscao/.space-vim/layers/+distributions/spacevim'}, 'ctrlp': {'dir': '/home/jyscao/.space-vim/layers/+vim/ctrlp'}, 'go': {'dir': '/home/jyscao/.space-vim/layers/+lang/go'}, 'asyncomplete': {'dir': '/home/jyscao/.space-vim/layers/+completion/asyncomplete'}, 'code-snippets': {'dir': '/home/jyscao/.space-vim/layers/+programming/code-snippets'}, 'graphviz': {'dir': '/home/jyscao/.space-vim/layers/+lang/graphviz'}, 'solidity': {'dir': '/home/jyscao/.space-vim/layers/+lang/solidity'}, 'git': {'dir': '/home/jyscao/.space-vim/layers/+version-control/git'}, 'github': {'dir': '/home/jyscao/.space-vim/layers/+version-control/github'}, 'haskell': {'dir': '/home/jyscao/.space-vim/layers/+lang/haskell'}, 'games': {'dir': '/home/jyscao/.space-vim/layers/+fun/games'}, 'java': {'dir': '/home/jyscao/.space-vim/layers/+lang/java'}, 'javascript': {'dir': '/home/jyscao/.space-vim/layers/+lang/javascript'}, 'scala': {'dir': '/home/jyscao/.space-vim/layers/+lang/scala'}, 'auto-completion': {'dir': '/home/jyscao/.space-vim/layers/+completion/auto-completion'}, 'ruby': {'dir': '/home/jyscao/.space-vim/layers/+lang/ruby'}, 'emoji': {'dir': '/home/jyscao/.space-vim/layers/+fun/emoji'}, 'file-manager': {'dir': '/home/jyscao/.space-vim/layers/+tools/file-manager'}, 'typescript': {'dir': '/home/jyscao/.space-vim/layers/+lang/typescript'}, 'lsp': {'dir': '/home/jyscao/.space-vim/layers/+tools/lsp'}, 'docker': {'dir': '/home/jyscao/.space-vim/layers/+tools/docker'}, 'deoplete': {'dir': '/home/jyscao/.space-vim/layers/+completion/deoplete'}, 'programming': {'dir': '/home/jyscao/.space-vim/layers/+programming/programming'}, 'chinese': {'dir': '/home/jyscao/.space-vim/layers/+misc/chinese'}, 'which-key': {'dir': '/home/jyscao/.space-vim/layers/+vim/which-key'}, 'syntax-checking': {'dir': '/home/jyscao/.space-vim/layers/+checkers/syntax-checking'}, 'ycmd': {'dir': '/home/jyscao/.space-vim/layers/+tools/ycmd'}, 'formatting': {'dir': '/home/jyscao/.space-vim/layers/+programming/formatting'}, 'html': {'dir': '/home/jyscao/.space-vim/layers/+lang/html'}, 'better-defaults': {'dir': '/home/jyscao/.space-vim/layers/+distributions/better-defaults'}, 'text-align': {'dir': '/home/jyscao/.space-vim/layers/+vim/text-align'}, 'vue': {'dir': '/home/jyscao/.space-vim/layers/+lang/vue'}, 'goyo': {'dir': '/home/jyscao/.space-vim/layers/+fun/goyo'}, 'better-motion': {'dir': '/home/jyscao/.space-vim/layers/+vim/better-motion'}, 'python': {'dir': '/home/jyscao/.space-vim/layers/+lang/python'}, 'cscope': {'dir': '/home/jyscao/.space-vim/layers/+tools/cscope'}, 'airline': {'dir': '/home/jyscao/.space-vim/layers/+themes/airline'}, 'elm': {'dir': '/home/jyscao/.space-vim/layers/+lang/elm'}, 'clojure': {'dir': '/home/jyscao/.space-vim/layers/+lang/clojure'}, 'c-c++': {'dir': '/home/jyscao/.space-vim/layers/+lang/c-c++'}, 'unite': {'dir': '/home/jyscao/.space-vim/layers/+completion/unite'}, 'editing': {'dir': '/home/jyscao/.space-vim/layers/+programming/editing'}, 'latex': {'dir': '/home/jyscao/.space-vim/layers/+lang/latex'}, 'markdown': {'dir': '/home/jyscao/.space-vim/layers/+lang/markdown'}, 'lightline': {'dir': '/home/jyscao/.space-vim/layers/+themes/lightline'}, 'erlang': {'dir': '/home/jyscao/.space-vim/layers/+lang/erlang'}, 'ctags': {'dir': '/home/jyscao/.space-vim/layers/+tools/ctags'}, 'rust': {'dir': '/home/jyscao/.space-vim/layers/+lang/rust'}, 'elixir': {'dir': '/home/jyscao/.space-vim/layers/+lang/elixir'}, 'tmux': {'dir': '/home/jyscao/.space-vim/layers/+tools/tmux'}, 'fzf': {'dir': '/home/jyscao/.space-vim/layers/+tools/fzf'}},
        nvim = 1,
        os = {'linux': 1, 'windows': 0, 'mac': 0},
        plugins = ['liuchengxu/space-vim-dark', 'liuchengxu/space-vim-theme', 'liuchengxu/vim-better-default', 'liuchengxu/eleline.vim', 'junegunn/fzf', 'junegunn/fzf.vim', 'kshenoy/vim-signature', 'tpope/vim-rsi', 'xtal8/traces.vim', 'dominikduda/vim_current_word', 't9md/vim-choosewin', 'mhinz/vim-startify', 'ntpeters/vim-better-whitespace', 'haya14busa/is.vim', 'osyo-manga/vim-anzu', 'liuchengxu/vim-which-key'],
        private_base = '/private',
        speed_up_via_timer = 1,
        timer = 1,
        tmux = 0,
        topics = {'+themes': ['lightline', 'airline'], '+tools': ['ycmd', 'cscope', 'fzf', 'docker', 'ctags', 'lsp', 'file-manager', 'tmux'], '+programming': ['formatting', 'editing', 'programming', 'code-snippets'], '+misc': ['chinese'], '+completion': ['auto-completion', 'unite', 'asyncomplete', 'deoplete'], '+distributions': ['spacevim', 'better-defaults'], '+version-control': ['github', 'git'], '+fun': ['games', 'emoji', 'goyo'], '+lang': ['markdown', 'rust', 'ruby', 'html', 'vue', 'clojure', 'java', 'latex', 'c-c++', 'python', 'elixir', 'graphviz', 'scala', 'erlang', 'solidity', 'haskell', 'javascript', 'wasm', 'elm', 'go', 'typescript'], '+checkers': ['syntax-checking'], '+vim': ['which-key', 'text-align', 'ctrlp', 'better-motion']},
        version = '0.9.0',
        vim8 = 0,
    }
    let g:spacevim#map#leader#desc = {
          = {'c': ['tabclose', 'close-current-tab'], '1': 'tab-1', '2': 'tab-2', '3': 'tab-3', '4': 'tab-4', 'name': '+tab', '6': 'tab-6', '7': 'tab-7', '8': 'tab-8', '9': 'tab-9', '5': 'tab-5'},
        1 = 'window-1',
        2 = 'window-2',
        3 = 'window-3',
        4 = 'window-4',
        5 = 'window-5',
        6 = 'window-6',
        7 = 'window-7',
        8 = 'window-8',
        9 = 'window-9',
        ; = ['<Plug>NERDCommenterToggle', 'commenter'],
        ? = ['Maps', 'show-keybindings'],
        Q = ['qa!', 'quit-without-saving'],
        a = {'name': '+align'},
        b = {'name': '+buffer', 'b': 'fzf-buffer', 'd': 'delete-buffer', 'f': 'first-buffer', 'h': 'home-buffer', 'k': 'kill-buffer', 'l': 'last-buffer', 'n': 'next-buffer', 'p': 'previous-buffer', '1': 'buffer-1', '2': 'buffer-2', '3': 'buffer-3', '4': 'buffer-4', '5': 'buffer-5', '6': 'buffer-6', '7': 'buffer-7', '8': 'buffer-8', '9': 'buffer-9', '?': 'fzf-buffer'},
        c = {'c': ['spacevim#vim#cscope#Find("calls")', 'find-functions-calling-this-function'], 'd': ['spacevim#vim#cscope#Find("called")', 'find-functions-called-by-this-function'], 's': ['spacevim#vim#cscope#Find("symbol")', 'find-this-symbol'], 't': ['spacevim#vim#cscope#Find("text")', 'text'], 'name': '+cscope', 'f': ['spacevim#vim#cscope#Find("file")', 'find-this-file'], 'g': ['spacevim#vim#cscope#Find("global")', 'global-definition'], 'i': ['spacevim#vim#cscope#Find("includes")', 'find-files-#include-this-file'], 'e': ['spacevim#vim#cscope#Find("egrep")', 'egrep']},
        d = 'scroll-down',
        e = {'p': 'previous-error', 'name': '+errors', 'n': 'next-error'},
        f = {'s': 'save-file', 'R': 'reload-vimrc', 'name': '+find/files/fold', 't': 'toggle-NERDTree', 'b': ['spacevim#map#manager#BLines()', 'fzf-find-current-buffer'], 'd': 'find-current-buffer-in-NERDTree', 'f': 'files-in-home-direcotry', '0': '0-fold-level', '1': '1-fold-level', '2': '2-fold-level', '3': '3-fold-level', '4': '4-fold-level', '5': '5-fold-level', '6': '6-fold-level', '7': '7-fold-level', '8': '8-fold-level', '9': '9-fold-level', '?': 'files-in-current-direcotry'},
        g = {'s': ['Gstatus', 'fugitive-status'], 'p': ['Git push', 'fugitive-push'], 'b': ['Gblame', 'fugitive-blame'], 'c': ['BCommits', 'commits-for-current-buffer'], 'd': ['Gdiff', 'fugitive-diff'], 'name': '+git/version-control', 'w': ['Gwrite', 'fugitive-write'], 'y': ['Goyo', 'goyo-mode'], 'C': ['Gcommit', 'fugitive-commit'], 'l': ['Glog', 'fugitive-log'], 'r': ['Gread', 'fugitive-read'], 'e': ['Gedit', 'fugitive-edit']},
        h = {'name': '+help'},
        j = {'b': 'jump-backword-wordwise', 'name': '+jump/json', 'f': 'jump-forward-wordwise', 'w': 'jump-to-word-bidirectional', 'j': 'easymotion-goto-char', 'F': ['execute line(".")."!python -m json.tool"', 'format-current-raw-oneline-json'], 'l': 'jump-linewise', 'J': 'easymotion-goto-char-2'},
        l = {'a': ['spacevim#lang#util#CodeAction()', 'code-action'], 'r': ['spacevim#lang#util#FindReferences()', 'references'], 's': ['spacevim#lang#util#DocumentSymbol()', 'document-symbol'], 'name': '+lsp', 'f': ['spacevim#lang#util#Format()', 'formatting'], 'g': {'d': ['spacevim#lang#util#Definition()', 'definition'], 'name': '+goto', 'i': ['spacevim#lang#util#Implementation()', 'implementation'], 't': ['spacevim#lang#util#TypeDefinition()', 'type-definition']}, 'h': ['spacevim#lang#util#Hover()', 'hover'], 'S': ['spacevim#lang#util#WorkspaceSymbol()', 'workspace-symbol'], 'R': ['spacevim#lang#util#Rename()', 'rename']},
        name = 'space-vim root',
        p = {'a': ['Rag', 'search-in-project-via-ag'], 'r': ['spacevim#map#manager#Rg()', 'search-in-project-via-rg'], 's': ['spacevim#map#manager#Rg()', 'search-in-project'], 'name': '+projects', 'f': ['spacevim#map#manager#FindFiles()', 'find-file-in-project'], 'w': ['spacevim#map#manager#RgCword()', 'find-cword-in-project-via-rg'], 'W': ['spacevim#plug#fzf#SearchCword()', 'find-cword-in-project']},
        q = ['q', 'quit'],
        r = {'c': 'replace-current-word-in-current-file'},
        s = {'b': ['spacevim#map#manager#BLines()', 'search-in-buffer'], 'c': 'search-clear-highlight', 'name': '+search/show', 'h': ['spacevim#util#SyntaxHiGroup()', 'show-highlight-group'], 'r': ['spacevim#map#manager#SearchRecently()', 'search-recently-buffers-and-files'], 'B': ['spacevim#map#manager#BufCword()', 'search-cword-in-buffer']},
        t = {'p': ['setlocal paste!', 'paste-mode'], 'c': ['spacevim#vim#toggle#CursorColumn()', 'cursor-column'], 'b': ['spacevim#map#manager#BufTags()', 'tags-in-current-buffer'], 's': ['SyntasticToggleMode', 'syntastic'], 'T': ['TagbarToggle', 'tagbar'], 'name': '+toggle/tag', 'g': ['spacevim#plug#toggle#Git()', 'git-status-indicator'], 'i': ['IndentGuidesToggle', 'indent-guide'], 'C': ['spacevim#vim#toggle#ColorColumn()', 'color-column']},
        u = 'scroll-up',
        w = {'H': 'expand-window-left', 'J': 'expand-window-below', 'K': 'expand-window-up', 'L': 'expand-window-right', 'name': '+windows', 'd': 'delete-window', 'h': 'window-left', 'j': 'window-below', 'k': 'window-up', 'l': 'window-right', '-': 'split-window-below', 'o': ['only', 'close-all-windows-except-current'], '2': 'layout-double-columns', 's': 'split-window-below', 'v': 'split-window-below', 'w': 'other-window', '|': 'split-window-right', '=': 'balance-window', '?': 'fzf-window'},
        x = {'a': ['<Plug>(EasyAlign)', 'easy-align'], 'd': ['StripWhitespace', 'delete-trailing-whitespace'], 'name': '+text'},
    }
    let g:spacevim#map#manager#quick_open = ['~/.spacevim', '~/.space-vim/init.vim', '~/.bashrc', '~/.zshrc', '~/.tmux.conf']
    let g:spacevim_layers = ['fzf', 'better-defaults', 'which-key']
    let g:spacevim_plug_home = '~/.vim/plugged'
clipboard: error invoking xclip: Waiting for selection requests, Control-C to quit   Waiting for selection request number 1   Waiting for selection request number 2 

Problem Description

Unable to use the fzf binary automatically installed through space-vim. Firstly, in layers/+tools/fzf/packages.vim, where fzf is added to the plugins list w/ MP 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all', 'on': [] }, the installation directory of ~/.fzf is not automatically added to the user's $PATH (at least not in my case running Fedora 32). Though this was just a minor annoyance, easily fixed by modifying one's $PATH.

The bigger problem is that this installed fzf executable appears to be busted. Since when I try to use it, it gives a segfault:

~ $ .fzf/bin/fzf --version
Segmentation fault

Funnily enough fzf-tmux appears to work fine:

~ $ .fzf/bin/fzf-tmux --version
fzf-tmux (with fzf 0.24.1 (Fedora))

And it was able to start indexing my files when I just ran ~ $ .fzf/bin/fzf-tmux alone.

Error in :messages

Error detected while processing function fzf#vim#files[15]..<SNR>80_fzf[1]..<SNR>80_check_requirements:                                             
line   14:
E605: Exception not caught: Failed to run "fzf --version": []

The above error is certainly caused by the FZF binary.

Diagnosis & Suggestions

After a quick search, this problem is possibly related to fzf.vim issue #915. Though it might not, since the above segfault error was displayed inside of nvim, so that user's fzf binary outside of nvim could be fully functional. I cannot be sure either way.

If it the problem is indeed caused by Neovim, then there isn't much that can be done proactively on your end. But it'll probably be good to add a warning in the fzf layer's README that this can be a potential problem.

The simplest workaround is to just install FZF using the system package manager, which in my case was just # dnf install fzf, with the binary located at /usr/bin/fzf. This version works perfectly well both inside and outside of space-vim/Neovim.

Also a minor suggestion wrt the installation target on Linux machines at least, it's usually more standard to install to either ~/bin/ or ~/.local/bin/ rather that a subdir under ~/ itself. At minimum, users should be informed that they might have to manually add ~/.fzf/ to their $PATH.

liuchengxu commented 3 years ago

PR welcome, I'm currently using vim-clap.

rene-descartes2021 commented 2 years ago

fzf's install script is supposed to append the binary's path to the user's $PATH. I think it reasonable to presume that fzf's install script terminated early due to the segmentation fault, and thus didn't add the binary to the $PATH. Thus, a bug in fzf and not space-vim. And probably fixed since. So I think this issue can be closed.

The detection of a system-wide install of fzf before doing a user-specific install of fzf would make sense. A simple check in layers/+tools/fzf/packages.vim

if !executable('fzf')
  MP 'junegunn/fzf',  { 'dir': '~/.fzf', 'do': './install --all' }
endif

In PR #486 I propose moving the default user install of fzf to ~/.config/fzf (per XDG spec as used within fzf's install) instead of ~/.fzf, fzf is installed to ~/.fzf for historical reasons, as said a link from PR #486. I didn't like that ~/.fzf convention either.