on main help sign in
fix(lsp): small UI improvements (#1211)

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>

commit04210801f02d2ee5db7ae89a7ec28e34d5d14d5b authorCarlos Alexandro Becker <caarlos0@users.noreply.github.com> dateThu 9 Oct 2025, 23:16 (1 year ago) parent390983a
1 file changed+25−26
internal/tui/components/lsp/lsp.go+25−26
internal/tui/components/lsp/lsp.go+25−26
@@ -56,32 +56,7 @@ func RenderLSPList(lspClients *csync.Map[string, *lsp.Client], opts RenderOption
5656 break
5757 }
5858
59− // Determine icon color and description based on state
60− icon := t.ItemOfflineIcon
61− description := l.LSP.Command
62−
63− if l.LSP.Disabled {
64− description = t.S().Subtle.Render("disabled")
65− } else if state, exists := lspStates[l.Name]; exists {
66− switch state.State {
67− case lsp.StateStarting:
68− icon = t.ItemBusyIcon
69− description = t.S().Subtle.Render("starting...")
70− case lsp.StateReady:
71− icon = t.ItemOnlineIcon
72− description = l.LSP.Command
73− case lsp.StateError:
74− icon = t.ItemErrorIcon
75− if state.Error != nil {
76− description = t.S().Subtle.Render(fmt.Sprintf("error: %s", state.Error.Error()))
77− } else {
78− description = t.S().Subtle.Render("error")
79− }
80− case lsp.StateDisabled:
81− icon = t.ItemOfflineIcon.Foreground(t.FgMuted)
82− description = t.S().Base.Foreground(t.FgMuted).Render("no root markers found")
83− }
84− }
59+ icon, description := iconAndDescription(l, t, lspStates)
8560
8661 // Calculate diagnostic counts if we have LSP clients
8762 var extraContent string
@@ -134,6 +109,30 @@ func RenderLSPList(lspClients *csync.Map[string, *lsp.Client], opts RenderOption
134109 return lspList
135110}
136111
112+func iconAndDescription(l config.LSP, t *styles.Theme, states map[string]app.LSPClientInfo) (lipgloss.Style, string) {
113+ if l.LSP.Disabled {
114+ return t.ItemOfflineIcon.Foreground(t.FgMuted), t.S().Subtle.Render("disabled")
115+ }
116+
117+ info := states[l.Name]
118+ switch info.State {
119+ case lsp.StateStarting:
120+ return t.ItemBusyIcon, t.S().Subtle.Render("starting...")
121+ case lsp.StateReady:
122+ return t.ItemOnlineIcon, ""
123+ case lsp.StateError:
124+ description := t.S().Subtle.Render("error")
125+ if info.Error != nil {
126+ description = t.S().Subtle.Render(fmt.Sprintf("error: %s", info.Error.Error()))
127+ }
128+ return t.ItemErrorIcon, description
129+ case lsp.StateDisabled:
130+ return t.ItemOfflineIcon.Foreground(t.FgMuted), t.S().Subtle.Render("inactive")
131+ default:
132+ return t.ItemOfflineIcon, ""
133+ }
134+}
135+
137136// RenderLSPBlock renders a complete LSP block with optional truncation indicator.
138137func RenderLSPBlock(lspClients *csync.Map[string, *lsp.Client], opts RenderOptions, showTruncationIndicator bool) string {
139138 t := styles.CurrentTheme()