Skip to content
This repository was archived by the owner on Oct 13, 2021. It is now read-only.

Commit ddb3665

Browse files
committed
Correct boolean interpretation of configurations
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.
1 parent fc9b2fd commit ddb3665

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

lua/completion.lua

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ local function applyAddtionalTextEdits(completed_item)
9898
if completed_item.user_data.lsp ~= nil then
9999
local item = completed_item.user_data.lsp.completion_item
100100
-- vim-vsnip have better additional text edits...
101-
if vim.fn.exists('g:loaded_vsnip_integ') == 1 then
101+
if vim.fn.exists('g:loaded_vsnip_integ') then
102102
api.nvim_call_function('vsnip_integ#do_complete_done', {
103103
{
104104
completed_item = completed_item,
@@ -129,7 +129,7 @@ local function hasConfirmedCompletion()
129129
require 'snippets'.expand_at_cursor(completed_item.user_data.actual_item, completed_item.word)
130130
end
131131
end
132-
if opt.get_option('enable_auto_paren') == 1 then
132+
if opt.get_option('enable_auto_paren') then
133133
autoAddParens(completed_item)
134134
end
135135
if completed_item.user_data.snippet_source == 'UltiSnips' then
@@ -174,7 +174,7 @@ function M.on_InsertEnter()
174174

175175
-- TODO: remove this
176176
local autoChange = false
177-
if opt.get_option('auto_change_source') == 1 then
177+
if opt.get_option('auto_change_source') then
178178
autoChange = true
179179
end
180180

@@ -189,13 +189,13 @@ function M.on_InsertEnter()
189189
-- complete if changes are made
190190
if l_changedTick ~= manager.changedTick then
191191
manager.changedTick = l_changedTick
192-
if opt.get_option('enable_auto_popup') == 1 then
192+
if opt.get_option('enable_auto_popup') then
193193
source.autoCompletion()
194194
end
195-
if opt.get_option('enable_auto_hover') == 1 then
195+
if opt.get_option('enable_auto_hover') then
196196
hover.autoOpenHoverInPopup(manager)
197197
end
198-
if opt.get_option('enable_auto_signature') == 1 then
198+
if opt.get_option('enable_auto_signature') then
199199
signature.autoOpenSignatureHelp()
200200
end
201201
end

lua/completion/matching.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ local opt = require 'completion.option'
44
local M = {}
55

66
local function setup_case(prefix, word)
7-
local ignore_case = opt.get_option('matching_ignore_case') == 1
7+
local ignore_case = opt.get_option('matching_ignore_case')
88

9-
if ignore_case and opt.get_option('matching_smart_case') == 1 and prefix:match('[A-Z]') then
9+
if ignore_case and opt.get_option('matching_smart_case') and prefix:match('[A-Z]') then
1010
ignore_case = false
1111
end
1212

lua/completion/source.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ local triggerCurrentCompletion = function(bufnr, line_to_cursor, prefix, textMat
8787
if value.server_capabilities.completionProvider == nil then
8888
break
8989
end
90-
if opt.get_option('enable_server_trigger') == 1 then
90+
if opt.get_option('enable_server_trigger') then
9191
triggered = triggered or util.checkTriggerCharacter(line_to_cursor,
9292
value.server_capabilities.completionProvider.triggerCharacters)
9393
end
@@ -101,7 +101,7 @@ local triggerCurrentCompletion = function(bufnr, line_to_cursor, prefix, textMat
101101
if complete_source['triggered_only'] ~= nil then
102102
local triggered_only = util.checkTriggerCharacter(line_to_cursor, complete_source['triggered_only'])
103103
if not triggered_only then
104-
if opt.get_option('auto_change_source') == 1 then
104+
if opt.get_option('auto_change_source') then
105105
manager.changeSource = true
106106
end
107107
return
@@ -164,7 +164,7 @@ function M.autoCompletion()
164164
-- not sure if I should clear cache here
165165
complete.clearCache()
166166
-- api.nvim_input("<c-g><c-g>")
167-
if opt.get_option('trigger_on_delete') == 1 then
167+
if opt.get_option('trigger_on_delete') then
168168
M.triggerCompletion(false)
169169
end
170170
M.stop_complete = false

0 commit comments

Comments
 (0)