summaryrefslogtreecommitdiff
path: root/lua/core/telescope.lua
diff options
context:
space:
mode:
authorkylo252 <[email protected]>2021-08-14 14:16:38 +0200
committerGitHub <[email protected]>2021-08-14 16:46:38 +0430
commitfe55935c056a6b5f3dafa606b253324b1edc7ab5 (patch)
treecf0515ef155e0f758b87e54ea3bc3be619141eec /lua/core/telescope.lua
parenta42cde2638726cde84a1548764ff4c3825d8537e (diff)
feat: use telescope to quickly open lunarvim files (#1310)
Diffstat (limited to 'lua/core/telescope.lua')
-rw-r--r--lua/core/telescope.lua38
1 files changed, 36 insertions, 2 deletions
diff --git a/lua/core/telescope.lua b/lua/core/telescope.lua
index f8862260..30533b65 100644
--- a/lua/core/telescope.lua
+++ b/lua/core/telescope.lua
@@ -1,6 +1,6 @@
local M = {}
local Log = require "core.log"
-M.config = function()
+function M.config()
local status_ok, actions = pcall(require, "telescope.actions")
if not status_ok then
return
@@ -77,7 +77,41 @@ M.config = function()
}
end
-M.setup = function()
+function M.find_lunarvim_files(opts)
+ opts = opts or {}
+ local themes = require "telescope.themes"
+ local theme_opts = themes.get_ivy {
+ previewer = false,
+ sorting_strategy = "ascending",
+ layout_strategy = "bottom_pane",
+ layout_config = {
+ height = 5,
+ width = 0.5,
+ },
+ prompt = ">> ",
+ prompt_title = "~ LunarVim files ~",
+ cwd = CONFIG_PATH,
+ find_command = { "git", "ls-files" },
+ }
+ opts = vim.tbl_deep_extend("force", theme_opts, opts)
+ require("telescope.builtin").find_files(opts)
+end
+
+function M.grep_lunarvim_files(opts)
+ opts = opts or {}
+ local themes = require "telescope.themes"
+ local theme_opts = themes.get_ivy {
+ sorting_strategy = "ascending",
+ layout_strategy = "bottom_pane",
+ prompt = ">> ",
+ prompt_title = "~ search LunarVim ~",
+ cwd = CONFIG_PATH,
+ }
+ opts = vim.tbl_deep_extend("force", theme_opts, opts)
+ require("telescope.builtin").live_grep(opts)
+end
+
+function M.setup()
local status_ok, telescope = pcall(require, "telescope")
if not status_ok then
Log:get_default().error "Failed to load telescope"