From c1c4e63e5b7cb75f71c137bfd39ae44cd85e537b Mon Sep 17 00:00:00 2001 From: Cam Spiers Date: Sat, 3 Jul 2021 06:18:57 +1200 Subject: Add snap as an optional alternative to telescope (#582) Co-authored-by: Cam Spiers --- lua/default-config.lua | 1 + lua/lv-snap/init.lua | 14 ++++++++++++++ lua/lv-which-key/init.lua | 19 ++++++++++++------- lua/plugins.lua | 9 +++++++++ 4 files changed, 36 insertions(+), 7 deletions(-) create mode 100644 lua/lv-snap/init.lua (limited to 'lua') diff --git a/lua/default-config.lua b/lua/default-config.lua index 88f2117d..a9a5d880 100644 --- a/lua/default-config.lua +++ b/lua/default-config.lua @@ -51,6 +51,7 @@ O = { codi = {active = false}, telescope_fzy = {active = false}, sanegx = {active = false}, + snap = {active = false}, ranger = {active = false}, todo_comments = {active = false}, lsp_colors = {active = false}, diff --git a/lua/lv-snap/init.lua b/lua/lv-snap/init.lua new file mode 100644 index 00000000..115b1eda --- /dev/null +++ b/lua/lv-snap/init.lua @@ -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 diff --git a/lua/lv-which-key/init.lua b/lua/lv-which-key/init.lua index 02d99ec8..3af04edf 100644 --- a/lua/lv-which-key/init.lua +++ b/lua/lv-which-key/init.lua @@ -68,9 +68,14 @@ vim.api.nvim_set_keymap('n', 'e', -- ":NvimTreeToggle", -- {noremap = true, silent = true}) --- telescope -vim.api.nvim_set_keymap('n', 'f', ':Telescope find_files', - {noremap = true, silent = true}) +-- telescope or snap +if O.plugin.snap.active then + vim.api.nvim_set_keymap('n', 'f', ':Snap find_files', + {noremap = true, silent = true}) +else + vim.api.nvim_set_keymap('n', 'f', ':Telescope find_files', + {noremap = true, silent = true}) +end -- dashboard vim.api.nvim_set_keymap('n', ';', ':Dashboard', @@ -98,7 +103,7 @@ local mappings = { b = { name = "Buffers", j = {"BufferPick", "jump to buffer"}, - f = {"Telescope buffers", "Find buffer"}, + f = {O.plugin.snap.active and "Snap buffers" or "Telescope buffers", "Find buffer"}, w = {"BufferWipeout", "wipeout buffer"}, e = { "BufferCloseAllButCurrent", "close all but current buffer" @@ -226,13 +231,13 @@ local mappings = { -- "Telescope lsp_workspace_diagnostics", -- "Workspace Diagnostics" -- }, - f = {"Telescope find_files", "Find File"}, + f = {O.plugin.snap.active and "Snap find_files" or "Telescope find_files", "Find File"}, h = {"Telescope help_tags", "Find Help"}, -- m = {"Telescope marks", "Marks"}, M = {"Telescope man_pages", "Man Pages"}, - r = {"Telescope oldfiles", "Open Recent File"}, + r = {O.plugin.snap.active and "Snap oldfiles" or "Telescope oldfiles", "Open Recent File"}, R = {"Telescope registers", "Registers"}, - t = {"Telescope live_grep", "Text"} + t = {O.plugin.snap.active and "Snap live_grep" or "Telescope live_grep", "Text"} }, S = { name = "Session", diff --git a/lua/plugins.lua b/lua/plugins.lua index 6203c2f2..23e9365d 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -45,6 +45,15 @@ return require("packer").startup(function(use) config = [[require('lv-telescope')]], cmd = "Telescope" } + -- Snap + use { + "camspiers/snap", + rocks = "fzy", + config = function() + require("lv-snap").config() + end, + disable = not O.plugin.snap.active, + } -- Autocomplete use { "hrsh7th/nvim-compe", -- cgit v1.2.3