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

toggle/show on start broke the plugin #26

Closed
cd-a opened this issue Nov 10, 2021 · 12 comments · Fixed by #37
Closed

toggle/show on start broke the plugin #26

cd-a opened this issue Nov 10, 2021 · 12 comments · Fixed by #37

Comments

@cd-a
Copy link

cd-a commented Nov 10, 2021

Everything was working fine yesterday (Nov 9, early morning update before the toggle/show on start commits), today after updating it doesn't work anymore.

I have added the show_on_start to the config

require('nvim-biscuits').setup({
  cursor_line_only = true,
  show_on_start = true,
})

But nothing is shown.

When I use the toggle key, either binding it in the config or manually with require('nvim-biscuits').toggle_biscuits() it does toggle it, but only for the one line the cursor is on, and then this one stays.

No other line gets displayed. If I go to another line, then toggle again, the previous one hides, toggle again, then the current line (and only this one) toggles.

If I toggle it on a line that doesn't have a closing bracket, nothing happens at all.

@cmgriffing
Copy link
Contributor

Using the latest main branch it worked for me just now. Could you try again with the latest main branch code?

@cd-a
Copy link
Author

cd-a commented Nov 18, 2021

I've tried the latest main branch and it does work indeed again, however not for cursorline only.

If I put the cursorline only setting, I have to go now to a line, toggle it on with the keybind, and then it shows there permanently. If I want another line, I have to go there, toggle off, and toggle on again.

I remember before, that cursorline was showing the info dynamically on whatever line you were on at the moment, that was great.

@cmgriffing
Copy link
Contributor

I am unable to reproduce this on a mac with the homebrew installed version:

NVIM v0.5.1
Build type: Release
LuaJIT 2.1.0-beta3

I then tried brew install --HEAD neovim and it still worked for me.

NVIM v0.6.0-dev+612-gd99d4af7b
Build type: Release
LuaJIT 2.1.0-beta3

Could you list what OS and version you are on?

@cd-a
Copy link
Author

cd-a commented Nov 23, 2021

NVIM v0.5.1
Build type: Release
LuaJIT 2.1.0-beta3

Here is a better explanation:

This config:

lua <<EOF
require('nvim-biscuits').setup({
  toggle_keybind = "<leader>cb",
  -- cursor_line_only = true,
  show_on_start = true
})
EOF

produces this
full

So it's all working as expected, and I'm using the keybind to toggle. So far so good.

Now, this config with the cursor_line_only set:

lua <<EOF
require('nvim-biscuits').setup({
  toggle_keybind = "<leader>cb",
  cursor_line_only = true,
  show_on_start = true
})
EOF

I get this:
line

Again I'm using the keybind to toggle.
Notice how I have it on the second to last line, and at the end I move down to the last line. But it still only shows for the second last line.

Then I have to press toggle -> it deletes line above. Then toggle again, to show it on the current line.

So the issue is, that like a week ago the cursor_line_only worked without toggling, it was showing dynamically on every line that I was on, and hiding all the others, which is how it should be, imo.

Do you have the same behaviour or does that actually work for you?

@cmgriffing
Copy link
Contributor

Yes this actually works for me. We tested and toggled as much as we could on stream. Could not reproduce your issue.

What is your OS?

@cd-a
Copy link
Author

cd-a commented Nov 24, 2021

I did a lot more testing and found out a few things.

First of all, my machines are on macOS 10.15.2 and 11.6.1

They behave the same.

I now noticed that it’s the files that make the difference. In most files it works as expected, but I have some large ts files that don’t work, and also some large tsx files that don’t.

Also sometimes it works fine, and then after editing a large file it stops working, even in smaller files. Restarting vim then makes it work again in the small file at least.

I don’t know what exactly is causing this, and I’ll have to keep watching until I find a way to reproduce.

It could be an interference with other plugins, or keybindings, or maybe when treesitter reaches a point that there is an error in the code it can’t parse all the way down then it locks up. I’ll try to investigate further.

@benjamineskola
Copy link
Contributor

benjamineskola commented Dec 24, 2022

I can reproduce this. I just installed nvim-biscuits for the first time and couldn't get it to work as expected. The way in which it's broken resembles this report. When I rolled back to d1bb237 it worked as expected.

More specifically: on HEAD, it didn't seem to work on startup at all, even with enable_on_startup = true, but I could toggle on using the function. If I also set cursor_line_only = true, then toggle only enables and disables for the current line, and the biscuit remains on that initial line when I move away from it, until I toggle off and on again.

I'm also on macOS (13), and I'm using neovim 0.8.1 from homebrew.

@cmgriffing
Copy link
Contributor

Hmm, I still cannot reproduce, but I only have a few plugins. Can you list your other plugins?

I only have these:

vim.cmd "call plug#begin()"
vim.cmd "Plug 'rust-lang/rust.vim'"
vim.cmd "Plug 'nvim-lua/plenary.nvim'"
vim.cmd "Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}"
vim.cmd "Plug '/Volumes/T7/repos/nvim-biscuits'"
vim.cmd "call plug#end()"

I could be doing something very wrong though. I don't use neovim enough to know what though.

@cmgriffing
Copy link
Contributor

How about this, are either of you able to hop into my Twitch Stream to help me figure this out? We would use Twitch Guest Stars and it might take some kind of OBS setup to share the screen via that, but I would be happy to try it out.

The ideal days for these are Sundays for me. (Pacific time). But I can set time aside for any day that works for either of you.

@cmgriffing
Copy link
Contributor

OK, nvm. I think we discovered the issue. It has to do with the toggle_keybind not being set, I think. There may be more to it though, so I will fix that at the very least and then we can look into some of the other issues that may still be there.

@benjamineskola
Copy link
Contributor

It seems to me that this conditional is the issue — shouldn't the and be an or?

We want to render the biscuits if the user hasn't set a keybinding; we also want to render them if the user has set a keybinding and has set show_on_start = true.

The following appears to work for me:

    if (not toggle_keybind) or config.get_language_config(final_config, lang, "show_on_start") then
        nvim_biscuits.decorate_nodes(bufnr, lang)
    else
        nvim_biscuits.should_render_biscuits = false
    end

@cmgriffing
Copy link
Contributor

As a further note. I believe most of the issue was fixed by @benjamineskola.

However, I think I had also uncovered a couple edge cases regarding specific languages and sometimes an edge case where there was no proper bufnr to attach to.

Try it with the latest changes. (Ben's and mine)

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

Successfully merging a pull request may close this issue.

3 participants