Skip to content

lsp‐component

Zeioth edited this page Apr 3, 2024 · 6 revisions

You can add this component to the statusline section of heirline opts.

require("heirline-components.all").component.lsp()

You can see how this component look on the right of the next image: It will show the currently loaded lsp clients. screenshot_2024-02-27_19-15-13_332762773 While the clients are loading, you will see a % load indicator. screenshot_2024-02-27_19-07-18_634049513

Available providers

These are the available providers for this component and its options.

lsp_progress = {
  str = "",
  padding = { right = 1 },
  update = {
    "User",
    pattern = { "HeirlineComponentsUpdateLspProgress" },
    callback = vim.schedule_wrap(function() vim.cmd.redrawstatus() end),
  },
  init = require("heirline-components.core.init").lsp_progress()
},
lsp_client_names = {
  str = "LSP",
  update = {
    "LspAttach",
    "LspDetach",
    "BufEnter",
    "VimResized",
    callback = vim.schedule_wrap(function() vim.cmd.redrawstatus() end),
  },
  icon = { kind = "ActiveLSP", padding = { right = 2 } },
},
hl = hl.get_attributes "lsp",
surround = {
  separator = "right",
  color = "lsp_bg",
  condition = condition.lsp_attached,
},
on_click = {
  name = "heirline_lsp",
  callback = function() vim.schedule(vim.cmd.LspInfo) end,
},

For example to disable the lsp client names:

component.lsp({ lsp_client_names = false })

More info

The provider lsp_progress can be manually updated by triggering the event User HeirlineComponentsUpdateLspProgress. But this is not necessary.

Clone this wiki locally