nvim-telescope / telescope-file-browser.nvim

File Browser extension for telescope.nvim
MIT License
1.6k stars 89 forks source link

Getting Error when using a dot in file path cwd `cwd = "~/.config/"` ERROR:'replacement string' item co ntains newline' #365

Closed MikeLemo1 closed 3 months ago

MikeLemo1 commented 3 months ago

Description

I'm basically getting the following error running this code:

function M.nvim_config()
  require("telescope").extensions.file_browser.file_browser {
    prompt_title = " NVim Config Browser",
    cwd = "~/.config/nvim",
    layout_strategy = "horizontal",
    layout_config = { preview_width = 0.65, width = 0.75 },
  }
end

with :require("telescope").extensions.file_browser.file_browser

The error message:

Error executing vim.schedule lua callback: ...scope.nvim/lua/telescope/previewers/buffer_previewer.lua:143: 'replacement string' item co
ntains newlines
stack traceback:
        [C]: in function 'nvim_buf_set_lines'
        ...scope.nvim/lua/telescope/previewers/buffer_previewer.lua:143: in function 'set_colorize_lines'
        ...scope.nvim/lua/telescope/previewers/buffer_previewer.lua:152: in function ''
        vim/_editor.lua: in function <vim/_editor.lua:0>

But regradless the error the files browser does open at the correct directory

Any idea how to fix / skip / cancel this error message?

Neovim version

NVIM v0.10.0-dev-2194+g3ab6f60dc
Build type: RelWithDebInfo
LuaJIT 2.1.1706185428
Run "nvim -V1 -v" for more info

Operating system and version

Ubuntu 22.04

Steps to reproduce

function M.nvim_config()
  require("telescope").extensions.file_browser.file_browser {
    prompt_title = " NVim Config Browser",
    cwd = "~/.config/nvim",
    layout_strategy = "horizontal",
    layout_config = { preview_width = 0.65, width = 0.75 },
  }
end

Expected behavior

No response

Actual behavior

Error executing vim.schedule lua callback: ...scope.nvim/lua/telescope/previewers/buffer_previewer.lua:143: 'replacement string' item co
ntains newlines
stack traceback:
        [C]: in function 'nvim_buf_set_lines'
        ...scope.nvim/lua/telescope/previewers/buffer_previewer.lua:143: in function 'set_colorize_lines'
        ...scope.nvim/lua/telescope/previewers/buffer_previewer.lua:152: in function ''
        vim/_editor.lua: in function <vim/_editor.lua:0>

Minimal config

local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({
    "git",
    "clone",
    "--filter=blob:none",
    "https://github.com/folke/lazy.nvim.git",
    lazypath,
  })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  {
    "nvim-telescope/telescope-file-browser.nvim",
    dependencies = {
      "nvim-telescope/telescope.nvim",
      "nvim-lua/plenary.nvim",
    },
    config = function()
      require("telescope").setup({})
      require("telescope").load_extension("file_browser")
    end,
  },
}

require("lazy").setup(plugins, {
  root = root .. "/plugins",
})
jamestrew commented 3 months ago

Do you have something in your ~/.config/nvim that has a newline character? Edit: hmm I can't replicate this even with a file with a newline character. Are you able to share what you have in the ~/.config/nvim directory? output of ls could help.

MikeLemo1 commented 3 months ago

Yeah my bad previous experinments with fzf generated wierd name files that I now caough after you mentioned that is possible one of the files there deleted em and the error disappeared, nothing bad to do with telescope

jamestrew commented 3 months ago

Np I'll close the issue then.

MikeLemo1 commented 3 months ago

Yeah thanks for eveything!