Git Product home page Git Product logo

smart-open.nvim's Issues

Can't search with spaces between search keywords?

If I'm searching for a file which I don't remember the exact name of, I usually enter space separated words which I think are part of the name.

For example, if the file is called timeline-item-person.ts I might search for person item.

In the standard Telescope find files, this will get a match, however it seems that smart open needs me to use the exact word separator which the files use on disk (ie. -), for example, neither of the following will find any files for the above mentioned file name: person item, item person.

Is this expected?

(Also, thanks for the great add-on, love it!)

Inconsistent search result keyword highlighting?

Telescope built in find files will highlight all partial matches in the file name, for example if I search person item then the search result will have the following highlights (bold used to indicate highlight): timeline-**item**-**person**.

However, smart open highlight behaves much more erratically, for example, see this screenshot, I see some fragments of the search term highlighted, but not others.

Screenshot 2023-01-31 at 20 47 35

Error when starting

Below errors are thrown when I start the smart open through Telescope

Error executing vim.schedule lua callback: .../smart-open.nvim/lua/smart-open/util/priority_insert.lua:9: attempt to compare nil with number                                          
stack traceback:                                                                                                                                                                      
        .../smart-open.nvim/lua/smart-open/util/priority_insert.lua:9: in function 'priority_insert'                                                                                  
        ...m/lua/telescope/_extensions/smart_open/finder/finder.lua:94: in function ''                                                                                                
        vim/_editor.lua: in function <vim/_editor.lua:0>                                                                                                                              

Weird thing is this only happen for this specific CWD while in other projects it's working fine.

I'm on the 0.2.x branch

space after filename is not working (should search for folder instead filename)

if i search only the file works:

image

if i search the path afterwards, doesn't works:

image

Tried with fzf and fzy and filename_first is true.

--

With filename_first false works only using /:

image

If i try to use space, doesn't work (i prefer space 100000x times):
image

Would be awesome to have a option to use space as separator instead / for filename_first false.

Is possible to do it?

Telescope to_fuzzy_refine action not working

After starting a search with lua require('telescope').extensions.smart_open.smart_open(), the telescope action to_fuzzy_refine doesn't work and triggers the following warning:

[telescope] [WARN  20:13:41] /Users/user/.local/share/nvim/lazy/telescope.nvim/lua/telescope/pickers.lua:669: Finder failed with msg:  ...escope-fzf-native.nvim/lua/telescope/_extensions/fzf.lua:97: bad argument #1 to 'get_score' (cannot
convert 'number' to 'const char *')

Error on load extension

The error:

Error detected while processing :source (no file):                                                                                            
E5108: Error executing lua ...im/site/pack/packer/start/sqlite.lua/lua/sqlite/defs.lua:55: libsqlite3.so: cannot open shared object file: No such file 
or directory
stack traceback:
        [builtin#203]: at 0x55f830986100
        ...im/site/pack/packer/start/sqlite.lua/lua/sqlite/defs.lua:55: in main chunk
        [C]: in function 'require'
        ...m/site/pack/packer/start/sqlite.lua/lua/sqlite/utils.lua:252: in function '__index'
        ...nvim/site/pack/packer/start/sqlite.lua/lua/sqlite/db.lua:662: in main chunk
        [C]: in function 'require'
        ...im/site/pack/packer/start/sqlite.lua/lua/sqlite/init.lua:66: in function '__index'
        ...n.nvim/lua/telescope/_extensions/smart_open/dbclient.lua:27: in function 'new'
        ...smart-open.nvim/lua/telescope/_extensions/smart_open.lua:52: in function 'setup'
        .../start/telescope.nvim/lua/telescope/_extensions/init.lua:64: in function 'load_extension'
        [string ":source (no file)"]:11: in main chunk

How the plugin is installed:

    use {
        "danielfalk/smart-open.nvim",
        requires = {
            { "tami5/sqlite.lua" },
            { 'kyazdani42/nvim-web-devicons', opt = true },
        }
    }

relevant part of my after/plugin/telescope.lua

telescope.load_extension("smart_open")
vim.keymap.set("n", "<Leader><Leader>", telescope.extensions.smart_open.smart_open)

Devicons are uncolored

here is how it looks like with smart open:
Pasted image 2023-01-14 22 19 44

and here how it looks like with the other telescope pickers:
Pasted image 2023-01-14 22 20 18

Path name is truncated (and inconsistently)

It seems sometimes the filepath is truncated, for example, I have a file in tools/foobar_query_benchmark/main.go
And when I type in bench/main I can find the file but the path was truncated. At the same time, other file with longer path doesn't get truncated.
image

I wonder if there is a way to configure so that either:

  1. Everything is truncated based on an consistent length limit, or
  2. Allow the user to disable the truncation

Again, thanks for the plugin I'm already enjoying the quickness when working on a large codebase.

Current buffer is excluded

Not sure if this is intended but it seems the file opened in the current buffer is excluded from the search result. While I understand the reason of doing so I'm still wondering if there is a way to toggle such behavior? I would like to just using the same keystroke to open any file at any time.

Thanks

Is there a way to get a preview?

This is what my current fuzzy finder looks like:
image
image

atm, the things I like are:

  • typing on top, results underneath
  • preview with tree-sitter highlighting
  • because of the preview thing, there is also a bit of responsiveness based on terminal shape/size

Custom highlight group for directories

Currently, the plugin uses the builtin highlight group Directory to highlight directories. Would you accept a PR that introduces a custom hlgroup such as SmartOpenDirectory (or any other name you might suggest) that would link to Directory by default? This would allow users to redefine the highlight only for the plugin, not globally, e.g. to a different hlgroup such as Comment.

Highlighting doesn't seem to work right when using fzf sorter

The fzf sorter seems to break when you have a whitespace in your search. it begins to highlight correctly, but as soon as you have a space you do not get both parts highlighted right.

As you can see below, it also breaks sometimes even on queries with no space for some reason:

no space:
image

space:
image

Dropping sqlite like telescope-frecency?

Hi,
Recently I saw that telescope-frecency has dropped the sqlite3 requirement, and since this plugin was inspired by that I wonder if it is considered to follow/borrow from it and drop this requirement as well.

I tried telescope-frecency and see it faster to startup as well, however I still like the "smart" search of this plugin.

Thanks for the plugin.

cwd_only including items outside working directory

          I found an issue, I _really_ need the search to be contained to the `cwd`. searching outside of the `cwd` has _only_ caused problems for me ๐Ÿ˜ข 

image

on the main branch,
this was enough to keep the search scoped to the cwd

nnoremap <C-t> :lua require('telescope').extensions.smart_open.smart_open({cwd_only = true})<CR>

is there a way to regain this narrowing of scope?

Originally posted by @NullVoxPopuli in #22 (comment)

Various installation issues

So first, in the installation instructions, the repo name seems to be wrong: "nvim-telescope/telescope_smart_open.nvim", should be danielfalk/smart-open.nvim.

Then when I restart nvim, I get this error:
Pasted image 2023-01-14 17 28 11

So it looks like fzy-native is required, even though the docs state that it's only optional. Well, I tried installing it nonetheless. But then I get this error:
Pasted image 2023-01-14 17 30 00

and this time, I have no idea how I might fix it myself :(

When no input, show recent files first

Hello
I believe that when we open a project, and just open :Telescope smart_open, the most "interesting" / "smart" choice we can have is the recent file rather than the files with the high score. But I understand it's a matter of opinion. (I think this is what vscode is doing) :)

Space in search prompt

Hey, cool plugin!

I was wondering, how the matching handles spaces in the search. I often use them to match different parts of the path of a files path, like this:

  • mat mod to match path/to/match/mod.rs
  • test sub ex to match path/test/submodule/example.rs

With smart open, there are no files shown at all in this case. In general, adding a space to the search, seems to result in no results at all.

As a workaround, I could type everything without a space and would get a result mostly expected.
But my muscle memory is somewhat used to that from other finders such as rofi.

Option to hide open buffer indicators

Really cool plugin. Thank you!
Similiar to oldfiles in telescope. Would be nice to have a configuration to hide the open_buffer_indicators. Personally I don't find it helpful. It might be just me :)

Add ability to pass in picker options through telescope setup

I would like to customize smart-open like so:

telescope.setup({
  extensions = {
    smart_open = {
      preview = { hide_on_startup = true },
      layout_config = {
        width = 0.65,
      },
      mappings = {
        i = {
          ["<esc>"] = require("telescope.actions").close,
        },
      },
    },
  },

Many plugins allow passing in these standard telescope picker options

Not all files are searchable?

I'm in a rather large monorepo, and it seems the max number of files indexed is 6505.

My monorepo has multiples of tens of thousands of files ๐Ÿ™ƒ

But anywho, I can type in full paths in to the smart-open box, and the file won't show up.


Update:

ah ha, I found this in the README:

max_unindexed (default: 6500)

Stop scanning the current directory when max_unindexed files have been found. This limit is in place to prevent performance problems when run from a directory with an excessive number of files under it.

So I need to make this something like 100_000 ๐Ÿ™ƒ

Devicons highlighting is broken on nvim nightly

Devicons with smart_open isn't highlighted whereas find_files does.

Minimal repro:

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

-- 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",
    "--single-branch",
    "https://github.com/folke/lazy.nvim.git",
    lazypath,
  })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  -- do not remove the colorscheme!
  "folke/tokyonight.nvim",
  -- add any other pugins here
  {
    "nvim-telescope/telescope.nvim",
    opts = true,
    dependencies = {
      {
        "danielfalk/smart-open.nvim",
        config = function()
          require("telescope").load_extension("smart_open")
        end,
      },
      "kkharji/sqlite.lua",
      "nvim-lua/plenary.nvim",
      "nvim-tree/nvim-web-devicons",
    },
    keys = {
      { "<leader>ff", "<cmd>Telescope smart_open<CR>" },
    },
  },
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

-- add anything else here
vim.opt.termguicolors = true
-- do not remove the colorscheme!
vim.cmd([[colorscheme tokyonight]])

mappings does not work

return {
  "danielfalk/smart-open.nvim",
  -- branch = "0.2.x",
  dependencies = {
    "kkharji/sqlite.lua",
    "nvim-telescope/telescope.nvim",
    { "nvim-telescope/telescope-fzf-native.nvim", build = "make" },
  },
  keys = {
    {
      "<leader>fs",
      function()
        require("telescope").extensions.smart_open.smart_open({
          prompt_title = "Smart Open",
          cwd_only = true,
          filename_first = true,
        })
      end,
      desc = "Smart Open File",
    },
  },
  config = function()
    local telescope = require("telescope")
    local hbac = function()
      vim.cmd("Telescope hbac buffers")
    end
    telescope.setup({
      extensions = {
        smart_open = {
          match_algorithm = "fzf",
          mappings = {
            i = {
              ["<C-g>"] = hbac,
            },
          },
        },
      },
    })
    telescope.load_extension("smart_open")
  end,
}

My customized <C-h> doesn't work. Seems the mapping is not registered.

In newly-visited projects, not all files are findable

I noticed this the most with ci.yml (GitHub Action file), as I hope around between projects.

My smart-open command is:

nnoremap <C-t> :lua require('telescope').extensions.smart_open.smart_open({cwd_only = true})<CR>

maybe there is some default filter I need to configure?

Increase result limit for the number of entries

Increase the result limit for the number of entries or provide a configuration option for it.

Rationale: It's useful to page up/down through the results sometimes.


For now, I have been manually overriding it via:

diff --git a/lua/smart-open/matching/multithread/create.lua b/lua/smart-open/matching/multithread/create.lua
index 0d07b4a..0a2650e 100644
--- a/lua/smart-open/matching/multithread/create.lua
+++ b/lua/smart-open/matching/multithread/create.lua
@@ -12,7 +12,7 @@ local function create_matcher(matching_algorithm, context)
   local slot_count = 4 -- threadpool thread count
   local last_processed_index = 0
   local top_entries = {} -- treat it as ascending (lowest relevance last)
-  local top_entry_count = 20
+  local top_entry_count = 1024
   local waiting_threads = 0
   local history_data_cache = {}

diff --git a/lua/smart-open/matching/multithread/process.lua b/lua/smart-open/matching/multithread/process.lua
index 08d769d..f881c64 100644
--- a/lua/smart-open/matching/multithread/process.lua
+++ b/lua/smart-open/matching/multithread/process.lua
@@ -1,6 +1,6 @@
 -- prompt, cancel_token, options, last_processed_index
 local function process(prompt, cancel_token, encoded_options, encoded_entries)
-  local result_limit = 20
+  local result_limit = 1024

   local ok, result = pcall(function()
     local options = vim.mpack.decode(encoded_options)
Also relevant
diff --git a/lua/telescope/_extensions/smart_open/finder/finder.lua b/lua/telescope/_extensions/smart_open/finder/finder.lua
index e4975fa..d27d61b 100644
--- a/lua/telescope/_extensions/smart_open/finder/finder.lua
+++ b/lua/telescope/_extensions/smart_open/finder/finder.lua
@@ -65,9 +65,9 @@ return function(history, opts, context)
     __call = function(_, prompt, process_result, process_complete)
       results = {}
 
-      if prompt == "" and #db_results >= 50 then
+      if prompt == "" and #db_results >= 200 then
         for _, result in pairs(db_results) do
-          priority_insert(results, 50, result, function(x)
+          priority_insert(results, 200, result, function(x)
             return x.base_score
           end)
         end
@@ -90,7 +90,7 @@ return function(history, opts, context)
           local to_insert =
             vim.tbl_extend("keep", { ordinal = entry.relevance, display = opts.display, prompt = prompt }, entry)
 
-          priority_insert(results, 50, to_insert, function(e)
+          priority_insert(results, 200, to_insert, function(e)
             return e.relevance or e.base_score
           end)

`Error executing luv callback` in a large project

whenever I execute

nnoremap <C-t> :lua require('telescope').extensions.smart_open.smart_open({cwd_only = true})<CR>

(aka Ctrl + t), I get this error:

Error executing luv callback:
...telescope/_extensions/smart_open/display/entry_maker.lua:94: attempt to perform arithmetic on local 'max_frecency_score' (
a nil value)
stack traceback:
        ...telescope/_extensions/smart_open/display/entry_maker.lua:94: in function 'entry_maker'
        ...m/lua/telescope/_extensions/smart_open/finder/finder.lua:34: in function 'on_insert'
        ...im/lua/telescope/_extensions/smart_open/file_scanner.lua:78: in function <...im/lua/telescope/_extensions/smart_op
en/file_scanner.lua:66>
        [C]: at 0x559809c92b5a
        [C]: in function 'pcall'
        ...ck/packer/start/telescope.nvim/lua/telescope/pickers.lua:381: in function 'find'
        ...pen.nvim/lua/telescope/_extensions/smart_open/picker.lua:59: in function 'start'
        ...smart-open.nvim/lua/telescope/_extensions/smart_open.lua:22: in function 'smart_open'
        [string ":lua"]:1: in main chunk}

5 second pause before opening

Hi, thanks for the great tool, I use it all the time. I'm having a problem where there's sometimes a ~5 second pause when trying to open the telescope buffer for smart-open.

It normally opens instantly. But then it will 'break' and go from then onward always have a 5 second delay before opening. So it's not like it's just randomly getting caught up whenever, it seems that's there's something very specific and permanent that must have changed to cause it to always have a delay.

My go-to solution is to delete the smart-open.sqlite3 file in case some bad data got written into it. But that doesn't seem to do it. My next thought, is could it be related to some bad data in my old-files list? Because when you delete smart-open.sqlite3 the next time it's launched the database is populated with data from the old files.

I've been using this plugin for about a year and I've come across this issue a few times. I've never worked out what's causing it or how I've fixed it. It's happened on both my Windows machine and my Linux machine.

Do you have any suggestions or ideas? Where can I start with debugging this?

Use default `TelescopePrompt` filetype

vim.api.nvim_buf_set_option(picker.prompt_bufnr, "filetype", "smart_open")

Any particular reason why this need to be set as smart_open filetype? Most extensions have TelescopePrompt filetype ignored to prevent weird interactions.

Changing this to other filetype just make more hustle for users to have manually ignore this filetype in other extension. For example autopairs.nvim

Error on 0.2 branch when opening and the picker list contains an entry with no name

I noticed this bug appearing recently, if the results list contains a directory then the result does not have a name, which seems to trigger the error message.

Screenshot 2023-05-10 at 07 58 19
Screenshot 2023-05-10 at 07 59 39


Also, more generally, when opening I often see the Press ENTER or type command to continue message and the picker isn't populated until I press enter, this is not accompanied by any error - I'm not sure if this is related and only seems to happen when opening for the first time:

Screenshot 2023-05-10 at 07 57 40

EDIT: Actually, for this second issue, it seems that it's triggered by a warning: ๐ŸŽฅ example

config method is required even with lazy.nvim

Hello I spent time trying to figure out why is the plugin was not working (:Telescope smart_open was not available).
I put:

 config = function()
    require"telescope".load_extension("smart_open")
  end, 

this line (from the section packer), in the lazy block, and it started to work.
I'm not a pro regarding the neovim package manager, but the config block might be required in lazy.nvim :)

ps: I use Lazy.nvim in the "lunarvim" context so it could have some magic happening

Crash related to Windows directory separtor

Thanks for making this, I'm finding it very useful.

On Windows I am getting a crash: attempting to perform arithmetic on a nil value "last"

Here is the code causing the issue.

function M.get_pos(path)
local last, penultimate, current
local k = 0
repeat
penultimate = last
last = current
current, k = path:find("/", k + 1, true)
until current == nil
return is_index_filename[path:sub(last + 1, path:len())] and penultimate + 1 or last + 1
end

The variable last is still nil at the end of the function because on Windows, the path separator is \ instead of /. If I changed "/" into "\\" the error is fixed.

So I believe that all we need to do is change the directory separator depending on if Windows or not.

SQLite error on first run

Hi, I got this error on first run. No error on subsequent run. Just reporting.

Error executing vim.schedule lua callback: .../.local/share/nvim/lazy/sqlite.lua/lua/sqlite/assert.lua:47: sqlite.lua: eval has failed to execute statement, ERRMSG: NOT NULL constraint failed: files.path
stack traceback:
	[C]: in function 'assert'
	.../.local/share/nvim/lazy/sqlite.lua/lua/sqlite/assert.lua:47: in function 'should_eval'
	...ntau/.local/share/nvim/lazy/sqlite.lua/lua/sqlite/db.lua:329: in function 'eval'
	...n.nvim/lua/telescope/_extensions/smart_open/dbclient.lua:49: in function 'update_file'
	...en.nvim/lua/telescope/_extensions/smart_open/history.lua:150: in function 'handle_open'
	...en.nvim/lua/telescope/_extensions/smart_open/history.lua:114: in function 'batch_import'
	...en.nvim/lua/telescope/_extensions/smart_open/history.lua:93: in function ''
	vim/_editor.lua: in function ''
	vim/_editor.lua: in function <vim/_editor.lua:0>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.