Furkanzmc / zettelkasten.nvim

A Vim Philosophy Oriented Zettelkasten Note Taking Plugin
The Unlicense
227 stars 10 forks source link

I can not run :ZkBrowse, browser.lua:164: table index is nil #28

Closed bandithijo closed 1 year ago

bandithijo commented 1 year ago

First, I want to say thank you for your hard work. This is such a great plugin for zettelkasting.

I have problem, when run :ZkBrowse, it throws error like below,

Error executing Lua callback: vim/_editor.lua:0: nvim_exec2()..BufReadCmd Autocommands for "zk://browser": Vim(append):Error executing lua callback: ...ker/start/zettelkasten.nvim/lua/zettelkasten/browser.lua:164: table index is nil
stack traceback:
  ...ker/start/zettelkasten.nvim/lua/zettelkasten/browser.lua:164: in function 'get_note_information'
  ...ker/start/zettelkasten.nvim/lua/zettelkasten/browser.lua:190: in function 'get_notes'
  ...pack/packer/start/zettelkasten.nvim/lua/zettelkasten.lua:286: in function 'get_note_browser_content'
  ...k/packer/start/zettelkasten.nvim/plugin/zettelkasten.lua:34: in function <...k/packer/start/zettelkasten.nvim/plugin/zettelkasten.lua:27>
  [C]: in function 'nvim_exec2'
  vim/_editor.lua: in function 'cmd'
  ...k/packer/start/zettelkasten.nvim/plugin/zettelkasten.lua:20: in function <...k/packer/start/zettelkasten.nvim/plugin/zettelkasten.lua:19>
stack traceback:
  [C]: in function 'nvim_exec2'
  vim/_editor.lua: in function 'cmd'
  ...k/packer/start/zettelkasten.nvim/plugin/zettelkasten.lua:20: in function <...k/packer/start/zettelkasten.nvim/plugin/zettelkasten.lua:19>

This is my config,

local status_ok, _ = pcall(require, "zettelkasten")
if not status_ok then
  return
end

require("zettelkasten").setup({
  notes_path = "notes",
  browseformat = "%f - %h [%r Refs] [%b B-Refs] %t"
})

if vim.fn.executable("ctags") == 1 then
  vim.api.nvim_buf_create_user_command(
    0,
    "MdZkUpdateTags",
    "!ctags -R --langdef=markdowntags --languages=markdowntags --langmap=markdowntags:.md --kinddef-markdowntags=t,tag,tags --mline-regex-markdowntags='/(^|[[:space:]])\\#(\\w\\S*)/\\2/t/{mgroup=1}' .",
    {
      range = false,
    }
  )
end

This is my neovim :version,

:version
NVIM v0.9.1
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/cc -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wvla -Wdouble-promotion -Wmissing-noreturn -Wmissing -format-attribute -Wmissing-prototypes -fno-common -Wno-unused-result -Wimplicit-fallthrough -fdiagnostics-color=always -fstack-protector-strong -DUNIT_TESTING -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -I/home/bandithijo/.local/src/neovim/.deps/usr/include/luajit-2.1 -I/usr/include -I/home/bandithijo/.local/src/neovim/.deps/usr/include -I/home/bandithijo/.local/src/neovim/build/src/nvim/auto -I/home/bandithijo/.local/src/neovim/build/include -I/home/bandithijo/.local/src/neovim/build/cmake.config -I/home/bandithijo/.local/src/neovim/src -I/usr/include -I/home/bandithijo/.local/src/neovim/.deps/usr/include -I/home/bandithijo/.local/src/neovim/.deps/usr/include -I/home/bandithijo/.local/src/neovim/.deps/usr/include -I/home/bandithijo/.local/src/neovim /.deps/usr/include -I/home/bandithijo/.local/src/neovim/.deps/usr/include -I/home/bandithijo/.local/src/neovim/.deps/usr/include

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/local/share/nvim"

This is my ctags --version,

Universal Ctags 6.0.0(p6.0.20221218.0), Copyright (C) 2015-2022 Universal Ctags Team
Universal Ctags is derived from Exuberant Ctags.
Exuberant Ctags 5.8, Copyright (C) 1996-2009 Darren Hiebert
  Compiled: Feb 24 2023, 18:05:01
  URL: https://ctags.io/
  Output version: 0.0
  Optional compiled features: +wildcards, +regex, +iconv, +option-directory, +xpath, +json, +interactive, +sandbox, +yaml, +packcc, +optscript, +pcre2

I hope the initialize information is enough, please, mention me if you need more information.

Thank you 🙂

bandithijo commented 1 year ago

After walking around on doucmentation :h zettelkasten.txt, I found how to use notes_path

            - {notes_path} (optional, string): Defaults to an empty string. If
              provided, |:ZkNew| uses the notes path to set the working
              directory. If this is not set. You need to make sure that your
              working directory is your notes directory. Otherwise some
              features may not work.

So, I change the notes_path into my project path,

require("zettelkasten").setup({
  notes_path = "~/zet",
  browseformat = "%f - %h [%r Refs] [%b B-Refs] %t"
})

I also found at :h zettelkasten.nvim-101, that said

`zettelkasten.nvim` also assumes a single folder where all the notes reside.
If you need to organize things you can use `#tags` to group them or create a
note that will be used as a reference for other notes.

And, I got error if I have header without timestamp ID, so I fixed all file without timestamp on header.

Thank you for the docs. I apologize for my inaccuracy. 🙏😋

Furkanzmc commented 1 year ago

Hi @bandithijo!

Thanks for creating the issue. I am only seeing it now after you've closed it. I'm happy to see that the documentation was useful!

However, it's still a valid bug to report. The plugin should report that the path you provided doesn't exist. I'll push a fix for it.

Thanks!