Commit Graph

85 Commits

Author SHA1 Message Date
hrsh7th
11a95792a5 Disable sort_text by default 2023-01-06 15:29:16 +09:00
hrsh7th
4748ea5a5a Fix locality sorting 2023-01-06 13:45:46 +09:00
hrsh7th
431f045968 Refactor a bit 2022-11-25 01:57:19 +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
69476c9e06 ci 2022-10-15 15:16:27 +09:00
AF
99ef854322 fix(context): compatibility with nvim<0.8 (#1224)
`get_captures_at_position` has been renamed to `get_captures_at_pos`: neovim/neovim#20331.
Fallback to `get_captures_at_position` in case `get_captures_at_pos` is `nil`.
2022-10-11 09:16:58 +09:00
AF
0ad2450ff6 fix(context): in_treesitter_capture (#1211)
* fix(context): `in_treesitter_capture`

`in_treesitter_capture` used to compare a node:type() with what should
be a capture, returning always a falsy value.
The example https://github.com/hrsh7th/nvim-cmp/wiki/Advanced-techniques#disabling-completion-in-certain-contexts-such-as-comments
did not work as expected, being in_treesitter_capture("comment") always
not true.
Now it works as expected.

* feat(context): `in...capture`, `in...group` table

`in_treesitter_capture` and `in_syntax_group` can take a list of string
as argument.

* refactor(context): in...capture use vim.treesitter

Use vim.treesitter.get_captures_at_cursor()

* fix(context): get_captures_at_cursor -> ..._at_pos

get_captures_at_cursor() sometimes fails. Do it explicitly with
get_captures_at_pos(buf, row, col)

* refactor(context): vim.fn -> vim.api

Get row and col using vim.api and not vim.fn in in_syntax_group, as done
in in_treesitter_capture
2022-10-10 17:06:41 +09:00
NEX
da2d88ec1a ADD: formatting.expandable_indicator to show the expandable indicator (#1207)
* ADD: formatting.expandable_indicator to show the `expandable` indicator

* UPDATA: doc/cmp.txt  lua/cmp/entry.lua  lua/cmp/typed/cmp.lua
2022-10-02 22:39:52 +09:00
hrsh7th
beb1d14c5e Add scrolloff option for completion window. 2022-10-02 19:47:01 +09:00
hrsh7th
8523568448 Fix #1102 2022-08-15 01:25:50 +09:00
hrsh7th
76ba56ce96 Decrease waits 2022-07-24 13:14:01 +09:00
Mitsuo Heijo
9897465a76 Fix stylua integration (#1054) 2022-06-29 21:08:06 +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
MurdeRM3L0DY
0e65333c7f make debounce and throttle time configurable (#1026)
* make debounce and throttle time configurable

* fix documentation
2022-06-15 02:21:55 +09:00
Jongwook Choi
f51dc68e1b fix: Fix stylua errors and install_stylua script (#923)
- Fix code style issues, suggested by stylua
- Update install_stylua.lua script so that it can run in macOS as well.
2022-04-20 13:21:37 +09:00
hrsh7th
f9f6d8dc49 Fix scopes comparator 2022-04-20 13:20:51 +09:00
Łukasz Kurpiewski
07132dc597 fix: use vim.treesitter.query instead of deprecated nvim-treesitter.ts_utils (#919) 2022-04-19 19:43:36 +09:00
hrsh7th
dbc7229029 Fix #894 2022-04-14 03:03:53 +09:00
hrsh7th
0c1f37c518 Fix mapping normalization order 2022-04-14 02:37:21 +09:00
hrsh7th
f4b3dda782 Improve cmdline preset 2022-04-14 01:17:28 +09:00
hrsh7th
93cf84f7de Remove all default mappings 2022-04-14 00:10:33 +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
3192a0c578 Fix #875 2022-04-08 23:59:30 +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
801a9f98bb Improve macro handling 2022-04-08 22:04:08 +09:00
hrsh7th
15f08a8faa Avoid misleading suggested configuration 2022-03-31 13:49:25 +09:00
hrsh7th
c1589830bd Prefer above identifier for locality sort 2022-03-31 13:48:35 +09:00
hrsh7th
3a1649297a Improve scopes sorter 2022-03-31 13:35:31 +09:00
hrsh7th
a97d2f46f0 Use get_word instead to sort. 2022-03-31 11:16:53 +09:00
hrsh7th
c1d0cd0fc5 Use cache for locality sort 2022-03-30 21:36:42 +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
c07350181f Implement matching config.
Fix #796
2022-02-13 16:44:45 +09:00
hrsh7th
070c5572ad Implement shell like common string completion.
Fix #785
2022-02-13 14:34:28 +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
ad3c1adbc3 Refactor context module, return false (not {}) in context.in_treesitter_capture (#777) 2022-02-11 14:23:59 +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
max397574
966dfdc402 add function to check if in comment (#676)
* feat(utils): added function to check if in comment

* moved functions into config.context and generalized

* feat(configs.context): added annotations
2021-12-29 19:48:26 +09:00
hrsh7th
c2652f0ac0 Implement #349 2021-12-02 15:56:42 +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
Lukas Reineke
17d57f96cc Add reason to complete function (#529)
fix #528
2021-11-17 01:17:58 +09:00
hrsh7th
c67ed9d8bc Fix #463 2021-11-03 02:29:06 +09:00
hrsh7th
e8cb695b0b Fix #436 2021-11-01 14:00:59 +09:00
anstadnik
ab7f368547 Add mappings for visual mode (#438) 2021-10-30 13:55:26 +09:00
hrsh7th
3945dc5d00 Add basic recently_used comparator 2021-10-29 18:46:51 +09:00
hrsh7th
52d9411cf2 Re-fix native tab mapping 2021-10-28 18:49:12 +09:00
hrsh7th
c01de2bd19 Fix #425 2021-10-28 16:48:02 +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