Commit Graph

65 Commits

Author SHA1 Message Date
hrsh7th
746896cb28 use vim.uv.hrtime instead of os.clock 2024-11-25 10:49:06 +09:00
hrsh7th
cc683345c9 Format with stylua 2024-10-20 04:57:03 +00:00
hrsh7th
07f3f005c9 add performance.filtering_context_budget
fixes #2060
2024-10-20 13:56:45 +09:00
yioneko
1a1d7ecb73 perf: improve for source providing huge list of items (#1980)
* perf: avoid creating closure in cache.ensure and drop some cached getters

This mainly addresses the perf issue on large amount of calls to
`entry.new`. Previously every `cache.ensure` calls in the code path of
it creates an anonymous function, and it seems that luajit just could
not inline it. Function creation is not expensive in luajit, but that
overhead is noticeable if every `cache.ensure` call creates a function.
The first improvemnt is to solidate the cache callback and attach it to
the metatable of `entry`. This ensures that every created entry instance
share the same cache callback and no new functions will be frequently created,
reduces the ram usage and GC overhead.

To improve it further, some frequently accessed fields of entry like
`completion_item` and `offset` is refactored to use simple table access
instead of getter pattern. The current cached getter is implemented
using `cache.ensure`, which introduces two more levels of function calls
on each access: `cache.key` and `cache.get`. The overhead is okay if but
noticeable if entries amount is quite large: you need to call 4 functions on
a simple `completion_item` field access for each item.

All of the changes done in the commit is just constant time
optimization. But the different is huge if tested with LS providing
large amount of entries like tailwindcss.

* perf: delay fuzzy match on displayed vim item

`entry.get_vim_item` is a very heavy call, especially when user do
complex stuff on item formatting. Delay its call to window displaying to
let `performance.max_view_entries` applied to it.

* remove unneeded fill_defaults

* update gha

---------

Co-authored-by: hrsh7th <629908+hrsh7th@users.noreply.github.com>
2024-10-20 13:28:20 +09:00
Mehdi
41d7633e41 feat: sort source entries before slicing when using max_item_count (#1765)
* feat: sort source entries beforce slicing when using max_item_count

* feat: optimize filtering by max_item_count after sort

* fix: useless check if max_item_counts map is initialized

* fix: directly use entry source object when checking max_item_count
2023-12-10 20:37:02 +09:00
hrsh7th
6c84bc75c6 implement is_invalid detection 2023-08-10 16:52:10 +09:00
hrsh7th
e1f1b40790 Format with stylua 2023-06-23 04:29:59 +00:00
hrsh7th
9e49ed3fee fix confirm resolve 2023-06-23 13:29:35 +09:00
hrsh7th
09ff53ff57 Format with stylua 2023-06-09 12:27:08 +00:00
hrsh7th
559b688cda restore max_item_count 2023-06-09 21:26:42 +09:00
hrsh7th
3874e09e80 fix(entry): remove offset + 1 for tailwindcss 2023-05-28 22:33:20 +09:00
hrsh7th
15e8a636df Restore schedule_wrap 2023-05-27 23:02:35 +09:00
Folke Lemaitre
abb5c7519d feat: cmp async (#1583) 2023-05-26 02:46:53 +09:00
Folke Lemaitre
768548bf49 perf(source): only filter up to 200 entries and dont use the cache (#1574) 2023-05-16 14:00:44 +09:00
hrsh7th
0c6a89af9a Improve perf 2023-02-18 16:46:02 +09:00
hrsh7th
4c05626ccd Improve a bit 2022-11-25 03:20:07 +09:00
hrsh7th
e820335208 LSP 3.17 (#1306)
* 3.17

* PositionEncodingKind

* Implement PositionEncodingKind

* Remove luarc.json
2022-11-16 01:27:15 +09:00
yuys13
2427d06b65 Format by stylua (#1195) 2022-09-27 12:27:31 +09:00
hrsh7th
e1f31778a8 Optimize performance 2022-09-25 21:24:27 +09:00
Jonatan Branting
913eb85998 feat: add filter option to sources (#1067)
* feat: add `source.filter` config

This allows the user to specify a `filter` function for each source,
like this:

```lua
-- don't show entries with kind "Text" from the "nvim_lsp" source

sources = {
{
  name = "nvim_lsp",
  filter = function(entry, ctx)
    local kind = types.lsp.CompletionItemKind[entry:get_kind()]

    if kind == "Text" then
      return true
    end
  },
}
```

By utilizing the `ctx` parameter, the user can also ignore certain
entries in certain contexts.

* fixup! feat: add `source.filter` config

* fixup! feat: add `source.filter` config
2022-09-08 12:48:27 +09:00
hrsh7th
bf5593df8e Improve typings 2022-07-24 12:44:53 +09:00
hrsh7th
0318a3cbc1 Improve the codes for sumneko friendly 2022-05-13 19:25:00 +09:00
hrsh7th
c07350181f Implement matching config.
Fix #796
2022-02-13 16:44:45 +09:00
hrsh7th
2e4270d028 Improve incomplete handling 2021-11-24 12:57:04 +09:00
hrsh7th
ac476e05df Remove misc.readonly
Fix #571
2021-11-23 23:22:22 +09:00
hrsh7th
1944b46336 Allow to take the full SourceConfig from source API (#561)
* - SourceConfig.opts -> SourceConfig.option
- Add SourceConfig.trigger_characters
- Allow accessing full SourceConfig from source

* fmt&lint
2021-11-23 21:17:03 +09:00
Jonas Strittmatter
c2a9e0ccaa Fix possible nil argument to string.byte (#550) 2021-11-18 18:57:24 +09:00
hrsh7th
83a328c876 Improve completion reset handling 2021-11-18 02:54:27 +09:00
hrsh7th
286b9f78d1 Refactor get_active_entry and core.filter (#535)
* Refactor get_active_entry and core.filter

* Refactor source.lua
2021-11-17 22:38:56 +09:00
hrsh7th
8c08bdf7a4 Allow the callback invoking multiple times if it's the recent one 2021-11-04 18:34:28 +09:00
hrsh7th
b4622ed7d2 Fix 2021-11-02 15:46:01 +09:00
hrsh7th
7bc2738e14 Support isIncomplete only response 2021-11-02 15:21:19 +09:00
hrsh7th
cae2e8f48b RFC: cmdline completion (#362)
* manual support dot-repeat

* cmdwin and terminal

* cmdline only

* Fix

* fix

* Improve

* Fix test

* Support macro

* disable cmdline for now

* Simplify

* fmt

* consume once

* Ignore = type

* cmdline

* fmt

* Improve

* update

* fmt

* Support incsearch

* fix

* Add api

* Avoid cmdline completion if the native_menu enabled

* fix for macro

* Improve

* fmt

* Insert-mode only by default

* Update

* avoid conflict

* Improve default mapping

* Fix

* fix

* similar to native

* Update

* Fix README.md

* Improve

* Use <afile>
2021-10-27 12:38:46 +09:00
hrsh7th
ebe040b1a9 Fix #279 2021-10-16 13:27:36 +09:00
hrsh7th
d8e6a865e4 Use instead of 2021-10-11 00:43:53 +09:00
hrsh7th
67d43ddd59 Fix incorrect highlight 2021-10-11 00:26:21 +09:00
hrsh7th
3a51a8ec7b Fix #294 2021-10-10 11:57:02 +09:00
hrsh7th
ada9ddeff7 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>
2021-10-08 18:27:33 +09:00
hrsh7th
07f84fe8d6 Fix #232 2021-09-22 02:15:34 +09:00
hrsh7th
b99d7292b0 Fix #219 2021-09-19 01:49:07 +09:00
hrsh7th
b47a703a48 RFC: CmpStatus command (#210)
* Add `CmpStatus` command

* Update headings

* Fix heading

* Update headings

* Add README.md

* Fix tests

* Force invoke InsertEnter
2021-09-17 13:29:28 +09:00
hrsh7th
6173796b2b Support Vim script plugins 2021-09-13 23:57:59 +09:00
hrsh7th
abed04a6d4 Improve performance and buf fixes 2021-09-07 01:14:17 +09:00
hrsh7th
889109cbc0 Implement source specific options 2021-09-03 20:30:40 +09:00
hrsh7th
61984efaf0 Improve scheduling 2021-08-27 21:34:34 +09:00
hrsh7th
ec3f8aedaf Add completion.get_trigger_characters as configurable option 2021-08-26 16:50:23 +09:00
hrsh7th
d1b32f241f Add SourceBaseApiParams to get_trigger_characters API 2021-08-25 11:30:45 +09:00
hrsh7th
f7bb6f1c6e Add SourceBaseApiParams 2021-08-25 11:30:45 +09:00
hrsh7th
cbb80af6dd Fix is_available call 2021-08-24 13:49:05 +09:00
hrsh7th
ed4f2fc4a6 Reset if empty response was returned on waiting status. 2021-08-24 01:45:58 +09:00