Correct boolean interpretation for config variables#365
Correct boolean interpretation for config variables#365baco wants to merge 6 commits intonvim-lua:masterfrom
Conversation
Instead of comparing configuration values read from local config files with integer values 1 or 0, use their boolean interpretation as they can be directly set to v:true or v:false respectively in config files.
ddb3665 to
6e26f0e
Compare
| if completed_item.user_data.lsp ~= nil then | ||
| local item = completed_item.user_data.lsp.completion_item | ||
| -- vim-vsnip have better additional text edits... | ||
| if vim.fn.exists('g:loaded_vsnip_integ') == 1 then |
There was a problem hiding this comment.
I think that the == 1 is mandatory here, as VimL functions return an integer.
There was a problem hiding this comment.
Result may be an integer, but according to documentation, any value other than zero is considered True, and only 0 is considered False:
exists()
exists({expr}) The result is a Number, which is TRUE if {expr} is
defined, zero otherwise.
So which integer doesn't really matters, as long as it can be interpreted the same way boolean expressions are interpreted in C language.
Restricting the comparison to == 1 may lead to unexpected behaviors if for instance, on runtime, the exists() function decides to return 2; which according to documentation is also a valid return value when the expression is defined.
There was a problem hiding this comment.
But 0 is true in Lua. You could do if XX ~= 0
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
There was a problem hiding this comment.
But
0istruein Lua. You could doif XX ~= 0
Ok, true, corrected the PR
|
I think the change should be done in |
Instead of comparing configuration values read from local config files
with integer values 1 or 0, use their boolean interpretation as they can
be directly set to v:true or v:false respectively in config files.
Solves #364