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

Commit

Permalink
Correct boolean interpretation of configurations
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
baco-ceg authored and baco committed Apr 3, 2021
1 parent fc9b2fd commit 6e26f0e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
12 changes: 6 additions & 6 deletions lua/completion.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
if vim.fn.exists('g:loaded_vsnip_integ') then
api.nvim_call_function('vsnip_integ#do_complete_done', {
{
completed_item = completed_item,
Expand Down Expand Up @@ -129,7 +129,7 @@ local function hasConfirmedCompletion()
require 'snippets'.expand_at_cursor(completed_item.user_data.actual_item, completed_item.word)
end
end
if opt.get_option('enable_auto_paren') == 1 then
if opt.get_option('enable_auto_paren') then
autoAddParens(completed_item)
end
if completed_item.user_data.snippet_source == 'UltiSnips' then
Expand Down Expand Up @@ -174,7 +174,7 @@ function M.on_InsertEnter()

-- TODO: remove this
local autoChange = false
if opt.get_option('auto_change_source') == 1 then
if opt.get_option('auto_change_source') then
autoChange = true
end

Expand All @@ -189,13 +189,13 @@ function M.on_InsertEnter()
-- complete if changes are made
if l_changedTick ~= manager.changedTick then
manager.changedTick = l_changedTick
if opt.get_option('enable_auto_popup') == 1 then
if opt.get_option('enable_auto_popup') then
source.autoCompletion()
end
if opt.get_option('enable_auto_hover') == 1 then
if opt.get_option('enable_auto_hover') then
hover.autoOpenHoverInPopup(manager)
end
if opt.get_option('enable_auto_signature') == 1 then
if opt.get_option('enable_auto_signature') then
signature.autoOpenSignatureHelp()
end
end
Expand Down
4 changes: 2 additions & 2 deletions lua/completion/matching.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ local opt = require 'completion.option'
local M = {}

local function setup_case(prefix, word)
local ignore_case = opt.get_option('matching_ignore_case') == 1
local ignore_case = opt.get_option('matching_ignore_case')

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

Expand Down
6 changes: 3 additions & 3 deletions lua/completion/source.lua
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ local triggerCurrentCompletion = function(bufnr, line_to_cursor, prefix, textMat
if value.server_capabilities.completionProvider == nil then
break
end
if opt.get_option('enable_server_trigger') == 1 then
if opt.get_option('enable_server_trigger') then
triggered = triggered or util.checkTriggerCharacter(line_to_cursor,
value.server_capabilities.completionProvider.triggerCharacters)
end
Expand All @@ -101,7 +101,7 @@ local triggerCurrentCompletion = function(bufnr, line_to_cursor, prefix, textMat
if complete_source['triggered_only'] ~= nil then
local triggered_only = util.checkTriggerCharacter(line_to_cursor, complete_source['triggered_only'])
if not triggered_only then
if opt.get_option('auto_change_source') == 1 then
if opt.get_option('auto_change_source') then
manager.changeSource = true
end
return
Expand Down Expand Up @@ -164,7 +164,7 @@ function M.autoCompletion()
-- not sure if I should clear cache here
complete.clearCache()
-- api.nvim_input("<c-g><c-g>")
if opt.get_option('trigger_on_delete') == 1 then
if opt.get_option('trigger_on_delete') then
M.triggerCompletion(false)
end
M.stop_complete = false
Expand Down

0 comments on commit 6e26f0e

Please sign in to comment.