mirror of
https://github.com/LunarVim/LunarVim.git
synced 2025-08-29 14:28:18 +02:00
feat: use telescope to quickly open lunarvim files (#1310)
This commit is contained in:
parent
a42cde2638
commit
fe55935c05
2 changed files with 48 additions and 2 deletions
|
@ -1,6 +1,6 @@
|
||||||
local M = {}
|
local M = {}
|
||||||
local Log = require "core.log"
|
local Log = require "core.log"
|
||||||
M.config = function()
|
function M.config()
|
||||||
local status_ok, actions = pcall(require, "telescope.actions")
|
local status_ok, actions = pcall(require, "telescope.actions")
|
||||||
if not status_ok then
|
if not status_ok then
|
||||||
return
|
return
|
||||||
|
@ -77,7 +77,41 @@ M.config = function()
|
||||||
}
|
}
|
||||||
end
|
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")
|
local status_ok, telescope = pcall(require, "telescope")
|
||||||
if not status_ok then
|
if not status_ok then
|
||||||
Log:get_default().error "Failed to load telescope"
|
Log:get_default().error "Failed to load telescope"
|
||||||
|
|
|
@ -169,6 +169,18 @@ M.config = function()
|
||||||
},
|
},
|
||||||
L = {
|
L = {
|
||||||
name = "+LunarVim",
|
name = "+LunarVim",
|
||||||
|
c = {
|
||||||
|
"<cmd>edit ~/.config/lvim/config.lua<cr>",
|
||||||
|
"Edit config.lua",
|
||||||
|
},
|
||||||
|
f = {
|
||||||
|
"<cmd>lua require('core.telescope').find_lunarvim_files()<cr>",
|
||||||
|
"Find LunarVim files",
|
||||||
|
},
|
||||||
|
g = {
|
||||||
|
"<cmd>lua require('core.telescope').grep_lunarvim_files()<cr>",
|
||||||
|
"Grep LunarVim files",
|
||||||
|
},
|
||||||
k = { "<cmd>lua require('keymappings').print()<cr>", "View LunarVim's default keymappings" },
|
k = { "<cmd>lua require('keymappings').print()<cr>", "View LunarVim's default keymappings" },
|
||||||
i = {
|
i = {
|
||||||
"<cmd>lua require('core.info').toggle_popup(vim.bo.filetype)<cr>",
|
"<cmd>lua require('core.info').toggle_popup(vim.bo.filetype)<cr>",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue