fiatjaf / neuron.vim

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

properly supply cwd when performing ftdetect #56

Closed lehmacdj closed 2 years ago

lehmacdj commented 3 years ago

While running neuron on my system I noticed that ftdetect wasn't creating the augroups because get(g:, 'neuron_dir') returned 0 instead of the current directory as expected. I was able to work around this issue by supplying an explicit default to get.

lehmacdj commented 3 years ago

I just checked and it looks like g:neuron_dir is being populated correctly in plugin/neuron.vim. However, I think what's going on is that ftdetect/neuron.vim is executed before g:neuron_dir has a chance to be initialized.

I don't really have an idea for a more elegant remedy than this PR, but maybe we should instead of using get for accessing default variables, access them using an autoload function, i.e. neuron#neuron_dir() that takes care of initializing the global when it is first called if uninitialized before?

lehmacdj commented 3 years ago

@fiatjaf or @fenetikm gentle ping here too.

I'm not super happy with how I'm solving this here, would be open to a better suggestion that can also solve this problem if you have one.

fiatjaf commented 2 years ago

I don't understand what you did here or your suggestions about autoload functions, but you clearly know much more vimscript than me.