Skip to content

disable preview for certain file name in require("fzf-lua").files() #1899

Closed Answered by phanen
smartding asked this question in Q&A
Discussion options

You must be logged in to vote
require('fzf-lua').files {
  previewer = {
    _ctor = function()
      local base = require 'fzf-lua.previewer.builtin'.buffer_or_file
      local previewer = base:extend()
      function previewer:populate_preview_buf(entry_str)
        if entry_str:match('%.env') then
          local entry = self:parse_entry(entry_str)
          local tmpbuf = self:get_tmp_buffer()
          vim.bo[tmpbuf].filetype = 'plaintext'
          pcall(
            vim.api.nvim_buf_set_lines,
            tmpbuf,
            0,
            -1,
            false,
            {
              'This file is sensitive!!!!!!!!!!!!',
              'Do not preview it!!!!!!!!!!!!!!!',
            }
          )
          --

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by smartding
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants