added customization to man previewer cmd

main
bhagwan 3 years ago
parent d8630ff38b
commit f322d59653

@ -347,6 +347,9 @@ require'fzf-lua'.setup {
cmd = "git diff", cmd = "git diff",
args = "--color", args = "--color",
}, },
man = {
cmd = "man -c %s | col -b",
},
builtin = { builtin = {
delay = 100, -- delay(ms) displaying the preview delay = 100, -- delay(ms) displaying the preview
-- prevents lag on fast scrolling -- prevents lag on fast scrolling
@ -525,7 +528,6 @@ require'fzf-lua'.setup {
-- "topleft" : up -- "topleft" : up
-- "botright" : down -- "botright" : down
-- helptags = { previewer = { split = "topleft" } }, -- helptags = { previewer = { split = "topleft" } },
-- manpages = { previewer = { split = "topleft" } },
-- uncomment to use `man` command as native fzf previewer -- uncomment to use `man` command as native fzf previewer
-- manpages = { previewer = { _ctor = require'fzf-lua.previewer'.fzf.man_pages } }, -- manpages = { previewer = { _ctor = require'fzf-lua.previewer'.fzf.man_pages } },
-- optional override of file extension icon colors -- optional override of file extension icon colors

@ -381,6 +381,9 @@ Consult the list below for available settings:
cmd = "git diff", cmd = "git diff",
args = "--color", args = "--color",
}, },
man = {
cmd = "man -c %s | col -b",
},
builtin = { builtin = {
delay = 100, -- delay(ms) displaying the preview delay = 100, -- delay(ms) displaying the preview
-- prevents lag on fast scrolling -- prevents lag on fast scrolling
@ -559,7 +562,6 @@ Consult the list below for available settings:
-- "topleft" : up -- "topleft" : up
-- "botright" : down -- "botright" : down
-- helptags = { previewer = { split = "topleft" } }, -- helptags = { previewer = { split = "topleft" } },
-- manpages = { previewer = { split = "topleft" } },
-- uncomment to use `man` command as native fzf previewer -- uncomment to use `man` command as native fzf previewer
-- manpages = { previewer = { _ctor = require'fzf-lua.previewer'.fzf.man_pages } }, -- manpages = { previewer = { _ctor = require'fzf-lua.previewer'.fzf.man_pages } },
-- optional override of file extension icon colors -- optional override of file extension icon colors

@ -129,6 +129,10 @@ M.globals = {
args = "--color", args = "--color",
_ctor = previewers.fzf.git_diff, _ctor = previewers.fzf.git_diff,
}, },
man = {
cmd = "man -c %s | col -b",
_ctor = previewers.builtin.man_pages,
},
builtin = { builtin = {
-- default preview delay 100ms, same as native fzf preview -- default preview delay 100ms, same as native fzf preview
-- https://github.com/junegunn/fzf/issues/2417#issuecomment-809886535 -- https://github.com/junegunn/fzf/issues/2417#issuecomment-809886535
@ -379,9 +383,7 @@ M.globals.manpages = {
["ctrl-v"] = actions.man_vert, ["ctrl-v"] = actions.man_vert,
["ctrl-t"] = actions.man_tab, ["ctrl-t"] = actions.man_tab,
}, },
previewer = { previewer = "man",
_ctor = previewers.builtin.man_pages,
},
} }
M.globals.lsp = { M.globals.lsp = {
previewer = M._default_previewer_fn, previewer = M._default_previewer_fn,

@ -30,7 +30,7 @@ function Previewer.base:new(o, opts, fzf_win)
)}) )})
self.type = "builtin" self.type = "builtin"
self.win = fzf_win self.win = fzf_win
self.delay = o.delay self.delay = o.delay or 100
self.title = self.win.winopts.preview.title self.title = self.win.winopts.preview.title
self.syntax = o.syntax self.syntax = o.syntax
self.syntax_delay = o.syntax_delay self.syntax_delay = o.syntax_delay
@ -502,9 +502,8 @@ function Previewer.man_pages:new(o, opts, fzf_win)
__index = vim.tbl_deep_extend("keep", __index = vim.tbl_deep_extend("keep",
self, Previewer.help_tags, Previewer.base self, Previewer.help_tags, Previewer.base
)}) )})
-- self.split = o.split
-- self.help_cmd = o.help_cmd or "Man"
self.filetype = "man" self.filetype = "man"
self.cmd = o.cmd or "man -c %s | col -b"
return self return self
end end
@ -517,14 +516,12 @@ function Previewer.man_pages:populate_preview_buf(entry_str)
local entry = self:parse_entry(entry_str) local entry = self:parse_entry(entry_str)
-- mark the buffer for unloading the next call -- mark the buffer for unloading the next call
self.preview_bufloaded = true self.preview_bufloaded = true
local cmd = ("man -c %s | col -b"):format(entry) local cmd = self.cmd:format(entry)
local output, err = utils.io_systemlist(cmd) local output, _ = utils.io_systemlist(cmd)
if err == 0 then -- vim.api.nvim_buf_set_option(self.preview_bufnr, 'modifiable', true)
-- vim.api.nvim_buf_set_option(self.preview_bufnr, 'modifiable', true) vim.api.nvim_buf_set_lines(self.preview_bufnr, 0, -1, false, output)
vim.api.nvim_buf_set_lines(self.preview_bufnr, 0, -1, false, output) vim.api.nvim_buf_set_option(self.preview_bufnr, 'filetype', self.filetype)
vim.api.nvim_buf_set_option(self.preview_bufnr, 'filetype', self.filetype) self.win:update_scrollbar()
self.win:update_scrollbar()
end
end end
function Previewer.marks:new(o, opts, fzf_win) function Previewer.marks:new(o, opts, fzf_win)

Loading…
Cancel
Save