andreyorst / fzf.kak

FZF for Kakoune
MIT License
143 stars 33 forks source link

Can't setup fzf via kakrc #95

Closed MrOneTwo closed 2 years ago

MrOneTwo commented 2 years ago

Hello, it seems my fzf config isn't read. This is my kakrc.

plug "andreyorst/fzf.kak" config %{
  map global normal <c-p> ': fzf-mode<ret>'
} defer "fzf" %{
  set-option global fzf_grep_command 'rg'
  set-option global fzf_file_command "find . \( -path '*/.svn*' -o
                                                -path '*/.git*' -o
                                                -path '*/.cache*' -o
                                                -path '*/.mypy_cache*' \) -prune -o -type f -print"
  set-option global fzf_preview false
}

None of those get set when Kakoune is run but running this works:

set-option global fzf_preview false

Setting any of those options manually works but not from kakrc.

Kakoune ver: v2021.11.08-1-ge7100dc8

The debug buffer just after booting Kakoune:

error running hook ModuleLoaded(fzf)/: 2:3: 'set-option': option not found: 'fzf_grep_command'. Use declare-option first
andreyorst commented 2 years ago

plug "andreyorst/fzf.kak" config %{ map global normal ': fzf-mode' } defer "fzf" %{ set-option global fzf_grep_command 'rg' set-option global fzf_file_command "find . ( -path '/.svn' -o -path '/.git' -o -path '/.cache' -o -path '/.mypy_cache' ) -prune -o -type f -print" set-option global fzf_preview false }

None of those get set when Kakoune is run but running this works:

set-option global fzf_preview false

This is because fzf_file_command is not defined in the fzf module but in the fzf-file module, so you need to use defer fzf-file around this set-option block. Same for fzf_grep_command. Please see the readme for where the options are defined, and please see plug.kak's readme on how to use the defer keyword.

MrOneTwo commented 2 years ago

@andreyorst Ohhhh... that actually helps me to understand how the plugins are structured. Thank you and sorry for bothering you with my misunderstanding of the subject.

andreyorst commented 2 years ago

no problem!

Tentacular261 commented 2 years ago

For anyone else with the same issue, here is the corrected config:

plug "andreyorst/fzf.kak" config %{
  map global normal <c-p> ': fzf-mode<ret>'
} defer "fzf-file" %{
  set-option global fzf_grep_command 'rg'
  set-option global fzf_file_command "find . \( -path '*/.svn*' -o
                                                -path '*/.git*' -o
                                                -path '*/.cache*' -o
                                                -path '*/.mypy_cache*' \) -prune -o -type f -print"
  set-option global fzf_preview false
}

Notice that the fzf-file module is what needed to be deferred, not the fzf module. You can tell which module to use for fzf from the README. It lists the module to use for each configuration setting (the fzf_grep_command, fzf_file_command, and fzf_preview settings in this example).