aboutsummaryrefslogtreecommitdiff
path: root/lua/cmake-explorer/telescope/make_entry.lua
blob: cc919bd7a0d159ad63b04815f0b489c2cbf15c51 (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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
local make_entry = require("telescope.make_entry")
local entry_display = require("telescope.pickers.entry_display")
local config = require("cmake-explorer.config")

local M = {}

M.gen_from_configure = function(opts)
  local project = require("cmake-explorer").project
  local displayer = entry_display.create({
    separator = " ",
    items = {
      { width = project.display.short_len + 5 },
      { remaining = true },
    },
  })
  local make_display = function(entry)
    vim.print(entry)
    return displayer({
      { entry.value.display.short, "TelescopeResultsIdentifier" },
      { entry.value.display.long,  "TelescopeResultsComment" },
    })
  end
  return function(entry)
    return make_entry.set_default_entry_mt({
      value = entry,
      ordinal = table.concat(entry.short, config.variants_display.short_sep),
      display = make_display,
    }, opts)
  end
end

M.gen_from_build = function(opts)
  local project = require("cmake-explorer").project
  local displayer = entry_display.create({
    separator = " ",
    items = {
      { width = project.display.short_len + 5 },
      { remaining = true },
    },
  })
  local make_display = function(entry)
    vim.print(entry)
    return displayer({
      { entry.value.display.short, "TelescopeResultsIdentifier" },
      { entry.value.display.long,  "TelescopeResultsComment" },
    })
  end
  return function(entry)
    return make_entry.set_default_entry_mt({
      value = entry,
      ordinal = table.concat(entry.short, config.variants_display.short_sep),
      display = make_display,
    }, opts)
  end
end

return M