From ed8f85f1539bcf0976b72eb806c37d173953f90e Mon Sep 17 00:00:00 2001 From: jgmdev Date: Thu, 3 Jun 2021 00:25:26 -0400 Subject: [PATCH] [autocomplete] Exposed can_complete() Also fixed issue where the user init.lua could get executed before the plugin which would result on the user config options been overwritten by the plugin. --- data/plugins/autocomplete.lua | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/data/plugins/autocomplete.lua b/data/plugins/autocomplete.lua index 33c90df7..3cea655a 100644 --- a/data/plugins/autocomplete.lua +++ b/data/plugins/autocomplete.lua @@ -11,13 +11,13 @@ local DocView = require "core.docview" local Doc = require "core.doc" -- Amount of characters that need to be written for autocomplete -config.autocomplete_min_len = 1 +config.autocomplete_min_len = config.autocomplete_min_len or 1 -- The max amount of visible items -config.autocomplete_max_height = 6 +config.autocomplete_max_height = config.autocomplete_max_height or 6 -- The max amount of scrollable items -config.autocomplete_max_suggestions = 100 +config.autocomplete_max_suggestions = config.autocomplete_max_suggestions or 100 -- Maximum amount of symbols to cache per document -config.max_symbols = 2000 +config.max_symbols = config.max_symbols or 2000 local autocomplete = {} @@ -468,6 +468,13 @@ function autocomplete.complete(completions, on_close) autocomplete.open(on_close) end +function autocomplete.can_complete() + if #partial >= config.autocomplete_min_len then + return true + end + return false +end + -- -- Commands