Giter Club home page Giter Club logo

vim-zettel's Introduction

The vim-zettel package

This is a Vim plugin that implements ideas of the Zettelkasten method using Vimwiki. It supports both Vimwiki and Markdown syntaxes.

Main features:

  • customizable filenames (date and time, title, consecutive numbering)
  • links always show titles, regardless of the actual filename
  • fulltext support using FZF for searching and hyperlinking
  • search your Zettelkasten from LaTeX or Markdown documents and insert selected notes to the document
  • template support
  • automatically updated tag index
  • backlinks

You can read the full documentation using

:help vim-zettel

command in Vim after package installation.

Install

Using Vundle:

Plugin 'vimwiki/vimwiki'
Plugin 'junegunn/fzf'
Plugin 'junegunn/fzf.vim'
Plugin 'michal-h21/vim-zettel'

Using vim-plug

call plug#begin()
Plug 'vimwiki/vimwiki'
Plug 'junegunn/fzf'
Plug 'junegunn/fzf.vim'
Plug 'michal-h21/vim-zettel'
call plug#end()

Silver Searcher is used for searching in the notes by default. The used command can be changed by setting the g:zettel_fzf_command variable.

Usage

Vim-zettel adds some commands and mappings on top of Vimwiki. See Vimwiki documentation on how to set up a basic wiki and navigate it.

Known issues

Related packages

The following packages may be useful in conjunction with Vimwiki and Vim-zettel:

  • Notational FZF - fast searching notes with preview window. Similar functionality is now built in in Vim-Zettel using :ZettelOpen command.

To search in the Zettelkasten, set the following variable with path to the Zettelkasten direcory in .vimrc:

let g:nv_search_paths = ['/path/to/zettelkasten/dir']
  • Vimwiki-sync - automatically commit changes in wiki and synchronize them with external Git repository.

vim-zettel's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vim-zettel's Issues

What about rebuild all tags?

VimwikiGenerateTagLinks creates or updates already created tags list, but ZettelGenerateTags only create new list. Maybe you can add something about ZettelRebuildTags for updating already created list, it would be very cool!

Network graph

Take this as a feature request please. I wonder if it is possible to create a plugin etc. to draw a usable graph of the network of all notes based on the links. I saw this on the foambubble project.

Not an editor command: ZettelNew

So I have this plugin installed
Screen Shot 2020-03-28 at 8 11 40 PM

But whenever I try to use the :ZettelNew command in either plain vim or within vimWikiIndex, I get "Not an editor command: ZettelNew"

Is there additional configuration that I need to add to make this work?

Screen Shot 2020-03-28 at 8 13 29 PM

error on :ZettelCapture

When I try to invoke :ZettelCapture on a file I get the following error:

Vimwiki Error: Wiki 1 is not registered in g:vimwiki_list!

This happens whether I invoke it from the command line via:

vim -c ZettelCapture filename

Or inside of of vim.

Backlinks bug

One problem I have had using this command is the following. If file A points to file B and I run :ZettelBackLinks in file B, a link to file A will appear in the end of file B, which is fine. However, if I run :ZettelBackLinks in file A, it will also show file B in its backlinks, but it is an artificial backlink.

Worse yet is that, if I remove the link from A to B in the body of the note, the links will remain in the Backlinks section.

Is it possible to modify the command so that it ignores links that appear after the Backlinks section?

Originally posted by @brunopc in #12 (comment)

ZettelOpen and ZettelSearch fail because of an "Error running fzf..."

I tried starting with a fresh Vim configuration, reinstalling Vundle, fzf, fzf.vim, Vimwiki, and Vim-Zettel and rebuilding my configuration from scratch. I also tried configuring the g:zettel_fzf_command variable with "rg --column --line-number --ignore-case --no-heading --color=always " as I have both fzf and rg on my system and set the g:nv_search_paths variable to the location of my zettelkasten. Nothing seems to make a difference.

T not working to yank the link

Hi,
Everything works great except T to yank the current zettel as a md link. Nothing happens when I press T.

I'm not sure what kind of info to give you to help.

Template not applied when using ZettelNew

.vimrc

Plug 'vimwiki/vimwiki'
Plug 'michal-h21/vim-zettel'
let g:vimwiki_list = [{'path': '~/SynologyDrive/zettelkasten/', 'ext': '.txt'}]
let g:zettel_options = [{'template' : '/Users/adam/.vim/zettel_templates/default.tpl'}]
let g:zettel_format = "%raw_title"

I'm using the .txt extension here so I can easily view the files on my phone using the Synology Drive app. The files themselves are in vimwiki syntax.

default.tpl

= %title =

When using :ZettelNew Something a file named Something.txt is created, but the contents are using the default template:

%title Something
%date 2020-08-05 18:01


vim-zettel initial setup is broken

I tried to setup vim-zettel plugin following the README.md

I've got following plugins installed with Vundle
" My Plugins |
Plugin 'VundleVim/Vundle.vim' |~
Plugin 'vimwiki/vimwiki' |~
Plugin 'junegunn/fzf' |~
Plugin 'junegunn/fzf.vim' |~
Plugin 'michal-h21/vim-zettel'

$ cat .vimrc | grep -v ^\" | grep -v ^$
set nocompatible              " be iMproved, required
filetype off                  " required
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
Plugin 'vimwiki/vimwiki'
Plugin 'junegunn/fzf'
Plugin 'junegunn/fzf.vim'
Plugin 'michal-h21/vim-zettel'
call vundle#end()            " required
filetype plugin indent on    " required
let g:vimwiki_list = [{'path':'~/vimwiki/','ext':'.md','syntax':'markdown'}, {"path":"~/scratchbox/vimwiki/wiki/"}]

When I trying to type :Zettel I can see only ZettelCapture and ZettelInsertNote options.
According the documentation there are should be more available commands
Also typing :ZettelNew returns:
E492: Not an editor command: ZettelNew

I think I missed something during initial setup but I can't see any clues at the README.md

Unable to follow any links.

After resolving vimwiki/vimwiki#987
I'm bringing this here. I cannot follow links when this plugin is enabled, but when I removed it the ability to follow links returned.

I'm somewhat clueless to speculate, but its happening.

ZettelNew Generate error

Hello, I've been using your awesome plugin and I make some settings for my workflow. After the last update when I want to generate a New Zettel this error echoes:

new zettel: 20200628212841-prueba2                                                                                                                   
Error detected while processing function zettel#vimwiki#zettel_new[23]..zettel#vimwiki#prepare_template_variables[3]..zettel#vimwiki#get_link[1]..zettel#vimwi
ki#get_title:
line    3:
E484: Can't open file 20200628212841-prueba2.md
Error detected while processing function zettel#vimwiki#zettel_new[23]..zettel#vimwiki#prepare_template_variables[7]..<SNR>121_read_footer:
line    1:
"20200628212841-prueba2.md" [New] 17L, 124C written

My settings in my .vimrc are:


" Zettel Vim
	let g:vimwiki_list = [{"path":"~/Documents/Zettelkasten/", 'auto_tags': 1, 'auto_toc': 1, 'syntax': 'markdown', 'ext': '.md'}, {"path":"~/Documents/Zettelkasten/"}]
	let g:vimwiki_use_mouse = 1
	let g:vimwiki_auto_chdir = 1
	let g:zettel_fzf_command = "rg --column --line-number --ignore-case --no-heading --color=always "
"	let g:zettel_options = [{},{'front_matter' : {'tags' : ''}, 'template' :  '~/Templates/zettel.tpl'}]
	let g:zettel_options = [{"template" :  "~/Templates/zettel.tpl"}]
	let g:zettel_format = "%Y%m%d%H%M%S-%title"
	" inoremap [[ [[<esc>:ZettelSearch<CR>
	imap <silent> [[ [[<esc><Plug>ZettelSearchMap
	nmap gZ <Plug>ZettelReplaceFileWithLink
	" xnoremap z :call zettel#vimwiki#zettel_new_selected()<CR>
	xmap z <Plug>ZettelNewSelectedMap
	nnoremap <leader>zn :ZettelNew<SPACE>
	nnoremap <leader>bl :VimwikiBacklinks<cr>
	nmap <leader>T <Plug>ZettelYankNameMap
	nnoremap <leader>zl :ZettelSearch<cr>
	nnoremap <leader>gt :VimwikiRebuildTags!<cr>:VimwikiGenerateTagLinks<cr><c-l>
	nnoremap <leader>O  :ZettelOpen<cr>


" Pandoc
	au FileType vimwiki call pandoc#completion#Init()
	let g:vimwiki_filetypes = ['pandoc', 'markdown', 'textile']
	let g:vimwiki_folding = 'custom'
	let g:pandoc#filetypes#handled = ["pandoc", "markdown", "textile"]
	let g:pandoc#folding#fdc = 0
	let g:pandoc#folding#level = 999
	let g:pandoc#folding#mode = 'stacked'
	let g:pandoc#modules#enabled = ['folding', 'command', 'bibliographies', 'completion']
	let g:pandoc#biblio#use_bibtool = 1
	let g:pandoc#completion#bib#mode = 'citeproc'
	let g:pandoc#biblio#bibs = ["/home/ivanvg/Documents/biblio.bib"]

I'm using VimWiki, vim-pandoc and vim-zettel. Maybe the error is related to Plug Conflicts.

My zettel plugin is:

---
title: "%title"
author:
date: "%date"
year:
tag:
---



Backlinks: %backlink
----
%footer

Thanks in advance

Tags

Thank you @michal-h21 for creating the plugin. I recently learned about zettlekasten method and exploring the plugin.
I was exploring the tags command but using ZettleGenerateTags doesn't generate any tags.I am confused about its usage.
It would be helpful if you share some example or workflow. eg. Adding tags manually to a zettle.

ZettelInbox not reporting all unlinked pages

Despite having several new, unlinked Zettel files, :ZettelInbox is only generating this for me:

# Unlinked notes
[index](index)

I'm using nvim, and my (relevant) .config/nvim/init.vim is:

let g:vimwiki_list = [
    \{'path': '/path/to/wiki/', 'syntax': 'markdown', 'ext': '.wiki'}
  \]

" ## vim-zettel
" Filename format. The filename is created using strftime() function
let g:zettel_format = "%Y%m%d-%H%M"

" command used for VimwikiSearch 
" possible values: "ag", "rg", "grep"
let g:zettel_fzf_command = "ag"

Open Source License?

Thanks for this plugin, it's been fabulous to use and has really changed how I work.

Do you have any plans to release it under an open source license (in a LICENSE file or README.md) for others to contribute?

Support backlinks for another type of anchors

Thank you for this great work!

According to vimwiki's description of anchors, every header, tag, and bold text can be used as anchors.
The VimwikiBacklinks command can list all of these types of anchors. However when using ZettelBackLinks , it seems only full links without # are recognized and generated below the Backlinks section.

Output of VimwikiBacklinks
zettel1

And output of ZettelBackLinks
zettel2

Links of this form [[title#bold text]] are ignored. A support of titles and bold texts may allow fine-grained references between notes.

FR: only search wiki files with the right extension

I have some css/js files (and some codes) in the wiki directory because I need to generate a website from it. So when searching for a zettel, these files are also listed.

screenshot

It would be nice if vim-zettel could filter files by the ext field in g:vimwiki_list

I'm unable to acces any vimwiki mappings and suspect this is the issue...

No mappings for this plugin and the vimwiki plugin are loading for me, although functions and otherwise appear to work which makes doing anything a gigantic pain.

The only clue I have now is this from dein log:

Error generating helptags:
Vim(helptags):E154: Duplicate tag "g:vimwiki_markdown_link_ext" in file /~/.cache/dein/.cache/init.vim/.dein/doc/zettel.txt
function dein#util#_check_vimrcs[15]..dein#recache_runtimepath[1]..dein#install#_recache_runtimepath[19]..<SNR>150_helptags, line 12

Any suggestions or help?

Updating title on save?

Thanks for your work on this!

Is there a way to update the %title bit of the filename on save?
(When using let g:zettel_format = "%y%m%d-%H%M-%title")

Wiki link style

vimwiki creates [[202005011153 Vimwiki]] link style, but vim-zettel [202005011153 Vimwiki](202005011153 Vimwiki). Is this expected behavior?
I put this in my init.vim:

let g:vimwiki_list = [{'path': '~/Dropbox/D-Downloads/vimwikitest/',
                        \ 'syntax': 'markdown', 'ext': '.md',
                        \  'maxhi': 1 }]

use random id to name the file

it'd be great if you could add feature allow us to create file using random id with optional length (prefer 7-8).

this could be done using mktemp XXXXXXX.md for example

note: mktemp in macOS doesn't have --suffix option

Expand Vim doc

It would be nice to update the Vim documentation with information from README.

No possibility to generate markdown friendly links

I would like my zettel to be available on github. So I have my vimwiki configured with let g:vimwiki_markdown_link_ext = 1
and it generates links like the following [title](link.md) so I can use these links when commiting raw files on github.
But it seems that there is no way to set it up for vim-zettel. It generates links like that: [200716-1536](200716-1536)
@michal-h21 could you please let me know if it's possible to configure. Thanks!

FZF rg integration not working

Looks like when trying to use the [[ search mapping with rg instead of ag there is an undefined function error calling the fzf plugin.

Screen Shot 2020-03-09 at 12 53 43 PM

Steps to reproduce:

  1. let g:zettel_fzf_command = 'rg' in vimrc
  2. Try to use the [[ key map to create link to another Zettel

I'm not sure how the fzf plugin works, but I'd be happy to take a look or help debug it.

Bad behavior generating new zettel when there is a dot in the name (double heading and backlinks)

While selecting a text and creating a new zettel, this happened:

image

I manage to isolate the problem (the dot). To reproduce follow these steps:

  1. Write any text inside a zettel whit a dot somewhere, for example:
    A Concise Introduction to Logic - Patrick J. Hurley
    image
  2. "V" to select the entire line, and "z" to create a new zettel:
    image
  3. Repeat step 2 (inside the generated zettel) but with any text that you want and this will show up:
    image
  4. hit enter and this is the zettel generated:
    image

It does not matter what the title says as long as there is a dot somewhere.

Setup for markdown and issue creating new zettel

Thanks for creating this repo. I plan to start using vim for a zettelkasten and this looks ideal to add the necessary additional functionality to vimwiki.

I was wondering in terms of basic setup whether it was possible to modify a variable so that new links are in markdown syntax rather than the default for vimwiki? Additionally, when creating new zettels if I have the following text:

this is a test

and select 'is' in visual mode - pressing z while creating a new zettel with only 'is' as the title, the rest of line is erroneously included in the link. Resulting in:

this [[180319-2212|is a test]]

Searching for titles

Not sure if this is already implemented, but it'd be nice to search through files (something like Ctrl-P but which also works with titles) like [[ or ZettleSearch does currently, but instead of inserting a link, open it instead.

I can use Ctrl-P if I have %title in the filename, but I'd rather not go that way.

(Edit): :Ag works as expected if vim is opened from the same dir as the wiki, and not when using the -c VimwikiIndex command.

Support for vim-plug

I was wondering if support for installing with vim-plug was possible.
For now vim-zettel can only be installed with Vundle, right?

Vimwiki removed VimwikiGet function

We use the VimwikiGet function to get retrieve various information about the wiki. It seems that this function is no longer available in Vimwiki, there are various vimwiki#vars# functions instead.

Generate outline of child notes

It would be nice if it was possible to generate outline of child notes of the current note. Possible caveat: when the note has backlink to the parent note, it is not possible to differentiate it from child notes. This may lead to outline that contain the whole Zettelkasten, which is not really desirable.

ZettelNew not using template file when not created from a word

ZettelNew does not use the template file when not created from an existing word/page (i.e. there is no backlink.)

Looks like that's a known issue based on a comment in autoload/zettel/vimwiki.vim in function! zettel#vimwiki#zettel_new(...):

variables are available only when this function is called from zettel_new_selected

...
let template = zettel#vimwiki#get_option("template")
if !empty(template)
  let variables = get(a:, 2, 0)
  if !empty(variables) " HERE is the check that fails
    call zettel#vimwiki#expand_template(template, variables)
  endif
endif
...

Originally posted by @Laptop765 in #27 (comment)

Additional template options for new zettels

I was wondering whether it would be feasible to add options to allow users to modify the default template for new zettels. For example, currently when a new zettel is created it generates a YAML with title and date. It would useful if users could specify in .vimrc a list of any additional items to include in the YAML (e.g. tags) as well as another list for any section headers to automatically add with specified header level (e.g. # or ##) and 1-2 new lines separating them. For example, I try to ensure every zettel has a "Related" section for links to related zettels and a "References" section for any books, journal articles, and so on referenced in the zettel. Would be handy if there were automatically added to any new zettel created.

Delete notes doesn't delete tags

When deleting a note using vimwiki's \wd command the corresponding entry in the .tags file doesn't get deleted which gives an error when running ZettelGenerateTags afterwards.

ZettelBackLinks error

Thanks for this cool plugin! I'm experiencing an issue where VimwikiBacklinks correctly shows backlinks, but when I run ZettelBackLinks I get:

Error detected while processing function zettel#vimwiki#backlinks[14]..<SNR>127_insert_link_array:
line    2:
E119: Not enough arguments for function: vimwiki#base#update_listing_in_buffer

Any thoughts? The same thing happens for ZettelGenerateLinks (VimwikiGenerateLinks works).

FZF Search command being overwritten

First of all, just wanted to say thanks for making this! I just recently found out about ZettelKasten and wanted to give it a shot. As a long time vimwiki user, I was trying to figure out how to adapt it to work for this new method.

It looks like the g:zettel_fzf_command variable is overwritten in the plugin.
When setting let g:zettel_fzf_command = 'rg' in my vimrc ag is still used.

I think wrapping the setting of this variable in a conditional should prevent that.

I can open a PR to address this if you're open to it.

Error on :ZettelNew

I have installed and made the configuration as readme file says, but when I enter into the vimwiki and type the command :ZettelNew it appears: "E492: Not an editor command: ZettelNew".
I'm on neovim rather than vim itself.
I know that it should be a silly question. Beg your pardon.

Regards

Backlinks

Some other plain-text Zettelkasten plugins have the ability to see all backlinks for the a note.

Could vim-zettel implement something like this?

Motivation or Tutorial?

First of all, thanks for the effort you put into this project. I have only learned about the Zettelkasten method the day before yesterday, but this seems incredibly useful.

Having said that, I had some difficulties getting started with vim-zettel.
There are some issues you inevitably encounter when trying to use :ZettelCapture (#10) or :ZettelNew (#27) with a user-provided template. There are workarounds, but already I have to wonder if I am using vim-zettel as intended, since surely there must be some "happy path" where everything works fine if you stick to the intended workflow.

In this regard, some tutorial would be really helpful.

Furthermore, there seems to be quite some overlap between vim-zettel und vimwiki. If all I wanted to do is create and keep updating "some knowledge graph" - because right now, with my limited knowledge, this is what I perceive the Zettelkasten to be - the vimwiki functionality already seems to cover that, albeit as a newcomer I can't appreciate the finer details. What does vim-zettel buy you in addition?

ZettelNew default header

ZettelNew's default header used to generate something like:

---
title: Testing ZettelNew
date: 2020-03-10 12:16
---

But now generates something like:

%title Testing again
%date 2020-03-13 14:31

Could we reset the default to the original style, or at least remove the leading %s if the ---s are no longer wanted?

Order of additonal options in the frontmatter of new notes cannot be changed

I would like to insert the preamble some additional options such as default bibtex file etc. My .vimrc setting is the following:

let g:zettel_options = [{"front_matter" : { "tags" : "", "csl": "'/references/apa-tr.csl'", "bibliography": "'/references/zettel.bib'" }, "template" :  "~/.vim/templates/zettel.tpl"}]

It does not matter in what order I put it, the preamble comes out the same:

---
title: Title
date: 2020-08-29 20:25
csl: '/references/apa-tr.csl'
tags: 
bibliography: '/references/zettel.bib'
---

Whereas, I want the tags: at the end:

---
title: Title
date: 2020-08-29 20:25
csl: '/references/apa-tr.csl'
bibliography: '/references/zettel.bib'
tags: 
---

I tried the following with no success:

let g:zettel_options = [{"front_matter" : { "csl": "'/references/apa-tr.csl'", "bibliography": "'/references/zettel.bib'", "tags" : "" }, "template" :  "~/.vim/templates/zettel.tpl"}]

It seems that it sorts additional options by the number of characters in option names (may be not). How can I force it to put tags: at the end of the preamble?

template not applied when filename begins with a letter

I changed the default file name to put the date at the end of the file name. After that I noticed that the template is not automatically applied when creating a new zettel. I did some experimenting and found that if I put a number at the beginning of the file name, the template works again.

These zettel names will bring in the template automatically:

[[2020-08-26-test-z|test-z]]
[[1test-it-2020-08-26|1test-it]]

These don't:

[[test-it-2020-08-26|test-it]]
[[-test-it-2020-08-26|-test-it]]

I would like to have the words come first in the file name, any ideas on how to get that to work?

Error expanding template

After updating to the latest version of vim-zettel I am now experiencing an error when creating new zettels. I have not changed my vim config or my template file.

Error detected while processing function zettel#vimwiki#zettel_new_selected[8]..zettel#vimwiki#zettel_new[25]..zettel
#vimwiki#expand_template:
line    3:

My vimrc has:

let g:zettel_options = [
                         \{},
                         \ {"front_matter" : {"tags" : ""}, "template" : "~/Dropbox/notes/zettel/template.tpl"}

Please let me know what additional info you need to help identify what is causing the error.

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.