Commit Graph

70 Commits

Author SHA1 Message Date
Maria José Solano
1c03ebc7dc feat: add toggle_doc functionality (#1647)
* feat: Add toggle_doc functionality

fix: Update docs view on entry change

* Replace toggle logic by open/close

* add docs and pinned flags

* add faq for disabling docs

* chore(git): ignore .DS_Store

---------

Co-authored-by: hrsh7th <629908+hrsh7th@users.noreply.github.com>
2023-08-12 11:50:49 +09:00
hrsh7th
e55033fce4 Fix #1322 2022-12-27 15:53:05 +09:00
stnley
ec86960d79 fix: "count" option inserting characters (#1293)
* fix: "count" option inserting characters

Closes #1291

* Remove loop

Co-authored-by: stnley <michael@stnley.io>
2022-11-11 10:53:29 +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
yuys13
2427d06b65 Format by stylua (#1195) 2022-09-27 12:27:31 +09:00
hrsh7th
347fabf906 Fix #1146 2022-08-23 14:52:04 +09:00
hrsh7th
49c4050e24 Refactor a bit 2022-08-20 19:23:05 +09:00
hrsh7th
bf5593df8e Improve typings 2022-07-24 12:44:53 +09:00
William Boman
033a817ced fix: only scroll docs if docs view is visible (#1011) 2022-05-25 10:32:11 +09:00
hrsh7th
0318a3cbc1 Improve the codes for sumneko friendly 2022-05-13 19:25:00 +09:00
hrsh7th
a226b6a4ff Fix #973 2022-05-09 11:55:29 +09:00
hrsh7th
f81bfee109 Fix #964
Fix #963
Fix #966
2022-05-04 23:51:59 +09:00
hrsh7th
e64421ef58 Fix #960 2022-05-04 02:57:43 +09:00
hrsh7th
5054c14490 dev (#956)
* Adjust empty line count

* Implement vim.api.nvim_create_autocmd (#844)

* Implement vim.api.nvim_create_autocmd

* Only use vim.api.nvim_create_autocmd on nighly

* Cleanup

* cleanup

* Rename autos.lua to autocmds.lua

* Fix forgot to rename autos to autocmds

* Remove legacy autocmd

* Add descriptions on autocmds

* Update descriptions on autocmds

* Update CmpStatus command to lua API (#922)

Signed-off-by: Micah Halter <micah@balena.io>

* Move highlights to nvim_set_hl lua API (#925)

Signed-off-by: Micah Halter <micah@balena.io>

* Add default to highlight

* Refactor autocmds

* fmt

* Improve performance

* Fix bug

* Improve matching logic
Fixes https://github.com/hrsh7th/nvim-cmp/discussions/954

* Fix format

* Improve performance
Fix #825

* Fix cmdline redraw bug

* Fix event

Co-authored-by: hrsh7th <>
Co-authored-by: zer09 <zer09@users.noreply.github.com>
Co-authored-by: Micah Halter <micah@mehalter.com>
2022-05-04 01:47:01 +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
hrsh7th
801a9f98bb Improve macro handling 2022-04-08 22:04:08 +09:00
hrsh7th
a5024f916a Add locality sort (easy version) 2022-03-30 21:16:20 +09:00
hrsh7th
2de24d3e1c Rename locals to scopes 2022-03-30 20:50:36 +09:00
hrsh7th
dc3113a79f Add sort (required nvim-treesitter) 2022-03-30 20:41:32 +09:00
hrsh7th
e23de1f2b4 Add cmp.get_entries. Fixes #831 2022-03-15 11:37:24 +09:00
hrsh7th
bf78446d59 Refactor wildmenu_entries_view 2022-02-13 18:53:09 +09:00
hrsh7th
33fc65f174 test&lint&fmt 2022-02-13 14:38:31 +09:00
hrsh7th
070c5572ad Implement shell like common string completion.
Fix #785
2022-02-13 14:34:28 +09:00
hrsh7th
20152c6afd Fix #789 2022-02-12 21:01:22 +09:00
hrsh7th
26a9184c88 Add filetype config
Use view.entries == 'native' instead of experimental.native_menu
2022-02-11 15:20:24 +09:00
Jonas Strittmatter
df05fe6ff4 Fix: close the view if cmp.enabled = false and the user types some text (#781)
A scenario where this lead to unintended behaviour previously was the following:

If cmp.enabled was configured such that it disabled cmp when in a comment,
and the user typed '--' in a lua file (this starts a comment), the cmp window
would not close if further text is typed on that line (although cmp should be disabled).
2022-02-11 13:36:54 +09:00
hrsh7th
55f04e49dc Improve sync API 2022-01-31 14:30:57 +09:00
hrsh7th
0d23640fb6 Fix #757 2022-01-31 14:27:33 +09:00
hrsh7th
d93104244c Wait for filtering completion 2022-01-25 16:27:21 +09:00
hrsh7th
57101a2e26 Re fix #754 2022-01-25 11:51:06 +09:00
hrsh7th
27123b1297 Fix #754 2022-01-24 23:46:47 +09:00
hrsh7th
3f7b7b258a Add complete_done event and improved the recently_used sorter.
Fix #708
2022-01-08 13:38:55 +09:00
hrsh7th
da4c071f6b Fix #648 2021-12-14 22:41:45 +09:00
hrsh7th
7960dad502 fmt 2021-12-02 16:10:35 +09:00
hrsh7th
c2652f0ac0 Implement #349 2021-12-02 15:56:42 +09:00
Lukas Reineke
17d57f96cc Add reason to complete function (#529)
fix #528
2021-11-17 01:17:58 +09:00
hrsh7th
753f5b7c92 Fix #516 (#517)
* Fix #516

* Fix

* Fix and tests

* fmt lint
2021-11-14 02:47:31 +09:00
hrsh7th
c7a1b9f7c0 Handle InsertEnter and CmdlineEnter seperately 2021-11-09 15:31:56 +09:00
hrsh7th
97e4229be6 Remove triggering insert enter event 2021-11-09 15:20:05 +09:00
hrsh7th
823c73c16d Improve avoiding InsertEnter's invalid mode detection 2021-11-09 15:01:44 +09:00
hrsh7th
a0053885ba Use key sequence to avoid the invalid mode detection 2021-11-09 14:05:13 +09:00
hrsh7th
dc6b458fd2 tmp fix for serveral bugs 2021-11-04 02:31:42 +09:00
hrsh7th
2a58b8f926 Fix #421 2021-11-03 03:16:45 +09:00
hrsh7th
674d2b1389 Rewrite keymap.lua (#452)
* Move feedkeys related codes to `cmp.utils.feedkeys`

* Improve mapping handling

* Fix test

* fmt
2021-11-01 22:15:28 +09:00
hrsh7th
3945dc5d00 Add basic recently_used comparator 2021-10-29 18:46:51 +09:00
hrsh7th
1c498a5497 Add cmp.event:on() (#418) 2021-10-28 11:02: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
f1da3adddc Add cmp.config.disable for opt-out default setting 2021-10-25 22:50:38 +09:00
hrsh7th
e4a2cec153 Implement source group.
Fixes #391
2021-10-22 18:24:03 +09:00
Alex Tylor
b546f50f09 Expose get_selected_entry() from view module to main cmp module fixes #385 (#386)
* Expose get_selected_entry() from view module to main cmp module fixes #385

* add get_active_entry() also

* fix linting

* remove unused vars

Co-authored-by: alex.tylor <atylor@gmail.com>
2021-10-22 17:47:55 +09:00