From 04392ea377dfd8b878d6e61d9695f7794c397b29 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Wed, 17 Nov 2021 21:50:32 +0000 Subject: [PATCH] feat: experimenting with custom Telescope commands --- nvim/.config/nvim/after/plugin/telescope.lua | 6 ++-- .../nvim/lua/opdavies/telescope/mappings.lua | 32 +++++++++++++++++++ 2 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 nvim/.config/nvim/lua/opdavies/telescope/mappings.lua diff --git a/nvim/.config/nvim/after/plugin/telescope.lua b/nvim/.config/nvim/after/plugin/telescope.lua index cb05f56..6f5f447 100644 --- a/nvim/.config/nvim/after/plugin/telescope.lua +++ b/nvim/.config/nvim/after/plugin/telescope.lua @@ -38,14 +38,16 @@ local options = { } -- Builtin -map('n', 'df', 'lua require("telescope.builtin").find_files{ cwd="~/dotfiles", hidden=true }', options) map('n', 'fb', 'lua require("telescope.builtin").buffers()', options) map('n', 'fc', 'lua require("telescope.builtin").lsp_code_actions()', options) map('n', 'fd', 'lua require("telescope.builtin").lsp_workspace_diagnostics()', options) map('n', 'fe', 'lua require("telescope.builtin").file_browser{ cwd = vim.fn.expand("%:p:h") }', options) -map('n', 'ff', 'lua require("telescope.builtin").find_files{ hidden = true }', options) map('n', 'fg', 'lua require("telescope.builtin").git_files{}', options) map('n', 'fh', 'lua require("telescope.builtin").help_tags()', options) map('n', 'fl', 'lua require("telescope.builtin").live_grep()', options) map('n', 'fr', 'lua require("telescope.builtin").registers()', options) map('n', 'fr', 'lua require("telescope.builtin").registers()', options) + +-- Custom +map("n", "en", 'lua require("opdavies.telescope.mappings").edit_neovim()', options) +map("n", "ff", 'lua require("opdavies.telescope.mappings").fd()', options) diff --git a/nvim/.config/nvim/lua/opdavies/telescope/mappings.lua b/nvim/.config/nvim/lua/opdavies/telescope/mappings.lua new file mode 100644 index 0000000..4a692aa --- /dev/null +++ b/nvim/.config/nvim/lua/opdavies/telescope/mappings.lua @@ -0,0 +1,32 @@ +local M = {} + +function M.edit_neovim() + local opts = { + prompt_title = "~ dotfiles ~", + shorten_path = false, + cwd = "~/.config/nvim", + + layout_strategy = "flex", + layout_config = { + width = 0.9, + height = 0.8, + + horizontal = { + width = { padding = 0.15 }, + }, + vertical = { + preview_height = 0.75, + }, + }, + } + + require("telescope.builtin").find_files(opts) +end + +function M.fd() + local themes = require "telescope.themes" + + require("telescope.builtin").find_files(themes.get_ivy()) +end + +return M