telescope.nvim icon indicating copy to clipboard operation
telescope.nvim copied to clipboard

Live grep only highlights one match per line

Open Sebastian-0 opened this issue 1 year ago • 2 comments

Description

When using the live_grep view and searching only the first match on each line is highlighted. This is mainly a problem when the search also matches the file name, then you can't easily see at a glance what in the file actually matches the search.

For example: image The first few lines look as expected, but when the path also matches the search the matching code is no longer highlighted. It's still usable but way harder to read.

I've tried finding a setting to control this but I've been unsuccessful, if there is one please tell me!

Neovim version

NVIM v0.9.1
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3

Operating system and version

Ubuntu 22.04

Telescope version / branch / rev

0.1.x (550055e640fd6eea88430ba5da3a3bc08679cf94)

checkhealth telescope

==============================================================================
telescope: require("telescope.health").check()

Checking for required plugins ~
- OK plenary installed.
- OK nvim-treesitter installed.

Checking external dependencies ~
- OK rg: found ripgrep 13.0.0
- OK fd: found fd 8.3.1

===== Installed extensions ===== ~

Steps to reproduce

Make sure you have a file tree where there are folders with name xxxx and within those folders there are files also containing the string xxxx.

  1. Open nvim with vanilla Telescope installation (I left minimial config unchanged)
  2. Open live_grep builtin
  3. Type xxxx

Expected behavior

All instances of xxxx should be highlighted, both from the path and from the file contents.

Actual behavior

Only the first instance of xxxx is highlighted, this will be from the path if it matches, otherwise from the file contents.

Minimal config

vim.cmd [[set runtimepath=$VIMRUNTIME]]
vim.cmd [[set packpath=/tmp/nvim/site]]
local package_root = '/tmp/nvim/site/pack'
local install_path = package_root .. '/packer/start/packer.nvim'
local function load_plugins()
  require('packer').startup {
    {
      'wbthomason/packer.nvim',
      {
        'nvim-telescope/telescope.nvim',
        requires = {
          'nvim-lua/plenary.nvim',
          { 'nvim-telescope/telescope-fzf-native.nvim', run = 'make' },
        },
      },
      -- No extra plugins necessary
    },
    config = {
      package_root = package_root,
      compile_path = install_path .. '/plugin/packer_compiled.lua',
      display = { non_interactive = true },
    },
  }
end
_G.load_config = function()
  require('telescope').setup()
  require('telescope').load_extension('fzf')
  -- No settings necessary
end
if vim.fn.isdirectory(install_path) == 0 then
  print("Installing Telescope and dependencies.")
  vim.fn.system { 'git', 'clone', '--depth=1', 'https://github.com/wbthomason/packer.nvim', install_path }
end
load_plugins()
require('packer').sync()
vim.cmd [[autocmd User PackerComplete ++once echo "Ready!" | lua load_config()]]

Sebastian-0 avatar Nov 09 '23 09:11 Sebastian-0

will look into this.

lrfurtado avatar Nov 09 '23 20:11 lrfurtado

There's already a PR that will pretty much address this by highlighting the pattern matches as ripgrep does.

Although it'll be a while till it's merged. #2536

jamestrew avatar Nov 10 '23 17:11 jamestrew