Use floating window for completion menus (#224)

* WIP

* WIP

* Fix #226

* Insert text

* Emulate vim native

* テキトウ

* Tekito

* Move scrollbar impl

* aaa

* Ignore unexpected event

* fix

* fix scroll

* Refactor (conflict...)

* Fix bug

* Positive integer

* Refactor a bit

* Fix for pumheight=0

* fx

* Improve matching highlight

* Improve colorscheme handling

* fmt

* Add cmp.visible

* Fix pum pos

* ABBR_MARGIN

* Fix cel calculation

* up

* refactor

* fix

* a

* a

* compat

* Remove current completion state

* Fix ghost text

* Add feature toggle

* highlight customization

* Update

* Add breaking change announcement

* Add README.md

* Remove unused function

* extmark ephemeral ghost text

* Support native comp

* Fix docs  pos

* a

* Remove if native menu visible

* theme async

* Improvement idea: option to disables insert on select item (#240)

* use ghost text instead of insertion on prev/next item

* add disables_insert_on_selection option

* move disable_insert_on_select option as argumet on

* update README

* use an enum behavior to disable insert on select

* Adopt contribution

* Preselect

* Improve

* Change configuration option

* a

* Improve

* Improve

* Implement proper <C-e> behavior to native/custom

* Support <C-c> maybe

* Improve docs view

* Improve

* Avoid syntax leak

* TODO: refactor

* Fix

* Revert win pos

* fmt

* ghost text remaining

* Don't use italic by default

* bottom

* dedup by label

* Ignore events

* up

* Hacky native view partial support

* up

* perf

* improve

* more cache

* fmt

* Fix format option

* fmt

* recheck

* Fix

* Improve

* Improve

* compat

* implement redraw

* improve

* up

* fmt/lint

* immediate ghost text

* source timeout

* up

* Support multibyte

* disable highlight

* up

* improve

* fmt

* fmt

* fix

* fix

* up

* up

* Use screenpos

* Add undojoin check

* Fix height

* matcher bug

* Fix dot-repeat

* Remove undojoin

* macro

* Support dot-repeat

* MacroSafe

* Default item count is 200

* fmt

Co-authored-by: Eric Puentes <eric.puentes@mercadolibre.com.co>
This commit is contained in:
hrsh7th
2021-10-08 18:27:33 +09:00
committed by GitHub
parent 5bed2dc9f3
commit ada9ddeff7
31 changed files with 1802 additions and 718 deletions

View File

@@ -104,10 +104,12 @@ source.get_entries = function(self, ctx)
if not inputs[o] then
inputs[o] = string.sub(ctx.cursor_before_line, o)
end
e.score = matcher.match(inputs[o], e:get_filter_text(), { e:get_word() })
local score, matches = matcher.match(inputs[o], e:get_filter_text(), { e:get_word() })
e.score = score
e.exact = false
e.matches = matches
if e.score >= 1 then
e.exact = vim.tbl_contains({ e:get_filter_text(), e:get_word() }, inputs[o])
e.exact = e:get_filter_text() == inputs[o] or e:get_word() == inputs[o]
table.insert(entries, e)
end
end
@@ -115,7 +117,7 @@ source.get_entries = function(self, ctx)
return entries
end)
local max_item_count = self:get_config().max_item_count
local max_item_count = self:get_config().max_item_count or 200
local limited_entries = {}
for _, e in ipairs(entries) do
table.insert(limited_entries, e)
@@ -306,37 +308,40 @@ source.complete = function(self, ctx, callback)
option = self:get_config().opts,
completion_context = completion_context,
},
self.complete_dedup(vim.schedule_wrap(function(response)
if #((response or {}).items or response or {}) > 0 then
debug.log(self:get_debug_name(), 'retrieve', #(response.items or response))
local old_offset = self.offset
local old_entries = self.entries
async.timeout(
self.complete_dedup(vim.schedule_wrap(function(response)
if #((response or {}).items or response or {}) > 0 then
debug.log(self:get_debug_name(), 'retrieve', #(response.items or response))
local old_offset = self.offset
local old_entries = self.entries
self.status = source.SourceStatus.COMPLETED
self.incomplete = response.isIncomplete or false
self.entries = {}
for i, item in ipairs(response.items or response) do
if (misc.safe(item) or {}).label then
local e = entry.new(ctx, self, item)
self.entries[i] = e
self.offset = math.min(self.offset, e:get_offset())
self.status = source.SourceStatus.COMPLETED
self.incomplete = response.isIncomplete or false
self.entries = {}
for i, item in ipairs(response.items or response) do
if (misc.safe(item) or {}).label then
local e = entry.new(ctx, self, item)
self.entries[i] = e
self.offset = math.min(self.offset, e:get_offset())
end
end
end
self.revision = self.revision + 1
if #self:get_entries(ctx) == 0 then
self.offset = old_offset
self.entries = old_entries
self.revision = self.revision + 1
if #self:get_entries(ctx) == 0 then
self.offset = old_offset
self.entries = old_entries
self.revision = self.revision + 1
end
else
debug.log(self:get_debug_name(), 'continue', 'nil')
if completion_context.triggerKind == types.lsp.CompletionTriggerKind.TriggerCharacter then
self:reset()
end
self.status = prev_status
end
else
debug.log(self:get_debug_name(), 'continue', 'nil')
if completion_context.triggerKind == types.lsp.CompletionTriggerKind.TriggerCharacter then
self:reset()
end
self.status = prev_status
end
callback()
end))
callback()
end)),
2000
)
)
return true
end