aboutsummaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
authormathew <glephunter@gmail.com>2023-08-15 18:47:14 +0800
committerglepnir <glephunter@gmail.com>2023-12-16 18:59:59 +0800
commite38027ef69f75653ee953b16ebf4a8652a3fb748 (patch)
treed27158d56da5810b942a3d561ae15b2711b2a7cd /runtime
parent7e7da962de404e3a0952bcc0adc6fbe53eda3cfb (diff)
downloadrneovim-e38027ef69f75653ee953b16ebf4a8652a3fb748.tar.gz
rneovim-e38027ef69f75653ee953b16ebf4a8652a3fb748.tar.bz2
rneovim-e38027ef69f75653ee953b16ebf4a8652a3fb748.zip
feat(ui): completeopt support popup like vim
Diffstat (limited to 'runtime')
-rw-r--r--runtime/doc/api.txt15
-rw-r--r--runtime/doc/builtin.txt2
-rw-r--r--runtime/doc/news.txt3
-rw-r--r--runtime/doc/options.txt4
-rw-r--r--runtime/lua/vim/_meta/api.lua10
-rw-r--r--runtime/lua/vim/_meta/api_keysets.lua3
-rw-r--r--runtime/lua/vim/_meta/options.lua4
-rw-r--r--runtime/lua/vim/_meta/vimfn.lua2
8 files changed, 43 insertions, 0 deletions
diff --git a/runtime/doc/api.txt b/runtime/doc/api.txt
index 48bbdc33df..72ac357ac0 100644
--- a/runtime/doc/api.txt
+++ b/runtime/doc/api.txt
@@ -700,6 +700,21 @@ nvim_chan_send({chan}, {data}) *nvim_chan_send()*
• {chan} id of the channel
• {data} data to write. 8-bit clean: can contain NUL bytes.
+nvim_complete_set({index}, {*opts}) *nvim_complete_set()*
+ Set info for the completion candidate index. if the info was shown in a
+ window, then the window and buffer ids are returned for further
+ customization. If the text was not shown, an empty dict is returned.
+
+ Parameters: ~
+ • {index} the completion candidate index
+ • {opts} Optional parameters.
+ • info: (string) info text.
+
+ Return: ~
+ Dictionary containing these keys:
+ • winid: (number) floating window id
+ • bufnr: (number) buffer id in floating window
+
nvim_create_buf({listed}, {scratch}) *nvim_create_buf()*
Creates a new, empty, unnamed buffer.
diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt
index 714320279a..98201c0eed 100644
--- a/runtime/doc/builtin.txt
+++ b/runtime/doc/builtin.txt
@@ -802,6 +802,8 @@ complete_info([{what}]) *complete_info()*
no item is selected when using the <Up> or
<Down> keys)
inserted Inserted string. [NOT IMPLEMENTED YET]
+ preview_winid Info floating preview window id.
+ preview_bufnr Info floating preview buffer id.
*complete_info_mode*
mode values are:
diff --git a/runtime/doc/news.txt b/runtime/doc/news.txt
index ad2de7a40a..406ac879eb 100644
--- a/runtime/doc/news.txt
+++ b/runtime/doc/news.txt
@@ -252,6 +252,9 @@ The following new APIs and features were added.
• |vim.text.hexencode()| and |vim.text.hexdecode()| convert strings to and
from byte representations.
+• 'completeopt' option supports "popup" flags to show extra information in
+ in floating window.
+
==============================================================================
CHANGED FEATURES *news-changed*
diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt
index fda60eaab2..970f687c99 100644
--- a/runtime/doc/options.txt
+++ b/runtime/doc/options.txt
@@ -1516,6 +1516,10 @@ A jump table for the options with a short description can be found at |Q_op|.
select one from the menu. Only works in combination with
"menu" or "menuone".
+ popup Show extra information about the currently selected
+ completion in a popup window. Only works in combination
+ with "menu" or "menuone". Overrides "preview".
+
*'completeslash'* *'csl'*
'completeslash' 'csl' string (default "")
local to buffer
diff --git a/runtime/lua/vim/_meta/api.lua b/runtime/lua/vim/_meta/api.lua
index 231e1c3404..c8afbd58dd 100644
--- a/runtime/lua/vim/_meta/api.lua
+++ b/runtime/lua/vim/_meta/api.lua
@@ -773,6 +773,16 @@ function vim.api.nvim_command(command) end
--- @return string
function vim.api.nvim_command_output(command) end
+--- Set info for the completion candidate index. if the info was shown in a
+--- window, then the window and buffer ids are returned for further
+--- customization. If the text was not shown, an empty dict is returned.
+---
+--- @param index integer the completion candidate index
+--- @param opts vim.api.keyset.complete_set Optional parameters.
+--- • info: (string) info text.
+--- @return table<string,any>
+function vim.api.nvim_complete_set(index, opts) end
+
--- Create or get an autocommand group `autocmd-groups`.
--- To get an existing group id, do:
---
diff --git a/runtime/lua/vim/_meta/api_keysets.lua b/runtime/lua/vim/_meta/api_keysets.lua
index f64cdb8afd..4ec8b03d30 100644
--- a/runtime/lua/vim/_meta/api_keysets.lua
+++ b/runtime/lua/vim/_meta/api_keysets.lua
@@ -68,6 +68,9 @@ error('Cannot require a meta file')
--- @class vim.api.keyset.cmd_opts
--- @field output? boolean
+--- @class vim.api.keyset.complete_set
+--- @field info? string
+
--- @class vim.api.keyset.context
--- @field types? any[]
diff --git a/runtime/lua/vim/_meta/options.lua b/runtime/lua/vim/_meta/options.lua
index 5e65ca6b1b..c908d7ae54 100644
--- a/runtime/lua/vim/_meta/options.lua
+++ b/runtime/lua/vim/_meta/options.lua
@@ -1061,6 +1061,10 @@ vim.bo.cfu = vim.bo.completefunc
--- select one from the menu. Only works in combination with
--- "menu" or "menuone".
---
+--- popup Show extra information about the currently selected
+--- completion in a popup window. Only works in combination
+--- with "menu" or "menuone". Overrides "preview".
+---
--- @type string
vim.o.completeopt = "menu,preview"
vim.o.cot = vim.o.completeopt
diff --git a/runtime/lua/vim/_meta/vimfn.lua b/runtime/lua/vim/_meta/vimfn.lua
index ead5d8d13b..59d9836688 100644
--- a/runtime/lua/vim/_meta/vimfn.lua
+++ b/runtime/lua/vim/_meta/vimfn.lua
@@ -1024,6 +1024,8 @@ function vim.fn.complete_check() end
--- no item is selected when using the <Up> or
--- <Down> keys)
--- inserted Inserted string. [NOT IMPLEMENTED YET]
+--- preview_winid Info floating preview window id.
+--- preview_bufnr Info floating preview buffer id.
---
--- *complete_info_mode*
--- mode values are: