From 14d1a89d3f0e118c28cb6b4956e3d78748bc3600 Mon Sep 17 00:00:00 2001 From: ippachi Date: Wed, 31 Aug 2022 21:47:36 +0900 Subject: [PATCH 1/5] improve documentation add keyword_length option to ducumentation --- README.md | 6 +++++- doc/cmp-rg.txt | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8676fa8..3214fec 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,11 @@ Add `rg` to your cmp sources ```lua require'cmp'.setup { sources = { - { name = 'rg' } + { + name = 'rg', + -- Try it when you feel cmp performance is poor + -- keyword_length = 3 + } } } ``` diff --git a/doc/cmp-rg.txt b/doc/cmp-rg.txt index 6f45ad4..d0c1b0e 100644 --- a/doc/cmp-rg.txt +++ b/doc/cmp-rg.txt @@ -106,7 +106,11 @@ debug *cmp-rg-debug* > require'cmp'.setup { sources = { - { name = 'rg' } + { + name = 'rg', + -- Try it when you feel cmp performance is poor + -- keyword_length = 3 + } } } From 3c6777d527561fce0f995cc3425c67158bc4b7ce Mon Sep 17 00:00:00 2001 From: Lukas Reineke Date: Thu, 1 Sep 2022 09:51:44 +0900 Subject: [PATCH 2/5] Format readme and docs --- README.md | 20 +++++++++----------- doc/cmp-rg.txt | 12 ++++++------ 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 3214fec..5d7a27f 100644 --- a/README.md +++ b/README.md @@ -16,11 +16,9 @@ Use your favourite plugin manager to install. ```lua -- init.lua -require("packer").startup( - function() - use "lukas-reineke/cmp-rg" - end -) +require("packer").startup(function() + use "lukas-reineke/cmp-rg" +end) ``` #### Example with Plug @@ -39,14 +37,14 @@ call plug#end() Add `rg` to your cmp sources ```lua -require'cmp'.setup { +require("cmp").setup { sources = { { - name = 'rg', - -- Try it when you feel cmp performance is poor - -- keyword_length = 3 - } - } + name = "rg", + -- Try it when you feel cmp performance is poor + -- keyword_length = 3 + }, + }, } ``` diff --git a/doc/cmp-rg.txt b/doc/cmp-rg.txt index d0c1b0e..28661ee 100644 --- a/doc/cmp-rg.txt +++ b/doc/cmp-rg.txt @@ -104,14 +104,14 @@ debug *cmp-rg-debug* Add `rg` to your cmp sources > - require'cmp'.setup { + require("cmp").setup { sources = { { - name = 'rg', - -- Try it when you feel cmp performance is poor - -- keyword_length = 3 - } - } + name = "rg", + -- Try it when you feel cmp performance is poor + -- keyword_length = 3 + }, + }, } ============================================================================== From d81d8250888f05575c669d8b1c00bb3ce5b94b7c Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Wed, 31 Aug 2022 16:10:04 +0100 Subject: [PATCH 3/5] fix(timer): close timers before Neovim exits --- lua/cmp-rg/init.lua | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lua/cmp-rg/init.lua b/lua/cmp-rg/init.lua index 5f58c23..d6c29f0 100644 --- a/lua/cmp-rg/init.lua +++ b/lua/cmp-rg/init.lua @@ -7,9 +7,18 @@ require "cmp-rg.types" local source = {} source.new = function() + local timer = vim.loop.new_timer() + vim.api.nvim_create_autocmd("VimLeavePre", { + callback = function() + if timer and not timer:is_closing() then + timer:stop() + timer:close() + end + end, + }) return setmetatable({ running_job_id = 0, - timer = vim.loop.new_timer(), + timer = timer, json_decode = vim.fn.has "nvim-0.6" == 1 and vim.json.decode or vim.fn.json_decode, }, { __index = source }) end From 5116afe905f20658c09115f78e1be4b8dabaee06 Mon Sep 17 00:00:00 2001 From: Lukas Reineke Date: Fri, 2 Sep 2022 14:18:19 +0900 Subject: [PATCH 4/5] bug: Implement chunk size fix #42 --- lua/cmp-rg/init.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lua/cmp-rg/init.lua b/lua/cmp-rg/init.lua index d6c29f0..c2979d9 100644 --- a/lua/cmp-rg/init.lua +++ b/lua/cmp-rg/init.lua @@ -35,6 +35,7 @@ source.complete = function(self, request, callback) end local seen = {} local items = {} + local chunk_size = 5 local function on_event(_, data, event) if event == "stdout" then @@ -120,7 +121,10 @@ source.complete = function(self, request, callback) end end end - callback { items = items, isIncomplete = true } + if #items - chunk_size >= chunk_size then + chunk_size = chunk_size * 2 + callback { items = items, isIncomplete = true } + end end if event == "stderr" and request.option.debug then From 6b11e67db6f8d956a5969ed01b88ddbb3287fe8b Mon Sep 17 00:00:00 2001 From: Lukas Reineke Date: Mon, 5 Sep 2022 11:55:12 +0900 Subject: [PATCH 5/5] Version 1.3.8 --- doc/cmp-rg.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/cmp-rg.txt b/doc/cmp-rg.txt index 28661ee..a38b994 100644 --- a/doc/cmp-rg.txt +++ b/doc/cmp-rg.txt @@ -2,7 +2,7 @@ Author: Lukas Reineke -Version: 1.3.7 +Version: 1.3.8 ============================================================================== CONTENTS *cmp-rg*