fix: lsp sort

Kujtim Hoxha created

Change summary

internal/ui/model/lsp.go | 9 ++++++++-
internal/ui/model/ui.go  | 2 ++
2 files changed, 10 insertions(+), 1 deletion(-)

Detailed changes

internal/ui/model/lsp.go 🔗

@@ -23,8 +23,14 @@ type LSPInfo struct {
 func (m *UI) lspInfo(width, maxItems int, isSection bool) string {
 	var lsps []LSPInfo
 	t := m.com.Styles
+	lspConfigs := m.com.Config().LSP.Sorted()
+
+	for _, cfg := range lspConfigs {
+		state, ok := m.lspStates[cfg.Name]
+		if !ok {
+			continue
+		}
 
-	for _, state := range m.lspStates {
 		client, ok := m.com.App.LSPClients.Get(state.Name)
 		if !ok {
 			continue
@@ -39,6 +45,7 @@ func (m *UI) lspInfo(width, maxItems int, isSection bool) string {
 
 		lsps = append(lsps, LSPInfo{LSPClientInfo: state, Diagnostics: lspErrs})
 	}
+
 	title := t.Subtle.Render("LSPs")
 	if isSection {
 		title = common.Section(t, title, width)

internal/ui/model/ui.go 🔗

@@ -265,6 +265,8 @@ func New(com *common.Common) *UI {
 		completions: comp,
 		attachments: attachments,
 		todoSpinner: todoSpinner,
+		lspStates:   make(map[string]app.LSPClientInfo),
+		mcpStates:   make(map[string]mcp.ClientInfo),
 	}
 
 	status := NewStatus(com, ui)