From a501c3f9f3ddb92b3b3ae36b74676127753a672e Mon Sep 17 00:00:00 2001 From: hachy <1613863+hachy@users.noreply.github.com> Date: Sun, 12 Nov 2023 12:58:23 +0900 Subject: [PATCH] docs: add completion examples --- doc/cmdpalette.txt | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/doc/cmdpalette.txt b/doc/cmdpalette.txt index 49a500c..c61d38c 100644 --- a/doc/cmdpalette.txt +++ b/doc/cmdpalette.txt @@ -78,13 +78,20 @@ Following is the default configuration. =========================================================================== FAQ *cmdpalette-faq* -Q: I want to use cmdline-completion +Q: I want to use completion -A: Cmdpalette does not provide cmdline-completion, because it is not a real -cmdline-window. +A: Tab completion can be enabled with the following settings. -The other way to enable cmdline-completion is to use plugins such as the -following. +>lua + vim.api.nvim_create_autocmd("filetype", { + pattern = "cmdpalette", + callback = function() + vim.keymap.set("i", "", "", { buffer = true }) + end, + }) +< + +Completion can also be enabled with plugins such as the following. https://github.com/Shougo/ddc-source-cmdline https://github.com/hrsh7th/cmp-cmdline @@ -117,16 +124,26 @@ Example for cmp-cmdline }, } - cmp.setup.filetype("cmdpalette", { - mapping = cmp.mapping.preset.cmdline(), + require("cmp").setup.filetype("cmdpalette", { sources = { { name = "cmdline" }, }, }) + + vim.api.nvim_create_autocmd("filetype", { + pattern = "cmdpalette", + callback = function() + vim.keymap.set("i", "", function() + require("cmp").complete() + end, { buffer = true }) + end, + }) < + Q: I want to change sign highlight A: + >lua vim.api.nvim_set_hl(0, "CmdpaletteSign", { link = "Todo" }) <