telescope-file-browser.nvim icon indicating copy to clipboard operation
telescope-file-browser.nvim copied to clipboard

'path_display' telescope opt doesn't work properly with the file-browser

Open LamprosPitsillos opened this issue 3 years ago • 4 comments

Description

_W

Neovim version

NVIM v0.8.0-dev-1000-gc0050b71e
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by inferno@InfernoPC

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

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

Operating system and version

Artix Linux

Steps to reproduce

nvim -u minimal_conf.lua

Expected behavior

To have only one slash at the end "/"

Actual behavior

Instead it has two slashes at the end "//"

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-file-browser.nvim',
        },
      },
      -- 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
local layout = require('telescope.actions.layout')
local previewers = require("telescope.previewers")
local sorters = require("telescope.sorters")
_G.load_config = function()
  require('telescope').setup({
	defaults = {
		vimgrep_arguments = {
			"rg",
			"--color=never",
			"--no-heading",
			"--with-filename",
			"--line-number",
			"--column",
			"--smart-case",
		},
		prompt_prefix = ":: ",
		selection_caret = "> ",
		entry_prefix = "  ",
		initial_mode = "insert",
		selection_strategy = "reset",
		sorting_strategy = "descending",
		layout_strategy = "horizontal",
		layout_config = {
			horizontal = {
				mirror = false,
				height = 20,
			},
			vertical = {
				mirror = false,
				width = 0.5
			},
		},
		file_sorter = sorters.get_fuzzy_file,
		file_ignore_patterns = {},
		generic_sorter = sorters.get_generic_fuzzy_sorter,
		winblend = 10,
		border = {},
		borderchars = { "─", "│", "─", "│", "╭", "╮", "╯", "╰" },
		color_devicons = true,
		use_less = true,
		path_display = { "smart" },
		-- set_env = { ['COLORTERM'] = 'truecolor' }, -- default = nil,
		file_previewer = previewers.vim_buffer_cat.new,
		grep_previewer = previewers.vim_buffer_vimgrep.new,
		qflist_previewer = previewers.vim_buffer_qflist.new,
		mappings = {
			i = {
				["<C-]>"] = layout.toggle_preview,
				-- ["<C-]>"] = layout.cycle_layout_next,
			},
		}

		-- Developer configurations: Not meant for general override
		-- buffer_previewer_maker = require'telescope.previewers'.buffer_previewer_maker
	},
	extensions = {
		file_browser = {
			hijack_netrw = true,
		},
		fzf = {
			fuzzy = true, -- false will only do exact matching
			override_generic_sorter = true, -- override the generic sorter
			override_file_sorter = true, -- override the file sorter
			case_mode = "smart_case", -- or "ignore_case" or "respect_case"
			-- the default case_mode is "smart_case"
		},
	},
	["ui-select"] = {
		require("telescope.themes").get_dropdown({
			-- even more opts
		}),
	},
	pickers = {
		find_files = {
			find_command = {
				"fd",
				"--type",
				"f",
				"--strip-cwd-prefix",
				"-E",
				"*cache*"
			},
		},
	},
})
  require('telescope').load_extension('file_browser')
  -- ADD INIT.LUA SETTINGS THAT ARE _NECESSARY_ FOR REPRODUCING THE ISSUE
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()]]

LamprosPitsillos avatar Sep 09 '22 22:09 LamprosPitsillos

Does it happen with a true minimal config?

My best guess is to try commenting out

		path_display = { "smart" },

and see whether it works then.

fdschmidt93 avatar Sep 10 '22 10:09 fdschmidt93

Yes , that was it ! Should i leave this issue open , since i don't think it's an intended behavior of the path_display = { "smart" } ?

LamprosPitsillos avatar Sep 10 '22 10:09 LamprosPitsillos

Yes , that was it ! Should i leave this issue open , since i don't think it's an intended behavior of the path_display = { "smart" } ?

_W

path_display = { "tail" } is also broken , and the others I tried also have some strange behaviors. I noticed that the buildin pickers of telescope follow the path_display as expected but file-browser seems to have a hard time with them.

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-file-browser.nvim',
				},
			},
			-- 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({
		defaults = {
			path_display = { "tail" },
		},
	})
	require('telescope').load_extension('file_browser')
	-- ADD INIT.LUA SETTINGS THAT ARE _NECESSARY_ FOR REPRODUCING THE ISSUE
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()]]

Here is the minimal config i managed to make to reproduce the issue.

LamprosPitsillos avatar Sep 10 '22 14:09 LamprosPitsillos

I also just had this same thing happen. It works on my other PC but when I pulled it to this one from git I started getting double slashes at the end of folders as well.

BaneOfCode avatar Oct 03 '22 14:10 BaneOfCode

Am also facing the same issue with "smart" path_display option in telescope;

vignesh0025 avatar Oct 09 '22 17:10 vignesh0025