michal-h21 / vim-zettel

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

Make #vimwiki#make_random_chars compatible to Vim 8.1 #83

Closed bwildenhain closed 3 years ago

bwildenhain commented 3 years ago

Adapted vimwiki.vim to work without srand (i.e. version prior to 8.1.2342).

Fixes #81

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

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 didn't simply copy-paste the nvim-code, but adapted it slightly, so it works in vim compiled with lua-support without any errors (packages vim-nox or vim-gtk3 in Debian), but of course, it would be better to have code which is compatible with lua-less vim.

NMme commented 3 years ago

I see, thank you for clarifying!

bwildenhain commented 3 years ago

I created PR #84 without depending on lua.