zk-org / zk-nvim

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

Only ZkNew and ZkIndex commands available #106

Closed Joelius300 closed 1 year ago

Joelius300 commented 1 year ago

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.

dzintars commented 1 year ago

Not sure what are you looking for. You can create your own actions like this:

local function make_new_fn(defaults)
  return function(options)
    options = vim.tbl_extend('force', defaults, options or {})
    require('zk').new(options)
  end
end

require('zk.commands').add('ZkNewFleeting', make_new_fn({ dir = 'vault', template = 'fleeting.md' }))

vim.keymap.set(
  'n',
  '<leader>zn',
  "<cmd>ZkNewFleeting { title = vim.fn.input('Fleeting Title: ')}<cr>",
  { desc = 'zk-nvim | New fleeting note' }
)

You can utilize GitHub search like filename:zk-nvim.lua path:nvim/lua to find how other people configure their zk-nvim.

UnkwUsr commented 1 year ago

Very strange, but looks like you use very old version of the plugin, where only :ZkIndex and :ZkNew commands presented yet (like at commit 89179f1).

Can you find local folder with installed plugin and check file lua/zk/commands/builtin.lua? (if your version is really very old as I expect, then you'll not even have that file yet)

Joelius300 commented 1 year ago

@dzintars thanks for the comment, I'll look into it when I better understand what's going on here. Also very cool search trick but I only find one repo. Liquidmantis/dotfiles

@UnkwUsr thanks for the comment. I found lua/zk/commands/builtin.lua under ~/.local/share/nvim/site/pack/packer/start/zk-nvim on my Manjaro system. It contains multiple calls to commands.add with the first two being "ZkIndex" and "ZkNew", followed by the for me nonexistent "ZkNewFromTitleSelection". I compared it with https://github.com/mickael-menu/zk-nvim/blob/main/lua/zk/commands/builtin.lua and it seems to be the same code.

dzintars commented 1 year ago

Mby old LSP? I mean old zk?

Joelius300 commented 1 year ago

I'll confirm in a sec but I'm almost certain it's on version 12, maybe even already on 13, but not lower.

Edit: its 12 (0.12.0)

UnkwUsr commented 1 year ago

Try a minimal config: create a file (for example, min.lua) with the following content:

-- P.S. stealed from gitsigns:
-- https://github.com/lewis6991/gitsigns.nvim/blob/main/.github/ISSUE_TEMPLATE/bug_report.yaml

vim.o.packpath = '/tmp/nvim/site'

local plugins = {
  zk = 'https://github.com/mickael-menu/zk-nvim',
}

for name, url in pairs(plugins) do
  local install_path = '/tmp/nvim/site/pack/test/start/'..name
  if vim.fn.isdirectory(install_path) == 0 then
    vim.fn.system { 'git', 'clone', '--depth=1', url, install_path }
  end
end

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

And run nvim --clean -u min.lua. Do you have all the :Zk* commands?

Joelius300 commented 1 year ago

@UnkwUsr Yes I do! If I don't use telescope as the picker (because that's not loaded in this minimal config) then I can display all my notes with :ZkNotes for example.

Does that mean there's a conflict somewhere? Or AstroNvim is causing issues?

UnkwUsr commented 1 year ago

Yes, there can be conflict somewhere. Try to reproduce with clean AstroNvim, and if it does, then create issue there.

github-actions[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs in the next 5 days.

github-actions[bot] commented 1 year ago

This issue was closed because it has been stalled for 5 days with no activity.

Joelius300 commented 1 year ago

Delighted to report that the major update of AstroNvim (3.10.0 right now) has solved this issue for me :)