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

builtin tag picker does not respect tagrelative option

Open patrick96 opened this issue 2 years ago • 5 comments

Description

I keep my ctags inside the .git folder of my repos to not clutter up the source tree.

For that I generate my tags with ctags --tag-relative -f .git/tags ... and add .git/tags to the tags option.

By default tagrelative is set in neovim and indeed nvim correctly reads the tag file, as confirmed by running :tselect with the cursor on main.

However for :Telescope tags, the relative path (../main.c) is taken relative to the current working directory and not relative to the directory the tags file is in, and so neither the preview nor opening the file works.

Neovim version

NVIM v0.5.1
Build type: Release
LuaJIT 2.0.5
Compilation: /usr/bin/cc -D_FORTIFY_SOURCE=2 -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_TS_HAS_SET_MATCH_LIMIT -O2 -DNDEBUG -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=always -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/build/neovim/src/neovim-0.5.1/build/config -I/build/neovim/src/neovim-0.5.1/src -I/usr/include -I/build/neovim/src/neovim-0.5.1/build/src/nvim/auto -I/build/neovim/src/neovim-0.5.1/build/include
Compiled by builduser

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/share/nvim"

Run :checkhealth for more info

Operating system and version

ArchLinux

checkhealth telescope

health#telescope#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.2.1

## ===== Installed extensions =====

Steps to reproduce

mkdir .git
echo "int main() { return 0; }" > main.c
ctags --tag-relative --fields=afiKlmnsSzt -f ".git/tags" main.c
nvim -u minimal.lua

In nvim, run :Telescope tags

Expected behavior

The main.c file is previewed correctly and opened once the tag is selected

Actual behavior

The preview is empty and the wrong path is opened (../main.c instead of main.c). 2021-10-06-022649_2060x1360_scrot

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' },
        },
      },
      -- ADD PLUGINS THAT ARE _NECESSARY_ FOR REPRODUCING THE ISSUE
    },
    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')
  vim.opt.tags:prepend('.git/tags')
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()]]

patrick96 avatar Oct 06 '21 00:10 patrick96

Thanks for reporting. https://github.com/nvim-telescope/telescope.nvim/pull/1314 should fix the issue. Can you confirm this?

Conni2461 avatar Oct 07 '21 11:10 Conni2461

Hi, thanks a lot for the quick response :)

With the PR, both the preview and the file opening works. However, I noticed that :Telescope current_buffer_tags is still empty and the files listed for :Telescope tags are still using the paths relative to the .git folder (as in the screenshot above).

patrick96 avatar Oct 07 '21 12:10 patrick96

Yeah i know what the issue is. I will provide a fix in the next day and will ping you again.

Conni2461 avatar Oct 07 '21 12:10 Conni2461

Thanks, I appreciate it :)

patrick96 avatar Oct 07 '21 12:10 patrick96

Wondering is there something one can do to get PR above merged? Thanks so much.

fenetikm avatar Jan 11 '22 02:01 fenetikm

Is there any progress with this? I still have the issue.

OscarCreator avatar Jun 22 '23 07:06 OscarCreator

Okay, so I checked out the code and it looks like we do cat tags other_dir/tags to list all entries in the tagfiles. But in this process we lose the location of the tag file. So what needs to be done is separate executing per tag file (to be able to store dir of tag file) some way.

OscarCreator avatar Jun 23 '23 05:06 OscarCreator

Had to revert the commit which closed this issue due to some performance issues so I'm reopening this.

jamestrew avatar Aug 01 '23 00:08 jamestrew