michal-h21 / vim-zettel

VimWiki addon for managing notes according to Zettelkasten method
MIT License
557 stars 73 forks source link

[FR] Zettel Open automatically filters title content instead of name of random alphanumeric note. #70

Open bangedorrunt opened 3 years ago

bangedorrunt commented 3 years ago

At the moment, Zettel Open is not helpful for note which is named based on random alphanumeric characters. I think it is more convenient to have an option allow to use Zettel Open which already filtered note title as output. A title could be recognized based on the following

Let's say I have a file named 35DFA979.md

For front-matter style:

---
title: loremipsum
...
---

or simply markdown header

# loremipsum

loremipsum
==========

Zettel Open will output content of loremipsum only

My concept could be illustrated by using RipGrep to filtered title content based on front-matter style:

command! -bang -nargs=* ZettelOpen call fzf#run(fzf#wrap(
      \ {'source': "rg -NIU --pcre2 -- '(?<=---\ntitle: ).*' | cut -d' ' -f2-"}, <bang>0))

I'm not very good at Vimscript in general speaking, I hope you could find this request interesting enough.

The purpose of naming file randomly is super useful that you don't have to think much about name of the note and don't have to worry about renaming it if you change of mind in future. But this could rise a problem that don't allow us to search note based on file name.

michal-h21 commented 3 years ago

ZettelOpen should show window with contents of actually selected file. It should look like this:

Snímek z 2020-09-23 14-23-50

(these are from my debugging archive, so it is best to not try to understand the contents :)

Do you want to get rid of filenames in the matched lines listing completely?

bangedorrunt commented 3 years ago

Yes, I'd like to get rid of that encrypted-look file name, no line number, no title:, only content of title. The output should be much clearer. For example

From

Rg> Lorem |
> 35DFA979.md:10:1:title: Lorem
> 35DFB909.md:10:1:title: Lorem Ipsum
> 351GA976.md:10:1:title: Lorem Ipsum Lorem
> ....

To

Rg> Lorem |
> Lorem
> Lorem Ipsum
> Lorem Ipsum Lorem
> ....

Also with --prompt option, we could change Rg> to Open Note: or something similar.

Open Note > Lorem |
> Lorem
> Lorem Ipsum
> Lorem Ipsum Lorem
> ....

Updated:

In addition, the purpose of Zettel Open is to open note, so I'm asking if it is logical to limit search to only front-matter style and/or markdown-header style only content? Technically, I'm talking about limiting search to first few lines of note. Because if I need to search for note content, we have Zettel Search for that purpose.

michal-h21 commented 3 years ago

I've just realized that filenames are actually important in FZF listings, the selected filenames are extracted from here.

bangedorrunt commented 3 years ago

I've just realized that filenames are actually important in FZF listings, the selected filenames are extracted from here.

Thank you for your update. I don't know but I think you could somehow hide the filenames in FZF. This screenshot is from neuron.vim

screenshot.png

They also use FZF for searching notes

rattletat commented 3 years ago

You can achieve this by installing ripgrep and putting this in your vim config:

let g:zettel_fzf_command = "rg --column --line-number --color=always --smart-case --regexp '^title: (.+)' --replace '$1'"
let g:zettel_fzf_options = ['--with-nth=-1']