code-biscuits / nvim-biscuits

A neovim port of Assorted Biscuits. Ends up with more supported languages too.
MIT License
246 stars 11 forks source link

Lazy loading #47

Open orhnk opened 1 year ago

orhnk commented 1 year ago

I don't feel the need biscuits as in a daily basis But in some scenarios (Complex Code) It is a game changer.

For this purpose biscuits are lazy loaded when I press <leader>bb (See Details)

Problem

https://github.com/code-biscuits/nvim-biscuits/assets/101834410/8c3ee9a3-61cb-4d58-8773-11ba56283f27

As you can see, These things happen respectfully:


-> CONFIG <- > [!NOTE] > This plugin is lazy loaded `lazy = true` is not required > (Config specific) - **Using**: Lazy.nvim ```lua { "code-biscuits/nvim-biscuits", keys = { { "bb", function() require("nvim-biscuits").toggle_biscuits() end, mode = "n", desc = "Enable Biscuits", }, }, dependencies = { "nvim-treesitter/nvim-treesitter", }, config = function(_, opts) require("nvim-biscuits").setup(opts) end, opts = { cursor_line_only = true, show_on_start = true, default_config = { max_length = 47, min_distance = 5, prefix_string = " šŸ“Ž ", }, language_config = { html = { prefix_string = " šŸŒ ", }, javascript = { prefix_string = " āœØ ", max_length = 80, }, python = { disabled = true, }, }, }, }, ```
cmgriffing commented 1 year ago

Awesome feedback! This seems like an interesting bug and I will try to look into it soon(ish).

orhnk commented 1 year ago

[!NOTE] So here is what happens (i think):

  • setup([[...]]) function enables biscuits by default (take a look at appendix I)
  • toggle_biscuits() function disables the plugin (which is already enabled by Lazy)

[!IMPORTANT] When I try to load it lazily (without toggle function) still biscuits doesn't work on the current buffer

cmgriffing commented 5 months ago

I'm pretty sure I got this working with this PR: https://github.com/code-biscuits/nvim-biscuits/pull/52

Please check out the section in the README that relates to lazy.nvim. https://github.com/code-biscuits/nvim-biscuits?tab=readme-ov-file#configuration-lazynvim-support Basically, you just need to call BufAttach instead of toggle_biscuits. Keep in mind that this was not possible before the PR linked above, so there is no way you could have known to do that.

I will leave this Issue open for a bit so that you can test things out. Feel free to close it yourself if everything is working now. I will probably close it in a few weeks if I haven't heard back, but feel free to open another issue after that if you still have trouble getting things working right.