nvim-telescope / telescope.nvim

Find, Filter, Preview, Pick. All lua, all the time.
MIT License
15.06k stars 816 forks source link

filename_first doesn't works with buffer list #3157

Open Wordluc opened 1 month ago

Wordluc commented 1 month ago

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 commented 1 month ago

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 commented 1 month ago

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

KorayAydemir commented 4 days ago

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