I am trying to show on lualine the current attached LSP server name. I don't want to install plugins in order to do this so I am searching for a way to do it with the Neovim API. I've read the docs and searched online but I didn't found anything useful.

Any help is appreciated.

1 Answer 1


The vim.lsp.get_clients() function gets the active clients. If you prefix it with buf_ it only gets the active clients of the current buffer:

The vim.lsp.buf_… functions perform operations for all LSP clients attached to the given buffer.

So you could do something like:

:lua =vim.lsp.buf_get_clients()[1].name

to print it within nvim or to use it in Lua:


However, more than one LSP-client can be attached to a buffer. The [1] only gets the first one. So you need to check the length to handle cases were 0 or more than 1 client is attached.

New contributor
niklassc is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.