Debian Codegraph @

lua/lualine/extensions/fzf.lua

raw
1 --[[
2 lualine extension for fzf filetypes:
3 works with both https://github.com/junegunn/fzf.vim and https://github.com/ibhagwan/fzf-lua
4
5 -- fzf-lua must be set-up in split mode
6 ]]
7
8 local function has_fzf()
9 return pcall(require, 'fzf-lua')
10 end
11
12 local function fzf_picker()
13 if not has_fzf() then
14 return ''
15 end
16
17 local info_string = vim.inspect(require('fzf-lua').get_info()['fnc'])
18 return info_string:gsub('"', '')
19 end
20
21 local function fzf_element()
22 if not has_fzf() then
23 return ''
24 end
25
26 local fzf = require('fzf-lua')
27 local selected = fzf.get_info().selected
28 return fzf.path.entry_to_file(selected).path
29 end
30
31 local function fzf_statusline()
32 return 'FZF'
33 end
34
35 local M = {}
36
37 M.sections = {
38 lualine_a = { fzf_statusline },
39 lualine_y = { fzf_element },
40 lualine_z = { fzf_picker },
41 }
42
43 M.filetypes = { 'fzf' }
44
45 return M