aboutsummaryrefslogtreecommitdiff
path: root/lua/cmake-explorer/telescope/previewers.lua
blob: 39fea4a3c4bc456ee83024a49642752cf469a1ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
local previewers = require("telescope.previewers")
local config = require("cmake-explorer.config")

local M = {}

M.configure_previewer = function(opts)
  return previewers.new_buffer_previewer({
    title = "Configure Details",

    define_preview = function(self, entry)
      if self.state.bufname then
        return
      end
      local entries = {
        "Command:",
        config.cmake_path .. " " .. table.concat(entry.value.configure_args, " "),
      }
      vim.api.nvim_buf_set_lines(self.state.bufnr, 0, -1, false, entries)
    end,
  })
end

M.build_previewer = function(opts)
  return previewers.new_buffer_previewer({
    title = "Build Details",

    define_preview = function(self, entry)
      if self.state.bufname then
        return
      end
      local entries = {
        "Command:",
        config.cmake_path .. " " .. table.concat(entry.value.build_args, " "),
      }
      vim.api.nvim_buf_set_lines(self.state.bufnr, 0, -1, false, entries)
    end,
  })
end

return M