Commit Graph

233 Commits

Author SHA1 Message Date
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
林柏臣
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
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
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
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
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
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
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
hrsh7th
630cdf7d54 fix #1858 2024-03-22 18:44:52 +09:00
hrsh7th
be50b23910 Format with stylua 2024-03-22 07:59:56 +00:00
hrsh7th
b7b2c12610 - fix ci
- fix #1780
2024-03-22 16:59:37 +09:00
hankertrix
53d80d4d0c fix: small windows no longer constantly throw errors (#1824)
The entries_win:open function will fail when either the width or
the height of the window is less than 1, which will result in the
nvim_win_set_cursor being passed a nil value for self.entries_win.win
instead of a number, which causes an error to constantly appear when
the window is small. Hence, a guard clause to check for whether
self.entries_win.win is nil is added to stop the error from occurring.

Also fixed the rarer 'height' must be a positive Integer error caused
by the window.update function, within the clause to draw the scrollbar
background. This error happens on small windows when pressing and
holding down the backspace key to delete a lot of characters at once.
The nvim_open_win function call to create the scrollbar
background throws the error when self.style.height is 0. Hence, an
additional check is added alongside the info.scrollable check which also
skips drawing the scrollbar thumb as it is not needed when the height is
0 and will result in a weird scrollbar thumb floating some distance
away from the text when holding down backspace to delete a lot of
characters.
2024-03-22 03:02:15 +09:00
Josef Litoš
a1b4ef08c2 feat: avoid global variable use (#1813) 2024-03-22 02:56:07 +09:00
Maria José Solano
51260c02a8 fix: remove usages from vim.lsp.util.parse_snippet (#1734) 2023-10-25 10:54:30 +09:00
jmp
d3a3056204 ci: fix broken tests (#1729)
feedkeys_spec.lua:
In the "backspace test spec, the backspace
setting is given an integer, but only accepts
strings. Here, I assume that 0 was intended to
set backspace to a nil value, which can be done
with the empty string. I also corrected the name
of the test spec.

core_spec.lua:
In the "textedit" test spec, the actual and
expected outputs as well as the actual and
expected end characters did not match.
2023-10-18 15:37:12 +09:00
Folke Lemaitre
6f118169af fix(async): properly trigger callbacks when canceling and fix delays in throttle.sync (#1611) 2023-06-09 19:08:28 +09:00
Folke Lemaitre
abb5c7519d feat: cmp async (#1583) 2023-05-26 02:46:53 +09:00
hrsh7th
935b4069ce Improve misc.merge 2023-05-08 11:41:15 +09:00
hrsh7th
5a80cd4eca Fix #897 2023-05-07 15:00:04 +09:00
hrsh7th
11102d3db1 Squashed commit of the following:
commit 6e81cce2cf9b9487e92c15cdfb145647de7c2db5
Author: hrsh7th <629908+hrsh7th@users.noreply.github.com>
Date:   Thu Apr 27 01:11:41 2023 +0900

    Improve key identity check
2023-04-27 11:02:23 +09:00
hrsh7th
0c6a89af9a Improve perf 2023-02-18 16:46:02 +09:00
hrsh7th
ea9eaff573 Maybe improve cmdline redraw 2023-02-16 22:53:08 +09:00
tummetott
cfafe0a1ca Improved: ALL option settings do not fire the OptionSet event (#1417) 2023-02-04 01:09:00 +09:00
tummetott
e7e2ef7031 Setting local window options does not trigger the "OptionSet" event (#1415) 2023-01-26 20:10:50 +09:00
MovEaxEsp
c49ad26e89 keymap.lua: Fix duplicate keymap detection (#1379)
'listen' has some code in it to try to not re-set a map for an existing mapping, by checking the 'desc' of the table returned from 'get_map'. Since 'desc' was never included in the table returned from 'get_map', I'm assuming my changes here were always the intention.

This change seems to fix an issue I was seeing (with cmp-nvim-ultisnips at least) where every time I'd enter and leave Insert mode, seemingly another <Tab> handler was getting registered, overtime causing <Tab> in Insert mode to get slower and slower.
2022-12-31 02:58:28 +09:00
hrsh7th
e55033fce4 Fix #1322 2022-12-27 15:53:05 +09:00
Lyude
a9c701fa7e Round up width/height for windows (#1373)
Ever since neovim introduced the nvim_ui_pum_set_bounds() call, GUI clients
have gained the ability to inform neovim of the current bounds of an
external popup menu provided by ext_popupmenu.

Since external popup menus are allowed to be any size in pixels which may
or may not line up cleanly on the grid, nvim allows for fractional
coordinates to be reported. This also will mean that in the event of this,
we'll end up with a cmp.WindowStyle with a float value for width/height -
which is incompatible with vim.api.nvim_open_win() and will cause us to hit
errors with GUI clients using this API call.

So, fix this by simply rounding up the width/height.
2022-12-27 13:11:42 +09:00
NAKAI Tsuyoshi
8bbaeda725 fix(api): consider multibyte characters in get_screen_cursor (cmdline) (#1352)
* fix(api): consider multibyte characters in get_screen_cursor (cmdline)

* style: format with stylua

* test: tell luacheck that it is intended unreachable code
2022-12-15 20:27:02 +09:00
pure-bliss
8a9e8a89ee feat: added scrollbar option to window.completition ( #1087) (#1308)
* #1087 added hide_scrollbar option to window.completition

* Renamed hide_scrollbar to scrollbar, changed default value (#1087)

* doc description update (#1087)

* determining info.scrollbar value considering config scrollbar (#1087)

* window.bordered scrollbar default value fix (#1087)
2022-11-18 17:31:06 +09:00
hrsh7th
e820335208 LSP 3.17 (#1306)
* 3.17

* PositionEncodingKind

* Implement PositionEncodingKind

* Remove luarc.json
2022-11-16 01:27:15 +09:00
hrsh7th
3347dd3c59 Fix #1217 2022-10-15 15:20:35 +09:00
hrsh7th
69476c9e06 ci 2022-10-15 15:16:27 +09:00
figsoda
714ccb7483 fix compatibility with nvim < 0.8 (#1227) 2022-10-12 00:35:19 +09:00
hrsh7th
53bd574901 Fix #1213 2022-10-11 11:44:23 +09:00
hrsh7th
203aa26fc2 Fix for cmdheight=0
Fixes #1196
Fixes hrsh7th/cmp-cmdline#64
2022-10-02 20:22:13 +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
Lewis Russell
6b3dbc8377 fix(timer): close timers before Neovim exits (#1166) 2022-09-02 11:29:13 +09:00
yuki yano
b5885696b1 Add incsearch_redraw_keys settings (#1162) 2022-08-31 12:42:43 +09:00
hrsh7th
7e67df513a Fix #1135 2022-08-20 20:42:43 +09:00