2022-04-04 01:10:26 +02:00
|
|
|
local arpeggio = require("my.plugins.arpeggio")
|
2022-02-07 12:12:28 +01:00
|
|
|
|
|
|
|
local M = {}
|
|
|
|
|
2022-09-25 22:03:11 +02:00
|
|
|
local function find_files_by_extension(extension)
|
|
|
|
return "find_files find_command=rg,--files,--glob=**/*." .. extension
|
|
|
|
end
|
2022-02-07 12:12:28 +01:00
|
|
|
|
2022-10-09 03:28:51 +02:00
|
|
|
local function with_theme(base, theme)
|
|
|
|
return base .. " theme=" .. theme
|
|
|
|
end
|
|
|
|
|
|
|
|
local defaultTheme = "ivy"
|
|
|
|
|
2022-09-25 22:03:11 +02:00
|
|
|
local keybinds = {
|
2022-10-09 03:28:51 +02:00
|
|
|
{ "<C-P>", "find_files", "Find files" },
|
|
|
|
{ "<Leader>ft", find_files_by_extension("tex"), "Find tex files" },
|
|
|
|
{ "<Leader>fl", find_files_by_extension("lua"), "Find lua files" },
|
2022-10-14 13:44:47 +02:00
|
|
|
{ "<Leader>fp", find_files_by_extension("purs"), "Find purescript files" },
|
2022-10-09 03:28:51 +02:00
|
|
|
{ "<Leader>d", "diagnostics", "Diagnostics" },
|
|
|
|
{ "<C-F>", "live_grep", "Search in project" },
|
|
|
|
{ "<Leader>t", "builtin", "Show builtin pickers" },
|
2022-09-25 22:03:11 +02:00
|
|
|
}
|
2022-02-07 12:12:28 +01:00
|
|
|
|
2022-09-25 22:03:11 +02:00
|
|
|
local chords = {
|
|
|
|
{ "jp", "file_browser" }
|
2022-02-07 12:12:28 +01:00
|
|
|
}
|
|
|
|
|
2022-09-25 22:03:11 +02:00
|
|
|
local function mkAction(action)
|
2022-10-09 03:28:51 +02:00
|
|
|
if not string.find(action, "theme=") then
|
|
|
|
action = with_theme(action, defaultTheme)
|
|
|
|
end
|
|
|
|
|
2022-09-25 22:03:11 +02:00
|
|
|
return ":Telescope " .. action .. "<cr>"
|
|
|
|
end
|
2022-04-04 01:10:26 +02:00
|
|
|
|
2022-09-25 22:03:11 +02:00
|
|
|
local function setupKeybinds()
|
|
|
|
for _, mapping in pairs(keybinds) do
|
2022-10-09 03:28:51 +02:00
|
|
|
vim.keymap.set("n", mapping[1], mkAction(mapping[2]), { desc = mapping[3] })
|
2022-09-25 22:03:11 +02:00
|
|
|
end
|
2022-08-08 16:25:54 +02:00
|
|
|
|
2022-09-25 22:03:11 +02:00
|
|
|
for _, mapping in pairs(chords) do
|
|
|
|
arpeggio.chord("n", mapping[1], mkAction(mapping[2]))
|
2022-08-08 16:25:54 +02:00
|
|
|
end
|
2022-02-22 21:52:01 +01:00
|
|
|
end
|
2022-02-07 12:12:28 +01:00
|
|
|
|
2022-02-22 21:52:01 +01:00
|
|
|
function M.setup()
|
2022-09-25 22:03:11 +02:00
|
|
|
setupKeybinds()
|
2022-02-22 21:52:01 +01:00
|
|
|
|
2022-08-08 16:25:54 +02:00
|
|
|
local settings = {
|
|
|
|
defaults = { mappings = { i = { ["<C-h>"] = "which_key" } } },
|
|
|
|
pickers = { find_files = { hidden = true } },
|
|
|
|
extensions = {
|
|
|
|
file_browser = {
|
2022-09-25 22:03:11 +02:00
|
|
|
path = "%:p:h"
|
2022-08-08 16:25:54 +02:00
|
|
|
}
|
2022-02-22 21:52:01 +01:00
|
|
|
}
|
2022-08-08 16:25:54 +02:00
|
|
|
}
|
2022-02-22 21:52:01 +01:00
|
|
|
|
2022-08-08 16:25:54 +02:00
|
|
|
require("telescope").setup(settings)
|
|
|
|
require("telescope").load_extension "file_browser"
|
2022-02-07 12:12:28 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
return M
|