michal-h21 / vim-zettel

VimWiki addon for managing notes according to Zettelkasten method
MIT License
557 stars 73 forks source link

make_random_chars-function not working with current Vim-Version from the official Ubuntu (20.04) package repo #81

Closed NMme closed 2 years ago

NMme commented 3 years ago

Hi,

I am using the current version of Vim from the official Ubuntu 20.04 distribution package which currently is Vim-Version 8.1.2269

However I got issues using the vim-zettel plugin as the function _zettel#vim-wiki#make_randomchars require the function srand() and rand() which are only supported starting from Vim Version 8.1.2342.

Error message (for documentation):

Error detected while processing function zettel#vimwiki#make_random_chars: line 1: E117: Unknown function: srand Error detected while processing function zettel#vimwiki#make_random_chars[2]..1: line 1: E121: Undefined variable: seed E116: Invalid arguments for function rand(seed) % 26)->nr2char() ...

Maybe it would be helpful to make the plugin more accessible to new users by finding a work-around or note the required vim-version in the README until a newer vim-version is added to the Ubuntu distribution packages.

Best Regards

bwildenhain commented 3 years ago

I ran into the same issue on Debian stable. Also the nvim variant in vimwiki.vim didn't work here. Above PR fixes the issue.

NMme commented 3 years ago

Hi, conditioning the version is a good start, but copy-pasting the nvim make_random_chars() into it causes many errors as luaeval() etc. is not compatible with normal vim. So this code still produces errors for normal vim-version (<802). I think there needs to be a completely new function only utilizing alternative possibilites to create random chars, e.g. this example.

Further I found there is a disclaimer in the docu already, noting that make_random_char() requires vim version 8.1.2342 However whenever vimwiki.vim is called (e.g normal zettel-creation) without even using this mode the function still gets defined and generates a lot of error prompts. Maybe the whole make_random_char() functionality should just be made dependable on the version to not confuse users with these error prompts.

bwildenhain commented 3 years ago

The new PR doesn't depend on luaeval anymore, you're welcome to test.

NMme commented 3 years ago

Nice solution to the problem, working as it should. Thank you!

bwildenhain commented 3 years ago

@michal-h21 What do you think about it?