aboutsummaryrefslogtreecommitdiff
path: root/neovim/.config/nvim/lua/plugins/telescope.lua
diff options
context:
space:
mode:
Diffstat (limited to 'neovim/.config/nvim/lua/plugins/telescope.lua')
-rw-r--r--neovim/.config/nvim/lua/plugins/telescope.lua64
1 files changed, 64 insertions, 0 deletions
diff --git a/neovim/.config/nvim/lua/plugins/telescope.lua b/neovim/.config/nvim/lua/plugins/telescope.lua
new file mode 100644
index 0000000..01dcb2f
--- /dev/null
+++ b/neovim/.config/nvim/lua/plugins/telescope.lua
@@ -0,0 +1,64 @@
+local actions = require("telescope.actions")
+local finders = require("telescope.builtin")
+
+local action_mt = require "telescope.actions.mt"
+local action_state = require "telescope.actions.state"
+-- global for later inspection
+custom_actions = action_mt.transform_mod({
+ print_entry = function()
+ print(vim.inspect(action_state.get_selected_entry()))
+ end,
+})
+
+require("telescope").setup({
+ defaults = {
+ prompt_prefix = " ",
+ initial_mode = "insert",
+ sorting_strategy = "ascending",
+ layout_config = {
+ prompt_position = "top",
+ },
+ mappings = {
+ i = {
+ ["<C-M>"] = custom_actions['print_entry'],
+ ["<ESC>"] = actions.close,
+ ["<C-j>"] = actions.move_selection_next,
+ ["<C-k>"] = actions.move_selection_previous,
+ ["<TAB>"] = actions.toggle_selection + actions.move_selection_next,
+ ["<C-s>"] = actions.send_selected_to_qflist,
+ ["<C-q>"] = actions.send_to_qflist,
+ },
+ },
+ },
+ extensions = {
+ fzf = {
+ fuzzy = true,
+ override_generic_sorter = true,
+ override_file_sorter = true,
+ case_mode = "smart_case",
+ },
+ },
+})
+
+local Telescope = setmetatable({}, {
+ __index = function(_, k)
+ if vim.bo.filetype == "NvimTree" then
+ vim.cmd.wincmd("l")
+ end
+ return finders[k]
+ end,
+})
+
+vim.keymap.set("n", "<C-space>", function()
+ local ok = pcall(Telescope.git_files, { show_untracked = true })
+ if not ok then
+ Telescope.find_files()
+ end
+end)
+
+-- Get :help at the speed of light
+vim.keymap.set("n", "<leader>H", Telescope.help_tags)
+-- Search for string
+vim.keymap.set("n", "<leaders>s", Telescope.live_grep)
+-- Fuzzy find changed files in git
+vim.keymap.set("n", "<leader>c", Telescope.git_status)