fiatjaf / neuron.vim

šŸ“ Manage your Zettelkasten in {n}vim.
MIT License
83 stars 21 forks source link

Starting vim with new note fails with undefined var #53

Open MartinPotier opened 3 years ago

MartinPotier commented 3 years ago
vim -g "+call neuron#edit_zettel_new()"

image

Can I/How can I do this?

butgit commented 3 years ago

I replicated your command and it shows:

E233: cannot open display
Press ENTER or type command to continue

When I continue, I see:

Error detected while processing command line..function neuron#edit_zettel_new:
line    1:
"~/zettelkasten/517a280e.md" [New]
Press ENTER or type command to continue

Anyway, when I press enter, I can begin editing it in VIM without further problems. I can link it to other Zettels. I can also search other Zettels.

Have you checked if ag is installed? As read.me says, ag is required if you intend to use the content search command. In my case, I missed it during the setup. When I installed it and rebooted the OS, the problems similar to yours went away.

MartinPotier commented 3 years ago

Hmm, interesting. I do have ag installed, and neuron works correctly if I don't try invoking the edit_zettel_new at vim start.

Maybe neuron#edit_zettel_new() requires some setup to be done before it can be invoked?

fenetikm commented 3 years ago

Just pushed a changed that hopefully fixes this - essentially it was trying to write the current buffer before creating the zettel but since there was no buffer yet it was throwing errors.

MartinPotier commented 3 years ago

I have a different warning now:

image

This neuron_extension should already be defined, right (doc says it has a default -> .md)? Should IĀ define it explicitely?

MartinPotier commented 3 years ago

Actually, this error shows when I start vim, even without any arguments now.

MartinPotier commented 3 years ago

Adding in my vim config:

let g:neuron_extension = '.md'

did not remove the error message :/ Admittedly, I do not understand vimscript.

beandipper commented 3 years ago

Hi Martin, this looks like the result of a recent commit. It looks like somebody had something similar and they were able to fix it by making sure that g:neuron_dir = "/your/zettekasten/here/" line in your config came after your plugin lines. See https://github.com/fiatjaf/neuron.vim/pull/51#discussion_r530669097

MartinPotier commented 3 years ago

Oh bugger, my let g:neuron_dir = "/home/<me>/zk/" is the very last line on my vimrcā€¦

beandipper commented 3 years ago

Did moving it fix the issue?

MartinPotier commented 3 years ago

Should I? I understood it should be on the last line, therefore after the ā€œplugin linesā€

fenetikm commented 3 years ago

@beandipper could you please look at what happens if you change b to g for you in ftdetect - I've been thinking about it and unless you are running two different zettelkastens at the same time I don't think the use of a buffer variable for the directory is necessary.

fenetikm commented 3 years ago

ok, as noted elsewhere the issue is because of neuron_extension - pushed a fix.