nvim: Fix telescope grep

Fixed grepping for telescope to work again, and work with the native
'live_grep' function.

Replaced fzy extension with precompiled fzf since I have that installed
anyway.

Changed some theming around so I have a fast, minimal file switcher
instead of the big window by default. Can still call the big preview
window through the Telescope command if need be.
This commit is contained in:
Marty Oehme 2022-02-13 20:07:21 +01:00
parent dee44417a6
commit 438547251a
Signed by: Marty
GPG key ID: B7538B8F50A1C800
3 changed files with 37 additions and 40 deletions

View file

@ -76,9 +76,6 @@ map.n.nore[']q'] = ':cnext<cr>'
-- Location list -- Location list
map.n.nore['[l'] = ':lprevious<cr>' map.n.nore['[l'] = ':lprevious<cr>'
map.n.nore[']l'] = ':lnext<cr>' map.n.nore[']l'] = ':lnext<cr>'
-- Hunks (from gitsigns)
map.n.nore.expr['[h'] = [[&diff ? ']c' : '<cmd>Gitsigns prev_hunk<CR>']]
map.n.nore.expr[']h'] = [[&diff ? '[c' : '<cmd>Gitsigns next_hunk<CR>']]
-- set our leader key to space since with hjkl, space is largely useless -- set our leader key to space since with hjkl, space is largely useless
vim.g.mapleader = " " vim.g.mapleader = " "
@ -131,11 +128,9 @@ map.n.nore['<leader>s'] =
map.n.nore['<leader>S'] = map.n.nore['<leader>S'] =
[[:lua require 'telescope.builtin'.oldfiles(require 'telescope.themes'.get_ivy())<cr>]] [[:lua require 'telescope.builtin'.oldfiles(require 'telescope.themes'.get_ivy())<cr>]]
-- fuzzy find files in cwd -- fuzzy find files in cwd
map.n.nore['<leader>f'] = map.n.nore['<leader>f'] = [[:lua require 'telescope.builtin'.find_files()<cr>]]
[[:lua require 'telescope.builtin'.find_files({follow=true, hidden=true})<cr>]]
-- general full-text search in cwd with rg -- general full-text search in cwd with rg
map.n.nore['<leader>F'] = map.n.nore['<leader>F'] = [[:lua require 'telescope.builtin'.live_grep()<cr>]]
[[:lua require 'telescope'.extensions.fzf_writer.grep()<cr>]]
-- git status -- git status
map.n.nore['<leader>gs'] = [[:lua require 'telescope.builtin'.git_status()<cr>]] map.n.nore['<leader>gs'] = [[:lua require 'telescope.builtin'.git_status()<cr>]]
@ -187,9 +182,6 @@ map.n.nore.silent['<F10>'] = ':TZMinimalist<cr>'
-- map @@ to automatically insert citation reference at cursor -- map @@ to automatically insert citation reference at cursor
map.i.nore.silent['@@'] = '<c-g>u<c-o>:CiteRef<cr>' map.i.nore.silent['@@'] = '<c-g>u<c-o>:CiteRef<cr>'
-- map <leader>cc to insert a complete citation at cursor -- map <leader>cc to insert a complete citation at cursor
map.n.nore.silent['<leader>cc'] = ':CiteRef<cr>'
-- map <leader>cm to insert markdown prettified citation
map.n.nore.silent['<localleader>cm'] = ':CiteMarkdown<cr>'
-- SPELL CHECKING -- SPELL CHECKING
-- Spell check set to <leader>O, 'o' for 'orthography': -- Spell check set to <leader>O, 'o' for 'orthography':

View file

@ -1,32 +1,36 @@
-- Setup up telescope fuzzy finding settings
--
-- Makes use of optionally installed external programs to work fully:
-- rg (ripgrep) for in-text searches
-- fd for quicker directory structure searches
-- lsp for a variety of lsp queries
require("telescope").setup { require("telescope").setup {
defaults = { defaults = {
file_sorter = require("telescope.sorters").get_fzy_sorter,
vimgrep_arguments = { vimgrep_arguments = {
'rg', 'rg', '--ignore-vcs', '--hidden', '--color=never', '--no-heading',
'--ignore-vcs', '--with-filename', '--line-number', '--column', '--smart-case'
'--hidden', }
'--color=never',
'--no-heading',
'--with-filename',
'--line-number',
'--column',
'--smart-case'
}, },
pickers = {
buffers = {theme = "ivy"},
oldfiles = {theme = "ivy"},
find_files = {
theme = "dropdown",
-- nice minimal picker design
borderchars = {
{'', '', '', '', '', '', '', ''},
prompt = {"", "", " ", "", '', '', "", ""},
results = {
"", "", "", "", "", "", "", ""
}, },
extensions = { preview = {
fzy_native = { '', '', '', '', '', '', '', ''
override_generic_sorter = false, }
override_file_sorter = true
}, },
fzf_writer = { width = 0.8,
minimum_grep_characters = 2, previewer = false,
minimum_files_characters = 2, prompt_title = false
-- Disabled by default.
-- Will probably slow down some aspects of the sorter, but can make color highlights.
use_highlighter = true,
} }
} }
} }
require("telescope").load_extension("fzy_native") require("telescope").load_extension("fzf")
require("telescope").load_extension("fzf_writer")

View file

@ -159,11 +159,12 @@ require("packer").startup(function()
-- fuzzy matching -- fuzzy matching
use { use {
"nvim-telescope/telescope.nvim", "nvim-telescope/telescope.nvim",
requires = {{"nvim-lua/popup.nvim"}, {"nvim-lua/plenary.nvim"}}, requires = {
{"nvim-lua/popup.nvim"}, {"nvim-lua/plenary.nvim"},
{"nvim-telescope/telescope-fzf-native.nvim", run = 'make'}
},
config = function() require('plug._telescope') end config = function() require('plug._telescope') end
} }
use "nvim-telescope/telescope-fzy-native.nvim"
use "nvim-telescope/telescope-fzf-writer.nvim"
-- snippeting -- snippeting
use {"hrsh7th/vim-vsnip", event = "InsertEnter"} -- snippet engine use {"hrsh7th/vim-vsnip", event = "InsertEnter"} -- snippet engine