zk-org / zk-nvim

Neovim extension for zk
https://github.com/zk-org/zk
GNU General Public License v3.0
503 stars 41 forks source link

Can't filter notes by path #51

Closed purefun closed 2 years ago

purefun commented 2 years ago

According to https://github.com/mickael-menu/zk/blob/main/docs/editors-integration.md#zklist

:ZkNotes <dir> {} can't filter by the <dir>, It lists all notes instead.

require('zk').pick_notes({ notebook_path = '<dir>' }) has the same result.

purefun commented 2 years ago

May the doc https://github.com/mickael-menu/zk-nvim/blob/main/doc/zk.txt#L323 should be updated.

there is no api in require('zk').

mickael-menu commented 2 years ago

TLDR: To filter notes by paths, use hrefs, for example :ZkNotes {hrefs = {"<dir1>", "<dir2>"}}.

ZkNotes takes a single argument: a dictionary of options. So :ZkNotes <div> {} is not correct.

To pass the first argument to zk.list, we added an notebook_path option in zk-nvim. From the README:

The options parameter can be any valid Lua expression that evaluates to a table. For a list of available options, refer to the zk docs. In addition, options.notebook_path can be used to explicitly specify a notebook by providing a path to any file or directory within the notebook.

However, usually you don't need to mess with notebook_path. It is not used to filter notes by path but to locate the notebook where the command is run. To filter notes by paths, you need to use hrefs instead.

May the doc https://github.com/mickael-menu/zk-nvim/blob/main/doc/zk.txt#L323 should be updated.

there is no api in require('zk').

Yes I think it should be require("zk.api").list instead. Do you confirm @kabouzeid? I'll update the doc if needed.

purefun commented 2 years ago

Thank you for your response. That's very helpful.

kabouzeid commented 2 years ago

@mickael-menu yes that's correct