From c489d393695e90d424f9ae51e35c4d42358e6a71 Mon Sep 17 00:00:00 2001 From: Squibid Date: Fri, 9 Aug 2024 02:45:31 -0400 Subject: yes there's a bit of java in my nvim config why do you ask? --- lua/conf/plugins/telescope.lua | 78 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 lua/conf/plugins/telescope.lua (limited to 'lua/conf/plugins/telescope.lua') diff --git a/lua/conf/plugins/telescope.lua b/lua/conf/plugins/telescope.lua new file mode 100644 index 0000000..20f516d --- /dev/null +++ b/lua/conf/plugins/telescope.lua @@ -0,0 +1,78 @@ +local misc = require('core.misc') +local map = misc.map + +return { 'nvim-telescope/telescope.nvim', + disable = vim.version().minor < 9, + requires = { + 'nvim-lua/plenary.nvim', + { 'nvim-telescope/telescope-fzf-native.nvim', + config = function() + vim.cmd('make') + end + } + }, + function() + local telescope = require("telescope") + local actions = require('telescope.actions') + local action_layout = require("telescope.actions.layout") + + local function telescopew() + if vim.o.columns <= 80 then + return vim.o.columns + else + return 0.8 + end + end + + telescope.setup { + defaults = { + borderchars = { + prompt = { ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' }, + results = { ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' }, + preview = { ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' }, + }, + winblend = 0, + layout_strategy = 'horizontal', + sorting_strategy = 'descending', + scroll_strategy = 'limit', + layout_config = { + horizontal = { + width = telescopew(), + height = 20, + prompt_position = 'bottom', + anchor = 'N', + } + }, + mappings = { + i = { + [""] = actions.close, + [''] = actions.move_selection_next, + [''] = actions.move_selection_previous, + [''] = actions.select_default, + [''] = actions.preview_scrolling_up, + [''] = actions.preview_scrolling_down, + [""] = action_layout.toggle_preview + }, + n = { + ["gg"] = actions.move_to_top, + ["G"] = actions.move_to_bottom, + } + } + } + } + + local telebuilt = require('telescope.builtin') + map('n', 'f', function() + telebuilt.fd { follow = true } + end, { desc = 'Find files.' }) + map('n', 's', telebuilt.live_grep, { desc = 'Find string in project.' }) + map('n', 'b', telebuilt.current_buffer_fuzzy_find, { + desc = 'Find string in current buffer.', + }) + + -- enable previewing in the default colorscheme switcher + telebuilt.colorscheme = function() + require("telescope.builtin.__internal").colorscheme { enable_preview = true } + end + end +} -- cgit v1.2.1