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

filename_first doesn't works with buffer list

Open Wordluc opened this issue 1 year ago • 4 comments

Description

When using Telescope.nvim to display buffers, the buffer list does not show the file names first. This issue occurs even though the path_display option is set to show file names first (for files/grep, this setting works correctly).

image

Neovim version

NVIM v0.9.5
Build type: RelWithDebInfo
LuaJIT 2.1.1703942320

Operating system and version

Windows 11

Telescope version / branch / rev

master

checkhealth telescope

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

Checking external dependencies ~
- OK rg: found ripgrep 14.1.0 (rev e50df40a19)
- WARNING fd: not found. Install [sharkdp/fd](https://github.com/sharkdp/fd) for extended capabilities

Steps to reproduce

set the options path_display = { filename_first = { reverse_directories = false } } after (restart nvim), the options is applied of the other search but buffer

Expected behavior

see each each buffer with the name first

Actual behavior

some buffer have the name first other not

Minimal config

require("telescope").setup {
	defaults = {
		path_display = {
			filename_first = {
				reverse_directories = false
			}
		},
		file_ignore_patterns = { "./^.git/*", "./node_modules/*", "node_modules", "^node_modules/*", "node_modules/*" },
	} 
}
local builtin = require('telescope.builtin')
vim.keymap.set('n', '<leader>ff', builtin.find_files, {})
vim.keymap.set('n', '<leader>fvv', function()
	builtin.grep_string({ search = vim.fn.input("Grep > ") })
end)
vim.keymap.set('v', '<leader>fvv', function()
	vim.cmd('noau normal! "ay"')
	builtin.grep_string({ search = vim.fn.getreg("a") })
end)
vim.keymap.set('n', '<leader>fb', function()
	builtin.buffers({ sort_mru = true })
end)

vim.keymap.set('n', '<leader>fg', function()
	builtin.lsp_references()
end)
vim.keymap.set('n', '<leader>fv', builtin.live_grep, {})

vim.keymap.set('n', '<leader>fs', builtin.tagstack, {})

Wordluc avatar Jun 07 '24 18:06 Wordluc

Bug: Basically, the path sometimes uses "/" and other times "\". The firstname option works with "\", so I replaced "/" with "\". After that, the option works correctly. I modified the file: __internal.lua.

Temporary solution used:

		local info = vim.fn.getbufinfo(bufnr)[1]
		info.name = info.name:gsub("[/]", "\\")
		local element = {
			bufnr = bufnr,
			flag = flag,
			info = info,
		}

Wordluc avatar Jun 07 '24 19:06 Wordluc

fixing pull request: https://github.com/nvim-telescope/telescope.nvim/pull/3176#issue-2361716277

Wordluc avatar Jun 19 '24 08:06 Wordluc

It also doesn't work with git_files picker. It works fine with find_files.

KorayAydemir avatar Jul 31 '24 17:07 KorayAydemir

It doesn't work on git_status either. this is the work around(make_entry.lua, in line: 1356 ) local display_path = entry.path local path_style= nil if utils.iswin then --for plenary problem display_path = display_path:gsub("/", "\\") end display_path ,path_style = utils.transform_path(opts, display_path)

Wordluc avatar Sep 24 '24 08:09 Wordluc