WhoIsSethDaniel / lualine-lsp-progress.nvim

LSP progress lualine component
MIT License
62 stars 3 forks source link

Only show client attached to the particular buffer/filetype #5

Closed petobens closed 1 year ago

petobens commented 1 year ago

Hi! If I open a python and a lua file then (as it can be seen in the image) I see the pyright lsp shown while on the lua buffer. However if I run LspInfo I see that the pyright client is active but not attached to the buffer. How can we show only the attached clients? (i.e pyright in the python file; sumneko_lua and null in the lua file)

progress

WhoIsSethDaniel commented 1 year ago

Do you mean "how do I only show the progress of attached clients to the buffer I am currently viewing?" You can't do this with the current code. I'll consider an option that allows for this.

petobens commented 1 year ago

ow do I only show the progress of attached clients to the buffer I am currently viewing

Yep exactly that. I'm viewing a lua file (as in the video) then I don't wan't to see a "pyright" server indicator since it is attached but no active for lua.

WhoIsSethDaniel commented 1 year ago

I've added a new option that should allow a user to only see the status for LSP servers attached to the currently active buffer. e.g.

{ 'lsp_progress', only_show_attached = true }

By default this option is false.

WhoIsSethDaniel commented 1 year ago

It seems to work for me, but I don't typically have a variety of LSP servers running at once in different buffers. It's not a use case I have yet to experience myself.

petobens commented 1 year ago

Mmm it doesn't quite seem to work? If, as in the GIF, I do: lspr

  1. Open a python file -> I see the pyright indicator
  2. Open a lua file -> i see both the pyright and sumneko lua indicators

I expect to see pyright in the python file and sumneko in the lua file but not both.

For what its worth :LspInfo somehow does know which client is attached to which buffer and whether it is active or not: image

WhoIsSethDaniel commented 1 year ago

Unfortunately pyright is a bad example since it doesn't send status messages. It should be hidden in your configuration:

{ 'lsp_progress', hide = { 'pyright' } }

Since pyright sends no status messages it will never be removed from the list of servers to show. The code can be changed slightly to get rid of this defect, but pyright will continue to be shown when viewing your python file.

I test using a go file and a lua file and I switch between the buffers and the status changes as expected. When viewing the go file I see gopls status. When viewing the lua file I see lua-language-server status. For both I see null-ls status.

I will update the code to deal with servers that don't send status messages, but the real fix for that is to hide such servers.

petobens commented 1 year ago

Thanks for the explanation! Feel free to close.