Commit Graph

86 Commits

Author SHA1 Message Date
PlankCipher
0b751f6bee fix(ghost_text): ephemeral-like inline ghost-text workaround (#1688)
Refs:
  - https://github.com/hrsh7th/nvim-cmp/pull/1645
  - https://github.com/neovim/neovim/issues/24797
2023-11-06 17:58:22 +09:00
Maria José Solano
51260c02a8 fix: remove usages from vim.lsp.util.parse_snippet (#1734) 2023-10-25 10:54:30 +09:00
PlankCipher
51f1e11a89 fix(ghost_text): ephemeral causes a false positive of no inline support (#1645) 2023-08-12 11:55:52 +09:00
hrsh7th
3874e09e80 fix(entry): remove offset + 1 for tailwindcss 2023-05-28 22:33:20 +09:00
hrsh7th
1088b3743b Add extmark inline feature detection 2023-05-27 23:06:46 +09:00
Anshuman Medhi
950d0e3a93 ghost text inline (#1588) 2023-05-26 00:02:26 +09:00
François Fleur
d153771162 fix(ghost_text): safely apply virtual_text highlight (#1563) 2023-05-12 15:42:39 +09:00
Felipe Gomes
1cad30fcff Added a modified=false to documentation buffer, so it can be removed without E89 errors (#1557) 2023-05-05 15:54:16 +09:00
hrsh7th
0f47dcaf7e Add buftype=nofile for entries_win and docs_win
- reddit user mention this...
2023-05-04 19:35:24 +09:00
hrsh7th
8d2f190506 Fix #1550 2023-05-04 03:09:56 +09:00
Daniil Shvalov
524cc0ba61 fix(cmdline): properly compute string length (#1544) 2023-05-01 23:18:17 +09:00
hrsh7th
5dcbc91d9a Try to fix #1458 (#1548) 2023-05-01 23:15:54 +09:00
Joey Buiteweg
01f697a689 fix: in lua if(0) evaluates to true, so check vim.fn.has == 1 (#1465) 2023-02-27 15:39:37 +09:00
Joey Buiteweg
ba7a53478d fix: better check for if setcmdline() is available (#1456) 2023-02-22 16:23:58 +09:00
NAKAI Tsuyoshi
8202df9561 fix: prevent autocmd outbursts by using setcmdline instead of feedkey (#1446) 2023-02-19 00:58:05 +09:00
hrsh7th
0c6a89af9a Improve perf 2023-02-18 16:46:02 +09:00
Zahid
c53dd36adc Fix parantheses bug and use string.rep (#1297) 2022-11-12 11:16:12 +09:00
gegoune
c37ea78941 Update docs_view.lua (#1292)
Although I have `showbreak` set for normal editing I would rather not see that in documentation. RFC.

Setting to `NONE` as per `:h showbreak`:

```
	A window-local value overrules a global value.  If the global value is
	set and you want no value in the current window use NONE:  
		:setlocal showbreak=NONE
```
2022-11-11 11:27:19 +09:00
NAKAI Tsuyoshi
16ec8c6b12 fix(custom_entries_view): offset is also the number of bytes (#1288) 2022-11-10 09:26:26 +09:00
ADoyle
bdfadc1238 feat: select_next_item and select_prev_item support "count" option. deafults to 1 (#1262)
User can increase count value to select item with pagedown/pageup.

- cmp.select_prev_item({ behavior = behavior, count = 8 })
- cmp.select_next_item({ behavior = behavior, count = 8 })
2022-11-09 19:26:20 +09:00
NAKAI Tsuyoshi
c8d4afdad6 fix(custom_entries_view): consider multibyte characters (#1287) 2022-11-09 19:25:26 +09:00
sanka047
9bb8ee6e2d fix(custom_entries_view): remove off-by-one error with bottom_up selection order (#1261)
Closes #1260
2022-10-29 10:04:41 +09:00
hrsh7th
beb1d14c5e Add scrolloff option for completion window. 2022-10-02 19:47:01 +09:00
hrsh7th
3cc0c182ec Fix #1142 2022-08-20 21:58:53 +09:00
hrsh7th
9417f48a99 Restore filetype setting 2022-08-20 19:22:50 +09:00
hrsh7th
bf5593df8e Improve typings 2022-07-24 12:44:53 +09:00
gravndal
89df2cb223 Fix native_entries_view.info width and col calculations (#1075)
The dictionary returned by `pum_getpos()` uses `scrollbar` not
`scrollable` to indicate whether the scrollbar is visible or not.

In addition, the padding on the left side of the popup menu isn't
included in the output of `pum_getpos()`, meaning that both `col` and
`width` (as understood by nvim-cmp) are off by one when the cursor isn't
at column `0`.

These two issues were causing the documentation window and popup menu to
overlap.
2022-07-24 12:19:21 +09:00
hrsh7th
c4dcb1244a Fix border width calculation 2022-07-21 00:37:40 +09:00
Cameron
df6734aa01 Add Completion Window Options (#901)
* Add window.completion.side_padding and window.completion.col_offset

* add col_offset and side_padding options to config/window
2022-06-15 11:49:16 +09:00
hrsh7th
fae808a2bc dev (#813)
* feat: completion menu borders (#472)

* feat(custom_entries_view): pass custom border option

* feat(window): calculate offset needed for borders

* fix(window): adjust window height w/ too many results

* fix(window): center scrollbar with borders

* ref(custom_entries_view): use `FloatBorder` for borders

* fix(window): offset at bottom of window

* ref(window): move height adjustment to more logical place

* fix(window): improve popup placement

* fix(window): `border_offset` always `0` first time

* feat(window): support compact scrollbar with border

* fix(window): completion popup on cursorline

* perf(window): simplify offset calculation

String indexing will result in the same thing as if I gated it behind
`type()` calls here.

* docs(window): add `border` to `cmp.WindowStyle`

* docs(window): correct `border_offset_scrollbar`

* perf(window): calulated row -> `screenrow`

This will also be more accurate since it accounts for wrapped lines, as
well as buffers.

* fix(window): edge case with multiple splits

* ref(winhighlight): don't specify defaults by default

`NormalFloat:NormalFloat` isn't needed, since `NormalFloat` defaults to
`NormalFloat`. As for `FloatBorder`, that should be set to `Floatborder`
rather than `NormalFloat` or else you get unintended artifacts on the
edges of borders.

* fix(window): popup covers cursor when scrollbar disappears

* ref(window): calc `border_offset_col` on `set_style`

* perf(window): remove unecessary `col` calculation

Taking it out didn't change anything about the popup behavior.

* feat: add `CmpItemMenuThumb` group

* feat(window): improve scrollbar appearance

* chore(window): remove references to unused property

* docs: document new option `thin_scrollbar`

* ref(plugin): remove background from `thin_scrollbar`

* feat(view): pass `thin_scrollbar` option to window

* feat(window): gate new `thin_scrollbar` behind option

* fix(window): cmdline bugging out

* fix(cmp): docs_view pops up overlapped when using borders

This is related to 1cfe2f7dfd. The
calculation for how the popup position is calculated was changed, and
so it needed to be reworked to include borders in order to be able to
work.

* ref: `thin_scrollbar` flag -> `scrollbar` option

This change allows users to define which character they will use for
their scrollbar.

* fix(window): use `scrollbar` setting for scrollbar character

Thanks @Astrantia for pointing this one out.

* docs(README): add completion appearance options to FAQ

* fix(): account for `border_offset_row` with `has_bottom_space`

* style(custom_entries_view): group offset with `row`/`col`

* fix(window): scrollbar at full view height

Because the `bar_height` variable must be whole number, and must be rounded up
from a percent, there is a change that we will end up with the maximum
height as a number.

For example, `info.height` = 24 and `total` = 25.

* feat(window): allow scrollbar to be disabled

* fix(window): scrollbar size < 1

* ref(cmp): move border logic to `window.info`

* ref!: window highlighting based on borders

BREAKING CHANGE: `documentation.winhighlight` does not determine the
                 highlighting of the `documentation` view— `CmpWindow`
		 or `CmpBorderedWindow` depending on whether it has a
		 border.

* ref!: float appearance opts -> `cmp.setup.window`

`cmp.setup.completion.border` and `.scrollbar` were both moved to
`cmp.setup.window.completion.border` and `.scrollbar`

BREAKING CHANGE: `cmp.setup.documentation` has been moved to
                 `cmp.window.documentation`, as all of the pertaining
		 options were cosmetic.

TODO: document the change

* fix(window): attempt to get scrollbar's border

* fix(cmp): restore `view.menu.hl_group`

* fix(window): wrong scrollbar position

* ref: get default `CmpItemMenu` from border existence

* chore(cmp): remove old PR comments

* fix(window): scrollbar sometimes too big

* fix(window): docs far away with complete menu scrollbar

* perf(docs_view): reuse `border_width` value

* rev(cmp): restore `CmpItemMenu`

* ref(cmp): distinguish between `ScrollBar` and `ScrollThumb`

* fix(plugin): consistently refer to `Thumb` as `Thumb`

* rev(window): `Pmenu`-style scrollbar when no border

* fix(window): docs_view size wrong when first shown

* fix(window): docs_view scrollbar not responding to size

* fix(window): scrollbar sometimes to small, take 2

* fix(window): scrollbar bg not hiding

* ref(docs_view): put docs closer to completion menu

* fix(window): scrollbar position wrong with right border

* ref(config): add default border to documentation

* fix(window): scrollbar too close without border

* ref(plugin): link `CmpWindow` to `Pmenu`

I set `CmpWindow` to `NormalFloat`, because that is what you would
expect a floating window to use for a highlight group. However at
request I changed it to `Pmenu`.

* ref(plugin): link `CmpWindowBorder` to `CmpWindow`

* fix(window): scrollbar following thumb while scrolling

* ref: add more highlight groups

There just weren't enough highlight groups to satisfy the demands of the
project. If you change `CmpWindow` to `Pmenu`, then the `docs_view`
becomes `Pmenu` as well when on `main` it is `NormalFloat`.

* fix(window): scrollbar overlapping `docs_view` by default

* ref: remove `Bordered` highlight variants

* ref(utils): extract whitespace check to func

* feat: `window.completion.zindex` setting

* ref: `maxwidth|height` -> `max_`

* ref: simplify highlight groups

* feat: `window.*.winhighlight` setting

* ref(utils): `is_whitespace_char` -> `is_visible`

As hrsh7th noted, `''` is not a whitespace character. Yet, it is
necessary to group `''` and `' '` together for certain border behaviors
that are based on visibility. Thus I have renamed the function

* feat: specify `window.*.winhighlight` for un/bordered

* fix(custom_entries_view): set `winhighlight` on `open`

* ref: remove `Cmp*Scroll*` variants

There's no way for `window` to know which kind of window it is drawing a
scrollbar on. Simpler to just have one kind of scrollbar

* feat: distinguish between bordered and unbordered

* ref(cmp): `is_visible` -> `is_invisible`

That's what the function was checking for.

* fix(default): mislabeling of `default` and `bordered`

* chore: rebase fixup

* Change default highlight

* Add misc.rep

* Fix left-side docs_view with scrollbar

* Fix scrollbar

* Fix sbar/thumb win
Improve highlights

* Remove scrollbar cutomization for now

* Remove scrollbar option

* Simplify implementation

* Fix doc width

* Fix outdated docs

* Add comments

* Fix configuration schema

* fmt

* Fix for lint

Co-authored-by: Iron-E <36409591+Iron-E@users.noreply.github.com>
Co-authored-by: hrsh7th <>
2022-04-13 23:51:55 +09:00
tzachar
1558d110d7 Bottom up mode for custom menu (#848)
* Try to fix col adjustment (#843)

* Try to fix col adjuastment

* Improve duplicated text handling

* Bottom up mode for custom entry menu

When in command line mode, the custom entry window opens up to an
unexpected height, depending on the current count of completion items.
The above makes it hard to anticipate where to look at, and makes life a bit
harder.

This patch adds an option to open the custom entries view in a bottom up
mode, and flips the regular behaviour of next/prev entry in this mode.
Setup is as easy as:

```
cmp.setup.cmdline(':', {
  view = {
    entries = {name = 'custom', direction = 'bottom_up' }
  }
}
```

* fix stylua complaints

* sylua barfs

* solve some corner cases

* properly reverse entries table

* make custom view follow cursor

* respect default as top_down

* stylua

* more stylua

Co-authored-by: hrsh7th <hrsh7th@gmail.com>
2022-04-08 22:33:09 +09:00
hrsh7th
4bc038f72d fmt 2022-02-13 18:53:30 +09:00
hrsh7th
bf78446d59 Refactor wildmenu_entries_view 2022-02-13 18:53:09 +09:00
hrsh7th
070c5572ad Implement shell like common string completion.
Fix #785
2022-02-13 14:34:28 +09:00
hrsh7th
de69c657eb Fix menu position for horizontal splitting 2022-02-02 19:25:25 +09:00
tzachar
124f1611f1 Statusline view in search mode or command line mode (#729)
* Search mode horizontal view

Enabled by setting `experimental.horizontal_search = true`

* use stylua

* move to a floating window instead of abusing status line

* pass all tests

* rework

1. rename entries view file and memeber to wildmenu_entries_view
2. move config to config.view.entries
3. support both in insert mode and cmdline
4. make separator configurable by config.view.separator

* rearange wildmenu config

Changed config to:
```lua
  view = {
    entries = {name = 'wildmenu', separator = '|' }
  },
```

* allow view.entries to be either a literal string or a table
2022-02-01 16:47:34 +09:00
hrsh7th
098182e2c2 Fix #734 2022-01-15 18:56:29 +09:00
hrsh7th
796f925915 Fix #703 2022-01-07 00:38:42 +09:00
Daniel Steinberg
4a19645374 Use a default zindex of 50 for documentation (#661)
This matches the default zindex for floating windows.
2021-12-21 10:52:43 +09:00
Dmytro Meleshko
9c07c2d1c5 Fix vim.fn.complete being constantly called (#654) 2021-12-20 14:54:16 +09:00
hrsh7th
91b6f503c1 Fix #582 2021-12-14 22:12:00 +09:00
Dmytro Meleshko
727ddee59e Fix rendering of wide characters in the custom completion window (#641) 2021-12-13 13:05:55 +09:00
hrsh7th
7b744e0589 Fix multibyte chars 2021-11-27 18:52:57 +09:00
Lyude
a86017117b Fire change events when selecting different items with native menu completion (#514)
Previously we didn't do this, which resulted in the documentation window
not being shown when switching through different completion items. Fix
this by firing the change event in select_next_item and select_prev_item.
2021-11-27 17:43:40 +09:00
hrsh7th
6fa7681812 Fix #321 2021-11-23 22:34:47 +09:00
hrsh7th
f15be9e3ec Fix #559 2021-11-22 17:49:03 +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
1cfe2f7dfd Fix #526 2021-11-15 21:22:44 +09:00
hrsh7th
2de40ccf49 Fix #520 2021-11-15 14:26:50 +09:00
hrsh7th
753f5b7c92 Fix #516 (#517)
* Fix #516

* Fix

* Fix and tests

* fmt lint
2021-11-14 02:47:31 +09:00