ibhagwan / fzf-lua

Improved fzf.vim written in lua
GNU Affero General Public License v3.0
2.17k stars 142 forks source link

Bug: fzf error 2: invalid color specification: formatter:path.filename_first #1176

Closed nikbrunner closed 4 months ago

nikbrunner commented 4 months ago

RTFM Checklist

Operating system

Mac OS

Shell

zsh

Neovim version (nvim --version)

NVIM v0.9.5

Fzf version (fzf --version)

0.50.0 (brew)

Output of :lua print(os.getenv('FZF_DEFAULT_OPTS'))

--bind 'ctrl-e:execute(echo {+} | xargs -o nvim)'

Is the problem reproducible with mini.sh?

Fzf-lua configuration

Link to my config:

https://github.com/nikbrunner/vin/blob/main/lua/vin/specs/fzf.lua

The most important parts:

https://github.com/nikbrunner/vin/blob/91b57803fe2366cc20d2a7c09175880ca357cee7/lua/vin/specs/fzf.lua#L283-L286

https://github.com/nikbrunner/vin/blob/91b57803fe2366cc20d2a7c09175880ca357cee7/lua/vin/specs/fzf.lua#L235-L252

Describe the bug / steps to reproduce

Referenced discussion: https://github.com/ibhagwan/fzf-lua/issues/1051#issuecomment-2094812996

When I set the defaults = { formatter = "path.filename_first" } and also have the fzf_colors.prompt set, I will get an error:

15:21:05 │ [Fzf-lua] fzf error 2: invalid color specification: formatter:path.filename_first

I found this in the repo and I guessed it has something todo with the fzf colors.

Already requested ouptut from my side

:lua vim.print(vim.api.nvim_get_hl(0,{name="Conditional"}))

{ bold = true, cterm = { bold = true, italic = true }, fg = 10063577, italic = true }


:FzfLua files debug=true _base64=false formatter=path.filename_first

fzf_colors.prompt commented out:


[Fzf-lua]: FZF_DEFAULT_COMMAND: VIMRUNTIME='/opt/homebrew/Cellar/neovim/0.9.5/share/nvim/runtime' '/opt/homebrew/Cellar/neovim/0.9.5/bin/nvim' -n --headless --clean --cmd 'lua loadfile([[/Users/nbr/.local/share/nvim/lazy/fzf-lua/lua/fzf-lua/libuv.lua]])().spawn_stdio({file_icons = false, git_icons = true, _base64 = false, g = {_fzf_lua_server = "/var/folders/k5/jc_1pjxx7h781rvj5y3ysmth0000gp/T/nvim.nbr/hzpt74/fzf-lua.1714920037.7062.1"}, debug = true, cmd = "fd --color=never --type f --hidden --follow --exclude .git", formatter = "path.filename_first", color_icons = false},[==[return require("make_entry").file]==],[==[return require("make_entry").preprocess]==])' || true
[Fzf-lua]: fzf cmd: fzf --expect 'esc,alt-q,ctrl-q,ctrl-t,ctrl-v,ctrl-s,ctrl-g,ctrl-y,ctrl-c,alt-l' --border-label '[ Vin ]' --preview 'VIMRUNTIME='\''/opt/homebrew/Cellar/neovim/0.9.5/share/nvim/runtime'\'' '\''/opt/homebrew/Cellar/neovim/0.9.5/bin/nvim'\'' -n --headless --clean --cmd '\''lua loadfile([[/Users/nbr/.local/share/nvim/lazy/fzf-lua/lua/fzf-lua/shell_helper.lua]])().rpc_nvim_exec_lua({fzf_lua_server=[[/var/folders/k5/jc_1pjxx7h781rvj5y3ysmth0000gp/T/nvim.nbr/hzpt74/fzf-lua.1714920037.7062.1]], fnc_id=3 , debug=true})'\'' -- {}' --layout 'reverse' --no-scrollbar --prompt '  ' --reverse --padding '0,3' --multi --ansi --keep-right --height '100%' --border 'none' --no-info --color 'gutter:#d6dbd9,spinner:#998ed9,header:#606a67,border:#4db290,pointer:#998ed9,bg:#d6dbd9,label:#4db290,fg:#313533,marker:#7872c2,query:#998ed9,info:#998ed9,bg+:#e3e6e5,hl+:#998ed9,hl:#606a67,fg+:#4db290' --print-query --header ':: <^[[38;2;0;250;154mctrl-g^[[0m> to ^[[38;2;139;35;35mDisable .gitignore^[[0m' --bind 'f3:toggle-preview-wrap,ctrl-u:preview-page-up,ctrl-a:toggle-all,ctrl-c:abort,ctrl-d:preview-page-down,zero:execute-silent(mkdir '\''/var/folders/k5/jc_1pjxx7h781rvj5y3ysmth0000gp/T/nvim.nbr/hzpt74/3'\'' && VIMRUNTIME='\''/opt/homebrew/Cellar/neovim/0.9.5/share/nvim/runtime'\'' '\''/opt/homebrew/Cellar/neovim/0.9.5/bin/nvim'\'' -n --headless --clean --cmd '\''lua loadfile([[/Users/nbr/.local/share/nvim/lazy/fzf-lua/lua/fzf-lua/shell_helper.lua]])().rpc_nvim_exec_lua({fzf_lua_server=[[/var/folders/k5/jc_1pjxx7h781rvj5y3ysmth0000gp/T/nvim.nbr/hzpt74/fzf-lua.1714920037.7062.1]], fnc_id=4 , debug=true})'\'' -- ),f4:toggle-preview,ctrl-q:select-all+accept' --preview-window 'nohidden:right:0' --no-separator > '/var/folders/k5/jc_1pjxx7h781rvj5y3ysmth0000gp/T/nvim.nbr/hzpt74/5'

> `fzf_colors.prompt` commented in:

[Fzf-lua]: FZF_DEFAULT_COMMAND: VIMRUNTIME='/opt/homebrew/Cellar/neovim/0.9.5/share/nvim/runtime' '/opt/homebrew/Cellar/neovim/0.9.5/bin/nvim' -n --headless --clean --cmd 'lua loadfile([[/Users/nbr/.local/share/nvim/lazy/fzf-lua/lua/fzf-lua/libuv.lua]])().spawn_stdio({g = {_fzf_lua_server = "/var/folders/k5/jc_1pjxx7h781rvj5y3ysmth0000gp/T/nvim.nbr/PlPz1d/fzf-lua.1714919750.5470.1"}, file_icons = false, formatter = "path.filename_first", cmd = "fd --color=never --type f --hidden --follow --exclude .git", color_icons = false, git_icons = true, debug = true, _base64 = false},[==[return require("make_entry").file]==],[==[return require("make_entry").preprocess]==])' || true [Fzf-lua]: fzf cmd: fzf --expect 'ctrl-v,ctrl-t,ctrl-g,ctrl-y,esc,ctrl-c,alt-q,ctrl-q,alt-l,ctrl-s' --preview 'VIMRUNTIME='\''/opt/homebrew/Cellar/neovim/0.9.5/share/nvim/runtime'\'' '\''/opt/homebrew/Cellar/neovim/0.9.5/bin/nvim'\'' -n --headless --clean --cmd '\''lua loadfile([[/Users/nbr/.local/share/nvim/lazy/fzf-lua/lua/fzf-lua/shell_helper.lua]])().rpc_nvim_exec_lua({fzf_lua_server=[[/var/folders/k5/jc_1pjxx7h781rvj5y3ysmth0000gp/T/nvim.nbr/PlPz1d/fzf-lua.1714919750.5470.1]], fnc_id=3 , debug=true})'\'' -- {}' --bind 'ctrl-a:toggle-all,f3:toggle-preview-wrap,zero:execute-silent(mkdir '\''/var/folders/k5/jc_1pjxx7h781rvj5y3ysmth0000gp/T/nvim.nbr/PlPz1d/3'\'' && VIMRUNTIME='\''/opt/homebrew/Cellar/neovim/0.9.5/share/nvim/runtime'\'' '\''/opt/homebrew/Cellar/neovim/0.9.5/bin/nvim'\'' -n --headless --clean --cmd '\''lua loadfile([[/Users/nbr/.local/share/nvim/lazy/fzf-lua/lua/fzf-lua/shell_helper.lua]])().rpc_nvim_exec_lua({fzf_lua_server=[[/var/folders/k5/jc_1pjxx7h781rvj5y3ysmth0000gp/T/nvim.nbr/PlPz1d/fzf-lua.1714919750.5470.1]], fnc_id=4 , debug=true})'\'' -- ),ctrl-u:preview-page-up,ctrl-c:abort,ctrl-q:select-all+accept,f4:toggle-preview,ctrl-d:preview-page-down' --keep-right --preview-window 'nohidden:right:0' --no-separator --padding '0,3' --reverse --prompt ' ' --no-scrollbar --layout 'reverse' --border-label '[ Vin ]' --no-info --height '100%' --print-query --color 'query:#998ed9,formatter:path.filename_first,bg+:#e3e6e5,hl+:#998ed9,hl:#606a67,fg+:#4db290,marker:#7872c2,bg:#d6dbd9,gutter:#d6dbd9,spinner:#998ed9,info:#998ed9,border:#4db290,pointer:#998ed9,prompt:#998ed9,header:#606a67,label:#4db290,fg:#313533' --header ':: <^[[38;2;0;250;154mctrl-g^[[0m> to ^[[38;2;139;35;35mDisable .gitignore^[[0m' --multi --ansi --border 'none' > '/var/folders/k5/jc_1pjxx7h781rvj5y3ysmth0000gp/T/nvim.nbr/PlPz1d/5'


---
ibhagwan commented 4 months ago

@nikbrunner, is the debug output from when the command fails (when prompt is not commented)?

I’m confused because I don’t see prompt:… as part of the --color string, very strange error message and issue but rest assured we’ll get to the bottom of this :)

nikbrunner commented 4 months ago

@nikbrunner, is the debug output from when the command fails (when prompt is not commented)?

I’m confused because I don’t see prompt:… as part of the --color string, very strange error message and issue but rest assured we’ll get to the bottom of this :)

Yeah the first time it was without the prompt commented in. I forgot about that. 🤦 I updated the description. The first is without the prompt and the second one with.

ibhagwan commented 4 months ago

Ok now this makes sense, definitely a bug, look at the second output --color 'query:#998ed9,formatter:path.filename_first,….

Ty @nikbrunner! I’ll fix this in a couple of hours.

ibhagwan commented 4 months ago

https://github.com/ibhagwan/fzf-lua/commit/c8a73993708b91fe565199705bd3d28b9a16ffad

@nikbrunner, should work as expected now.

nikbrunner commented 4 months ago

It works! Perfect. Thank you so much (again). 😁 I don't know the code base of course, but the fix is very interesting.

ibhagwan commented 4 months ago

It works! Perfect. Thank you so much (again). 😁 I don't know the code base of course, but the fix is very interesting.

It's a long story, not that long ago I replaced the way globals are acquired to be able to better accomodate option overrides (fzf-lua accepts overrides from anywhere, setup, setup.defaults, call options, :FzfLua command, etc), I somewhat arbitrarily decided that any table that contains prompt is a picker and needs to have setup.defaults merged into it, obviously that "logic" came back to bite me lol, now changed to anything that has actions lol, simple and works until it doesn't lol

ibhagwan commented 4 months ago

Actually it did come to bite me already lol, the defaults weren't being applied to oldfiles as it inherits actions from files

https://github.com/ibhagwan/fzf-lua/commit/e627782478a3f8bd6e766b39c40631f60a1b66ba

nikbrunner commented 4 months ago

Very interesting. It is good that I noticed it and you were able to solve it. 😁 I love the new new previewer. Thank you again. 🙏