1
Fork 0
satellite/dotfiles/neovim/lua/my/plugins/telescope.lua

62 lines
1.6 KiB
Lua
Raw Normal View History

local mapSilent = require("my.keymaps").mapSilent
local M = {}
local bindings = {
2022-02-22 21:52:01 +01:00
builtin = {
-- Open files with control + P
find_files = "<c-P>",
2022-02-22 21:52:01 +01:00
-- Search through files with control + F
live_grep = "<c-F>",
2022-02-22 21:52:01 +01:00
-- See diagnostics with space + d
lsp_document_diagnostics = "<space>d",
lsp_workspace_diagnostics = "<space>wd",
2022-02-22 21:52:01 +01:00
-- Open a list with all the pickers
builtin = "<space>t",
2022-02-22 21:52:01 +01:00
-- List function, var names etc
treesitter = "<space>s",
2022-02-22 21:52:01 +01:00
-- Git stuff
git_commits = "<space>gj",
git_branches = "<space>gk"
},
["extensions.file_browser.file_browser"] = "<space>p"
}
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
if (type(keybinds) == "table") then
-- This means we found a table of keybinds, so we go deeper
setupKeybinds(keybinds, path .. "." .. name)
else
-- Maps the keybind to the action
mapSilent('n', keybinds, "<cmd>lua require('telescope" .. path .. "')." .. name .. "()<CR>")
end
end
2022-02-22 21:52:01 +01:00
end
2022-02-22 21:52:01 +01:00
function M.setup()
setupKeybinds(bindings)
local settings = {
defaults = {mappings = {i = {["<C-h>"] = "which_key"}}},
extensions = {
file_browser = {
mappings = {
-- Comment so this does not get collapsed
}
}
}
}
require("telescope").setup(settings)
require("telescope").load_extension "file_browser"
end
return M