From c5f5709f10228b95ce62440cdffb0fc9d8930727 Mon Sep 17 00:00:00 2001 From: siduck76 Date: Sat, 26 Jun 2021 08:11:39 +0530 Subject: [PATCH] lazy loading telescope! --- init.lua | 3 +- lua/highlights.lua | 6 +- lua/mappings.lua | 10 +++ lua/pluginList.lua | 14 ++++- lua/telescope-nvim.lua | 140 +++++++++++++++++++---------------------- 5 files changed, 90 insertions(+), 83 deletions(-) diff --git a/init.lua b/init.lua index 2dc2398..c9753d4 100644 --- a/init.lua +++ b/init.lua @@ -3,7 +3,7 @@ require "pluginList" require "misc-utils" require "top-bufferline" -require "telescope-nvim" +require("colorizer").setup() local cmd = vim.cmd local g = vim.g @@ -19,7 +19,6 @@ local base16 = require "base16" base16(base16.themes["nvchad-softgruv"], true) require "highlights" -require("colorizer").setup() require "mappings" require "file-icons" require "statusline" diff --git a/lua/highlights.lua b/lua/highlights.lua index cc5561d..587cc8f 100644 --- a/lua/highlights.lua +++ b/lua/highlights.lua @@ -118,8 +118,8 @@ fg_bg("BufferLineIndicator", black2, black2) fg_bg("BufferLineIndicatorSelected", black, black) -- separators -fg_bg("BufferLineSeparator", line, black2) -fg_bg("BufferLineSeparatorVisible", line, black2) +fg_bg("BufferLineSeparator", black2, black2) +fg_bg("BufferLineSeparatorVisible", black2, black2) fg_bg("BufferLineSeparatorSelected", black, black2) -- modified buffers @@ -139,5 +139,5 @@ fg("DashboardCenter", grey_fg) fg("DashboardShortcut", grey_fg) fg("DashboardFooter", grey_fg) --- Default nvim bg +-- Default nvim bg (based on terminal bg) -- cmd "hi Normal guibg=#1e222a" diff --git a/lua/mappings.lua b/lua/mappings.lua index cf0fb41..3c5fb85 100644 --- a/lua/mappings.lua +++ b/lua/mappings.lua @@ -107,7 +107,17 @@ map("n", "fm", [[ Neoformat]], opt) -- dashboard stuff map("n", "fw", [[ Telescope live_grep]], opt) +map("n", "db", [[ Dashboard]], opt) map("n", "fn", [[ DashboardNewFile]], opt) map("n", "bm", [[ DashboardJumpMarks]], opt) map("n", "sl", [[ SessionLoad]], opt) map("n", "ss", [[ SessionSave]], opt) + +-- Telescope +map("n", "gt", [[ Telescope git_status ]], opt) +map("n", "cm", [[ Telescope git_commits ]], opt) +map("n", "ff", [[ Telescope find_files ]], opt) +map("n", "fp", [[lua require('telescope').extensions.media_files.media_files()]], opt) +map("n", "fb", [[Telescope Buffers]], opt) +map("n", "fh", [[Telescope help_tags]], opt) +map("n", "fo", [[Telescope oldfiles]], opt) diff --git a/lua/pluginList.lua b/lua/pluginList.lua index b43aa31..ddd1b4d 100644 --- a/lua/pluginList.lua +++ b/lua/pluginList.lua @@ -70,6 +70,7 @@ return packer.startup( } use "kyazdani42/nvim-web-devicons" + use { "nvim-telescope/telescope.nvim", requires = { @@ -77,10 +78,16 @@ return packer.startup( {"nvim-lua/plenary.nvim"}, {"nvim-telescope/telescope-fzf-native.nvim", run = "make"}, {"nvim-telescope/telescope-media-files.nvim"} - } + }, + cmd = { + "Telescope" + }, + config = function() + require("telescope-nvim").config() + end } - -- misc plugins + -- git stuff use { "lewis6991/gitsigns.nvim", event = "BufRead", @@ -89,6 +96,7 @@ return packer.startup( end } + -- misc plugins use { "windwp/nvim-autopairs", event = "InsertEnter", @@ -113,7 +121,7 @@ return packer.startup( use { "glepnir/dashboard-nvim", cmd = { - "Telescope live_grep", + "Dashboard", "DashboardNewFile", "DashboardJumpMarks" }, diff --git a/lua/telescope-nvim.lua b/lua/telescope-nvim.lua index cc948ae..d74dacf 100644 --- a/lua/telescope-nvim.lua +++ b/lua/telescope-nvim.lua @@ -1,81 +1,71 @@ -require("telescope").setup { - defaults = { - vimgrep_arguments = { - "rg", - "--color=never", - "--no-heading", - "--with-filename", - "--line-number", - "--column", - "--smart-case" - }, - prompt_position = "top", - prompt_prefix = "  ", - selection_caret = " ", - entry_prefix = " ", - initial_mode = "insert", - selection_strategy = "reset", - sorting_strategy = "descending", - layout_strategy = "horizontal", - layout_defaults = { - horizontal = { - mirror = false, - preview_width = 0.5 +local M = {} + +M.config = function() + require("telescope").setup { + defaults = { + vimgrep_arguments = { + "rg", + "--color=never", + "--no-heading", + "--with-filename", + "--line-number", + "--column", + "--smart-case" }, - vertical = { - mirror = false + prompt_position = "top", + prompt_prefix = "  ", + selection_caret = " ", + entry_prefix = " ", + initial_mode = "insert", + selection_strategy = "reset", + sorting_strategy = "descending", + layout_strategy = "horizontal", + layout_defaults = { + horizontal = { + mirror = false, + preview_width = 0.55 + }, + vertical = { + mirror = false + } + }, + file_sorter = require "telescope.sorters".get_fuzzy_file, + file_ignore_patterns = {}, + generic_sorter = require "telescope.sorters".get_generic_fuzzy_sorter, + shorten_path = true, + winblend = 0, + width = 0.75, + preview_cutoff = 120, + results_height = 1, + results_width = 0.8, + border = {}, + borderchars = {"─", "│", "─", "│", "╭", "╮", "╯", "╰"}, + color_devicons = true, + use_less = true, + set_env = {["COLORTERM"] = "truecolor"}, -- default = nil, + file_previewer = require "telescope.previewers".vim_buffer_cat.new, + grep_previewer = require "telescope.previewers".vim_buffer_vimgrep.new, + qflist_previewer = require "telescope.previewers".vim_buffer_qflist.new, + -- Developer configurations: Not meant for general override + buffer_previewer_maker = require "telescope.previewers".buffer_previewer_maker + }, + extensions = { + fzf = { + fuzzy = true, -- false will only do exact matching + override_generic_sorter = false, -- override the generic sorter + override_file_sorter = true, -- override the file sorter + case_mode = "smart_case" -- or "ignore_case" or "respect_case" + -- the default case_mode is "smart_case" + }, + media_files = { + filetypes = {"png", "webp", "jpg", "jpeg"}, + find_cmd = "rg" -- find command (defaults to `fd`) } - }, - file_sorter = require "telescope.sorters".get_fuzzy_file, - file_ignore_patterns = {}, - generic_sorter = require "telescope.sorters".get_generic_fuzzy_sorter, - shorten_path = true, - winblend = 0, - width = 0.75, - preview_cutoff = 120, - results_height = 1, - results_width = 0.8, - border = {}, - borderchars = {"─", "│", "─", "│", "╭", "╮", "╯", "╰"}, - color_devicons = true, - use_less = true, - set_env = {["COLORTERM"] = "truecolor"}, -- default = nil, - file_previewer = require "telescope.previewers".vim_buffer_cat.new, - grep_previewer = require "telescope.previewers".vim_buffer_vimgrep.new, - qflist_previewer = require "telescope.previewers".vim_buffer_qflist.new, - -- Developer configurations: Not meant for general override - buffer_previewer_maker = require "telescope.previewers".buffer_previewer_maker - }, - extensions = { - fzf = { - fuzzy = true, -- false will only do exact matching - override_generic_sorter = false, -- override the generic sorter - override_file_sorter = true, -- override the file sorter - case_mode = "smart_case" -- or "ignore_case" or "respect_case" - -- the default case_mode is "smart_case" - }, - media_files = { - filetypes = {"png", "webp", "jpg", "jpeg"}, - find_cmd = "rg" -- find command (defaults to `fd`) } } -} -require('telescope').load_extension('fzf') -require("telescope").load_extension("media_files") + require("telescope").load_extension("fzf") + require("telescope").load_extension("media_files") +end -local opt = {noremap = true, silent = true} - -vim.g.mapleader = " " - --- mappings -vim.api.nvim_set_keymap("n", "ff", [[lua require('telescope.builtin').find_files()]], opt) -vim.api.nvim_set_keymap( - "n", - "fp", - [[lua require('telescope').extensions.media_files.media_files()]], - opt -) -vim.api.nvim_set_keymap("n", "fb", [[lua require('telescope.builtin').buffers()]], opt) -vim.api.nvim_set_keymap("n", "fh", [[lua require('telescope.builtin').help_tags()]], opt) -vim.api.nvim_set_keymap("n", "fo", [[lua require('telescope.builtin').oldfiles()]], opt) +return M