Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lazy loading #47

Open
orhnk opened this issue Aug 27, 2023 · 3 comments
Open

Lazy loading #47

orhnk opened this issue Aug 27, 2023 · 3 comments
Assignees

Comments

@orhnk
Copy link

orhnk commented Aug 27, 2023

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

demo-2023-08-27_10.53.42.mp4

As you can see, These things happen respectfully:

  • I enable the plugin with <leader>bb

  • Redo <leader>bb because toggle function disables it at first!!!

  • On cursor line there appears a "biscuit":

    • But it lacks highlighting
    • Moving cursor does not show other biscuits
  • Then I move to a new file:

    • Everything works OK.

-> CONFIG <-

[!NOTE]
This plugin is lazy loaded lazy = true is not required
(Config specific)

  • Using: Lazy.nvim

      {
        "code-biscuits/nvim-biscuits",
    
        keys = {
          {
            "<leader>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
Copy link
Contributor

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

@orhnk
Copy link
Author

orhnk commented Aug 30, 2023

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
Copy link
Contributor

I'm pretty sure I got this working with this PR:
#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.

@cmgriffing cmgriffing self-assigned this Apr 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants