Git Product home page Git Product logo

Comments (7)

b0o avatar b0o commented on August 26, 2024 3

By the way, I will be pushing quite a few changes soon, including better highlight support so that you won't need to use winhl. And thank you very much for the kind words!

from incline.nvim.

b0o avatar b0o commented on August 26, 2024 1

This is very interesting. It seems to be a Neovim bug. I can reproduce it with no plugins, like so:

  1. nvim --clean
  2. :lua vim.api.nvim_win_set_option(vim.api.nvim_open_win(vim.api.nvim_create_buf(false, true), false, { relative = "editor", width = 1, height = 1, row = 1, col = 1 }), "winhighlight", "Normal:Search")
  3. :copen

I've opened a neovim issue: neovim/neovim#18283

from incline.nvim.

akinsho avatar akinsho commented on August 26, 2024 1

@b0o thanks for looking into this and raising the issue in neovim core 👍🏿 , just tried out the new API, and it works great, doesn't leak into the quickfix any more 💯. Will close this out now then.

from incline.nvim.

sindrets avatar sindrets commented on August 26, 2024

@b0o like you've figured out, the problem is caused by the fact that both
nvim_win_set_option and nvim_buf_set_option do not behave like
:setlocal, even though that's how they're intended to work. I was fighting
with this bug for a while in my plugin diffview. Essentially, contrary to
when using :setlocal, setting options in a window A with nvim_win_set_option
and then creating a new window B from that window, B will inherit all window
options from A including those set with nvim_win_set_option.

I found that the simplest way to get around this is to just create a wrapper
around :setlocal. I've been using this wrapper in both my plugins, and I've
had no problems with this bug ever since (this code uses some ugly polymorphic
parameters, but I just really enjoy the convenience of overload signatures).

from incline.nvim.

b0o avatar b0o commented on August 26, 2024

Hey @sindrets, thank you for sharing! I just wrote a wrapper inspired by yours, it seems to have fixed the issue for me.

Before I merge those changes into main, I am curious to know what the purpose of no_win_event_call is, and if it is necessary in this case? I just tested the following to see if nvim_win_call triggers those events, but when I run these two commands I don't see any "event" messages:

  • :au WinEnter,WinLeave,WinNew,WinClosed,BufEnter,BufLeave * echom "event"
  • :lua vim.api.nvim_win_call(1002, function() vim.cmd [[setlocal winhighlight=Normal:Search]] end)

from incline.nvim.

sindrets avatar sindrets commented on August 26, 2024

@b0o Ah, it seems you're right: setlocal doesn't seem to trigger any of
these events, and it's probably only there due to an oversight. Thank you for
pointing that out!

Finding out what does and doesn't trigger these events can
be a bit surprising sometimes, so I've probably used this function a bit too
liberally. It has notably improved performance for me in instances where I'm
changing buffers multiple times in multiple windows over a short time span.

from incline.nvim.

b0o avatar b0o commented on August 26, 2024

@sindrets Cool, just wanted to make sure!

@akinsho I've merged the fix into main, would you mind giving it a try for me?

from incline.nvim.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.