MunifTanjim / nougat.nvim

🍫 Hyperextensible Statusline / Tabline / Winbar for Neovim 🚀
MIT License
197 stars 3 forks source link

:hammer_and_wrench: How to configure `lsp.servers` content? #55

Closed bayou-brogrammer closed 9 months ago

bayou-brogrammer commented 9 months ago

Did you check the docs and existing issues?

Problem

get_content of LSP config is currently hardcoded to a set function

Solution

Allow for a configurable opts to be passed to allow overriding the default implementation

Alternatives

An alternative would be created the Item then merging it with another table that has my custom function

local item = nut.lsp({
  config = {},
  prefix = "  ",
  hl = { fg = color.green },
  sep_right = sep.right_chevron_solid(true),
  on_click = function()
    vim.cmd("LspInfo")
  end,
})

stl:add_item(Utils.merge(item, { content = custom_content_fn }))

Additional Context

No response

MunifTanjim commented 9 months ago

What are you trying to config?

Did you try the config.content? For example, check https://github.com/MunifTanjim/nougat.nvim/issues/49#issuecomment-1823920378

local lsp_servers = nut.lsp.servers.create({
  ctx = {
    content = {
      lua_ls = "LuaLS",
    },
    hl = {
      lua_ls = { fg = "cyan" },
    },
  },
  priority = 1,
  hl = { bg = "gray", fg = "white" },
  sep_left = sep.left_lower_triangle_solid(true),
  config = {
    content = function(client, item)
      return {
        content = item.ctx.content[client.name] or client.name,
        hl = item.ctx.hl[client.name],
      }
    end,
    sep = " ",
  },
  suffix = " ",
})
MunifTanjim commented 9 months ago

A more detailed example: https://github.com/MunifTanjim/nougat.nvim/issues/49#issuecomment-1825004239