smart-open.nvim icon indicating copy to clipboard operation
smart-open.nvim copied to clipboard

Picker entry containing raw "ls" command output appears in 0.2.x

Open ebkalderon opened this issue 1 year ago • 1 comments

At the time of writing, the 0.2.x branch of smart-open.nvim produces a strange "phantom" entry, with an empty filename, seemingly containing raw ls command output. See the screenshot below: Screenshot from 2024-06-14 21-13-59 This weird entry appears in the Telescope entry regardless of the CWD. I can confirm that switching back to the 0.1.x branch of smart-open.nvim makes it magically go away, which means this bug is likely specific to the 0.2.x branch.

Below is the lazy.nvim configuration I used to configure telescope.nvim and smart-open.nvim:

Click to reveal full config
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
  vim.fn.system({
    "git",
    "clone",
    "--filter=blob:none",
    "https://github.com/folke/lazy.nvim.git",
    "--branch=stable",
    lazypath,
  })
end
vim.opt.rtp:prepend(lazypath)

require('lazy').setup({
  {
    "nvim-telescope/telescope.nvim",
    event = "VimEnter",
    dependencies = {
      "nvim-lua/plenary.nvim",
      {
        "nvim-telescope/telescope-fzf-native.nvim",
        build = "make",
        cond = function()
          return vim.fn.executable("make") == 1
        end,
      },
      {
        "danielfalk/smart-open.nvim",
        branch = "0.2.x",
        dependencies = { "kkharji/sqlite.lua" },
        config = true,
      },
      { "nvim-telescope/telescope-ui-select.nvim" },
      { "nvim-tree/nvim-web-devicons" },
    },
    config = function()
      require("telescope").setup({
        defaults = {
          file_ignore_patterns = {
            ".git/",
            "node_modules/",
            "target/",
            "%.gif",
            "%.jpeg",
            "%.jpg",
            "%.png",
          },
        },
        extensions = {
          smart_open = {
            match_algorithm = "fzf",
          },
          ["ui-select"] = {
            require("telescope.themes").get_dropdown(),
          },
        },
      })

      pcall(require("telescope").load_extension, "fzf")
      pcall(require("telescope").load_extension, "smart_open")
      pcall(require("telescope").load_extension, "ui-select")

      local builtin = require("telescope.builtin")
      vim.keymap.set("n", "<leader>sh", builtin.help_tags, { desc = "[S]earch [h]elp" })
      vim.keymap.set("n", "<leader>sH", builtin.highlights, { desc = "[S]earch [H]ighlight Groups" })
      vim.keymap.set("n", "<leader>sk", builtin.keymaps, { desc = "[S]earch [K]eymaps" })
      vim.keymap.set("n", "<leader>sf", builtin.find_files, { desc = "[S]earch [F]iles" })
      vim.keymap.set("n", "<leader>ss", builtin.builtin, { desc = "[S]earch [S]elect Telescope" })
      vim.keymap.set("n", "<leader>sw", builtin.grep_string, { desc = "[S]earch current [W]ord" })
      vim.keymap.set("n", "<leader>sg", builtin.live_grep, { desc = "[S]earch by [G]rep" })
      vim.keymap.set("n", "<leader>sd", builtin.diagnostics, { desc = "[S]earch [D]iagnostics" })
      vim.keymap.set("n", "<leader>sr", builtin.resume, { desc = "[S]earch [R]esume" })
      vim.keymap.set("n", "<leader>s.", builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' })
      vim.keymap.set("n", "<leader><leader>", builtin.buffers, { desc = "[ ] Find existing buffers" })
    end,
  },
})

To reproduce the screenshot above, try running the following command in Neovim:

:Telescope smart_open cwd_only=true theme=dropdown

Similar results can be seen if you use the Lua API to launch the picker.

ebkalderon avatar Jun 15 '24 01:06 ebkalderon

I believe this commit fixes the issue: https://github.com/danielfalk/smart-open.nvim/commit/99ea9c3cfc407d25204147dae93520ab6acc39a5

It's still only in the main and 0.1 branches, though.

wiseodd avatar Jul 15 '24 14:07 wiseodd

This is now in 0.2.x as well. Feel free to re-open if you come across it still.

danielfalk avatar Oct 15 '24 15:10 danielfalk