From 236b305a1821c79038ab907d08441ff8e0724818 Mon Sep 17 00:00:00 2001 From: bhagwan Date: Thu, 7 Jul 2022 13:04:01 -0700 Subject: [PATCH] feat: new FzfLuaXXX highlights, updated README --- README.md | 125 ++++++++++++++++++++++++++---- doc/fzf-lua.txt | 122 ++++++++++++++++++++++++----- lua/fzf-lua/config.lua | 52 +++++++++++-- lua/fzf-lua/init.lua | 43 ++++++++++ lua/fzf-lua/previewer/builtin.lua | 24 +++--- lua/fzf-lua/win.lua | 38 ++++----- 6 files changed, 333 insertions(+), 71 deletions(-) diff --git a/README.md b/README.md index f022fbc..e311be3 100644 --- a/README.md +++ b/README.md @@ -256,15 +256,57 @@ vim.api.nvim_set_keymap('n', '', : to create your own fzf-lua commands see [Wiki/ADVANCED](https://github.com/ibhagwan/fzf-lua/wiki/Advanced)** -I tried to make this plugin as customizable as possible, if you find you need to -change something that isn’t below, open an issue and I’ll do my best to add it. +Customization can be achieved by calling the `setup()` function (optional) or +individually sending parameters to a builtin command, A few examples below: -Customization can be achieved by calling the `setup()` function or individually sending parameters to a builtin command, for example: +> Different `fzf` layout: ```lua :lua require('fzf-lua').files({ fzf_opts = {['--layout'] = 'reverse-list'} }) ``` -Consult the list below for available settings: +> Using `files` with a different command and working directory: +```lua +:lua require'fzf-lua'.files({ prompt="LS> ", cmd = "ls", cwd="~/" }) +``` + +> Using `live_grep` with `git grep`: +```lua +:lua require'fzf-lua'.live_grep({ cmd = "git grep --line-number --column --color=always" }) +``` + +> `colorschemes` with non-default window size: +```lua +:lua require'fzf-lua'.colorschemes({ winopts = { height=0.33, width=0.33 } }) +``` + +Use `setup()` If you wish for a setting to persist and not have to send it using the call +arguments, e.g: +```lua +require('fzf-lua').setup{ + winopts = { + ... + } +} +``` + +Can also be called from a `.vim` file: +```lua +lua << EOF +require('fzf-lua').setup{ + ... +} +EOF +``` + +**Below is a list of most (still, not all default settings), please also +consult the issues if there's something you need and you can't find as there +have been many obscure requests which have been fulfilled and are yet to be +documented. If you're still having issues and/or questions do not hesitate to open an +issue and I'll be more than happy to help.** + +
+CLICK HERE TO EXPLORE THE DEFAULT OPTIONS + ```lua local actions = require "fzf-lua.actions" require'fzf-lua'.setup { @@ -292,18 +334,27 @@ require'fzf-lua'.setup { -- 'none', 'single', 'double', 'thicc' or 'rounded' (default) border = { '╭', '─', '╮', '│', '╯', '─', '╰', '│' }, fullscreen = false, -- start fullscreen? - hl = { + -- highlights should optimally be set by the colorscheme using + -- FzfLuaXXX highlights. If your colorscheme doesn't set these + -- or you wish to override its defaults use these: + --[[ hl = { normal = 'Normal', -- window normal color (fg+bg) - border = 'Normal', -- border color (try 'FloatBorder') - -- Only valid with the builtin previewer: + border = 'FloatBorder', -- border color + help_normal = 'Normal', -- window normal + help_border = 'FloatBorder', -- window border + -- Only used with the builtin previewer: cursor = 'Cursor', -- cursor highlight (grep/LSP matches) cursorline = 'CursorLine', -- cursor line cursorlinenr = 'CursorLineNr', -- cursor line number search = 'IncSearch', -- search matches (ctags|help) - -- title = 'Normal', -- preview border title (file/buffer) - -- scrollbar_f = 'PmenuThumb', -- scrollbar "full" section highlight - -- scrollbar_e = 'PmenuSbar', -- scrollbar "empty" section highlight - }, + title = 'Normal', -- preview border title (file/buffer) + -- Only used with 'winopts.preview.scrollbar = 'float' + scrollfloat_e = 'PmenuSbar', -- scrollbar "empty" section highlight + scrollfloat_f = 'PmenuThumb', -- scrollbar "full" section highlight + -- Only used with 'winopts.preview.scrollbar = 'border' + scrollborder_e = 'FloatBorder', -- scrollbar "empty" section highlight + scrollborder_f = 'FloatBorder', -- scrollbar "full" section highlight + }, ]] preview = { -- default = 'bat', -- override the default previewer? -- default uses the 'builtin' previewer @@ -315,7 +366,7 @@ require'fzf-lua'.setup { horizontal = 'right:60%', -- right|left:size layout = 'flex', -- horizontal|vertical|flex flip_columns = 120, -- #cols to switch to horizontal on flex - -- Only valid with the builtin previewer: + -- Only used with the builtin previewer: title = true, -- preview border title (file/buf)? scrollbar = 'float', -- `false` or string:'float|border' -- float: in-window floating border @@ -818,14 +869,56 @@ require'fzf-lua'.setup { } ``` -This can also be run from a `.vim` file using: +
+### Customizing Highlights + +FzfLua conviniently creates the below highlights: +```lua + -- key is the highlight group name + -- value[1] is the setup/call arg option name + -- value[2] is the default link if value[1] is undefined + FzfLuaNormal = { 'winopts.hl.normal', "Normal" }, + FzfLuaBorder = { 'winopts.hl.border', "FloatBorder" }, + FzfLuaCursor = { 'winopts.hl.cursor', "Cursor" }, + FzfLuaCursorLine = { 'winopts.hl.cursorline', "CursorLine" }, + FzfLuaCursorLineNr = { 'winopts.hl.cursornr', "CursorLineNr" }, + FzfLuaSearch = { 'winopts.hl.search', "IncSearch" }, + FzfLuaTitle = { 'winopts.hl.title', "FzfLuaNormal" }, + FzfLuaScrollBorderEmpty = { 'winopts.hl.scrollborder_e', "FzfLuaBorder" }, + FzfLuaScrollBorderFull = { 'winopts.hl.scrollborder_f', "FzfLuaBorder" }, + FzfLuaScrollFloatEmpty = { 'winopts.hl.scrollfloat_e', "PmenuSbar" }, + FzfLuaScrollFloatFull = { 'winopts.hl.scrollfloat_f', "PmenuThumb" }, + FzfLuaHelpNormal = { 'winopts.hl.help_normal', "FzfLuaNormal" }, + FzfLuaHelpBorder = { 'winopts.hl.help_border', "FzfLuaBorder" }, +``` + + +These can be easily customized either via the lua API: +```lua +:lua vim.api.nvim_set_hl(0, "FzfLuaBorder", { link = "FloatBorder" }) +``` + +Or vimscript: +```vim +:hi! link FzfLuaBorder FloatBorder +``` + +If you wish to further customize these highlights without having to +modify your preset colorscheme highlight links you can define the corresponding +`winopts.hl` option or even send it directly via a call argument: + +```lua +:lua require'fzf-lua'.files({ winopts={hl={normal="IncSearch"}} }) +``` + +Or via `setup`: ```lua -lua << EOF require('fzf-lua').setup{ --- ... + winopts = { + hl = { border = "FloatBorder", } + } } -EOF ``` ## Credits diff --git a/doc/fzf-lua.txt b/doc/fzf-lua.txt index 84a94a7..59188d8 100644 --- a/doc/fzf-lua.txt +++ b/doc/fzf-lua.txt @@ -296,17 +296,53 @@ CUSTOMIZATION *fzf-lua-customization* to create your own fzf-lua commands see Wiki/ADVANCED ** -I tried to make this plugin as customizable as possible, if you find you need -to change something that isn’t below, open an issue and I’ll do my best to -add it. +Customization can be achieved by calling the `setup()` function (optional) or +individually sending parameters to a builtin command, A few examples below: -Customization can be achieved by calling the `setup()` function or -individually sending parameters to a builtin command, for example: + Different `fzf` layout: > :lua require('fzf-lua').files({ fzf_opts = {['--layout'] = 'reverse-list'} }) < -Consult the list below for available settings: + Using `files` with a different command and working directory: + +> + :lua require'fzf-lua'.files({ prompt="LS> ", cmd = "ls", cwd="~/" }) +< + Using `live_grep` with `git grep`: + +> + :lua require'fzf-lua'.live_grep({ cmd = "git grep --line-number --column --color=always" }) +< + `colorschemes` with non-default window size: + +> + :lua require'fzf-lua'.colorschemes({ winopts = { height=0.33, width=0.33 } }) +< +Use `setup()` If you wish for a setting to persist and not have to send it +using the call arguments, e.g: + +> + require('fzf-lua').setup{ + winopts = { + ... + } + } +< +Can also be called from a `.vim` file: + +> + lua << EOF + require('fzf-lua').setup{ + ... + } + EOF +< +**Below is a list of most (still, not all default settings), please also +consult the issues if there's something you need and you can't find as there +have been many obscure requests which have been fulfilled and are yet to be +documented. If you're still having issues and/or questions do not hesitate to +open an issue and I'll be more than happy to help.** > local actions = require "fzf-lua.actions" @@ -335,18 +371,27 @@ Consult the list below for available settings: -- 'none', 'single', 'double', 'thicc' or 'rounded' (default) border = { '╭', '─', '╮', '│', '╯', '─', '╰', '│' }, fullscreen = false, -- start fullscreen? - hl = { + -- highlights should optimally be set by the colorscheme using + -- FzfLuaXXX highlights. If your colorscheme doesn't set these + -- or you wish to override its defaults use these: + --[[ hl = { normal = 'Normal', -- window normal color (fg+bg) - border = 'Normal', -- border color (try 'FloatBorder') - -- Only valid with the builtin previewer: + border = 'FloatBorder', -- border color + help_normal = 'Normal', -- window normal + help_border = 'FloatBorder', -- window border + -- Only used with the builtin previewer: cursor = 'Cursor', -- cursor highlight (grep/LSP matches) cursorline = 'CursorLine', -- cursor line cursorlinenr = 'CursorLineNr', -- cursor line number search = 'IncSearch', -- search matches (ctags|help) - -- title = 'Normal', -- preview border title (file/buffer) - -- scrollbar_f = 'PmenuThumb', -- scrollbar "full" section highlight - -- scrollbar_e = 'PmenuSbar', -- scrollbar "empty" section highlight - }, + title = 'Normal', -- preview border title (file/buffer) + -- Only used with 'winopts.preview.scrollbar = 'float' + scrollfloat_e = 'PmenuSbar', -- scrollbar "empty" section highlight + scrollfloat_f = 'PmenuThumb', -- scrollbar "full" section highlight + -- Only used with 'winopts.preview.scrollbar = 'border' + scrollborder_e = 'FloatBorder', -- scrollbar "empty" section highlight + scrollborder_f = 'FloatBorder', -- scrollbar "full" section highlight + }, ]] preview = { -- default = 'bat', -- override the default previewer? -- default uses the 'builtin' previewer @@ -358,7 +403,7 @@ Consult the list below for available settings: horizontal = 'right:60%', -- right|left:size layout = 'flex', -- horizontal|vertical|flex flip_columns = 120, -- #cols to switch to horizontal on flex - -- Only valid with the builtin previewer: + -- Only used with the builtin previewer: title = true, -- preview border title (file/buf)? scrollbar = 'float', -- `false` or string:'float|border' -- float: in-window floating border @@ -860,14 +905,55 @@ Consult the list below for available settings: -- nbsp = '\xc2\xa0', } < -This can also be run from a `.vim` file using: + + +CUSTOMIZING HIGHLIGHTS *fzf-lua-customizing-highlights* + +FzfLua conviniently creates the below highlights: + +> + -- key is the highlight group name + -- value[1] is the setup/call arg option name + -- value[2] is the default link if value[1] is undefined + FzfLuaNormal = { 'winopts.hl.normal', "Normal" }, + FzfLuaBorder = { 'winopts.hl.border', "FloatBorder" }, + FzfLuaCursor = { 'winopts.hl.cursor', "Cursor" }, + FzfLuaCursorLine = { 'winopts.hl.cursorline', "CursorLine" }, + FzfLuaCursorLineNr = { 'winopts.hl.cursornr', "CursorLineNr" }, + FzfLuaSearch = { 'winopts.hl.search', "IncSearch" }, + FzfLuaTitle = { 'winopts.hl.title', "FzfLuaNormal" }, + FzfLuaScrollBorderEmpty = { 'winopts.hl.scrollborder_e', "FzfLuaBorder" }, + FzfLuaScrollBorderFull = { 'winopts.hl.scrollborder_f', "FzfLuaBorder" }, + FzfLuaScrollFloatEmpty = { 'winopts.hl.scrollfloat_e', "PmenuSbar" }, + FzfLuaScrollFloatFull = { 'winopts.hl.scrollfloat_f', "PmenuThumb" }, + FzfLuaHelpNormal = { 'winopts.hl.help_normal', "FzfLuaNormal" }, + FzfLuaHelpBorder = { 'winopts.hl.help_border', "FzfLuaBorder" }, +< +These can be easily customized either via the lua API: + +> + :lua vim.api.nvim_set_hl(0, "FzfLuaBorder", { link = "FloatBorder" }) +< +Or vimscript: + +> + :hi! link FzfLuaBorder FloatBorder +< +If you wish to further customize these highlights without having to modify +your preset colorscheme highlight links you can define the corresponding +`winopts.hl` option or even send it directly via a call argument: + +> + :lua require'fzf-lua'.files({ winopts={hl={normal="IncSearch"}} }) +< +Or via `setup`: > - lua << EOF require('fzf-lua').setup{ - -- ... + winopts = { + hl = { border = "FloatBorder", } + } } - EOF < ------------------------------------------------------------------------------ diff --git a/lua/fzf-lua/config.lua b/lua/fzf-lua/config.lua index 1e02907..5c26961 100644 --- a/lua/fzf-lua/config.lua +++ b/lua/fzf-lua/config.lua @@ -35,18 +35,22 @@ M.globals = { col = 0.55, border = 'rounded', fullscreen = false, - hl = { + --[[ hl = { normal = 'Normal', - border = 'Normal', + border = 'FloatBorder', + help_normal = 'Normal', + help_border = 'FloatBorder', -- builtin preview only cursor = 'Cursor', cursorline = 'CursorLine', cursorlinenr = 'CursorLineNr', search = 'IncSearch', - -- title = 'Normal', - -- scrollbar_f = 'PmenuThumb', - -- scrollbar_e = 'PmenuSbar', - }, + title = 'Normal', + scrollfloat_e = 'PmenuSbar', + scrollfloat_f = 'PmenuThumb', + scrollborder_e = 'FloatBorder', + scrollborder_f = 'FloatBorder', + }, ]] preview = { default = "builtin", border = 'border', @@ -732,6 +736,10 @@ function M.normalize_opts(opts, defaults) opts[k] or {}, utils.tbl_deep_clone(M.globals[k]) or {}) end + -- overwrite highlights if supplied by the caller/provider setup + opts.winopts.__hl = vim.tbl_deep_extend("force", + opts.winopts.__hl, opts.winopts.hl or {}) + -- these options are copied from globals unless specifically set -- also check if we need to override 'opts.prompt' from cli args -- if we don't override 'opts.prompt' 'FzfWin.save_query' will @@ -929,6 +937,38 @@ M.bytecode = function(s, datatype) end end +-- returns nil if not found +M.get_global = function(s) + local keys = utils.strsplit(s, '.') + local iter = M.globals + for i=1,#keys do + iter = iter[keys[i]] + if not iter then break end + if i == #keys then + return iter + end + end +end + +-- builds the tree if needed +M.set_global = function(s, value) + local keys = utils.strsplit(s, '.') + local iter = M.globals + for i=1,#keys do + if i == #keys then + iter[keys[i]] = value + else + -- build the new leaf on parent + -- to preserve original table ref + local parent = iter + if not parent[keys[i]] then + parent[keys[i]] = {} + end + iter = parent[keys[i]] + end + end +end + M.set_action_helpstr = function(fn, helpstr) assert(type(fn) == 'function') M._action_to_helpstr[fn] = helpstr diff --git a/lua/fzf-lua/init.lua b/lua/fzf-lua/init.lua index 418af28..4e15cb0 100644 --- a/lua/fzf-lua/init.lua +++ b/lua/fzf-lua/init.lua @@ -32,6 +32,47 @@ end local M = {} +function M.setup_highlights() + + local highlights = { + FzfLuaNormal = { 'winopts.hl.normal', "Normal" }, + FzfLuaBorder = { 'winopts.hl.border', "FloatBorder" }, + FzfLuaCursor = { 'winopts.hl.cursor', "Cursor" }, + FzfLuaCursorLine = { 'winopts.hl.cursorline', "CursorLine" }, + FzfLuaCursorLineNr = { 'winopts.hl.cursornr', "CursorLineNr" }, + FzfLuaSearch = { 'winopts.hl.search', "IncSearch" }, + FzfLuaTitle = { 'winopts.hl.title', "FzfLuaNormal" }, + FzfLuaScrollBorderEmpty = { 'winopts.hl.scrollborder_e', "FzfLuaBorder" }, + FzfLuaScrollBorderFull = { 'winopts.hl.scrollborder_f', "FzfLuaBorder" }, + FzfLuaScrollFloatEmpty = { 'winopts.hl.scrollfloat_e', "PmenuSbar" }, + FzfLuaScrollFloatFull = { 'winopts.hl.scrollfloat_f', "PmenuThumb" }, + FzfLuaHelpNormal = { 'winopts.hl.help_normal', "FzfLuaNormal" }, + FzfLuaHelpBorder = { 'winopts.hl.help_border', "FzfLuaBorder" }, + } + for hl_name, v in pairs(highlights) do + -- define a new linked highlight and then override the + -- default config with the new FzfLuaXXX hl this leaves + -- the option for direct call option overrides (via winopts) + local hl_link = config.get_global(v[1]) + if not hl_link or vim.fn.hlID(hl_link) == 0 then + -- revert to default if hl option or link doesn't exist + hl_link = v[2] + end + if vim.fn.has('nvim-0.7') == 1 then + vim.api.nvim_set_hl(0, hl_name, { default = true, link = hl_link }) + else + vim.cmd(string.format("hi! link %s %s", hl_name, hl_link)) + end + -- save new highlight groups under 'winopts.__hl' + config.set_global(v[1]:gsub("%.hl%.", ".__hl."), hl_name) + end +end + +-- Setup highlights at least once on load in +-- case the user decides not to call `setup()` +M.setup_highlights() + + function M.setup(opts) local globals = vim.tbl_deep_extend("keep", opts, config.globals) -- backward compatibility before winopts was it's own struct @@ -73,6 +114,8 @@ function M.setup(opts) -- this doesn't happen automatically config.globals = globals globals = nil + -- setup highlights + M.setup_highlights() end M.resume = require'fzf-lua.core'.fzf_resume diff --git a/lua/fzf-lua/previewer/builtin.lua b/lua/fzf-lua/previewer/builtin.lua index e716587..fa158de 100644 --- a/lua/fzf-lua/previewer/builtin.lua +++ b/lua/fzf-lua/previewer/builtin.lua @@ -230,7 +230,7 @@ function Previewer.base:scroll(direction) if not api.nvim_win_is_valid(preview_winid) then return end if direction == 0 then - vim.api.nvim_win_call(preview_winid, function() + pcall(vim.api.nvim_win_call, preview_winid, function() -- for some reason 'nvim_win_set_cursor' -- only moves forward, so set to (1,0) first api.nvim_win_set_cursor(0, {1, 0}) @@ -244,7 +244,7 @@ function Previewer.base:scroll(direction) -- local input = direction > 0 and [[]] or [[]] -- ^D = 0x04, ^U = 0x15 ('g8' on char to display) local input = ('%c'):format(utils._if(direction>0, 0x04, 0x15)) - vim.api.nvim_win_call(preview_winid, function() + pcall(vim.api.nvim_win_call, preview_winid, function() vim.cmd([[norm! ]] .. input) utils.zz() end) @@ -476,7 +476,7 @@ function Previewer.buffer_or_file:populate_preview_buf(entry_str) elseif entry.uri then -- LSP 'jdt://' entries, see issue #195 -- https://github.com/ibhagwan/fzf-lua/issues/195 - vim.api.nvim_win_call(self.win.preview_winid, function() + pcall(vim.api.nvim_win_call, self.win.preview_winid, function() vim.lsp.util.jump_to_location(entry, "utf-16") self.preview_bufnr = vim.api.nvim_get_current_buf() end) @@ -599,7 +599,7 @@ function Previewer.buffer_or_file:do_syntax(entry) end function Previewer.buffer_or_file:set_cursor_hl(entry) - vim.api.nvim_win_call(self.win.preview_winid, function() + pcall(vim.api.nvim_win_call, self.win.preview_winid, function() local lnum, col = tonumber(entry.line), tonumber(entry.col) local pattern = entry.pattern or entry.text @@ -620,8 +620,8 @@ function Previewer.buffer_or_file:set_cursor_hl(entry) fn.clearmatches() - if self.win.winopts.hl.cursor and not (lnum<=1 and col<=1) then - fn.matchaddpos(self.win.winopts.hl.cursor, {{lnum, math.max(1, col)}}, 11) + if self.win.winopts.__hl.cursor and not (lnum<=1 and col<=1) then + fn.matchaddpos(self.win.winopts.__hl.cursor, {{lnum, math.max(1, col)}}, 11) end end) end @@ -807,8 +807,8 @@ function Previewer.help_file:set_cursor_hl(entry) api.nvim_win_set_cursor(0, {1, 0}) fn.clearmatches() fn.search(entry.hregex, "W") - if self.win.winopts.hl.search then - fn.matchadd(self.win.winopts.hl.search, entry.hregex) + if self.win.winopts.__hl.search then + fn.matchadd(self.win.winopts.__hl.search, entry.hregex) end self.orig_pos = api.nvim_win_get_cursor(0) utils.zz() @@ -940,8 +940,8 @@ function Previewer.tags:set_cursor_hl(entry) api.nvim_win_set_cursor(0, {1, 0}) fn.clearmatches() fn.search(entry.ctag, "W") - if self.win.winopts.hl.search then - fn.matchadd(self.win.winopts.hl.search, entry.ctag) + if self.win.winopts.__hl.search then + fn.matchadd(self.win.winopts.__hl.search, entry.ctag) end self.orig_pos = api.nvim_win_get_cursor(0) utils.zz() @@ -1007,8 +1007,8 @@ function Previewer.highlights:populate_preview_buf(entry_str) api.nvim_win_set_cursor(0, {1, 0}) fn.clearmatches() fn.search(selected_hl, "W") - if self.win.winopts.hl.search then - fn.matchadd(self.win.winopts.hl.search, selected_hl) + if self.win.winopts.__hl.search then + fn.matchadd(self.win.winopts.__hl.search, selected_hl) end self.orig_pos = api.nvim_win_get_cursor(0) utils.zz() diff --git a/lua/fzf-lua/win.lua b/lua/fzf-lua/win.lua index 0fdfae9..73efd17 100644 --- a/lua/fzf-lua/win.lua +++ b/lua/fzf-lua/win.lua @@ -294,18 +294,18 @@ end function FzfWin:reset_win_highlights(win, is_border) local hl = ("Normal:%s,FloatBorder:%s"):format( - self.winopts.hl.normal, self.winopts.hl.border) + self.winopts.__hl.normal, self.winopts.__hl.border) if self._previewer then for _, h in ipairs({ 'CursorLine', 'CursorLineNr' }) do - if self.winopts.hl[h:lower()] then - hl = hl .. (",%s:%s"):format(h, self.winopts.hl[h:lower()]) + if self.winopts.__hl[h:lower()] then + hl = hl .. (",%s:%s"):format(h, self.winopts.__hl[h:lower()]) end end end if is_border then -- our border is manuually drawn so we need -- to replace Normal with the border color - hl = ("Normal:%s"):format(self.winopts.hl.border) + hl = ("Normal:%s"):format(self.winopts.__hl.border) end vim.api.nvim_win_set_option(win, 'winhighlight', hl) end @@ -865,9 +865,9 @@ function FzfWin:clear_border_highlights() end function FzfWin:set_title_hl() - if self.winopts.hl.title and self._title_len and self._title_len>0 then - vim.api.nvim_win_call(self.border_winid, function() - fn.matchaddpos(self.winopts.hl.title, {{1, 9, self._title_len+1}}, 11) + if self.winopts.__hl.title and self._title_len and self._title_len>0 then + pcall(vim.api.nvim_win_call, self.border_winid, function() + fn.matchaddpos(self.winopts.__hl.title, {{1, 9, self._title_len+1}}, 11) end) end end @@ -920,16 +920,16 @@ function FzfWin:update_scrollbar_border(o) end api.nvim_buf_set_lines(self.border_buf, 1, -2, 0, lines) -- border highlights - if self.winopts.hl.scrollbar_f or self.winopts.hl.scrollbar_e then - vim.api.nvim_win_call(self.border_winid, function() - if self.winopts.hl.scrollbar_f then + if self.winopts.__hl.scrollborder_f or self.winopts.__hl.scrollborder_e then + pcall(vim.api.nvim_win_call, self.border_winid, function() + if self.winopts.hl.scrollborder_f then for i=1,#full do - fn.matchaddpos(self.winopts.hl.scrollbar_f, full[i], 11) + fn.matchaddpos(self.winopts.__hl.scrollborder_f, full[i], 11) end end - if self.winopts.hl.scrollbar_e then + if self.winopts.__hl.scrollborder_e then for i=1,#empty do - fn.matchaddpos(self.winopts.hl.scrollbar_e, empty[i], 11) + fn.matchaddpos(self.winopts.__hl.scrollborder_e, empty[i], 11) end end end) @@ -979,7 +979,7 @@ function FzfWin:update_scrollbar_float(o) style1.noautocmd = true self._sbuf1 = ensure_tmp_buf(self._sbuf1) self._swin1 = vim.api.nvim_open_win(self._sbuf1, false, style1) - local hl = self.winopts.hl.scrollbar_e or 'PmenuSbar' + local hl = self.winopts.__hl.scrollfloat_e or 'PmenuSbar' vim.api.nvim_win_set_option(self._swin1, 'winhighlight', ('Normal:%s,NormalNC:%s,NormalFloat:%s'):format(hl, hl, hl)) end @@ -993,7 +993,7 @@ function FzfWin:update_scrollbar_float(o) style2.noautocmd = true self._sbuf2 = ensure_tmp_buf(self._sbuf2) self._swin2 = vim.api.nvim_open_win(self._sbuf2, false, style2) - local hl = self.winopts.hl.scrollbar_f or 'PmenuThumb' + local hl = self.winopts.__hl.scrollfloat_f or 'PmenuThumb' vim.api.nvim_win_set_option(self._swin2, 'winhighlight', ('Normal:%s,NormalNC:%s,NormalFloat:%s'):format(hl, hl, hl)) end @@ -1154,8 +1154,8 @@ function FzfWin.toggle_help() opts.mode_width = opts.mode_width or 10 opts.name_width = opts.name_width or 28 opts.keybind_width = opts.keybind_width or 14 - opts.normal_hl = opts.normal_hl or self.winopts.hl.normal - opts.border_hl = opts.border_hl or self.winopts.hl.border + opts.normal_hl = opts.normal_hl or self.winopts.__hl.help_normal + opts.border_hl = opts.border_hl or self.winopts.__hl.help_border opts.winblend = opts.winblend or 0 opts.column_padding = opts.column_padding or " " opts.column_width = opts.keybind_width + opts.name_width + #opts.column_padding + 2 @@ -1261,8 +1261,8 @@ function FzfWin.toggle_help() vim.api.nvim_buf_set_option(self.km_bufnr, "bufhidden", "wipe") self.km_winid = vim.api.nvim_open_win(self.km_bufnr, false, winopts) vim.api.nvim_buf_set_name(self.km_bufnr, "_FzfLuaHelp") - vim.api.nvim_win_set_option(self.km_winid, "winhl", "Normal:" .. opts.normal_hl) - vim.api.nvim_win_set_option(self.km_winid, "winhl", "FloatBorder:" .. opts.border_hl) + vim.api.nvim_win_set_option(self.km_winid, "winhl", + string.format("Normal:%s,FloatBorder:%s", opts.normal_hl, opts.border_hl)) vim.api.nvim_win_set_option(self.km_winid, "winblend", opts.winblend) vim.api.nvim_win_set_option(self.km_winid, "foldenable", false) vim.api.nvim_win_set_option(self.km_winid, "wrap", false)