Comments (12)
I've been thinking about this, and I don't see a clean way to do it with fzf. However, skim
has an interactive mode that seems promising, and I've been writing up an experimental version of this plugin that uses it.
from notational-fzf-vim.
Here is my final solution for a notational velocity clone in a single command, just run it in the directory with your notes.
sk --ansi -i -c "(rg --files | rg -S \"{}\" & rg -S -l \"{}\" & echo {}.txt) | sort | uniq" --bind 'ctrl-x:execute(vim {})+abort,enter:execute(vim {})+abort' --preview "preview.sh {}" --preview-window down:wrap
It searches filenames and the file contents, avoids showing the same note multiple times, shows previews using the fzf preview script, opens notes in vim and ctrl+x creates and opens a new note in vim with the search query.
This is beautiful. I made a slight change to:
- provide full path of
preview.sh
- have vim jump to the line containing the search query (technically the "command query" per skim documentation)
sk --ansi -i -c "(rg --files | rg -S \"{}\" & rg -S -l \"{}\" & echo {}.txt) | sort | uniq" --bind 'ctrl-x:execute(vim {}),enter:execute(sterm={cq} && vim -c "/$sterm" {})+abort' --preview "$HOME/.vim/plugged/fzf.vim/bin/preview.sh {}" --preview-window down:wrap
from notational-fzf-vim.
Here is my final solution for a notational velocity clone in a single command, just run it in the directory with your notes.
sk --ansi -i -c "(rg --files | rg -S \"{}\" & rg -S -l \"{}\" & echo {}.txt) | sort | uniq" --bind 'ctrl-x:execute(vim {})+abort,enter:execute(vim {})+abort' --preview "preview.sh {}" --preview-window down:wrap
It searches filenames and the file contents, avoids showing the same note multiple times, shows previews using the fzf preview script, opens notes in vim and ctrl+x creates and opens a new note in vim with the search query.
from notational-fzf-vim.
I agree it shouldn't search just by name, it should definitely also search contents.
Right now, though, long notes totally take over the search results list.
In the OP's example any other files matching "broad" will never show up (or at least be "below the fold"). I would also really like it if it shows a line per match, but now I'm getting every line, regardless of match, in case the title matches...
from notational-fzf-vim.
Very glad this is still being considered. Skim seems like the right direction. If I run the NV as is for a simple query, the list is too large to be manageable:
But if I use skim in interactive mode, and tell ripgrep to only print the paths with at least one match via the -l flag:
sk --ansi -i -c 'rg -i -l --color=always --line-number "{}"' --preview "$HOME/.vim/plugged/fzf.vim/bin/preview.sh {}" --preview-window down:70%
I'm able to actually scan the list easily and use the preview window to quickly scan my entries.
This seems to be more in line with the original functionality of Notational Velocity.
That said, one of the ironic things is about this method is that it doesn't seem to search the actual filename, so you can miss entries if you search a term that is in the filename but not within the note itself. I couldn't find a way around this other than including the filename within the note itself. In the context of the plugin you just automate the inclusion of the filename during note creation. Something like :1put! =expand('%:t:r')
to grab the filename and add it as the first line? If someone knows a method to search both the contents and the filename, that would be ideal.
So I'm not sure how to integrate this into the plugin. I've been playing around with it just passing the sk
command to vim "$()"
- but would obviously like to integrate it into the plugin. @alok is this close to the method you are using for your experimental version?
from notational-fzf-vim.
from notational-fzf-vim.
i do like the direct jumping to the correct line! that is awesome. but when i search for a note name, i would like it to be unique.
ill keep trying it out and see if i can figure out something. thank you :)
from notational-fzf-vim.
from notational-fzf-vim.
You could probably use folding (similar to what nou.vim and other folding plugin does).
so it only fold the most duplicated query into either the most redundant or the filename.
Although, not sure how it would be possible with fzf, unless you redraw the tui in vim or something.
from notational-fzf-vim.
Ok, here's a solution that searches both the filename and the file contents, and avoids showing the same note multiple times:
sk --ansi -i -c '{ rg --files | rg -S "{}" & rg -S -l --color=always --line-number "{}" }' --preview "$HOME/.vim/plugged/fzf.vim/bin/preview.sh {}" --preview-window down
Skim seems to be a drop in replacement for fzf, so I changed the command! -nargs=* -bang NV call fzf#run(fzf#wrap({...
section to command! -nargs=* -bang NV call skim#run(skim#wrap({...
which works, but when you add the -l
files with matches flag the plugin fails to return results.
from notational-fzf-vim.
Great idea @zrwitter re jumping to the line containing the search query!
I've been using this NV clone for the past month and a half and it's been painless.
The one feature I still want to integrate is a way to score the results by the date the files were edited. I saw the --tiebreak function in skim but there didn't seem to be a criteria for it there.
Ideally, all things being equal, I'd like the first search results to be the most recently edited file since usually you're working on a project and using the same files again and again. This was how notational velocity worked I believe.
I contacted the author of skim to inquire if he had any ideas but never heard back. If anyone has a spark of inspiration on an approach, would love to see possible solutions.
from notational-fzf-vim.
Here is my final solution for a notational velocity clone in a single command, just run it in the directory with your notes.
sk --ansi -i -c "(rg --files | rg -S \"{}\" & rg -S -l \"{}\" & echo {}.txt) | sort | uniq" --bind 'ctrl-x:execute(vim {})+abort,enter:execute(vim {})+abort' --preview "preview.sh {}" --preview-window down:wrap
It searches filenames and the file contents, avoids showing the same note multiple times, shows previews using the fzf preview script, opens notes in vim and ctrl+x creates and opens a new note in vim with the search query.This is beautiful. I made a slight change to:
- provide full path of
preview.sh
- have vim jump to the line containing the search query (technically the "command query" per skim documentation)
sk --ansi -i -c "(rg --files | rg -S \"{}\" & rg -S -l \"{}\" & echo {}.txt) | sort | uniq" --bind 'ctrl-x:execute(vim {}),enter:execute(sterm={cq} && vim -c "/$sterm" {})+abort' --preview "$HOME/.vim/plugged/fzf.vim/bin/preview.sh {}" --preview-window down:wrap
This is great thanks @zrwitter @dclift.
Out of curiosity, is there a way to replicate the "highlighting" of the search term in the preview window? I.e. left side you can see where "Fruitional View" is highlighted in the file that contains the term.
Also, it seems like the jump to the line containing search query functionality is case sensitive. So while it'll find the file with fruitional view, when you enter the file it'll display an error "E486: Pattern not found: fruitional view" before opening the file and starting at the top, since in the text the term is actually Fruitional View.
from notational-fzf-vim.
Related Issues (20)
- Sort results by recent file access HOT 2
- fzf colors and preview HOT 5
- Sanitize/adjust file name on create_note_key HOT 3
- Some files in search path not appearing? HOT 11
- Support "window" position HOT 1
- Struggling to understand how it chooses which line to open the file in
- [suggestion] An option to set a alternative separator when saving new notes HOT 1
- Error on MacVim when choosing the highlight HOT 1
- E492 :NV not an editor command HOT 2
- README.md should explain that `g:nv_main_directory` must also appear in `g:nv_search_paths`
- Force fzf-vim to pass nohidden option to --preview-window to override shell defaults
- Question : pls explain note handler HOT 1
- help confirm mapping HOT 2
- Some files are missing (too many?) HOT 5
- "Command failed" error
- Is there a way to make a single key open or create a note depending on if results are found?
- Proposal to become mantainer of the project HOT 3
- windwos环境上gvim中使用出现Command failed" error
- Notational fzf not finding all results during TMUX session when starting from CLI using an alias HOT 2
- I really liked this tool, but I see lack of maint ? Any alternatives ? I would have supported it if I knew Python or vimscript. HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from notational-fzf-vim.