Add snap as an optional alternative to telescope (#582)

Co-authored-by: Cam Spiers <cam.spiers@jnctn.nz>
This commit is contained in:
Cam Spiers 2021-07-03 06:18:57 +12:00 committed by GitHub
parent 3d01da8a50
commit c1c4e63e5b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 36 additions and 7 deletions

View file

@ -51,6 +51,7 @@ O = {
codi = {active = false}, codi = {active = false},
telescope_fzy = {active = false}, telescope_fzy = {active = false},
sanegx = {active = false}, sanegx = {active = false},
snap = {active = false},
ranger = {active = false}, ranger = {active = false},
todo_comments = {active = false}, todo_comments = {active = false},
lsp_colors = {active = false}, lsp_colors = {active = false},

14
lua/lv-snap/init.lua Normal file
View file

@ -0,0 +1,14 @@
local M = {}
M.config = function()
local snap = require "snap"
local layout = snap.get"layout".bottom
local file = snap.config.file:with {consumer = "fzy", layout = layout}
local vimgrep = snap.config.vimgrep:with {layout = layout}
snap.register.command("find_files", file {producer = "ripgrep.file"})
snap.register.command("buffers", file {producer = "vim.buffer"})
snap.register.command("oldfiles", file {producer = "vim.oldfile"})
snap.register.command("live_grep", vimgrep {})
end
return M

View file

@ -68,9 +68,14 @@ vim.api.nvim_set_keymap('n', '<Leader>e',
-- ":NvimTreeToggle<CR>", -- ":NvimTreeToggle<CR>",
-- {noremap = true, silent = true}) -- {noremap = true, silent = true})
-- telescope -- telescope or snap
vim.api.nvim_set_keymap('n', '<Leader>f', ':Telescope find_files<CR>', if O.plugin.snap.active then
{noremap = true, silent = true}) vim.api.nvim_set_keymap('n', '<Leader>f', ':Snap find_files<CR>',
{noremap = true, silent = true})
else
vim.api.nvim_set_keymap('n', '<Leader>f', ':Telescope find_files<CR>',
{noremap = true, silent = true})
end
-- dashboard -- dashboard
vim.api.nvim_set_keymap('n', '<Leader>;', ':Dashboard<CR>', vim.api.nvim_set_keymap('n', '<Leader>;', ':Dashboard<CR>',
@ -98,7 +103,7 @@ local mappings = {
b = { b = {
name = "Buffers", name = "Buffers",
j = {"<cmd>BufferPick<cr>", "jump to buffer"}, j = {"<cmd>BufferPick<cr>", "jump to buffer"},
f = {"<cmd>Telescope buffers<cr>", "Find buffer"}, f = {O.plugin.snap.active and "<cmd>Snap buffers<cr>" or "<cmd>Telescope buffers<cr>", "Find buffer"},
w = {"<cmd>BufferWipeout<cr>", "wipeout buffer"}, w = {"<cmd>BufferWipeout<cr>", "wipeout buffer"},
e = { e = {
"<cmd>BufferCloseAllButCurrent<cr>", "close all but current buffer" "<cmd>BufferCloseAllButCurrent<cr>", "close all but current buffer"
@ -226,13 +231,13 @@ local mappings = {
-- "<cmd>Telescope lsp_workspace_diagnostics<cr>", -- "<cmd>Telescope lsp_workspace_diagnostics<cr>",
-- "Workspace Diagnostics" -- "Workspace Diagnostics"
-- }, -- },
f = {"<cmd>Telescope find_files<cr>", "Find File"}, f = {O.plugin.snap.active and "<cmd>Snap find_files<cr>" or "<cmd>Telescope find_files<cr>", "Find File"},
h = {"<cmd>Telescope help_tags<cr>", "Find Help"}, h = {"<cmd>Telescope help_tags<cr>", "Find Help"},
-- m = {"<cmd>Telescope marks<cr>", "Marks"}, -- m = {"<cmd>Telescope marks<cr>", "Marks"},
M = {"<cmd>Telescope man_pages<cr>", "Man Pages"}, M = {"<cmd>Telescope man_pages<cr>", "Man Pages"},
r = {"<cmd>Telescope oldfiles<cr>", "Open Recent File"}, r = {O.plugin.snap.active and "<cmd>Snap oldfiles<cr>" or "<cmd>Telescope oldfiles<cr>", "Open Recent File"},
R = {"<cmd>Telescope registers<cr>", "Registers"}, R = {"<cmd>Telescope registers<cr>", "Registers"},
t = {"<cmd>Telescope live_grep<cr>", "Text"} t = {O.plugin.snap.active and "<cmd>Snap live_grep<cr>" or "<cmd>Telescope live_grep<cr>", "Text"}
}, },
S = { S = {
name = "Session", name = "Session",

View file

@ -45,6 +45,15 @@ return require("packer").startup(function(use)
config = [[require('lv-telescope')]], config = [[require('lv-telescope')]],
cmd = "Telescope" cmd = "Telescope"
} }
-- Snap
use {
"camspiers/snap",
rocks = "fzy",
config = function()
require("lv-snap").config()
end,
disable = not O.plugin.snap.active,
}
-- Autocomplete -- Autocomplete
use { use {
"hrsh7th/nvim-compe", "hrsh7th/nvim-compe",