2022-02-07 12:12:28 +01:00
|
|
|
local mapSilent = require("my.keymaps").mapSilent
|
2022-04-04 01:10:26 +02:00
|
|
|
local arpeggio = require("my.plugins.arpeggio")
|
2022-02-07 12:12:28 +01:00
|
|
|
|
|
|
|
local M = {}
|
|
|
|
|
|
|
|
local bindings = {
|
2022-02-22 21:52:01 +01:00
|
|
|
builtin = {
|
|
|
|
-- Open files with control + P
|
|
|
|
find_files = "<c-P>",
|
2022-02-07 12:12:28 +01:00
|
|
|
|
2022-02-22 21:52:01 +01:00
|
|
|
-- Search through files with control + F
|
|
|
|
live_grep = "<c-F>",
|
2022-02-07 12:12:28 +01:00
|
|
|
|
2022-02-22 21:52:01 +01:00
|
|
|
-- See diagnostics with space + d
|
2022-05-15 20:56:19 +02:00
|
|
|
diagnostics = "<Leader>d",
|
2022-02-07 12:12:28 +01:00
|
|
|
|
2022-02-22 21:52:01 +01:00
|
|
|
-- Open a list with all the pickers
|
2022-04-04 09:01:13 +02:00
|
|
|
builtin = "<Leader>t",
|
2022-02-07 12:12:28 +01:00
|
|
|
|
2022-02-22 21:52:01 +01:00
|
|
|
-- List function, var names etc
|
2022-04-04 09:01:13 +02:00
|
|
|
treesitter = "<Leader>s",
|
2022-02-07 12:12:28 +01:00
|
|
|
|
2022-02-22 21:52:01 +01:00
|
|
|
-- Git stuff
|
2022-04-04 09:01:13 +02:00
|
|
|
git_commits = "<Leader>gj",
|
|
|
|
git_branches = "<Leader>gk"
|
2022-02-22 21:52:01 +01:00
|
|
|
},
|
2022-04-05 20:17:08 +02:00
|
|
|
["extensions.file_browser.file_browser"] = {chord = 1, key = "jp"},
|
2022-04-04 01:10:26 +02:00
|
|
|
extensions = {
|
2022-04-04 10:55:57 +02:00
|
|
|
unicode = {
|
|
|
|
picker = {mode = "i", kind = "dropdown", key = "ui", chord = 1}
|
|
|
|
}
|
2022-04-04 01:10:26 +02:00
|
|
|
}
|
2022-02-07 12:12:28 +01:00
|
|
|
}
|
|
|
|
|
2022-02-22 21:52:01 +01:00
|
|
|
local function setupKeybinds(obj, path)
|
|
|
|
if path == nil then path = "" end
|
|
|
|
for name, keybinds in pairs(obj) do
|
2022-04-04 01:10:26 +02:00
|
|
|
if (type(keybinds) == "table") and keybinds.key == nil then
|
2022-02-22 21:52:01 +01:00
|
|
|
-- This means we found a table of keybinds, so we go deeper
|
|
|
|
setupKeybinds(keybinds, path .. "." .. name)
|
|
|
|
else
|
2022-04-04 01:10:26 +02:00
|
|
|
local config = keybinds
|
|
|
|
local pickerArgument = ""
|
|
|
|
local key = config
|
|
|
|
local mode = "n"
|
|
|
|
local bind = mapSilent
|
|
|
|
|
|
|
|
if type(config) == "table" then
|
|
|
|
key = config.key
|
|
|
|
if config.mode ~= nil then mode = config.mode end
|
|
|
|
if config.kind ~= nil then
|
|
|
|
pickerArgument = "require('telescope.themes').get_" ..
|
|
|
|
config.kind .. "({})"
|
|
|
|
end
|
|
|
|
if config.chord then
|
|
|
|
-- Useful for insert mode bindings
|
|
|
|
bind = arpeggio.chordSilent
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-02-22 21:52:01 +01:00
|
|
|
-- Maps the keybind to the action
|
2022-04-04 01:10:26 +02:00
|
|
|
bind(mode, key,
|
|
|
|
"<cmd>lua require('telescope" .. path .. "')." .. name .. "(" ..
|
|
|
|
pickerArgument .. ")<CR>")
|
2022-02-22 21:52:01 +01:00
|
|
|
end
|
2022-02-07 12:12:28 +01: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()
|
|
|
|
setupKeybinds(bindings)
|
|
|
|
|
|
|
|
local settings = {
|
|
|
|
defaults = {mappings = {i = {["<C-h>"] = "which_key"}}},
|
2022-04-04 01:10:26 +02:00
|
|
|
pickers = {find_files = {hidden = true}},
|
2022-02-22 21:52:01 +01:00
|
|
|
extensions = {
|
|
|
|
file_browser = {
|
|
|
|
mappings = {
|
|
|
|
-- Comment so this does not get collapsed
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
require("telescope").setup(settings)
|
|
|
|
require("telescope").load_extension "file_browser"
|
2022-02-07 12:12:28 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
return M
|