From 7b3db285912a0bb2f3a6959f0d0bc8f1bf88c899 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 23 Nov 2023 19:32:53 +0000 Subject: [PATCH 1/5] docs: better README --- README.md | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 1444563..978eb8f 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,13 @@ -## Epo +## epo.nvim -a blazing fast and minimal less than 300 lines. neovim lsp auto-completion plugin. - -**Need neovim nightly** +Blazing fast and minimal lsp auto-completion plugin for neovim. +**Needs neovim nightly** ## Usage ```lua require('epo').setup({ - -- default value of options. fuzzy = false, -- increase this value can aviod trigger complete when delete character. debounce = 50, @@ -20,22 +18,19 @@ require('epo').setup({ }) ``` -register capabilities for `vim.snippet` +You may want to pass the capabilities to your lsp ```lua -server_config = { - capabilities = vim.tbl_deep_extend( +local capabilities = vim.tbl_deep_extend( 'force', vim.lsp.protocol.make_client_capabilities(), require('epo').register_cap() ) -} ``` ## Keymap -Super TAB and Shift-tab bind tab and shift-tab for completion and snippet -expand. +Supercharge TAB and Shift-tab for completion and snippet expansion. ```lua vim.keymap.set('i', '', function() @@ -66,7 +61,4 @@ vim.keymap.set('i', '', function() end, {expr = true}) ``` - -third param is fuzzy match enable. - ## License MIT From d9ab89b76e86068a09c1f7cea537a141307f131e Mon Sep 17 00:00:00 2001 From: xiaoshihou Date: Thu, 23 Nov 2023 20:40:43 +0000 Subject: [PATCH 2/5] squash --- README.md | 36 ++++++++++++++++++++++++++++++++++-- lua/epo/init.lua | 13 +++++++++---- 2 files changed, 43 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 978eb8f..a0baaa6 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,12 @@ Blazing fast and minimal lsp auto-completion plugin for neovim. **Needs neovim nightly** +**This plugin would be much feature-complete after [this pr](https://github.com/neovim/neovim/pull/24723) is merged** + ## Usage ```lua +vim.opt.completeopt = "menu,menuone,noselect" require('epo').setup({ fuzzy = false, -- increase this value can aviod trigger complete when delete character. @@ -15,6 +18,12 @@ require('epo').setup({ signature = false, -- extend vscode format snippet json files. like rust.json/typescriptreact.json/zig.json snippet_path = nil, + -- border for lsp signature popup + signature_border = 'rounded' + -- lsp kind formatting + kind_format = opt.kind_format or function(k) + return k:lower():sub(1, 1) + end }) ``` @@ -28,9 +37,10 @@ local capabilities = vim.tbl_deep_extend( ) ``` -## Keymap +
+Click to show some preset mappings -Supercharge TAB and Shift-tab for completion and snippet expansion. +- TAB complete ```lua vim.keymap.set('i', '', function() @@ -61,4 +71,26 @@ vim.keymap.set('i', '', function() end, {expr = true}) ``` +- `` completion + +```lua +-- For using enter as completion, may conflict with some autopair plugin +vim.keymap.set("i", "", function() + if vim.fn.pumvisible() == 1 then + return "" + end + return "" +end, { expr = true, noremap = true }) + +-- nvim-autopair compatibility +vim.keymap.set("i", "", function() + if vim.fn.pumvisible() == 1 then + return "" + end + return require("nvim-autopairs").autopairs_cr() +end, { expr = true, noremap = true }) +``` + +
+ ## License MIT diff --git a/lua/epo/init.lua b/lua/epo/init.lua index 63a24d4..9e8656f 100644 --- a/lua/epo/init.lua +++ b/lua/epo/init.lua @@ -7,7 +7,8 @@ local ns = api.nvim_create_namespace('Epo') local match_fuzzy = false local signature = false local debounce_time = 100 -local snippet_path = nil +local snippet_path, signature_border, kind_format + -- Ctrl-Y will trigger TextChangedI again -- avoid completion redisplay add a status check local disable = nil @@ -59,7 +60,7 @@ end local function lspkind(kind) local k = protocol.CompletionItemKind[kind] or 'Unknown' - return k:lower():sub(1, 1) + return kind_format(k) end local function show_info(bufnr) @@ -113,7 +114,7 @@ local function signature_help(client, bufnr, lnum) lines = { unpack(lines, 1, 3) } fbuf, fwin = util.open_floating_preview(lines, 'markdown', { close_events = {}, - border = 'rounded', + border = signature_border, }) vim.bo[fbuf].syntax = 'on' @@ -337,7 +338,7 @@ local function completion_handler(_, result, ctx) prefix = prefix:lower() for _, item in - ipairs(vim.list_extend(compitems, context.snippets[vim.bo[ctx.bufnr].filetype] or {})) + ipairs(vim.list_extend(compitems, context.snippets[vim.bo[ctx.bufnr].filetype] or {})) do local entry = { abbr = item.label, @@ -516,6 +517,10 @@ local function setup(opt) debounce_time = opt.debounce_time or 50 signature = opt.signature or false snippet_path = opt.snippet_path + signature_border = opt.signature_border or 'rounded' + kind_format = opt.kind_format or function(k) + return k:lower():sub(1, 1) + end -- Usually I just use one client for completion so just one api.nvim_create_autocmd('LspAttach', { From 227e5da687ed31a9917ffa5aa07305e0ca79f7bc Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 23 Nov 2023 21:06:31 +0000 Subject: [PATCH 3/5] squash --- README.md | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a0baaa6..12af8b5 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Blazing fast and minimal lsp auto-completion plugin for neovim. **Needs neovim nightly** -**This plugin would be much feature-complete after [this pr](https://github.com/neovim/neovim/pull/24723) is merged** +**This plugin would be much more feature-complete after [this pr](https://github.com/neovim/neovim/pull/24723) is merged** ## Usage @@ -37,6 +37,19 @@ local capabilities = vim.tbl_deep_extend( ) ``` +Completion menu look dull and boring? Your colorscheme may be missing these highlights: + +``` +Pmenu +PmenuExtra +PmenuSel +PmenuKind +PmenuKindSel +PmenuExtraSel +PmenuSbar +PmenuThumb +``` +
Click to show some preset mappings From 7c3246afba4315b744cc2d83a19f6c2344c50721 Mon Sep 17 00:00:00 2001 From: xiaoshihou514 <108414369+xiaoshihou514@users.noreply.github.com> Date: Thu, 23 Nov 2023 22:13:11 +0000 Subject: [PATCH 4/5] fixes --- README.md | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 12af8b5..9a4d8fa 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ## epo.nvim -Blazing fast and minimal lsp auto-completion plugin for neovim. +Blazingly fast, minimal lsp auto-completion and snippet plugin for neovim. **Needs neovim nightly** @@ -9,19 +9,23 @@ Blazing fast and minimal lsp auto-completion plugin for neovim. ## Usage ```lua +-- suggested completeopt vim.opt.completeopt = "menu,menuone,noselect" + +-- default settings require('epo').setup({ + -- fuzzy match fuzzy = false, -- increase this value can aviod trigger complete when delete character. debounce = 50, -- when completion confrim auto show a signature help floating window. signature = false, - -- extend vscode format snippet json files. like rust.json/typescriptreact.json/zig.json + -- vscode style json snippet path snippet_path = nil, - -- border for lsp signature popup + -- border for lsp signature popup, :h nvim_open_win signature_border = 'rounded' - -- lsp kind formatting - kind_format = opt.kind_format or function(k) + -- lsp kind formatting, k is kind string "Field", "Struct", "Keyword" etc. + kind_format = function(k) return k:lower():sub(1, 1) end }) @@ -51,7 +55,7 @@ PmenuThumb ```
-Click to show some preset mappings +Click to show some mapping presets - TAB complete @@ -84,7 +88,7 @@ vim.keymap.set('i', '', function() end, {expr = true}) ``` -- `` completion +- use `` to accept completion ```lua -- For using enter as completion, may conflict with some autopair plugin From f3404128b6013af0a323ef8611a3076557a8fed8 Mon Sep 17 00:00:00 2001 From: xiaoshihou514 <108414369+xiaoshihou514@users.noreply.github.com> Date: Fri, 24 Nov 2023 07:56:24 +0000 Subject: [PATCH 5/5] indent --- lua/epo/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/epo/init.lua b/lua/epo/init.lua index 9e8656f..d0ed101 100644 --- a/lua/epo/init.lua +++ b/lua/epo/init.lua @@ -338,7 +338,7 @@ local function completion_handler(_, result, ctx) prefix = prefix:lower() for _, item in - ipairs(vim.list_extend(compitems, context.snippets[vim.bo[ctx.bufnr].filetype] or {})) + ipairs(vim.list_extend(compitems, context.snippets[vim.bo[ctx.bufnr].filetype] or {})) do local entry = { abbr = item.label,