Coder Social home page Coder Social logo

zk-nvim'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

zk-nvim's Issues

"Attempt to index a nil value" after upgrading to `zk` 0.12.0

Zk seems to work fine yesterday; today I get this error:
Screenshot from 2022-12-09 07-09-57

I did some basic troubleshooting, remove zk-nvim from my plugins lua config, then reinstalled via packer. The error persists.

I followed the traceback to line 50 of ...zk-nvim/lua/zk/commands/init.lua

Screenshot from 2022-12-09 07-12-13

I am not sure if the LSP warning is an indication of the error, I'm not confident enough to troubleshoot Lua.

Neovim version: nightly
I'm not sure if relevant but might as well include additional info:
When I synced my plugins, there was a warning about breaking changes from a recent commit of nvim-treesitter. Unfortunately, I failed to record which commit it was, since I was not expecting an error to start my day.

I will continue to troubleshoot to the best of my ability but I am hoping for someone more knowledgeable to take a look

Auto rename file by note title on save

Hi, I want to auto rename the file based on note title on saving buffer, if title changed. And only rename if current buffer is a note.

Is there any buffer local flag which can tell if current buffer is a ZK note buffer?

Unknown zk LSP command: zk.link

Hi, I just discovered this plugin a few days ago and I love it! Thanks for your hard work on this plugin!

Everything works as expected except that when I execute the command ZkInsertLink or ZkInsertLinkAtSelection I get this error message:

Error executing vim.schedule lua callback: RPC[Error] code_name = InvalidRequest, message = "unknown zk LSP command: zk.link"

Here is my config for zk.nvim:

vim.env.ZK_NOTEBOOK_DIR= os.getenv('HOME') .. '/Notes'

require('zk').setup({
  picker = 'telescope',
})

and here is the info shown in :LspInfo

 Client: zk (id: 1, bufnr: [35, 8])
 	filetypes:       
 	autostart:       false
 	root directory:  Running in single file mode.
 	cmd:             zk lsp
 
 Client: zk (id: 2, bufnr: [35, 8])
 	filetypes:       markdown
 	autostart:       true
 	root directory:  Running in single file mode.
 	cmd:             zk lsp

Is there something is missing in my config? How can fix this problem?

Links inserted with ZkNewFromTitleSelection are missing the filetype

If I create a new note from a selection with ZkNewFromTitleSelection, it creates a new note and replaces the selection with the link but the link is missing the filetype:

A test sentence # running the command on "sentence"
--> A test [sentence](202210191900)

This works fine for clicking through links with zk-nvim by pressing enter, but when serving up the notes with emanote (as recommended in https://github.com/mickael-menu/zk docs), the links are broken because they are missing the filetype. Is there or a setting in zk-nvim to insert the filetype in a link? Or should I be configuring something on the emanote side?

Customize fzf preview window

Hey, I'm really sorry to bother you again! I just wanted to ask if it's possible to re-use fzf-preview preview command from .zk/config.toml when displaying notes with ZkNotes command using fzf?

I also use fzf.vim but for some reason built-in bindings to open files in new tab, split and vsplit (CTRL-T / CTRL-X / CTRL-V) don't seem to work. Any idea what I need to configure?

ZkNewFromTitleSelection should error when used with visual block selection

Not sure if this is possible, but sometimes I get tripped up when using visual block selection (V) and the ZkNewFromTitleSelection command. Currently, a new note will be created called "Untitled", which will also replace the line with that string.

To reproduce:

  1. Write some character on a line, like "My New Note"
  2. Visually block select the whole line
  3. Execute the ZkNewFromTitleSelection command

Expected: a new note titled "My New Note". Instead you get "Untitled".

If it can work, that's awesome, otherwise I think some kind of error should be thrown, and the new note should not be created.

ZkNew seems to not be following described behavior.

When looking at https://github.com/mickael-menu/zk/blob/main/docs/editors-integration.md#zknew it says that dir is relative to parent directory of notebook.

When I enter the notebook from my dashboard I run a ZkCd (after waitng 100 ms because I found it didn't work unless I did). Once in the note, running :pwd prints what I would expect:
image

Then I try this binding:

    ["<leader>znc"] = { function ()

        local code = string.lower(vim.fn.input('Class Code: '))
        local ucode = string.upper(code)

        -- Check if nil
        if code == nil then
            vim.notify("ZK: Please include code", "Float")
            return
        elseif vim.fn.isdirectory("classes/"..code) == 0 then
            vim.notify("A directory for "..ucode.." Doesn't Exist.", "Float")
        end

        local title = vim.fn.input('Title: ')

        if title == nil then
            vim.notify("ZK: Please include title", "Float")
            return
        else
            require("zk.commands").get("ZkNew")({ extra = { classcode = ucode }, dir = 'career/'..code, title = title })
        end
    end, "[z]K [n]ew [c]lass Note"},

And I get this output, which I don't understand why it isn't respecting the notebook dir.

Error executing vim.schedule lua callback: ...cal/share/nvim/site/pack/packer/start/zk-nvim/lua/zk.lua:68: RPC[Error] code_name
 = InvalidRequest, message = "new note: /home/vm/career/pols1: path is outside the notebook at /home/vm/Dropbox/Notebooks/Compe
ndium"
stack traceback:
        [C]: in function 'assert'
        ...cal/share/nvim/site/pack/packer/start/zk-nvim/lua/zk.lua:68: in function 'handler'
        /usr/share/nvim/runtime/lua/vim/lsp.lua:1252: in function ''
        vim/_editor.lua: in function <vim/_editor.lua:0>

I don't have $ZK_NOTEBOOK_DIR set, but from my understanding I shouldn't need it since ZkCd seems to figure out the correct directory. Am I missing something here?

Edit:
Just realized I can't use any new command, I am going to tear into my config file and double check it.

`$ZK_NOTEBOOK_DIR` not works

I have configurated $ZK_NOTEBOOK_DIR, and zk command runs well, but it still cannot found notebook in neovim.

~/.zshrc:

export ZK_NOTEBOOK_DIR="$HOME/Notes"
 $  echo $ZK_NOTEBOOK_DIR
/Users/<username>/Notes

zk command:

 $  zk list
INDEX index.md (12 hours ago)

  ‣ Content goes here.


Found 1 note

plugin settings:

zk.setup {
    picker = 'telescope'
}

nvim ZkNotes command:

Error executing vim.schedule lua callback: ...cal/share/nvim/site/pack/packer/st
art/zk-nvim/lua/zk.lua:99: RPC[Error] code_name = InvalidRequest, message = "fai
led to open notebook: no notebook found in /Users/<username>/.config/nvim or a paren
t directory"
stack traceback:
        [C]: in function 'assert'
        ...cal/share/nvim/site/pack/packer/start/zk-nvim/lua/zk.lua:99: in funct
ion 'handler'
        ...l/Cellar/neovim/0.6.1/share/nvim/runtime/lua/vim/lsp.lua:964: in func
tion 'cb'
        vim.lua:285: in function <vim.lua:285>
Press ENTER or type command to continue

 $  zk --version
zk 0.9.0

 $  nvim --version
NVIM v0.6.1
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by brew@Monterey

Bug: completion window doesn't popup when there's non ascii character ahead

Description

In this post, I use | to represent cursor location.

When use zk-nvim, I found that if there is a non-ascii character in front of the cursor, then [[ can't trigger completion.

For example, following content can trigger completion

alpha [[|

But this one can't

α [[|

Here is a minimal working init.lua:

require('packer').startup(function(use)
  -- Packer can manage itself
  use 'wbthomason/packer.nvim'

  use 'neovim/nvim-lspconfig'

  use 'hrsh7th/nvim-cmp'
  use 'mickael-menu/zk-nvim'
end)

-- nvim-cmp
require'cmp'.setup {
  sources = cmp.config.sources({
    { name = 'nvim_lsp' },
  })
}

-- zk
require("zk").setup{}

Reproduce

  1. Create a zk folder with an aribitary note
  2. Create a note with zk new
  3. Edit the new note by nvim <note name> -u init.lua (assume packer.nvim and these plugins have been installed)
  4. Input alpha [[, you'll notice that completion windows popup
  5. Start a new line and input α [[, nothing happens here.

α can be changed to any non-ascii character, such as 你好.

Feature request: apply template to already created note

Request:

A command to apply a template to the current file.

Background:

I keep tasks in my notes in github markdown format. Sometimes I want to kick a task to the future and for that, I move the task to a journal note with a future date. When that date arrives, I don't have my nice journal template in it. I have to copy out the contents, delete the file, then have zk recreate it and finally paste back in the contents. Needless to say, this is not ideal.

This would also be useful for me as I'd like to create some templates for things like reviews of books. I realize I can read in the template, but I do like to have the substitutions work. So if I even just had a way to ask zk to replace template values, that would be a big step forward.

If there's already a way to do this, I couldn't find it after poring over the docs, but would love to know the secret.

Thanks for this tool, it's great!

Feature request: link from selection

I am looking for some way to have the following workflow:

First, I type some text:

This is a sentence about a topic that is interesting.

I realize I have a note for "a topic" that I would like to link to, title "the topic". I visual-select it:

This is a sentence about a topic that is interesting.
                         ^^^^^^^

I would like a command like ZkLinkFromSelection where it opens a picker pre-populated with "a topic". I adjust the query to search for just "topic". When I select the entry titled "the topic", it replaces the buffer text with a link:

This is a sentence about [[the-topic-link|a topic]] that is interesting.

This is almost the same as ZkNewFromTitleSelection, except I don't want to create a new note, I want to link to an existing note.

The current workaround is to delete "a topic", type "[[the topic", use completion to produce the link "[[the-topic-link|the topic]]", then replace "the topic" with "a topic". It's a bit cumbersome.

What would it take to implement this feature?

Is :ZkNotes supposed to search notes contents as well as title? #71

I've started playing around with zk and zk.vim and I've found the behaviour of :ZkNotes confusing.

zk list --interactive seems to search both the titles of the notes and the content of the notes.

Using :ZkNotes only searches the titles.

I understand that zk is using fzf to achieve this, but I expected :ZkNotes to work the same way.

Is there any way to achieve the same behaviour or a reason to not do this?


(I opened a discussion, but it didn't any response so I'm hoping this is a better place to post 🙈)

On attach not working

Hello again !

I'm trying to hide diagnostics for zk, and I came up with this snippet:

				require("zk").setup({
					picker = "telescope",
					lsp = {
						config = {
							on_attach = function(_, buffer)
                                                                print(buffer)
								vim.diagnostic.hide(nil, buffer)
							end,
						},
					},
				})

However, it seems that the on_attach function is never called, as I never go into the print.
Am I missing something here ?

Is this still a desired plugin?

Hey @mickael-menu, first off: thanks for the great work on zk. I've started using it and it's been such a great experience. I've spent some time digging through the discussions on zk and megalithic's zk.nvim plugin, and noticed that there was some interest in extracting some of the features from zk.nvim and adding some configuration to a new plugin with some of the new zk LSP features, while leaving out some of the duplicates between the two. However, there hasn't been any traction on that here since that discussion a few months ago.

I at the moment am not really familiar with Go (I've done some very preliminary learning for it, but nothing particularly substantial yet), so contributing to zk directly may be a bit of a challenge for me at the moment. However, I've become reasonably comfortable writing Lua over the last year as I've spent more and more time learning about Neovim and constantly refining my own config.

If you still have an interest in scaffolding out a plugin here that helps to provide a better out-of-the-box experience for zk within Neovim, I would love to help migrate some of the features from zk.nvim and add some new features surrounding the additions to the zk LSP. I've found myself already writing some custom Telescope pickers and Lua function wrappers for zk to make my own zk experience in Neovim better, and would love to help provide some of those niceties to the rest of the community. I probably won't have the time to start doing that for about another week or two as I'm in the middle of a pretty busy period at work, but I wanted to reach out and see if there was interest in developing this still before I started submitting some PRs in a few weeks' time. Let me know what you think! Thanks again for the great work on zk 😄

Support for `fzf-lua` picker

Thanks for this great tool and plugin!

Would it be complicated to add fzf-lua as another picker?

It seems that the fzf picker in the documentation uses fzf.vim

Open ZK notes on any neovim location

Hello !

I would love to be able to open ZK notes on any neovim location. At the moment, I need to be inside a markdown file (in my notebook dir) to be able to use Zk commands.

The objective would be to specify a default notebook dir in the setup function, and doing :ZkNotes (or :ZkStart and then :ZkNotes, in order to start the lsp beforehand) would make me see my notes.

What do you think ?

Select template on note creation

Main Idea

With all of ZK's templates being in a single directory, I'd think it should be relatively easy to enable a way to select a template, preferably using ui.select(), when creating a new note.

image

Intended Use

Currently, I have this in my config, which I use which-key, but should be easily added to any keybinding setup.

wk.register({
        ['<leader>znb'] = {
        function ()
            local temp_title = vim.fn.input('Title: ')
            local temp_template = vim.ui.select( vim.fn.systemlist('ls -A $ZK_NOTEBOOK_DIR/.zk/templates/'), { prompt = 'Select template: ' }, function(choice) return choice end)
            local temp_usertags = vim.fn.input('Additional Tags: ')
            require('zk').new({
                dir = vim.fn.expand('%:p:h'),
                group = "base",
                title = temp_title,
                template = temp_template,
                extra = {
                    ['user-tags'] = temp_usertags,
                },
            })
        end, '[z]k [n]ew [b]ase'

})

In my case, I want to be able to select from base.md, dir-date.md, and dir-title.md and use that to fulfil the template field.

Sadly I keep getting this error. I'm guessing it has something to do with the fact I am calling ls. Does anyone have a solution?


Error executing vim.schedule lua callback: ...cal/share/nvim/site/pack/packer/start/zk-nvim/lua/zk.lua:68: RPC[Error] code_name = InvalidReq
uest, message = "new note: term://~/Dropbox/Notebooks/Compendium//1673314:/sbin: directory not found"
stack traceback:
        [C]: in function 'assert'
        ...cal/share/nvim/site/pack/packer/start/zk-nvim/lua/zk.lua:68: in function 'handler'
        /usr/share/nvim/runtime/lua/vim/lsp.lua:1383: in function ''
        vim/_editor.lua: in function <vim/_editor.lua:0>

ZkNewFrom*Selection unexpected behavior

Hello, trying to use zk-nvim, but have some trouble with ZkNewFrom*Selection function.

I visual the word reference than run command that you can see on pics, zk create new .md file, but the name of ref is empty. How to fix it?(

pic-window-220505-1736-58

pic-window-220505-1737-33

pic-window-220505-1737-47

Floaterm + ask for title

Is it possible to chain commands in some manner so i get asked for title and open new note in floaterm?

What i tried is:

vim.api.nvim_set_keymap("n", "<leader>zt", "<Cmd>Floaterm ZkNew { title = vim.fn.input('Title: ') }<CR>", opts)

but this gets me this error
Screenshot 2022-06-23 at 00 24 15

Support for fzf

Hello, I see the examples for Telescope, but is fzf supported aswell? If not, how much work would it be to support it?

Error executing vim.schedule Cannont insert link for `:ZkNewFromTitleSelection` `:ZkNewFromContentSelection`

Hi,

first of all thanks for the great tool that is zk and the neovim plugin! I am one of the poor users who are commited (forced?) to using zk on Windows. This issue is occurring for both Windows 10 and WSL with Ubuntu.

No matter if I use zk on native Windows or in WSL, I seem not to be able to use either of the linking commands coming with the plugin. However :ZkNew works, so the problem seems to be connected with inserting the link to the document. This is the error I'm getting (this one is from WSL run, but it differs from the Windows one only by how the path is formatted):

Error executing vim.schedule lua callback: ...cal/share/nvim/site/pack/packer/start/zk-nvim/lua/zk.lua:68: RPC[Error] code_name = InvalidRequest, message = "Cannot insert link in 'file:///mnt/c/Users/modzmi01/zk_notebook/index.md'"
stack traceback:
        [C]: in function 'assert'
        ...cal/share/nvim/site/pack/packer/start/zk-nvim/lua/zk.lua:68: in function 'handler'
        ...l/.local/nvim-linux64/share/nvim/runtime/lua/vim/lsp.lua:1383: in function ''
        vim/_editor.lua: in function <vim/_editor.lua:0>

I'm using nvim 0.8.3.

I'm configuring and attaching zk lsp through lspconfig, so I have turned off auto attach in the setup. Here are the bits of my config related to zk:

-- plugin config
require("zk").setup({
  -- can be "telescope", "fzf" or "select" (`vim.ui.select`)
  -- it's recommended to use "telescope" or "fzf"
  picker = "telescope",

  lsp = {
    -- `config` is passed to `vim.lsp.start_client(config)`
    config = {
      cmd = { "zk", "lsp" },
      name = "zk",
      -- on_attach = ...
      -- etc, see `:h vim.lsp.start_client()`
    },

    -- automatically attach buffers in a zk notebook that match the given filetypes
    auto_attach = {
      enabled = false,
      filetypes = { "markdown" },
    },
  },
})
--lsp setup
local zk_on_attach = function(client, bufnr)
  local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end
  local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end

  buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')

  -- Mappings.
  local opts = { noremap=true, silent=true }
  buf_set_keymap('n', 'gD', '<Cmd>lua vim.lsp.buf.declaration()<CR>', opts)
  buf_set_keymap('n', 'gd', '<Cmd>lua vim.lsp.buf.definition()<CR>', opts)
  buf_set_keymap('n', 'K', '<Cmd>lua vim.lsp.buf.hover()<CR>', opts)

  local opts = { noremap=true, silent=false }
  -- Open the link under the caret.
  buf_set_keymap("n", "<CR>", "<Cmd>lua vim.lsp.buf.definition()<CR>", opts)
  -- Create a new note after asking for its title.
  -- This overrides the global `<leader>zn` mapping to create the note in the same directory as the current buffer.
  buf_set_keymap("n", "<leader>zn", "<Cmd>ZkNew { dir = vim.fn.expand('%:p:h'), title = vim.fn.input('Title: ') }<CR>", opts)
  -- Create a new note in the same directory as the current buffer, using the current selection for title.
  buf_set_keymap("v", "<leader>znt", ":'<,'>ZkNewFromTitleSelection { dir = vim.fn.expand('%:p:h') }<CR>", opts)
  -- Create a new note in the same directory as the current buffer, using the current selection for note content and asking for its title.
  buf_set_keymap("v", "<leader>znc", ":'<,'>ZkNewFromContentSelection { dir = vim.fn.expand('%:p:h'), title = vim.fn.input('Title: ') }<CR>", opts)
  buf_set_keymap("n", "<leader>zj", "<Cmd>ZkNew { dir = 'journal/daily', title = vim.fn.input('Title: ')}<CR>", opts)

  -- Open notes linking to the current buffer.
  buf_set_keymap("n", "<leader>zb", "<Cmd>ZkBacklinks<CR>", opts)
  -- Alternative for backlinks using pure LSP and showing the source context.
  --map('n', '<leader>zb', '<Cmd>lua vim.lsp.buf.references()<CR>', opts)
  -- Open notes linked by the current buffer.
  buf_set_keymap("n", "<leader>zl", "<Cmd>ZkLinks<CR>", opts)
  -- Open the code actions for a visual selection.
  buf_set_keymap("v", "<leader>za", ":'<,'>lua vim.lsp.buf.range_code_action()<CR>", opts)
end

nvim_lsp["zk"].setup({capabilities = capabilities, on_attach = zk_on_attach, handlers = handlers})

link-format with auto completion

I tried to insert wiki link by typing [[, and the completion menu pops up. After selecting a file, the generated text became [[[Untitled](4vyz)]], which I would expect to be [Untitled](4vyz) or [[4vyz]]. Am I missing something or this is intended behavior? The README doesn't talk about this.

# actual text after completion:
[[[Untitled](4vyz)]]

# expected:
[Untitled](4vyz)
  • completion plugin: nvim-cmp

Error in telescope previewer: Expected Lua number

zk config:

vim.env.ZK_NOTEBOOK_DIR= os.getenv('HOME') .. '/Scratches/Notes'

require('zk').setup({
  picker = 'telescope',
  lsp = {
    config = {
      cmd = { 'zk', 'lsp' },
      name = 'zk',
    }
  }
})

How to reproduce

  1. Setup telescope properly and use the config provided above to setup zk
  2. Open telescope with :ZkNotes
  3. Inside telescope prompt, Enter normal mode and holding j; or holding <C-n> in insert mode
  4. See the error in 1~2 seconds.

Screenshot

image

Other useful information

This error does not appear / is harder to reproduce when your keystroke frequency is lower. Mine is 60 times/sec.

Create note from path with command similar to `:ZkNewFromTitleSelection`

For my workflow it would be very nice to be able to create notes in subdirectories from a path. I am trying to setup Zk for use with Emanote. :ZkNewFromTitleSelection works very similar, but I would like to provide a path instead of a title, since the title could be infered from my path given my configuration I think.

For example:
image

I would like the selected above to create a relative link to docs/awesomewm/Awesome\ Window\ Manager.md from inside Docs.md.

image

As mentioned, the ZkNewFromTitleSelection commands are quite close, but don't seem to handle the path how I need.

image

Something like ZkNewFromPathSelection would be super useful but I am kinda lost on where to go. Thanks for any help you can provide.

Insert link via filepicker

Hi there, just found this plugin, seems awesome so far!

One thing I'm trying to figure out how to implement is adding a command to insert a link (in markdown form) using a filepicker. Looking around on here this is what i have so far:

local function yankName(options, picker_options)
  zk.pick_notes(options, picker_options, function(notes)
    local pos = vim.api.nvim_win_get_cursor(0)[2]
    local line = vim.api.nvim_get_current_line()

    if picker_options.multi_select == false then
      notes = { notes }
    end
    for _, note in ipairs(notes) do
      local nline = line:sub(0, pos) .. note.absPath  .. line:sub(pos + 1)
      vim.api.nvim_set_current_line(nline)
    end
  end)
end
commands.add("ZkYankName", function(options) yankName(options, { title = "Zk Yank" }) end)

This inserts a link to the full path (see note.absPath) but I can't figure out how to access the title etc (I tried note.title and am not getting anything). Any ideas?

Once I get this working I'll probably also tweak it to put the link in the main register instead of insert it. With that, it'd also be cool to be able to pick a bunch of them out in multiselect. Is it easy to do that too?

Thank you!

How would one search for notes matching at least one tag in a list of options, but not necessarily all of them?

The --tag parameter to zk supports searching for notes which match at least one of a list of tags using the OR operator.

zk list --tag 'tag1 OR tag2'

I can't seem to replicate this behavior with zk-nvim. I've tried passing in a string in a similar format as above to no avail:

zk.list(NOTES_DIR, {
  tag = 'tag1 OR tag1'
}, function (err, notes) end)

Passing in a list of tags implicitly assumes an AND operator rather than an OR.

zk.list(NOTES_DIR, {
  tag = { 'tag1', 'tag2' }
}, function (err, notes) end)

Is there a way of searching like this?

Telescope Error when scrolling

When I use ZkNotes and scroll down and then back up I get this error.

Error executing vim.schedule lua callback: .../telescope.nvim_0.1.x/lua/telescope/previewers/utils.lua:158: Expected Lua number
stack traceback:
        [C]: in function 'nvim_win_get_height'
        .../telescope.nvim_0.1.x/lua/telescope/previewers/utils.lua:158: in function ''
        vim/_editor.lua: in function <vim/_editor.lua:0>
Press ENTER or type command to continue

Going back up one at a time ie slowly does not produce the error.
Holding down the up key and stopping produces many of these errors.
I can't repeat this in any another Telescope "action" which is why I am raising it here.

Does anyone else experience this ?

Telescope config ignored

When I use the build in picker commands with picker = "telescope" it seems to ignore my telescope config. This is fixed when I use the telescope plugin. Is there a reason that the telescope plugin is not recommended/full featured? And is there a way to get the commands like :ZkNotes/:ZkLinks/etc. to respect my telescope config?

How can we input tags from the nvim commandline?

Since we can easily input our title from the nvim commandline like this:

n = { "<cmd>ZkNew { dir = vim.fn.expand('%:p:h'), title = vim.fn.input('Title: ') }<cr>", "New Notes" }

Is there a way we could have same input option for tags as well?
This is my .zk/templates/default.md

---
title: {{ title }}
date: {{ date now "long" }}
tags: {{ tags }}
---

{{content}}

Command :ZkNotes produces error: unknown zk LSP command: zk.list

I installed and configured zk-nvim as described in readme (only require("zk").setup()).
When I run :ZkNotes I got:

Error executing vim.schedule lua callback: .../idevat/.local/share/nvim/plugged/zk-nvim/lua/zk/api.lua:26: RPC[Error] code_name = InvalidRequest, message = "unknown zk LSP command: zk.list"
stack traceback:
        [C]: in function 'assert'
        .../idevat/.local/share/nvim/plugged/zk-nvim/lua/zk/api.lua:26: in function 'handler'
        /home/idevat/.local/share/nvim/runtime/lua/vim/lsp.lua:963: in function 'cb'
        vim.lua:285: in function <vim.lua:285>

Only ZkNew and ZkIndex commands available

Disclaimer: I'm still at the beginning of this journey and have very little experience with zk and neovim.

After installing zk via the package manager and installing zk-nvim via AstroNvim's packer-like way, I can see the lsp attach to one of my notes inside an initialized Zettelkasten (see :LspInfo output below). However, when I try to invoke :ZkNotes, I find that only :ZkNew and :ZkIndex exist.

LspInfo

(typed :Zk and pressed tab)

image

Any idea what I am doing wrong? 😅

To install and setup the plugin, I have the following code in my user/init.lua file for the user specific configuration within AstroNvim.

plugins = {
  init = {
    "mickael-menu/zk-nvim",
  },
  ["zk"] = {
    picker = "telescope",
  },
},
lsp = {
  servers = {
    "zk",
  },
},

From my understanding, this should be equivalent to

(just packer)

use("mickael-menu/zk-nvim")

(setup)

require("zk").setup({ picker = "telescope" })

the additional servers entry is required because AstroNvim is using mason-lspconfig behind the scenes and wouldn't recognize zk otherwise.

's: expected string, got nil' on :ZkNotes

When :ZkNotes is executed, the following error occurs:

Error executing vim.schedule lua callback: vim/shared.lua:63: s: expected string, got nil
stack traceback:
	[C]: in function 'error'
	vim/shared.lua:608: in function 'validate'
	vim/shared.lua:63: in function 'gsplit'
	vim/shared.lua:128: in function 'split'
	...e/pack/packer/start/zk-nvim/lua/zk/pickers/telescope.lua:53: in function 'define_preview'
	...scope.nvim/lua/telescope/previewers/buffer_previewer.lua:386: in function 'preview'
	...ck/packer/start/telescope.nvim/lua/telescope/pickers.lua:1066: in function 'refresh_previewer'
	...ck/packer/start/telescope.nvim/lua/telescope/pickers.lua:1015: in function 'set_selection'
	...ck/packer/start/telescope.nvim/lua/telescope/pickers.lua:1351: in function '_do_selection'
	...ck/packer/start/telescope.nvim/lua/telescope/pickers.lua:1313: in function 'cb'
	vim.lua:285: in function <vim.lua:285>

Once the error is dismissed, the Telescope picker is opened, with an empty results field. When something is typed, the field populates with results, and when the input prompt is cleared (last character is deleted), the above error occurs again, identically.

Neovim version 0.6.1

Feature Request: list notes by multiple tags

Filter notes by a multiple tags.

Example: imagine a zettelkasten about applications; invoke ZkTags to show the tag picker, type "editor" and now instead of hitting ENTER to show the notes tagged with "editor", you hit C-t (for example) to filter the tag list to show only tags appearing in notes tagged as "editor". The tag list now shows "modal", "hex", "latex", "markdown", you type "modal" and hit ENTER to open a picker of notes tagged "editor" AND "modal".

Equivalent to zk list --tag "editor AND modal"

Most pieces are there I think (Telescope seems to support custom mappings to run commands in the picker) except perhaps the list tags filtered by tags.

This will speed up finding a note in a large collection if you don't remember the title but has been consistently tagged using a small number of tags.

failed to open notebook

I have one directory for all my notes, and i wanted to search for it from any path so i created a shortcut using high-api , but i got error:
2023-01-29_13-58
Here is what i used lua require('zk').pick_notes({'/home/kuba/Documents/orgmode'})

Can somebody tip me how i should use api? im pretty sure i just do something wrong

ZkNewFromTitleSelection and ZkNewFromContentSelection only capture the first letter of range

Hey!
So when I select a range of characters, and invoke '<,'>ZkNewFromTitleSelection or '<,'>ZkNewFromContentSelection, the earlier makes a note with the title of the first letter of range and the later, a note with content of the first range.
As an example
this is a note:

# note one

this should become a link

When I enter visual mode and select this should become a link and invoke with the above commands I end up with the first note with this content:

# note one

[t](9a963a5c)his should become a link

and another note with this content:

# t

I have tried this with neovim versions

NVIM v0.6.1
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by nixbld

and also the latest nightly build available on git.
I have also disabled all my other configurations.

Here is the content of my .zk/config.toml:

# zk configuration file

[note]



filename = "{{id}}"

extension = "md"

template = "default.md"


id-charset = "hex"

id-length = 8

# Letter case for the random IDs, among lower, upper or mixed.
id-case = "lower"

[extra]

[group.journal]
paths = [
    "journal",
]
[group.journal.note]
filename = "{{date now}}"
[format.markdown]


hashtags = true
colon-tags = false
multiword-tags = false

[tool]
editor = "nvim"

pager = "less -FIRX"
fzf-preview = "bat -p --color always {-1}"

[lsp]

[lsp.diagnostics]
dead-link = "error"

[lsp.completion]
note-label = "{{title-or-path}}"
note-filter-text = " {{title}} {{path}}"
note-detail = "{{filename-stem}}"

[filter]

[alias]
i = "zk edit -i"
ls = "zk list $@"
list = "zk list --quiet $@"
editlast = "zk edit --limit 1 --sort modified- $@"
recent = "zk edit --sort created- --created-after 'last two weeks' --interactive"
hist = "zk list --format path --delimiter0 --quiet $@ | xargs -t -0 git log --patch --"
conf = '$EDITOR "$ZK_NOTEBOOK_DIR/.zk/config.toml"'

Also here is the content of my zk.lua configuration file:

require("zk").setup({
	picker = "select",
	lsp = {
		-- `config` is passed to `vim.lsp.start_client(config)`
		config = {
			cmd = { "zk", "lsp" },
			name = "zk",
			-- on_attach = ...
			-- etc, see `:h vim.lsp.start_client()`
		},
		-- automatically attach buffers in a zk notebook that match the given filetypes
		auto_attach = {
			enabled = true,
			filetypes = { "markdown" },
		},
	},
})
require("telescope").load_extension("zk")
vim.api.nvim_set_keymap("v", "N", ":ZkNewFromTitleSelection<CR>", { noremap = true })
vim.api.nvim_set_keymap("n", "<Leader>zc", "<cmd>ZkNew<CR>", { noremap = true })
vim.api.nvim_set_keymap("x", "<Leader>zc", ":'<'>ZkNewFromTitleSelection<CR>", { noremap = true })
vim.api.nvim_set_keymap("n", "<Leader>zn", "<cmd>ZkNotes<CR>", { noremap = true })
vim.api.nvim_set_keymap("n", "<Leader>zb", "<cmd>ZkBacklinks<CR>", { noremap = true })
vim.api.nvim_set_keymap("n", "<Leader>zl", "<cmd>ZkLinks<CR>", { noremap = true })
vim.api.nvim_set_keymap("n", "<Leader>zt", "<cmd>ZkTags<CR>", { noremap = true })

Please tell me to provide any additional information, if needed.

Jump to the next link with <TAB>

One particular feature I like about Vimwiki is to jump to the next or previous link with <(S-)Tab>. This makes it very easy to browse a notebook.

Maybe it's something that could be added to zk-nvim as well.

Feature request: Jump to footnote

I am not sure about implications, but it would be neat to be able to jump to footnote.
image

In this case I am using vim-pandoc/vim-markdownfootnotes for quick footnote management.

Doc: ZkNotes match requires a dictionary to be passed in instead of a string

In the section of Example Mappings from README.md and zk-nvim's vim help file:

-- Search for the notes matching a given query.
vim.api.nvim_set_keymap("n", "<leader>zf", "<Cmd>ZkNotes { sort = { 'modified' }, match = vim.fn.input('Search: ') }<CR>", opts)

However, with the above config, the LSP client will complain about failing to parse the arguments:

Error executing vim.schedule lua callback: ...cal/share/nvim/site/pack/packer/start/zk-nvim/lua/zk.lua:101: RPC[Error] code_name = InvalidRequest, message = "failed to parse
zk.tag.list args, got: map[match: select:[title absPath path] sort:[modified]]: json: cannot unmarshal string into Go struct field cmdListOpts.match of type []string"
stack traceback:
        [C]: in function 'assert'
        ...cal/share/nvim/site/pack/packer/start/zk-nvim/lua/zk.lua:101: in function 'handler'
        /usr/share/nvim/runtime/lua/vim/lsp.lua:1383: in function ''
        vim/_editor.lua: in function <vim/_editor.lua:0>

Which is certainly caused by an api update on the upstream. The documentation should be updated as follows:

vim.api.nvim_set_keymap("n", "<leader>zf", "<Cmd>ZkNotes { sort = { 'modified' }, match = { vim.fn.input('Search: ') } }<CR>", opts)

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.