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

Commit abeb79f

Browse files
committed
feat: completion on delete(#75)
fix: luacheck
1 parent 704f9a3 commit abeb79f

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

lua/source.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ function M.autoCompletion(manager)
131131
-- reset completion when deleting character in insert mode
132132
if #prefix < M.prefixLength and vim.fn.pumvisible() == 0 then
133133
M.chain_complete_index = 1
134+
if vim.g.completion_trigger_on_delete == 1 then
135+
M.triggerCompletion(false, manager)
136+
end
134137
M.stop_complete = false
135138
end
136139
M.prefixLength = #prefix

lua/source/lsp.lua

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
local vim = vim
22
local protocol = require 'vim.lsp.protocol'
3-
local api = vim.api
43
local util = require 'completion.util'
54
local match = require 'completion.matching'
65
local M = {}
@@ -87,10 +86,8 @@ M.triggerFunction = function(prefix, _, bufnr, _)
8786
M.callback = true
8887
return
8988
end
90-
if api.nvim_get_mode()['mode'] == 'i' or api.nvim_get_mode()['mode'] == 'ic' then
91-
local matches = text_document_completion_list_to_complete_items(result, prefix, util.fuzzy_score)
92-
M.items = matches
93-
end
89+
local matches = text_document_completion_list_to_complete_items(result, prefix, util.fuzzy_score)
90+
M.items = matches
9491
M.callback = true
9592
end)
9693
end

plugin/completion.vim

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ if ! exists('g:completion_enable_auto_popup')
5353
let g:completion_enable_auto_popup = 1
5454
endif
5555

56+
if ! exists('g:completion_trigger_on_delete')
57+
let g:completion_trigger_on_delete = 0
58+
end
59+
5660
if ! exists('g:completion_trigger_keyword_length')
5761
let g:completion_trigger_keyword_length = 1
5862
endif

0 commit comments

Comments
 (0)