-
Notifications
You must be signed in to change notification settings - Fork 77
Correct boolean interpretation for config variables #365
base: master
Are you sure you want to change the base?
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
@@ -98,7 +98,7 @@ local function applyAddtionalTextEdits(completed_item) | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that the == 1
is mandatory here, as VimL functions return an integer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But
0
istrue
in 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