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

Status line #16

Closed
mightyiam opened this issue May 25, 2022 · 3 comments
Closed

Status line #16

mightyiam opened this issue May 25, 2022 · 3 comments

Comments

@mightyiam
Copy link

I've looked into what it would take to have lsp related info such as server status and diagnostics in a status line and it seems like a lot of hooking up work. Perhaps another task for lsp-zero?

@mightyiam
Copy link
Author

Well, I've been looking at lualine but it seems that the lightline ecosystem is a bit more mature with https://github.com/josa42/nvim-lightline-lsp

@VonHeikemen
Copy link
Owner

I believe lsp-status.nvim should help you with this. It has like a bunch of helper functions that query the language server. You can make it work even without a statusline plugin.

---
-- LSP
---
local lsp = require('lsp-zero')
lsp.preset('recommended')

lsp.on_attach(function(client, bufnr)
  vim.b.lsp_attached = true
end)

lsp.setup()

---
-- Statusline
---
local lsp_status = require('lsp-status')
lsp_status.config({
  status_symbol = '',
  indicator_errors = '',
  indicator_warnings = '',
  indicator_info = '',
  indicator_hint = '',
  indicator_ok = '',
})

function LspStatus()
  if vim.b.lsp_attached then
    return lsp_status.status()
  end

  return ''
end

vim.opt.statusline = '%=%{v:lua.LspStatus()}%r%m %l:%c %p%% %y '

To see notification reports of the server status I use fidget.nvim. This one has good defaults (for the server I have used), so I only add this.

require('fidget').setup({})

@mightyiam
Copy link
Author

Thank you, @VonHeikemen . I ended up using fidget-nvim only.

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

No branches or pull requests

2 participants