crispgm / cmp-beancount

nvim-cmp source for beancount accounts
MIT License
35 stars 4 forks source link

question of the hard coded item count limit #3

Closed sidkang closed 2 years ago

sidkang commented 2 years ago

First, Nice plugin. I just began to use this, it looks quite nice. I met a minor problem that If I'm not following the strict L:B:C pattern, the item available will not be refreshed to fetch the target account.

expectation

For example, If I want to get Assets:Receivable:Eason and it is beyond the 10 first completion item, if I use ARE to find it. The is the current completion behavior in vscode-beancount plugin which I'm used to.

If I want to use such way to get the completion, I think a simple approach could be allowing user to increase the limit. I tried the code below it seems worked.

local max_item_count = request.option.max_item_count
if max_item_count == nil or type(max_item_count) ~= 'number' then
    max_item_count = 10
end
...
if count >= max_item_count then
    break
end

As an amateur coder, I'm not quite good at this, maybe there are better ways to accomplish this.

crispgm commented 2 years ago

@sidkang Thanks for the suggestion. max_item_count will be added soon.

sidkang commented 2 years ago

Just read the nvim-cmp doc, it seems there is already the count limit implemented in the framework, maybe the limit in this plugin can be just removed and added in the config. For reference, below are the relevant urls.

https://github.com/hrsh7th/nvim-cmp/blob/9a0c639ac2324e6e9ecc54dc22b1d32bb6c42ab9/lua/cmp/source.lua#L123 https://github.com/hrsh7th/nvim-cmp/blob/1cad1815e165c2b436f41a1ee20327701842a761/doc/cmp.txt#L513-L516

crispgm commented 2 years ago

@sidkang You are right. It's removed.