Skip to content

Commit

Permalink
fix: fzf extension selected element parsing (#1198)
Browse files Browse the repository at this point in the history
* fix: fzf extension selected element parsing

On non-floating windows the selected element is not supported and showed 'nil'.
This fixes that and also uses fzf's path parser for a cleaner parsing of the
selection.

Closes #1197

* fix: fzf-lua extension lazy loading

Not calling require immediately will allow for better lazy loading using
lazy.nvim while the 'fzf' extension is enabled.
  • Loading branch information
trevarj authored Mar 4, 2024
1 parent f2de8f2 commit 8b56462
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions lua/lualine/extensions/fzf.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ works with both https://github.com/junegunn/fzf.vim and https://github.com/ibhag
-- fzf-lua must be set-up in split mode
]]

local fzf_lua, _ = pcall(require, 'fzf-lua')
local function has_fzf()
return pcall(require, 'fzf-lua')
end

local function fzf_picker()
if not fzf_lua then
if not has_fzf() then
return ''
end

Expand All @@ -17,16 +19,13 @@ local function fzf_picker()
end

local function fzf_element()
if not fzf_lua then
if not has_fzf() then
return ''
end

local info_string = vim.inspect(require('fzf-lua').get_info()['selected'])
local lines = {}
for w in info_string:gsub('"', ''):gmatch('%S+') do
table.insert(lines, w)
end
return lines[1]
local fzf = require('fzf-lua')
local selected = fzf.get_info().selected
return fzf.path.entry_to_file(selected).path
end

local function fzf_statusline()
Expand Down

0 comments on commit 8b56462

Please sign in to comment.