fiatjaf / neuron.vim

📝 Manage your Zettelkasten in {n}vim.
MIT License
83 stars 21 forks source link

Define neuron_dir so that it is available for nix installs #51

Closed beandipper closed 3 years ago

beandipper commented 3 years ago

This minor change makes it possible again to install the plugin through nix #50

After looking through the code I realized that the g:neuron_dir variable is set already in ftdetect/neuron.vim, however this wasn't available in plugin/neuron.vim and so the nix install failed.

Simply moving the lines from one file to the other fixed the problem. If there are any unwanted side-effects that could occur, or if you prefer to merge differently let me know

fenetikm commented 3 years ago

I tried putting this in my local version and when I run:

neuron -d <directory name> search | xargs nvim

I get:

Error detected while processing /Users/mjw/.config/nvim/plugged/neuron.vim/ftdetect/neuron.vim:
line    4:
E121: Undefined variable: g:neuron_dir
E116: Invalid arguments for function filereadable
E15: Invalid expression: !filereadable(g:neuron_dir."neuron.dhall")
line   10:
E121: Undefined variable: g:neuron_dir
E116: Invalid arguments for function fnameescape
line   11:
E121: Undefined variable: g:neuron_dir
E116: Invalid arguments for function fnameescape
line   12:
E121: Undefined variable: g:neuron_dir
E116: Invalid arguments for function fnameescape
fenetikm commented 3 years ago

I think you might need to leave the lines in the ftdetect file too?

beandipper commented 3 years ago

I can confirm that the change results in the same error that you got. After taking a look, I changed the few references to g:neuron_dir to a buffer local reference to it which seems to have fixed the issue: 26a85b7

Those calls appear to be trying to access neuron_dir when the current buffer is a neuron file, so I don't suppose it should be an problem. I would prefer to do this instead of duplicating global variable assignments, but me know if there are any downsides to doing it this way, as I have no experience with vim scripting and the plugin ecosystem.

fenetikm commented 3 years ago

Nice one @beandipper 👍 Works well for me too.