summaryrefslogtreecommitdiffstatshomepage
path: root/nvim/.config/nvim/lua/tobyvin/plugins/dressing.lua
blob: d0748c888f5424c2f00b02d51bd49a797474a6ef (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
58
59
60
61
62
63
64
65
local M = {
	"stevearc/dressing.nvim",
	dependencies = {
		"nvim-telescope/telescope.nvim",
	},
}

function M.config()
	local dressing = require("dressing")
	local themes = require("telescope.themes")

	local format_item_override = {
		["rust-tools/debuggables"] = function(item)
			item = item:gsub(" %-%-no%-run", "")
			item = item:gsub(" %-%-package", " -p")
			item = item:gsub(" %-%-all%-features", "")
			item = item:gsub(" %-%-all%-targets", "")
			item = item:gsub(" %-%-exact", "")
			item = item:gsub(" %-%-nocapture", "")
			return item
		end,
	}

	local config_overrides = {
		select = {
			["Ring history"] = {
				telescope = themes.get_dropdown({ preview = true }),
			},
		},
		input = {
			cmd = {
				relative = "win",
				insert_only = false,
			},
		},
	}

	dressing.setup({
		input = {
			get_config = function(opts)
				local overrides = config_overrides.input

				if overrides[opts.kind] ~= nil then
					return overrides[opts.kind]
				elseif overrides[opts.prompt] ~= nil then
					return overrides[opts.prompt]
				end
			end,
		},
		select = {
			get_config = function(opts)
				local overrides = config_overrides.select

				if overrides[opts.kind] ~= nil then
					return overrides[opts.kind]
				elseif overrides[opts.prompt] ~= nil then
					return overrides[opts.prompt]
				end
			end,
			format_item_override = format_item_override,
		},
	})
end

return M