Commit Graph

637 Commits

Author SHA1 Message Date
hrsh7th
c4c784a621 don't use deprecated functions 2025-04-01 12:42:10 +09:00
ColdSpirit0
1e1900b076 Preserve 'buflisted' state when applying LSP text edits (#2141) 2025-03-14 16:08:39 +09:00
Niza Toshpulatov
c27370703e Fix typos (#2135) 2025-03-01 08:51:11 +08:00
wsdjeg
5a11682453 Format with stylua 2025-02-23 15:16:29 +00:00
IguanaCucumber
1deeb87b68 fix(utils): Only call callback if type(callback) == "function" (#2038) 2025-02-23 23:16:18 +08:00
abeldekat
12509903a5 fix: Outdated completion item with mini.snippets (#2126)
* fix: Outdated completion item with mini.snippets

* fix: Outdated completion item with mini.snippets. Prevent completion suggestions directly after snippet expand

* fix: Outdated completion item with mini.snippets. Undo changes

* fix: Outdated completion item with mini.snippets. The cmp.resubscribe solution

---------

Co-authored-by: abeldekat <abel@nomail.com>
2025-01-23 16:22:37 +09:00
Andre Toerien
8c82d0bd31 fix: enable sort_text comparator by default (#2122) 2025-01-06 23:12:10 +09:00
Andre Toerien
2c35020d30 fixup! fix: remove deprecated use of vim.tbl_add_reverse_lookup (#1931) (#1991) 2025-01-06 23:10:21 +09:00
Rob Pilling
5a9ad0d88b Fix completion menu showing over the cmd win (#1904)
Removed/regressed in 5054c14490
2025-01-06 21:09:15 +09:00
hrsh7th
28ab7f7d05 use only the specified field's width for the window width 2025-01-06 18:40:08 +09:00
林柏臣
b555203ce4 fix: make <M-`> work again (#2107)
* fix: make <M-`> work again

* Update keymap_spec.lua

fix typo in keymap_spec.lua
2024-12-20 14:27:07 +09:00
mamekoro
8c447245e1 fix: typo in view.lua (#2103) 2024-12-20 12:10:40 +09:00
hrsh7th
98e8b9d593 expose latest response for creating compat layer 2024-12-18 15:12:58 +09:00
hrsh7th
3403e2e939 Format with stylua 2024-12-10 03:04:32 +00:00
hrsh7th
1d57252744 add cmp.get_registered_sources and CmpRegisterSource /CmpUnregisterSource autocmd. 2024-12-10 12:04:15 +09:00
Wick
ca4d3330d3 fix: some symbols can't be mapped correctly (#2081)
* fix: support , . / symbol binding

* test: add keymap test
2024-11-30 15:34:44 +09:00
hrsh7th
ed31156aa2 use vim.loop if vim.uv is not defined 2024-11-25 11:52:47 +09:00
hrsh7th
746896cb28 use vim.uv.hrtime instead of os.clock 2024-11-25 10:49:06 +09:00
Epheien
be7bd4c5f8 fix: scrollbar thumb ui issue (#2068)
Co-authored-by: eph <eph@MacBook-Pro.local>
2024-11-21 17:51:29 +09:00
hrsh7th
2d7e6da1ec Format with stylua 2024-11-21 08:40:20 +00:00
Karanveer B
6fade6db39 fix: make <C-'> work again (#2093) 2024-11-21 17:40:04 +09:00
Francois Poizat
40a03dc225 fix: make <c-,> and <c-:> work again (#2092) 2024-11-19 21:37:27 +09:00
hrsh7th
f17d9b4394 support cpying self-referenced table (#2076) 2024-11-02 13:54:35 +09:00
phanium
7d4051064c fix: make <c-;> work again (#2073)
* fix: make <c-;> work again

* fix: also <c-_>
2024-11-02 13:39:41 +09:00
David van Munster
29fb485457 feat: allow more completion highlight control (#1972)
* feat(view): allow hl_group to be a table

* feat: improve table field naming
2024-10-21 23:10:07 +09:00
hrsh7th
88661b7cbf Format with stylua 2024-10-21 12:05:14 +00:00
zeertzjq
19bd8c7c9a fix: use \<* notation for keymap.normalize (#2069)
Fix https://github.com/hrsh7th/nvim-cmp/pull/1935#issuecomment-2426250159
2024-10-21 21:05:01 +09:00
Greg Hurrell
5d0651c9d6 fix: don't blow up when nvim_buf_get_lines() returns Blobs (#2050)
* fix: don't blow up when `nvim_buf_get_lines()` returns Blobs

Some LSP servers may return binary garbage and `nvim_buf_get_lines()`
will return a `Blob` instead of a `String` in those cases.

I added some `print(vim.inspect())` debugging in
`entry.get_documentation()` to prove that by the time the text passes
through there, it's already garbage.

Here's an excerpt from a sample line returned by `nvim_buf_get_lines()`,
as rendered by `vim.inspect()`:

    default\0\0\0!      vim.opt.background = 'dark'\0\0\0000

(etc)

Now, this looks like an LSP bug to me, but I think we shouldn't allow
buggy LSP output to crash nvim-cmp. "Be conservative in what you send,
be liberal in what you accept" and all that.

So, degrade by coercing any `Blob` we see into a `String` before passing
it to `strdisplaywidth()`.

Closes: https://github.com/hrsh7th/nvim-cmp/issues/820

* add comment

---------

Co-authored-by: hrsh7th <629908+hrsh7th@users.noreply.github.com>
2024-10-21 20:38:46 +09:00
Jaehwang Jung
2c93d5e7e2 perf: use builtin for key normalization (#1935) 2024-10-21 10:35:21 +09:00
Roey Darwish Dror
82bd4b5943 Avoid calling del_extmark on non existing buffer (#2053)
This fixes a problem with Neogit is discussed here:

https://github.com/NeogitOrg/neogit/discussions/1492
2024-10-20 14:04:43 +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
hrsh7th
c183f45fab Format with stylua 2024-10-20 04:28:33 +00: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
pynappo
ae644feb7b Add newer fallback method for tree-sitter scopes (#2006) 2024-08-01 19:51:04 +09:00
NAKAI Tsuyoshi
d818fd0624 fix(view): check in get_selected_index (#1993) 2024-07-16 10:33:54 +09:00
NAKAI Tsuyoshi
e1757aea61 feat(view): add api get_selected_index (#1986) 2024-07-16 01:29:25 +09:00
Tristan Knight
7e348da6e5 fix(feedkeys): resolve issue with some copilot completions (#1981)
* fix(feedkeys): resolve issue with some copilot completions

* fix(feedkey): further adjustments

* fix: missed flag from testing

* fix(feedkeys): error handle and make tests pass
2024-07-14 15:04:40 +09:00
Logan Walls
a110e12d0b enable ghost_text for multi-line completions (#1886) 2024-06-08 15:59:43 +09:00
hrsh7th
5260e5e8ec use nvim_get_option_value instead of nvim{,_buf,_win}_get_option 2024-05-17 22:56:28 +09:00
Augusto César Dias
abacd4cb7f Move to non deprecated function calls (#1930)
* Move to non deprecated function calls

* Keeping it compatible with older versions
2024-05-17 18:49:38 +09:00
Lewis Russell
31a2939e55 fix: remove deprecated use of vim.tbl_add_reverse_lookup (#1931) 2024-05-17 15:54:23 +09:00
kjuq
2412237181 fix: cmp.close() when autocompletion = false (#1921)
cf. https://github.com/hrsh7th/nvim-cmp/pull/1920
2024-05-12 18:45:22 +09:00
kjuq
1d88772dc6 fix: unexpected behavior when autocomplete = false (#1920)
- https://github.com/hrsh7th/nvim-cmp/issues/1251
- https://github.com/hrsh7th/nvim-cmp/issues/1919
2024-05-12 17:14:05 +09:00
Jaehwang Jung
8f3c541407 perf: don't eagerly load vim.snippet (#1896)
Evaluating `vim.snippet` loads many modules, which takes about 1ms.
2024-04-23 11:00:27 +09:00
hrsh7th
ce16de5665 support snippet item in ghost_text 2024-04-02 16:05:54 +09:00
hrsh7th
7240362105 support snippet item in ghost_text 2024-04-02 16:04:51 +09:00
mcauley-penney
7aa3f71932 feat: add option for view to follow cursor (#1727)
* feat: add option for custom entry view to follow cursor

Creates an option to allow the custom entries
view to follow the user's cursor as they type.

To enable, set
```lua
require("cmp").setup({
  view = {
    entries = {
      follow_cursor = true
    }
  }
})
```

Original source at 7569056388

Closes #1660

Co-authored-by: lvimuser <109605931+lvimuser@users.noreply.github.com>

* doc: add view.follow_cursor option to docs

---------

Co-authored-by: lvimuser <109605931+lvimuser@users.noreply.github.com>
2024-03-31 15:46:16 +09:00
Yi Ming
97dc716fc9 feat: make winblend configurable (#1861) 2024-03-24 20:44:34 +09:00
hrsh7th
c34fa793ea re-improve resolve behavior 2024-03-24 17:45:24 +09:00