diff --git a/lua/fzf-lua/config.lua b/lua/fzf-lua/config.lua index dc6ea1da..ea89a7ba 100644 --- a/lua/fzf-lua/config.lua +++ b/lua/fzf-lua/config.lua @@ -209,7 +209,7 @@ M.globals.grep = { file_icons = true and M._has_devicons, color_icons = true, git_icons = true, - grep_opts = "--line-number --recursive --color=auto --perl-regexp", + grep_opts = "--binary-files=without-match --line-number --recursive --color=auto --perl-regexp", rg_opts = "--column --line-number --no-heading --color=always --smart-case", actions = M.globals.files.actions, } diff --git a/lua/fzf-lua/previewer/builtin.lua b/lua/fzf-lua/previewer/builtin.lua index 998a7999..4aaf5c82 100644 --- a/lua/fzf-lua/previewer/builtin.lua +++ b/lua/fzf-lua/previewer/builtin.lua @@ -143,7 +143,25 @@ function Previewer.base:display_entry(entry_str) -- store the new preview buffer self.preview_bufnr = self:clear_preview_buf() - -- specialized previewer populate function + local populate_preview_buf = function(entry_str) + if not self.win or not self.win:validate_preview() then return end + + -- specialized previewer populate function + self:populate_preview_buf(entry_str) + + -- is the preview a terminal buffer (alternative way) + --[[ local is_terminal = + vim.fn.getwininfo(self.win.preview_winid)[1].terminal == 1 ]] + + -- set preview window options + if not utils.is_term_buffer(self.preview_bufnr) then + self:set_winopts(self.win.preview_winid) + end + + -- reset the preview window highlights + self.win:reset_win_highlights(self.win.preview_winid) + end + if not self._entry_count then self._entry_count=1 else self._entry_count = self._entry_count+1 end local entry_count = self._entry_count @@ -151,24 +169,13 @@ function Previewer.base:display_entry(entry_str) vim.defer_fn(function() -- only display if entry hasn't changed if self._entry_count == entry_count then - self:populate_preview_buf(entry_str) + populate_preview_buf(entry_str) end end, self.delay) else - self:populate_preview_buf(entry_str) - end - - -- is the preview a terminal buffer (alternative way) - --[[ local is_terminal = - vim.fn.getwininfo(self.win.preview_winid)[1].terminal == 1 ]] - - -- set preview window options - if not utils.is_term_buffer(self.preview_bufnr) then - self:set_winopts(self.win.preview_winid) + populate_preview_buf(entry_str) end - -- reset the preview window highlights - self.win:reset_win_highlights(self.win.preview_winid) end function Previewer.base:action(_)