nvim-telekasten / telekasten.nvim

A Neovim (lua) plugin for working with a markdown zettelkasten / wiki and mixing it with a journal, based on telescope.nvim
MIT License
1.37k stars 86 forks source link

Unable to create new note #2

Closed lokesh-krishna closed 2 years ago

lokesh-krishna commented 2 years ago

Just setup telekasten following the readme but when I run :lua require("telekasten").new_note(), it returns the following error:

E5108: Error executing lua ...ite/pack/packer/start/telekasten.nvim/lua/telekasten.lua:460: attempt to call field 'input' (a nil value)

What might I be missing?

lokesh-krishna commented 2 years ago

Not sure if this is related but I also can't get the follow non-existing note bit working either. I get the following error if I attempt to follow a link to a note that doesn't exist:

E5108: Error executing lua ...ite/pack/packer/start/telekasten.nvim/lua/telekasten.lua:208: bad argument #1 to 'lines' (/home/loki/zettelkasten/templates/new_note.md: No such file or directory)

I however do have a file at /home/loki/sync/zetteklasten/templates/new_note.md and that's what I've specified as the home with:

lua << EOF
require('telekasten').setup({
  home = '/home/loki/sync/zettelkasten',
  dailies = '/home/loki/sync/zettelkasten/daily',
  weeklies = '/home/loki/sync/zettelkasten/weekly',
  templates = '/home/loki/sync/zettelkasten/templates',
  extension = ".md",

  follow_creates_nonexisting = true,
  dailies_create_nonexisting = true,
  weeklies_create_nonexisting = true,

  template_new_note = '/home/loki/sync/zettelkasten/templates/new_note.md',
  template_new_daily = '/home/loki/sync/zettelkasten/templates/daily.md',
  template_new_weekly= '/home/loki/sync/zettelkasten/templates/weekly.md',

  -- integrate with calendar-vim
  plug_into_calendar = true,
    calendar_opts = {
      weeknm = 4,
      calendar_monday = 1,
      calendar_mark = 'left-fit',
    }
})
EOF

No idea why telekasten is expecting it at /home/loki/zettelkasten as it's a configurable value and not hardcoded, right?

lokesh-krishna commented 2 years ago

Could fix the issue with following by forking and changing the default to ~/sync/zettelkasten so looks like the default is overwriting the user configuration.

ghost commented 2 years ago

Also unable to create a new note, I tried apply your fix @lokesh-krishna but still ran into another error after that.

E220: Missing }.
Cannot open file "input({"
Cannot open file "prompt"
Cannot open file "="
Cannot open file ""Title:"
Cannot open file """
Cannot open file "},"
Cannot open file "on_create)"
E480: No match: ui
E5108: Error executing lua ...ite/pack/packer/start/telekasten.nvim/lua/telekasten.lua:460: attempt to index field 'ui' (a nil value)

My config as of right now is as follows.

require("telekasten").setup {
  home = "/home/gregf/Nextcloud/zettelkasten",
  dailies = "/home/gregf/Nextcloud/zettelkasten/daily",
  weeklies = "/home/gregf/Nextcloud/zettelkasten/weekly",
  templates = "/home/gregf/Nextcloud/zettelkasten/templates",

  -- image subdir for pasting
  -- subdir name
  -- or nil if pasted images shouldn't go into a special subdir
  image_subdir = "img",

  -- markdown file extension
  extension = ".md",

  -- following a link to a non-existing note will create it
  follow_creates_nonexisting = true,
  dailies_create_nonexisting = true,
  weeklies_create_nonexisting = true,

  template_new_note = "/home/gregf/Nextcloud/zettelkasten/templates/new_note.md",
  template_new_daily = "/home/gregf/Nextcloud/zettelkasten/templates/daily.md",
  template_new_weekly = "/home/gregf/Nextcloud/zettelkasten/templates/weekly.md",

  -- image link style
  -- wiki:     ![[image name]]
  -- markdown: ![](image_subdir/xxxxx.png)
  image_link_style = "markdown",

  -- integrate with calendar-vim
  plug_into_calendar = true,
  calendar_opts = {
    -- calendar week display mode: 1 .. 'WK01', 2 .. 'WK 1', 3 .. 'KW01', 4 .. 'KW 1', 5 .. '1'
    weeknm = 4,
    -- use monday as first day of week: 1 .. true, 0 .. false
    calendar_monday = 1,
    -- calendar mark: where to put mark for marked days: 'left', 'right', 'left-fit'
    calendar_mark = "left-fit",
  },
}
renerocksai commented 2 years ago

Hi, I found that something is odd with replacing default values by Setup(). Will provide a fix. Sorry for the inconvenience!

In the meantime, you can of course hack telekasten.lua yourself and set your config there.

renerocksai commented 2 years ago

I just pushed a fix. Definitely I overlooked to update a lookup table in setup: the one that provides the template filenames. So this should fix all the path errors.

renerocksai commented 2 years ago

As for the ui attempt to index a nil value - there might be something odd with your neovim / lua. See :h vim.ui - it is documented.

However, maybe magically updating to the latest telekasten.nvim will fix your issue. Maaaaybee the missing } in your error message indicates something went whoopsy there.

renerocksai commented 2 years ago

Closing for now, pls re-open if problems persist

renerocksai commented 2 years ago

forgot to mention: if you provide a debug=true field in your config now, you can see all the fields being updated, and a final view of the Cfg table, looks like this, at startup:

image

image

renerocksai commented 2 years ago

Also, since you are actual users (yayyy!), pls note I provided a fix to calendar-nvim, so one can now use the big :CalendarT, too. Requires renerocksai/calendar-vim fork, though. See prerequisites in README.

lokesh-krishna commented 2 years ago

This definitely fixes the path errors but I still can't get the new note function to work. Still getting the same error as before:

E5108: Error executing lua ...ite/pack/packer/start/telekasten.nvim/lua/telekasten.lua:463: attempt to call field 'input' (a nil value)

I enabled the debug flag and this was the output:

Setup() setting `dailies_create_nonexisting`   ->   `true`
Setup() setting `debug`   ->   `true`
Setup() setting `template_new_note`   ->   `/home/loki/sync/zettelkasten/templates/new_note.md`
Setup() setting `follow_creates_nonexisting`   ->   `true`
Setup() setting `templates`   ->   `/home/loki/sync/zettelkasten/templates`
Setup() setting `weeklies_create_nonexisting`   ->   `true`
Setup() setting `dailies`   ->   `/home/loki/sync/zettelkasten/daily`
Setup() setting `home`   ->   `/home/loki/sync/zettelkasten`
Setup() setting `template_new_weekly`   ->   `/home/loki/sync/zettelkasten/templates/weekly.md`
Setup() setting `template_new_daily`   ->   `/home/loki/sync/zettelkasten/templates/daily.md`
Setup() setting `extension`   ->   `.md`
Setup() setting `plug_into_calendar`   ->   `true`
Setup() setting `weeklies`   ->   `/home/loki/sync/zettelkasten/weekly`
Resulting config:
-----------------
{
  calendar_opts = {
    calendar_mark = "left-fit",
    calendar_monday = 1,
    weeknm = 4
  },
  dailies = "/home/loki/sync/zettelkasten/daily",
  dailies_create_nonexisting = true,
  debug = true,
  extension = ".md",
  find_command = { "rg", "--files", "--sortr", "created" },
  follow_creates_nonexisting = true,
  home = "/home/loki/sync/zettelkasten",
  image_link_style = "markdown",
  plug_into_calendar = true,
  template_new_daily = "/home/loki/sync/zettelkasten/templates/daily.md",
  template_new_note = "/home/loki/sync/zettelkasten/templates/new_note.md",
  template_new_weekly = "/home/loki/sync/zettelkasten/templates/weekly.md",
  templates = "/home/loki/sync/zettelkasten/templates",
  weeklies = "/home/loki/sync/zettelkasten/weekly",
  weeklies_create_nonexisting = true
}
lokesh-krishna commented 2 years ago

Also, unrelated but could you consider enabling discussions for this repo? Just wanted to gush about how this is my favorite zettelkasten on vim experience and I've tried most of the ones out there. Issues aren't the right place to be doing that though, are they? :P

renerocksai commented 2 years ago

OK, discussions are open. :smile: