danielfalk / smart-open.nvim Goto Github PK
View Code? Open in Web Editor NEWNeovim plugin for fast file-finding
License: MIT License
Neovim plugin for fast file-finding
License: MIT License
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 *')
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?
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!)
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 :)
Searching for anything shows no results, but if I use the up/down keys, I can see the preview change when I have enough space for the preview to fit.
Looks like it's this issue: nvim-telescope/telescope.nvim#2667
Which is solved here: nvim-telescope/telescope.nvim#2679
(not a smart-open.nvim issue)
I'd like the file to be opened with a tab drop because thats how I organize my files. This doesn't seem to support that event when trying to override default mappings in telescope config. Also show_scores
is not working for me when set to true.
Please support for this feature, which is already supported by the official Telescope.
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?
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.
I wonder if there is a way to configure so that either:
Again, thanks for the plugin I'm already enjoying the quickness when working on a large codebase.
Is it normal and If it is how can I put it into old_files
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
Seems very fast: https://www.reddit.com/r/neovim/comments/1446q8o/jfind_over_130x_faster_than_telescope_while_using/
The main thing i'm looking for:
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.
I know this isn't exactly related to smart-open.nvim, as this problem can occur in any input,
but is there documentation somewhere for disabling cmp in everything except the main code buffers?
atm, it seems cwd_only can only be set via
require('telescope').extensions.smart_open.smart_open({cwd_only = true})
but because of issue: #7
I'd like to set cwd_only to true in the telescope configuration:
https://github.com/danielfalk/smart-open.nvim#example-configuration
Is it possible to allow use of fzf native (https://github.com/nvim-telescope/telescope-fzf-native.nvim) instead of fzy-native? I used fzf-native this with telescope-frecency.nvim, but smart-open looks promising to address some of the pain points I had with telescope-frecency.
if i search only the file works:
if i search the path afterwards, doesn't works:
Tried with fzf and fzy and filename_first is true
.
--
With filename_first false works only using /
:
If i try to use space, doesn't work (i prefer space 100000x times):
Would be awesome to have a option to use space
as separator instead / for filename_first false
.
Is possible to do it?
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.
smart-open.nvim/lua/smart-open/util/virtual_name.lua
Lines 16 to 26 in ecaf1f2
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.
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 ๐ข
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)
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]])
Prefer fzy if it exists, otherwise use fzf:
match_algorithm = { "fzy", "fzf" },
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)
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)
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.
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
.
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
telescope-zf-native.nvim is a native telescope bindings to zf for sorting results, which is designed for better matching on filepaths than fzf or fzy. Not only the matching on filenames are prioritized, but also it supports space-seperated and orderless text component match (just like emacs's awesome orderless). It would be nice to support this!
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.
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) :)
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
.
arguably it makes the plugin less "smart" but if cwd_only exists then history_only can also exist :)
I'd like to close the telescope prompt with C-c
, which is the default behavior of Telescope. It would be nice if there could be an option to disable the C-c
mapping in smart-open.nvim.
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
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.
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:
EDIT: Actually, for this second issue, it seems that it's triggered by a warning: ๐ฅ example
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>
I switched to fzf-lua since it was much faster at finding things than telescope. Would it be possible to integrate with the plugin? https://github.com/ibhagwan/fzf-lua
This is what my current fuzzy finder looks like:
atm, the things I like are:
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
๐
Regarding the README, a simpler mapping exists:
vim.keymap.set("n", "<leader><leader>", require("telescope").extensions.smart_open.smart_open)
Is it possible to also add historical files independent from the working directory?
Thanks!
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
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:
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:
and this time, I have no idea how I might fix it myself :(
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
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)
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}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.