kosayoda / nvim-lightbulb

VSCode 💡 for neovim's built-in LSP.
MIT License
783 stars 27 forks source link

Is it possible to disable the lightbulb for unfocused buffer? #42

Closed fitrh closed 1 year ago

fitrh commented 2 years ago

When splitting a window with different buffers, I want to see the lightbulb only in the current buffer.

I'm trying to use WinLeave and BufLeave events to call this function

require("nvim-lightbulb").update_lightbulb({
    virtual_text = { enabled = false },
})

But it doesn't work, is there a way to do so?

ctrlplusb commented 1 year ago

I'm also looking for a way to disable the lightbulb showing in my Nvim Tree panel.

fitrh commented 1 year ago

@ctrlplusb my workaround for this is putting this callback on WinLeave event

      local ns = vim.api.nvim_create_namespace("nvim-lightbulb")
      vim.api.nvim_buf_clear_namespace(args.buf, ns, 0, -1)
      require("nvim-lightbulb").update_lightbulb({
        virtual_text = { enabled = false },
      })
kosayoda commented 1 year ago

Hello! There are a few ways to solve this with the latest release.

  1. Configure ignore.ft to the filetypes you wish to ignore (like neo-tree)
  2. Set hide_in_unfocused_buffer = true to stop showing a lightbulb on WinLeave

Please file another issue should you find a problem with the feature