on main help sign in
chore(lint): enable staticcheck and fix its issues
commit5c319e64334fecf316333bf9e7c15760667b6138 authorTai Groot <tai@taigrr.com> dateTue 15 Jul 2025, 11:41 (1 year ago) parent2d332fc
24 files changed+503−498
.golangci.yml+1−1 internal/app/app.go+5−5 internal/config/load.go+53−53 internal/llm/provider/gemini.go+3−3 internal/llm/provider/openai.go+2−2 internal/llm/tools/diagnostics.go+2−2 internal/lsp/client.go+15−15 internal/lsp/protocol/interface.go+3−3 internal/lsp/protocol/pattern_interfaces.go+2−2 internal/lsp/protocol/tsdocument-changes.go+5−5 internal/lsp/protocol/tsprotocol.go+367−322 internal/lsp/protocol/uri.go+15−15 internal/lsp/transport.go+1−1 internal/lsp/util/edit.go+1−1 internal/lsp/watcher/watcher.go+7−7 internal/tui/components/core/status/status.go−2 internal/tui/components/logo/logo.go−36 internal/tui/exp/diffview/diffview.go+1−2 internal/tui/exp/diffview/testdata/TestDiffView/Unified/Narrow/DarkMode.golden+2−2 internal/tui/exp/diffview/testdata/TestDiffView/Unified/Narrow/LightMode.golden+2−2 internal/tui/exp/diffview/udiff_test.go+1−2 internal/tui/exp/list/list.go−2 internal/tui/page/chat/chat.go+14−13 internal/version/version.go+1
.golangci.yml+1−1
@@ -19,6 +19,7 @@ linters:
1919 # - revive
2020 - rowserrcheck
2121 - sqlclosecheck
22+ - staticcheck
2223 - tparallel
2324 # - unconvert
2425 # - unparam
@@ -27,7 +28,6 @@ linters:
2728 disable:
2829 - errcheck
2930 - ineffassign
30− - staticcheck
3131 - unused
3232 exclusions:
3333 generated: lax
internal/app/app.go+5−5
@@ -93,7 +93,7 @@ func New(ctx context.Context, conn *sql.DB, cfg *config.Config) (*App, error) {
9393}
9494
9595// RunNonInteractive handles the execution flow when a prompt is provided via CLI flag.
96−func (a *App) RunNonInteractive(ctx context.Context, prompt string, quiet bool) error {
96+func (app *App) RunNonInteractive(ctx context.Context, prompt string, quiet bool) error {
9797 slog.Info("Running in non-interactive mode")
9898
9999 ctx, cancel := context.WithCancel(ctx)
@@ -125,21 +125,21 @@ func (a *App) RunNonInteractive(ctx context.Context, prompt string, quiet bool)
125125 }
126126 title := titlePrefix + titleSuffix
127127
128− sess, err := a.Sessions.Create(ctx, title)
128+ sess, err := app.Sessions.Create(ctx, title)
129129 if err != nil {
130130 return fmt.Errorf("failed to create session for non-interactive mode: %w", err)
131131 }
132132 slog.Info("Created session for non-interactive run", "session_id", sess.ID)
133133
134134 // Automatically approve all permission requests for this non-interactive session
135− a.Permissions.AutoApproveSession(sess.ID)
135+ app.Permissions.AutoApproveSession(sess.ID)
136136
137− done, err := a.CoderAgent.Run(ctx, sess.ID, prompt)
137+ done, err := app.CoderAgent.Run(ctx, sess.ID, prompt)
138138 if err != nil {
139139 return fmt.Errorf("failed to start agent processing stream: %w", err)
140140 }
141141
142− messageEvents := a.Messages.Subscribe(ctx)
142+ messageEvents := app.Messages.Subscribe(ctx)
143143 readBts := 0
144144
145145 for {
internal/config/load.go+53−53
@@ -87,16 +87,16 @@ func Load(workingDir string, debug bool) (*Config, error) {
8787 return cfg, nil
8888}
8989
90−func (cfg *Config) configureProviders(env env.Env, resolver VariableResolver, knownProviders []provider.Provider) error {
90+func (c *Config) configureProviders(env env.Env, resolver VariableResolver, knownProviders []provider.Provider) error {
9191 knownProviderNames := make(map[string]bool)
9292 for _, p := range knownProviders {
9393 knownProviderNames[string(p.ID)] = true
94− config, configExists := cfg.Providers[string(p.ID)]
94+ config, configExists := c.Providers[string(p.ID)]
9595 // if the user configured a known provider we need to allow it to override a couple of parameters
9696 if configExists {
9797 if config.Disable {
9898 slog.Debug("Skipping provider due to disable flag", "provider", p.ID)
99− delete(cfg.Providers, string(p.ID))
99+ delete(c.Providers, string(p.ID))
100100 continue
101101 }
102102 if config.BaseURL != "" {
@@ -151,7 +151,7 @@ func (cfg *Config) configureProviders(env env.Env, resolver VariableResolver, kn
151151 if !hasVertexCredentials(env) {
152152 if configExists {
153153 slog.Warn("Skipping Vertex AI provider due to missing credentials")
154− delete(cfg.Providers, string(p.ID))
154+ delete(c.Providers, string(p.ID))
155155 }
156156 continue
157157 }
@@ -161,7 +161,7 @@ func (cfg *Config) configureProviders(env env.Env, resolver VariableResolver, kn
161161 if !hasAWSCredentials(env) {
162162 if configExists {
163163 slog.Warn("Skipping Bedrock provider due to missing AWS credentials")
164− delete(cfg.Providers, string(p.ID))
164+ delete(c.Providers, string(p.ID))
165165 }
166166 continue
167167 }
@@ -176,16 +176,16 @@ func (cfg *Config) configureProviders(env env.Env, resolver VariableResolver, kn
176176 if v == "" || err != nil {
177177 if configExists {
178178 slog.Warn("Skipping provider due to missing API key", "provider", p.ID)
179− delete(cfg.Providers, string(p.ID))
179+ delete(c.Providers, string(p.ID))
180180 }
181181 continue
182182 }
183183 }
184− cfg.Providers[string(p.ID)] = prepared
184+ c.Providers[string(p.ID)] = prepared
185185 }
186186
187187 // validate the custom providers
188− for id, providerConfig := range cfg.Providers {
188+ for id, providerConfig := range c.Providers {
189189 if knownProviderNames[id] {
190190 continue
191191 }
@@ -202,7 +202,7 @@ func (cfg *Config) configureProviders(env env.Env, resolver VariableResolver, kn
202202
203203 if providerConfig.Disable {
204204 slog.Debug("Skipping custom provider due to disable flag", "provider", id)
205− delete(cfg.Providers, id)
205+ delete(c.Providers, id)
206206 continue
207207 }
208208 if providerConfig.APIKey == "" {
@@ -210,17 +210,17 @@ func (cfg *Config) configureProviders(env env.Env, resolver VariableResolver, kn
210210 }
211211 if providerConfig.BaseURL == "" {
212212 slog.Warn("Skipping custom provider due to missing API endpoint", "provider", id)
213− delete(cfg.Providers, id)
213+ delete(c.Providers, id)
214214 continue
215215 }
216216 if len(providerConfig.Models) == 0 {
217217 slog.Warn("Skipping custom provider because the provider has no models", "provider", id)
218− delete(cfg.Providers, id)
218+ delete(c.Providers, id)
219219 continue
220220 }
221221 if providerConfig.Type != provider.TypeOpenAI {
222222 slog.Warn("Skipping custom provider because the provider type is not supported", "provider", id, "type", providerConfig.Type)
223− delete(cfg.Providers, id)
223+ delete(c.Providers, id)
224224 continue
225225 }
226226
@@ -231,50 +231,50 @@ func (cfg *Config) configureProviders(env env.Env, resolver VariableResolver, kn
231231 baseURL, err := resolver.ResolveValue(providerConfig.BaseURL)
232232 if baseURL == "" || err != nil {
233233 slog.Warn("Skipping custom provider due to missing API endpoint", "provider", id, "error", err)
234− delete(cfg.Providers, id)
234+ delete(c.Providers, id)
235235 continue
236236 }
237237
238− cfg.Providers[id] = providerConfig
238+ c.Providers[id] = providerConfig
239239 }
240240 return nil
241241}
242242
243−func (cfg *Config) setDefaults(workingDir string) {
244− cfg.workingDir = workingDir
245− if cfg.Options == nil {
246− cfg.Options = &Options{}
243+func (c *Config) setDefaults(workingDir string) {
244+ c.workingDir = workingDir
245+ if c.Options == nil {
246+ c.Options = &Options{}
247247 }
248− if cfg.Options.TUI == nil {
249− cfg.Options.TUI = &TUIOptions{}
248+ if c.Options.TUI == nil {
249+ c.Options.TUI = &TUIOptions{}
250250 }
251− if cfg.Options.ContextPaths == nil {
252− cfg.Options.ContextPaths = []string{}
251+ if c.Options.ContextPaths == nil {
252+ c.Options.ContextPaths = []string{}
253253 }
254− if cfg.Options.DataDirectory == "" {
255− cfg.Options.DataDirectory = filepath.Join(workingDir, defaultDataDirectory)
254+ if c.Options.DataDirectory == "" {
255+ c.Options.DataDirectory = filepath.Join(workingDir, defaultDataDirectory)
256256 }
257− if cfg.Providers == nil {
258− cfg.Providers = make(map[string]ProviderConfig)
257+ if c.Providers == nil {
258+ c.Providers = make(map[string]ProviderConfig)
259259 }
260− if cfg.Models == nil {
261− cfg.Models = make(map[SelectedModelType]SelectedModel)
260+ if c.Models == nil {
261+ c.Models = make(map[SelectedModelType]SelectedModel)
262262 }
263− if cfg.MCP == nil {
264− cfg.MCP = make(map[string]MCPConfig)
263+ if c.MCP == nil {
264+ c.MCP = make(map[string]MCPConfig)
265265 }
266− if cfg.LSP == nil {
267− cfg.LSP = make(map[string]LSPConfig)
266+ if c.LSP == nil {
267+ c.LSP = make(map[string]LSPConfig)
268268 }
269269
270270 // Add the default context paths if they are not already present
271− cfg.Options.ContextPaths = append(defaultContextPaths, cfg.Options.ContextPaths...)
272− slices.Sort(cfg.Options.ContextPaths)
273− cfg.Options.ContextPaths = slices.Compact(cfg.Options.ContextPaths)
271+ c.Options.ContextPaths = append(defaultContextPaths, c.Options.ContextPaths...)
272+ slices.Sort(c.Options.ContextPaths)
273+ c.Options.ContextPaths = slices.Compact(c.Options.ContextPaths)
274274}
275275
276−func (cfg *Config) defaultModelSelection(knownProviders []provider.Provider) (largeModel SelectedModel, smallModel SelectedModel, err error) {
277− if len(knownProviders) == 0 && len(cfg.Providers) == 0 {
276+func (c *Config) defaultModelSelection(knownProviders []provider.Provider) (largeModel SelectedModel, smallModel SelectedModel, err error) {
277+ if len(knownProviders) == 0 && len(c.Providers) == 0 {
278278 err = fmt.Errorf("no providers configured, please configure at least one provider")
279279 return
280280 }
@@ -282,11 +282,11 @@ func (cfg *Config) defaultModelSelection(knownProviders []provider.Provider) (la
282282 // Use the first provider enabled based on the known providers order
283283 // if no provider found that is known use the first provider configured
284284 for _, p := range knownProviders {
285− providerConfig, ok := cfg.Providers[string(p.ID)]
285+ providerConfig, ok := c.Providers[string(p.ID)]
286286 if !ok || providerConfig.Disable {
287287 continue
288288 }
289− defaultLargeModel := cfg.GetModel(string(p.ID), p.DefaultLargeModelID)
289+ defaultLargeModel := c.GetModel(string(p.ID), p.DefaultLargeModelID)
290290 if defaultLargeModel == nil {
291291 err = fmt.Errorf("default large model %s not found for provider %s", p.DefaultLargeModelID, p.ID)
292292 return
@@ -298,7 +298,7 @@ func (cfg *Config) defaultModelSelection(knownProviders []provider.Provider) (la
298298 ReasoningEffort: defaultLargeModel.DefaultReasoningEffort,
299299 }
300300
301− defaultSmallModel := cfg.GetModel(string(p.ID), p.DefaultSmallModelID)
301+ defaultSmallModel := c.GetModel(string(p.ID), p.DefaultSmallModelID)
302302 if defaultSmallModel == nil {
303303 err = fmt.Errorf("default small model %s not found for provider %s", p.DefaultSmallModelID, p.ID)
304304 return
@@ -312,7 +312,7 @@ func (cfg *Config) defaultModelSelection(knownProviders []provider.Provider) (la
312312 return
313313 }
314314
315− enabledProviders := cfg.EnabledProviders()
315+ enabledProviders := c.EnabledProviders()
316316 slices.SortFunc(enabledProviders, func(a, b ProviderConfig) int {
317317 return strings.Compare(a.ID, b.ID)
318318 })
@@ -327,13 +327,13 @@ func (cfg *Config) defaultModelSelection(knownProviders []provider.Provider) (la
327327 err = fmt.Errorf("provider %s has no models configured", providerConfig.ID)
328328 return
329329 }
330− defaultLargeModel := cfg.GetModel(providerConfig.ID, providerConfig.Models[0].ID)
330+ defaultLargeModel := c.GetModel(providerConfig.ID, providerConfig.Models[0].ID)
331331 largeModel = SelectedModel{
332332 Provider: providerConfig.ID,
333333 Model: defaultLargeModel.ID,
334334 MaxTokens: defaultLargeModel.DefaultMaxTokens,
335335 }
336− defaultSmallModel := cfg.GetModel(providerConfig.ID, providerConfig.Models[0].ID)
336+ defaultSmallModel := c.GetModel(providerConfig.ID, providerConfig.Models[0].ID)
337337 smallModel = SelectedModel{
338338 Provider: providerConfig.ID,
339339 Model: defaultSmallModel.ID,
@@ -342,14 +342,14 @@ func (cfg *Config) defaultModelSelection(knownProviders []provider.Provider) (la
342342 return
343343}
344344
345−func (cfg *Config) configureSelectedModels(knownProviders []provider.Provider) error {
346− defaultLarge, defaultSmall, err := cfg.defaultModelSelection(knownProviders)
345+func (c *Config) configureSelectedModels(knownProviders []provider.Provider) error {
346+ defaultLarge, defaultSmall, err := c.defaultModelSelection(knownProviders)
347347 if err != nil {
348348 return fmt.Errorf("failed to select default models: %w", err)
349349 }
350350 large, small := defaultLarge, defaultSmall
351351
352− largeModelSelected, largeModelConfigured := cfg.Models[SelectedModelTypeLarge]
352+ largeModelSelected, largeModelConfigured := c.Models[SelectedModelTypeLarge]
353353 if largeModelConfigured {
354354 if largeModelSelected.Model != "" {
355355 large.Model = largeModelSelected.Model
@@ -357,11 +357,11 @@ func (cfg *Config) configureSelectedModels(knownProviders []provider.Provider) e
357357 if largeModelSelected.Provider != "" {
358358 large.Provider = largeModelSelected.Provider
359359 }
360− model := cfg.GetModel(large.Provider, large.Model)
360+ model := c.GetModel(large.Provider, large.Model)
361361 if model == nil {
362362 large = defaultLarge
363363 // override the model type to large
364− err := cfg.UpdatePreferredModel(SelectedModelTypeLarge, large)
364+ err := c.UpdatePreferredModel(SelectedModelTypeLarge, large)
365365 if err != nil {
366366 return fmt.Errorf("failed to update preferred large model: %w", err)
367367 }
@@ -377,7 +377,7 @@ func (cfg *Config) configureSelectedModels(knownProviders []provider.Provider) e
377377 large.Think = largeModelSelected.Think
378378 }
379379 }
380− smallModelSelected, smallModelConfigured := cfg.Models[SelectedModelTypeSmall]
380+ smallModelSelected, smallModelConfigured := c.Models[SelectedModelTypeSmall]
381381 if smallModelConfigured {
382382 if smallModelSelected.Model != "" {
383383 small.Model = smallModelSelected.Model
@@ -386,11 +386,11 @@ func (cfg *Config) configureSelectedModels(knownProviders []provider.Provider) e
386386 small.Provider = smallModelSelected.Provider
387387 }
388388
389− model := cfg.GetModel(small.Provider, small.Model)
389+ model := c.GetModel(small.Provider, small.Model)
390390 if model == nil {
391391 small = defaultSmall
392392 // override the model type to small
393− err := cfg.UpdatePreferredModel(SelectedModelTypeSmall, small)
393+ err := c.UpdatePreferredModel(SelectedModelTypeSmall, small)
394394 if err != nil {
395395 return fmt.Errorf("failed to update preferred small model: %w", err)
396396 }
@@ -404,8 +404,8 @@ func (cfg *Config) configureSelectedModels(knownProviders []provider.Provider) e
404404 small.Think = smallModelSelected.Think
405405 }
406406 }
407− cfg.Models[SelectedModelTypeLarge] = large
408− cfg.Models[SelectedModelTypeSmall] = small
407+ c.Models[SelectedModelTypeLarge] = large
408+ c.Models[SelectedModelTypeSmall] = small
409409 return nil
410410}
411411
internal/llm/provider/gemini.go+3−3
@@ -73,7 +73,7 @@ func (g *geminiClient) convertMessages(messages []message.Message) []*genai.Cont
7373
7474 if len(msg.ToolCalls()) > 0 {
7575 for _, call := range msg.ToolCalls() {
76− args, _ := parseJsonToMap(call.Input)
76+ args, _ := parseJSONToMap(call.Input)
7777 assistantParts = append(assistantParts, &genai.Part{
7878 FunctionCall: &genai.FunctionCall{
7979 Name: call.Name,
@@ -93,7 +93,7 @@ func (g *geminiClient) convertMessages(messages []message.Message) []*genai.Cont
9393 case message.Tool:
9494 for _, result := range msg.ToolResults() {
9595 response := map[string]any{"result": result.Content}
96− parsed, err := parseJsonToMap(result.Content)
96+ parsed, err := parseJSONToMap(result.Content)
9797 if err == nil {
9898 response = parsed
9999 }
@@ -468,7 +468,7 @@ func (g *geminiClient) Model() provider.Model {
468468}
469469
470470// Helper functions
471−func parseJsonToMap(jsonStr string) (map[string]any, error) {
471+func parseJSONToMap(jsonStr string) (map[string]any, error) {
472472 var result map[string]any
473473 err := json.Unmarshal([]byte(jsonStr), &result)
474474 return result, err
internal/llm/provider/openai.go+2−2
@@ -463,6 +463,6 @@ func (o *openaiClient) usage(completion openai.ChatCompletion) TokenUsage {
463463 }
464464}
465465
466−func (a *openaiClient) Model() provider.Model {
467− return a.providerOptions.model(a.providerOptions.modelType)
466+func (o *openaiClient) Model() provider.Model {
467+ return o.providerOptions.model(o.providerOptions.modelType)
468468}
internal/llm/tools/diagnostics.go+2−2
@@ -108,7 +108,7 @@ func waitForLspDiagnostics(ctx context.Context, filePath string, lsps map[string
108108 diagChan := make(chan struct{}, 1)
109109
110110 for _, client := range lsps {
111− originalDiags := make(map[protocol.DocumentUri][]protocol.Diagnostic)
111+ originalDiags := make(map[protocol.DocumentURI][]protocol.Diagnostic)
112112 maps.Copy(originalDiags, client.GetDiagnostics())
113113
114114 handler := func(params json.RawMessage) {
@@ -148,7 +148,7 @@ func waitForLspDiagnostics(ctx context.Context, filePath string, lsps map[string
148148 }
149149}
150150
151−func hasDiagnosticsChanged(current, original map[protocol.DocumentUri][]protocol.Diagnostic) bool {
151+func hasDiagnosticsChanged(current, original map[protocol.DocumentURI][]protocol.Diagnostic) bool {
152152 for uri, diags := range current {
153153 origDiags, exists := original[uri]
154154 if !exists || len(diags) != len(origDiags) {
internal/lsp/client.go+15−15
@@ -42,7 +42,7 @@ type Client struct {
4242 notificationMu sync.RWMutex
4343
4444 // Diagnostic cache
45− diagnostics map[protocol.DocumentUri][]protocol.Diagnostic
45+ diagnostics map[protocol.DocumentURI][]protocol.Diagnostic
4646 diagnosticsMu sync.RWMutex
4747
4848 // Files are currently opened by the LSP
@@ -81,7 +81,7 @@ func NewClient(ctx context.Context, command string, args ...string) (*Client, er
8181 handlers: make(map[int32]chan *Message),
8282 notificationHandlers: make(map[string]NotificationHandler),
8383 serverRequestHandlers: make(map[string]ServerRequestHandler),
84− diagnostics: make(map[protocol.DocumentUri][]protocol.Diagnostic),
84+ diagnostics: make(map[protocol.DocumentURI][]protocol.Diagnostic),
8585 openFiles: make(map[string]*OpenFileInfo),
8686 }
8787
@@ -449,13 +449,13 @@ func (c *Client) pingTypeScriptServer(ctx context.Context) error {
449449
450450 // If we have any open files, try to get document symbols for one
451451 for uri := range c.openFiles {
452− filePath := protocol.DocumentUri(uri).Path()
452+ filePath := protocol.DocumentURI(uri).Path()
453453 if strings.HasSuffix(filePath, ".ts") || strings.HasSuffix(filePath, ".js") ||
454454 strings.HasSuffix(filePath, ".tsx") || strings.HasSuffix(filePath, ".jsx") {
455455 var symbols []protocol.DocumentSymbol
456456 err := c.Call(ctx, "textDocument/documentSymbol", protocol.DocumentSymbolParams{
457457 TextDocument: protocol.TextDocumentIdentifier{
458− URI: protocol.DocumentUri(uri),
458+ URI: protocol.DocumentURI(uri),
459459 },
460460 }, &symbols)
461461 if err == nil {
@@ -583,7 +583,7 @@ func (c *Client) pingWithServerCapabilities(ctx context.Context) error {
583583
584584type OpenFileInfo struct {
585585 Version int32
586− URI protocol.DocumentUri
586+ URI protocol.DocumentURI
587587}
588588
589589func (c *Client) OpenFile(ctx context.Context, filepath string) error {
@@ -604,7 +604,7 @@ func (c *Client) OpenFile(ctx context.Context, filepath string) error {
604604
605605 params := protocol.DidOpenTextDocumentParams{
606606 TextDocument: protocol.TextDocumentItem{
607− URI: protocol.DocumentUri(uri),
607+ URI: protocol.DocumentURI(uri),
608608 LanguageID: DetectLanguageID(uri),
609609 Version: 1,
610610 Text: string(content),
@@ -618,7 +618,7 @@ func (c *Client) OpenFile(ctx context.Context, filepath string) error {
618618 c.openFilesMu.Lock()
619619 c.openFiles[uri] = &OpenFileInfo{
620620 Version: 1,
621− URI: protocol.DocumentUri(uri),
621+ URI: protocol.DocumentURI(uri),
622622 }
623623 c.openFilesMu.Unlock()
624624
@@ -648,7 +648,7 @@ func (c *Client) NotifyChange(ctx context.Context, filepath string) error {
648648 params := protocol.DidChangeTextDocumentParams{
649649 TextDocument: protocol.VersionedTextDocumentIdentifier{
650650 TextDocumentIdentifier: protocol.TextDocumentIdentifier{
651− URI: protocol.DocumentUri(uri),
651+ URI: protocol.DocumentURI(uri),
652652 },
653653 Version: version,
654654 },
@@ -677,7 +677,7 @@ func (c *Client) CloseFile(ctx context.Context, filepath string) error {
677677
678678 params := protocol.DidCloseTextDocumentParams{
679679 TextDocument: protocol.TextDocumentIdentifier{
680− URI: protocol.DocumentUri(uri),
680+ URI: protocol.DocumentURI(uri),
681681 },
682682 }
683683
@@ -712,7 +712,7 @@ func (c *Client) CloseAllFiles(ctx context.Context) {
712712 // First collect all URIs that need to be closed
713713 for uri := range c.openFiles {
714714 // Convert URI back to file path using proper URI handling
715− filePath := protocol.DocumentUri(uri).Path()
715+ filePath := protocol.DocumentURI(uri).Path()
716716 filesToClose = append(filesToClose, filePath)
717717 }
718718 c.openFilesMu.Unlock()
@@ -730,7 +730,7 @@ func (c *Client) CloseAllFiles(ctx context.Context) {
730730 }
731731}
732732
733−func (c *Client) GetFileDiagnostics(uri protocol.DocumentUri) []protocol.Diagnostic {
733+func (c *Client) GetFileDiagnostics(uri protocol.DocumentURI) []protocol.Diagnostic {
734734 c.diagnosticsMu.RLock()
735735 defer c.diagnosticsMu.RUnlock()
736736
@@ -738,7 +738,7 @@ func (c *Client) GetFileDiagnostics(uri protocol.DocumentUri) []protocol.Diagnos
738738}
739739
740740// GetDiagnostics returns all diagnostics for all files
741−func (c *Client) GetDiagnostics() map[protocol.DocumentUri][]protocol.Diagnostic {
741+func (c *Client) GetDiagnostics() map[protocol.DocumentURI][]protocol.Diagnostic {
742742 return c.diagnostics
743743}
744744
@@ -757,7 +757,7 @@ func (c *Client) OpenFileOnDemand(ctx context.Context, filepath string) error {
757757// GetDiagnosticsForFile ensures a file is open and returns its diagnostics
758758// This is useful for on-demand diagnostics when using lazy loading
759759func (c *Client) GetDiagnosticsForFile(ctx context.Context, filepath string) ([]protocol.Diagnostic, error) {
760− documentUri := protocol.URIFromPath(filepath)
760+ documentURI := protocol.URIFromPath(filepath)
761761
762762 // Make sure the file is open
763763 if !c.IsFileOpen(filepath) {
@@ -771,14 +771,14 @@ func (c *Client) GetDiagnosticsForFile(ctx context.Context, filepath string) ([]
771771
772772 // Get diagnostics
773773 c.diagnosticsMu.RLock()
774− diagnostics := c.diagnostics[documentUri]
774+ diagnostics := c.diagnostics[documentURI]
775775 c.diagnosticsMu.RUnlock()
776776
777777 return diagnostics, nil
778778}
779779
780780// ClearDiagnosticsForURI removes diagnostics for a specific URI from the cache
781−func (c *Client) ClearDiagnosticsForURI(uri protocol.DocumentUri) {
781+func (c *Client) ClearDiagnosticsForURI(uri protocol.DocumentURI) {
782782 c.diagnosticsMu.Lock()
783783 defer c.diagnosticsMu.Unlock()
784784 delete(c.diagnostics, uri)
internal/lsp/protocol/interface.go+3−3
@@ -2,7 +2,7 @@ package protocol
22
33import "fmt"
44
5−// TextEditResult is an interface for types that represent workspace symbols
5+// WorkspaceSymbolResult is an interface for types that represent workspace symbols
66type WorkspaceSymbolResult interface {
77 GetName() string
88 GetLocation() Location
@@ -48,7 +48,7 @@ func (r Or_Result_workspace_symbol) Results() ([]WorkspaceSymbolResult, error) {
4848 }
4949}
5050
51−// TextEditResult is an interface for types that represent document symbols
51+// DocumentSymbolResult is an interface for types that represent document symbols
5252type DocumentSymbolResult interface {
5353 GetRange() Range
5454 GetName() string
@@ -98,7 +98,7 @@ func (te *TextEdit) GetRange() Range { return te.Range }
9898func (te *TextEdit) GetNewText() string { return te.NewText }
9999func (te *TextEdit) isTextEdit() {}
100100
101−// Convert Or_TextDocumentEdit_edits_Elem to TextEdit
101+// AsTextEdit converts Or_TextDocumentEdit_edits_Elem to TextEdit
102102func (e Or_TextDocumentEdit_edits_Elem) AsTextEdit() (TextEdit, error) {
103103 if e.Value == nil {
104104 return TextEdit{}, fmt.Errorf("nil text edit")
internal/lsp/protocol/pattern_interfaces.go+2−2
@@ -44,8 +44,8 @@ func (g *GlobPattern) AsPattern() (PatternInfo, error) {
4444 basePath := ""
4545 switch baseURI := v.BaseURI.Value.(type) {
4646 case string:
47− basePath = DocumentUri(baseURI).Path()
48− case DocumentUri:
47+ basePath = DocumentURI(baseURI).Path()
48+ case DocumentURI:
4949 basePath = baseURI.Path()
5050 default:
5151 return nil, fmt.Errorf("unknown BaseURI type: %T", v.BaseURI.Value)
internal/lsp/protocol/tsdocument-changes.go+5−5
@@ -23,18 +23,18 @@ type DocumentChange struct {
2323
2424// Valid reports whether the DocumentChange sum-type value is valid,
2525// that is, exactly one of create, delete, edit, or rename.
26−func (ch DocumentChange) Valid() bool {
26+func (d DocumentChange) Valid() bool {
2727 n := 0
28− if ch.TextDocumentEdit != nil {
28+ if d.TextDocumentEdit != nil {
2929 n++
3030 }
31− if ch.CreateFile != nil {
31+ if d.CreateFile != nil {
3232 n++
3333 }
34− if ch.RenameFile != nil {
34+ if d.RenameFile != nil {
3535 n++
3636 }
37− if ch.DeleteFile != nil {
37+ if d.DeleteFile != nil {
3838 n++
3939 }
4040 return n == 1
internal/lsp/protocol/tsprotocol.go+367−322
@@ -133,7 +133,7 @@ type CallHierarchyItem struct {
133133 // More detail for this item, e.g. the signature of a function.
134134 Detail string `json:"detail,omitempty"`
135135 // The resource identifier of this item.
136− URI DocumentUri `json:"uri"`
136+ URI DocumentURI `json:"uri"`
137137 // The range enclosing this symbol not including leading/trailing whitespace but everything else, e.g. comments and code.
138138 Range Range `json:"range"`
139139 // The range that should be selected and revealed when this symbol is being picked, e.g. the name of a function.
@@ -225,16 +225,18 @@ type ChangeAnnotation struct {
225225// An identifier to refer to a change annotation stored with a workspace edit.
226226//
227227// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#changeAnnotationIdentifier
228−type ChangeAnnotationIdentifier = string // (alias)
229−// @since 3.18.0
230−//
231−// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#changeAnnotationsSupportOptions
232−type ChangeAnnotationsSupportOptions struct {
233− // Whether the client groups edits with equal labels into tree nodes,
234− // for instance all edits labelled with "Changes in Strings" would
235− // be a tree node.
236− GroupsOnLabel bool `json:"groupsOnLabel,omitempty"`
237−}
228+type (
229+ ChangeAnnotationIdentifier = string // (alias)
230+ // @since 3.18.0
231+ //
232+ // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#changeAnnotationsSupportOptions
233+ ChangeAnnotationsSupportOptions struct {
234+ // Whether the client groups edits with equal labels into tree nodes,
235+ // for instance all edits labelled with "Changes in Strings" would
236+ // be a tree node.
237+ GroupsOnLabel bool `json:"groupsOnLabel,omitempty"`
238+ }
239+)
238240
239241// Defines the capabilities provided by the client.
240242//
@@ -1249,7 +1251,7 @@ type CreateFile struct {
12491251 // A create
12501252 Kind string `json:"kind"`
12511253 // The resource to create.
1252− URI DocumentUri `json:"uri"`
1254+ URI DocumentURI `json:"uri"`
12531255 // Additional options
12541256 Options *CreateFileOptions `json:"options,omitempty"`
12551257 ResourceOperation
@@ -1279,18 +1281,20 @@ type CreateFilesParams struct {
12791281// The declaration of a symbol representation as one or many {@link Location locations}.
12801282//
12811283// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#declaration
1282−type Declaration = Or_Declaration // (alias)
1283−// @since 3.14.0
1284−//
1285−// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#declarationClientCapabilities
1286−type DeclarationClientCapabilities struct {
1287− // Whether declaration supports dynamic registration. If this is set to `true`
1288− // the client supports the new `DeclarationRegistrationOptions` return value
1289− // for the corresponding server capability as well.
1290− DynamicRegistration bool `json:"dynamicRegistration,omitempty"`
1291− // The client supports additional metadata in the form of declaration links.
1292− LinkSupport bool `json:"linkSupport,omitempty"`
1293−}
1284+type (
1285+ Declaration = Or_Declaration // (alias)
1286+ // @since 3.14.0
1287+ //
1288+ // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#declarationClientCapabilities
1289+ DeclarationClientCapabilities struct {
1290+ // Whether declaration supports dynamic registration. If this is set to `true`
1291+ // the client supports the new `DeclarationRegistrationOptions` return value
1292+ // for the corresponding server capability as well.
1293+ DynamicRegistration bool `json:"dynamicRegistration,omitempty"`
1294+ // The client supports additional metadata in the form of declaration links.
1295+ LinkSupport bool `json:"linkSupport,omitempty"`
1296+ }
1297+)
12941298
12951299// Information about where a symbol is declared.
12961300//
@@ -1301,11 +1305,13 @@ type DeclarationClientCapabilities struct {
13011305// by the client.
13021306//
13031307// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#declarationLink
1304−type DeclarationLink = LocationLink // (alias)
1305−// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#declarationOptions
1306−type DeclarationOptions struct {
1307− WorkDoneProgressOptions
1308−}
1308+type (
1309+ DeclarationLink = LocationLink // (alias)
1310+ // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#declarationOptions
1311+ DeclarationOptions struct {
1312+ WorkDoneProgressOptions
1313+ }
1314+)
13091315
13101316// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#declarationParams
13111317type DeclarationParams struct {
@@ -1329,18 +1335,20 @@ type DeclarationRegistrationOptions struct {
13291335// by the client.
13301336//
13311337// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#definition
1332−type Definition = Or_Definition // (alias)
1333−// Client Capabilities for a {@link DefinitionRequest}.
1334−//
1335−// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#definitionClientCapabilities
1336−type DefinitionClientCapabilities struct {
1337− // Whether definition supports dynamic registration.
1338− DynamicRegistration bool `json:"dynamicRegistration,omitempty"`
1339− // The client supports additional metadata in the form of definition links.
1340− //
1341− // @since 3.14.0
1342− LinkSupport bool `json:"linkSupport,omitempty"`
1343−}
1338+type (
1339+ Definition = Or_Definition // (alias)
1340+ // Client Capabilities for a {@link DefinitionRequest}.
1341+ //
1342+ // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#definitionClientCapabilities
1343+ DefinitionClientCapabilities struct {
1344+ // Whether definition supports dynamic registration.
1345+ DynamicRegistration bool `json:"dynamicRegistration,omitempty"`
1346+ // The client supports additional metadata in the form of definition links.
1347+ //
1348+ // @since 3.14.0
1349+ LinkSupport bool `json:"linkSupport,omitempty"`
1350+ }
1351+)
13441352
13451353// Information about where a symbol is defined.
13461354//
@@ -1348,13 +1356,15 @@ type DefinitionClientCapabilities struct {
13481356// the defining symbol
13491357//
13501358// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#definitionLink
1351−type DefinitionLink = LocationLink // (alias)
1352−// Server Capabilities for a {@link DefinitionRequest}.
1353−//
1354−// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#definitionOptions
1355−type DefinitionOptions struct {
1356− WorkDoneProgressOptions
1357−}
1359+type (
1360+ DefinitionLink = LocationLink // (alias)
1361+ // Server Capabilities for a {@link DefinitionRequest}.
1362+ //
1363+ // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#definitionOptions
1364+ DefinitionOptions struct {
1365+ WorkDoneProgressOptions
1366+ }
1367+)
13581368
13591369// Parameters for a {@link DefinitionRequest}.
13601370//
@@ -1380,7 +1390,7 @@ type DeleteFile struct {
13801390 // A delete
13811391 Kind string `json:"kind"`
13821392 // The file to delete.
1383− URI DocumentUri `json:"uri"`
1393+ URI DocumentURI `json:"uri"`
13841394 // Delete options.
13851395 Options *DeleteFileOptions `json:"options,omitempty"`
13861396 ResourceOperation
@@ -1783,11 +1793,13 @@ type DocumentDiagnosticParams struct {
17831793// @since 3.17.0
17841794//
17851795// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#documentDiagnosticReport
1786−type DocumentDiagnosticReport = Or_DocumentDiagnosticReport // (alias)
1787−// The document diagnostic report kinds.
1788−//
1789−// @since 3.17.0
1790−type DocumentDiagnosticReportKind string
1796+type (
1797+ DocumentDiagnosticReport = Or_DocumentDiagnosticReport // (alias)
1798+ // The document diagnostic report kinds.
1799+ //
1800+ // @since 3.17.0
1801+ DocumentDiagnosticReportKind string
1802+)
17911803
17921804// A partial result for a document diagnostic report.
17931805//
@@ -1795,7 +1807,7 @@ type DocumentDiagnosticReportKind string
17951807//
17961808// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#documentDiagnosticReportPartialResult
17971809type DocumentDiagnosticReportPartialResult struct {
1798− RelatedDocuments map[DocumentUri]interface{} `json:"relatedDocuments"`
1810+ RelatedDocuments map[DocumentURI]interface{} `json:"relatedDocuments"`
17991811}
18001812
18011813// A document filter describes a top level text document or
@@ -1804,14 +1816,16 @@ type DocumentDiagnosticReportPartialResult struct {
18041816// @since 3.17.0 - proposed support for NotebookCellTextDocumentFilter.
18051817//
18061818// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#documentFilter
1807−type DocumentFilter = Or_DocumentFilter // (alias)
1808−// Client capabilities of a {@link DocumentFormattingRequest}.
1809−//
1810−// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#documentFormattingClientCapabilities
1811−type DocumentFormattingClientCapabilities struct {
1812− // Whether formatting supports dynamic registration.
1813− DynamicRegistration bool `json:"dynamicRegistration,omitempty"`
1814−}
1819+type (
1820+ DocumentFilter = Or_DocumentFilter // (alias)
1821+ // Client capabilities of a {@link DocumentFormattingRequest}.
1822+ //
1823+ // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#documentFormattingClientCapabilities
1824+ DocumentFormattingClientCapabilities struct {
1825+ // Whether formatting supports dynamic registration.
1826+ DynamicRegistration bool `json:"dynamicRegistration,omitempty"`
1827+ }
1828+)
18151829
18161830// Provider options for a {@link DocumentFormattingRequest}.
18171831//
@@ -2061,39 +2075,41 @@ type DocumentRangesFormattingParams struct {
20612075// The use of a string as a document filter is deprecated @since 3.16.0.
20622076//
20632077// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#documentSelector
2064−type DocumentSelector = []DocumentFilter // (alias)
2065−// Represents programming constructs like variables, classes, interfaces etc.
2066−// that appear in a document. Document symbols can be hierarchical and they
2067−// have two ranges: one that encloses its definition and one that points to
2068−// its most interesting range, e.g. the range of an identifier.
2069−//
2070−// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#documentSymbol
2071−type DocumentSymbol struct {
2072− // The name of this symbol. Will be displayed in the user interface and therefore must not be
2073− // an empty string or a string only consisting of white spaces.
2074− Name string `json:"name"`
2075− // More detail for this symbol, e.g the signature of a function.
2076− Detail string `json:"detail,omitempty"`
2077− // The kind of this symbol.
2078− Kind SymbolKind `json:"kind"`
2079− // Tags for this document symbol.
2080− //
2081− // @since 3.16.0
2082− Tags []SymbolTag `json:"tags,omitempty"`
2083− // Indicates if this symbol is deprecated.
2084− //
2085− // @deprecated Use tags instead
2086− Deprecated bool `json:"deprecated,omitempty"`
2087− // The range enclosing this symbol not including leading/trailing whitespace but everything else
2088− // like comments. This information is typically used to determine if the clients cursor is
2089− // inside the symbol to reveal in the symbol in the UI.
2090− Range Range `json:"range"`
2091− // The range that should be selected and revealed when this symbol is being picked, e.g the name of a function.
2092− // Must be contained by the `range`.
2093− SelectionRange Range `json:"selectionRange"`
2094− // Children of this symbol, e.g. properties of a class.
2095− Children []DocumentSymbol `json:"children,omitempty"`
2096−}
2078+type (
2079+ DocumentSelector = []DocumentFilter // (alias)
2080+ // Represents programming constructs like variables, classes, interfaces etc.
2081+ // that appear in a document. Document symbols can be hierarchical and they
2082+ // have two ranges: one that encloses its definition and one that points to
2083+ // its most interesting range, e.g. the range of an identifier.
2084+ //
2085+ // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#documentSymbol
2086+ DocumentSymbol struct {
2087+ // The name of this symbol. Will be displayed in the user interface and therefore must not be
2088+ // an empty string or a string only consisting of white spaces.
2089+ Name string `json:"name"`
2090+ // More detail for this symbol, e.g the signature of a function.
2091+ Detail string `json:"detail,omitempty"`
2092+ // The kind of this symbol.
2093+ Kind SymbolKind `json:"kind"`
2094+ // Tags for this document symbol.
2095+ //
2096+ // @since 3.16.0
2097+ Tags []SymbolTag `json:"tags,omitempty"`
2098+ // Indicates if this symbol is deprecated.
2099+ //
2100+ // @deprecated Use tags instead
2101+ Deprecated bool `json:"deprecated,omitempty"`
2102+ // The range enclosing this symbol not including leading/trailing whitespace but everything else
2103+ // like comments. This information is typically used to determine if the clients cursor is
2104+ // inside the symbol to reveal in the symbol in the UI.
2105+ Range Range `json:"range"`
2106+ // The range that should be selected and revealed when this symbol is being picked, e.g the name of a function.
2107+ // Must be contained by the `range`.
2108+ SelectionRange Range `json:"selectionRange"`
2109+ // Children of this symbol, e.g. properties of a class.
2110+ Children []DocumentSymbol `json:"children,omitempty"`
2111+ }
2112+)
20972113
20982114// Client Capabilities for a {@link DocumentSymbolRequest}.
20992115//
@@ -2237,7 +2253,7 @@ type FileDelete struct {
22372253// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#fileEvent
22382254type FileEvent struct {
22392255 // The file's uri.
2240− URI DocumentUri `json:"uri"`
2256+ URI DocumentURI `json:"uri"`
22412257 // The change type.
22422258 Type FileChangeType `json:"type"`
22432259}
@@ -2556,17 +2572,19 @@ type GeneralClientCapabilities struct {
25562572// @since 3.17.0
25572573//
25582574// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#globPattern
2559−type GlobPattern = Or_GlobPattern // (alias)
2560−// The result of a hover request.
2561−//
2562−// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#hover
2563−type Hover struct {
2564− // The hover's content
2565− Contents MarkupContent `json:"contents"`
2566− // An optional range inside the text document that is used to
2567− // visualize the hover, e.g. by changing the background color.
2568− Range Range `json:"range,omitempty"`
2569−}
2575+type (
2576+ GlobPattern = Or_GlobPattern // (alias)
2577+ // The result of a hover request.
2578+ //
2579+ // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#hover
2580+ Hover struct {
2581+ // The hover's content
2582+ Contents MarkupContent `json:"contents"`
2583+ // An optional range inside the text document that is used to
2584+ // visualize the hover, e.g. by changing the background color.
2585+ Range Range `json:"range,omitempty"`
2586+ }
2587+)
25702588
25712589// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#hoverClientCapabilities
25722590type HoverClientCapabilities struct {
@@ -2664,8 +2682,7 @@ type InitializeResult struct {
26642682}
26652683
26662684// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#initializedParams
2667−type InitializedParams struct {
2668−}
2685+type InitializedParams struct{}
26692686
26702687// Inlay hint information.
26712688//
@@ -2918,16 +2935,18 @@ type InlineCompletionTriggerKind uint32
29182935// @since 3.17.0
29192936//
29202937// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#inlineValue
2921−type InlineValue = Or_InlineValue // (alias)
2922−// Client capabilities specific to inline values.
2923−//
2924−// @since 3.17.0
2925−//
2926−// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#inlineValueClientCapabilities
2927−type InlineValueClientCapabilities struct {
2928− // Whether implementation supports dynamic registration for inline value providers.
2929− DynamicRegistration bool `json:"dynamicRegistration,omitempty"`
2930−}
2938+type (
2939+ InlineValue = Or_InlineValue // (alias)
2940+ // Client capabilities specific to inline values.
2941+ //
2942+ // @since 3.17.0
2943+ //
2944+ // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#inlineValueClientCapabilities
2945+ InlineValueClientCapabilities struct {
2946+ // Whether implementation supports dynamic registration for inline value providers.
2947+ DynamicRegistration bool `json:"dynamicRegistration,omitempty"`
2948+ }
2949+)
29312950
29322951// @since 3.17.0
29332952//
@@ -3058,25 +3077,31 @@ type InsertTextFormat uint32
30583077// item insertion.
30593078//
30603079// @since 3.16.0
3061−type InsertTextMode uint32
3062−type LSPAny = interface{}
3080+type (
3081+ InsertTextMode uint32
3082+ LSPAny = interface{}
3083+)
30633084
30643085// LSP arrays.
30653086// @since 3.17.0
30663087//
30673088// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#lSPArray
3068−type LSPArray = []interface{} // (alias)
3069−type LSPErrorCodes int32
3089+type (
3090+ LSPArray = []interface{} // (alias)
3091+ LSPErrorCodes int32
3092+)
30703093
30713094// LSP object definition.
30723095// @since 3.17.0
30733096//
30743097// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#lSPObject
3075−type LSPObject = map[string]LSPAny // (alias)
3076−// Predefined Language kinds
3077−// @since 3.18.0
3078−// @proposed
3079−type LanguageKind string
3098+type (
3099+ LSPObject = map[string]LSPAny // (alias)
3100+ // Predefined Language kinds
3101+ // @since 3.18.0
3102+ // @proposed
3103+ LanguageKind string
3104+)
30803105
30813106// Client capabilities for the linked editing range request.
30823107//
@@ -3124,19 +3149,17 @@ type LinkedEditingRanges struct {
31243149}
31253150
31263151// created for Literal (Lit_ClientSemanticTokensRequestOptions_range_Item1)
3127−type Lit_ClientSemanticTokensRequestOptions_range_Item1 struct {
3128−}
3152+type Lit_ClientSemanticTokensRequestOptions_range_Item1 struct{}
31293153
31303154// created for Literal (Lit_SemanticTokensOptions_range_Item1)
3131−type Lit_SemanticTokensOptions_range_Item1 struct {
3132−}
3155+type Lit_SemanticTokensOptions_range_Item1 struct{}
31333156
31343157// Represents a location inside a resource, such as a line
31353158// inside a text file.
31363159//
31373160// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#location
31383161type Location struct {
3139− URI DocumentUri `json:"uri"`
3162+ URI DocumentURI `json:"uri"`
31403163 Range Range `json:"range"`
31413164}
31423165
@@ -3151,7 +3174,7 @@ type LocationLink struct {
31513174 // the definition position.
31523175 OriginSelectionRange *Range `json:"originSelectionRange,omitempty"`
31533176 // The target resource identifier of this link.
3154− TargetURI DocumentUri `json:"targetUri"`
3177+ TargetURI DocumentURI `json:"targetUri"`
31553178 // The full target range of this link. If the target for example is a symbol then target range is the
31563179 // range enclosing this symbol not including leading/trailing whitespace but everything else
31573180 // like comments. This information is typically used to highlight the range in the editor.
@@ -3167,7 +3190,7 @@ type LocationLink struct {
31673190//
31683191// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#locationUriOnly
31693192type LocationUriOnly struct {
3170− URI DocumentUri `json:"uri"`
3193+ URI DocumentURI `json:"uri"`
31713194}
31723195
31733196// The log message parameters.
@@ -3217,15 +3240,17 @@ type MarkdownClientCapabilities struct {
32173240// @deprecated use MarkupContent instead.
32183241//
32193242// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#markedString
3220−type MarkedString = Or_MarkedString // (alias)
3221−// @since 3.18.0
3222−// @deprecated use MarkupContent instead.
3223−//
3224−// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#markedStringWithLanguage
3225−type MarkedStringWithLanguage struct {
3226− Language string `json:"language"`
3227− Value string `json:"value"`
3228−}
3243+type (
3244+ MarkedString = Or_MarkedString // (alias)
3245+ // @since 3.18.0
3246+ // @deprecated use MarkupContent instead.
3247+ //
3248+ // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#markedStringWithLanguage
3249+ MarkedStringWithLanguage struct {
3250+ Language string `json:"language"`
3251+ Value string `json:"value"`
3252+ }
3253+)
32293254
32303255// A `MarkupContent` literal represents a string value which content is interpreted base on its
32313256// kind flag. Currently the protocol supports `plaintext` and `markdown` as markup kinds.
@@ -3342,7 +3367,7 @@ type NotebookCell struct {
33423367 Kind NotebookCellKind `json:"kind"`
33433368 // The URI of the cell's text document
33443369 // content.
3345− Document DocumentUri `json:"document"`
3370+ Document DocumentURI `json:"document"`
33463371 // Additional metadata stored with the cell.
33473372 //
33483373 // Note: should always be an object literal (e.g. LSPObject)
@@ -3493,20 +3518,22 @@ type NotebookDocumentClientCapabilities struct {
34933518// @since 3.17.0
34943519//
34953520// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#notebookDocumentFilter
3496−type NotebookDocumentFilter = Or_NotebookDocumentFilter // (alias)
3497−// A notebook document filter where `notebookType` is required field.
3498−//
3499−// @since 3.18.0
3500−//
3501−// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#notebookDocumentFilterNotebookType
3502−type NotebookDocumentFilterNotebookType struct {
3503− // The type of the enclosing notebook.
3504− NotebookType string `json:"notebookType"`
3505− // A Uri {@link Uri.scheme scheme}, like `file` or `untitled`.
3506− Scheme string `json:"scheme,omitempty"`
3507− // A glob pattern.
3508− Pattern *GlobPattern `json:"pattern,omitempty"`
3509−}
3521+type (
3522+ NotebookDocumentFilter = Or_NotebookDocumentFilter // (alias)
3523+ // A notebook document filter where `notebookType` is required field.
3524+ //
3525+ // @since 3.18.0
3526+ //
3527+ // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#notebookDocumentFilterNotebookType
3528+ NotebookDocumentFilterNotebookType struct {
3529+ // The type of the enclosing notebook.
3530+ NotebookType string `json:"notebookType"`
3531+ // A Uri {@link Uri.scheme scheme}, like `file` or `untitled`.
3532+ Scheme string `json:"scheme,omitempty"`
3533+ // A glob pattern.
3534+ Pattern *GlobPattern `json:"pattern,omitempty"`
3535+ }
3536+)
35103537
35113538// A notebook document filter where `pattern` is required field.
35123539//
@@ -4101,51 +4128,53 @@ type PartialResultParams struct {
41014128// @since 3.17.0
41024129//
41034130// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#pattern
4104−type Pattern = string // (alias)
4105−// Position in a text document expressed as zero-based line and character
4106−// offset. Prior to 3.17 the offsets were always based on a UTF-16 string
4107−// representation. So a string of the form `a𐐀b` the character offset of the
4108−// character `a` is 0, the character offset of `𐐀` is 1 and the character
4109−// offset of b is 3 since `𐐀` is represented using two code units in UTF-16.
4110−// Since 3.17 clients and servers can agree on a different string encoding
4111−// representation (e.g. UTF-8). The client announces it's supported encoding
4112−// via the client capability [`general.positionEncodings`](https://microsoft.github.io/language-server-protocol/specifications/specification-current/#clientCapabilities).
4113−// The value is an array of position encodings the client supports, with
4114−// decreasing preference (e.g. the encoding at index `0` is the most preferred
4115−// one). To stay backwards compatible the only mandatory encoding is UTF-16
4116−// represented via the string `utf-16`. The server can pick one of the
4117−// encodings offered by the client and signals that encoding back to the
4118−// client via the initialize result's property
4119−// [`capabilities.positionEncoding`](https://microsoft.github.io/language-server-protocol/specifications/specification-current/#serverCapabilities). If the string value
4120−// `utf-16` is missing from the client's capability `general.positionEncodings`
4121−// servers can safely assume that the client supports UTF-16. If the server
4122−// omits the position encoding in its initialize result the encoding defaults
4123−// to the string value `utf-16`. Implementation considerations: since the
4124−// conversion from one encoding into another requires the content of the
4125−// file / line the conversion is best done where the file is read which is
4126−// usually on the server side.
4127−//
4128−// Positions are line end character agnostic. So you can not specify a position
4129−// that denotes `\r|\n` or `\n|` where `|` represents the character offset.
4130−//
4131−// @since 3.17.0 - support for negotiated position encoding.
4132−//
4133−// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#position
4134−type Position struct {
4135− // Line position in a document (zero-based).
4136− //
4137− // If a line number is greater than the number of lines in a document, it defaults back to the number of lines in the document.
4138− // If a line number is negative, it defaults to 0.
4139− Line uint32 `json:"line"`
4140− // Character offset on a line in a document (zero-based).
4141− //
4142− // The meaning of this offset is determined by the negotiated
4143− // `PositionEncodingKind`.
4144− //
4145− // If the character value is greater than the line length it defaults back to the
4146− // line length.
4147− Character uint32 `json:"character"`
4148−}
4131+type (
4132+ Pattern = string // (alias)
4133+ // Position in a text document expressed as zero-based line and character
4134+ // offset. Prior to 3.17 the offsets were always based on a UTF-16 string
4135+ // representation. So a string of the form `a𐐀b` the character offset of the
4136+ // character `a` is 0, the character offset of `𐐀` is 1 and the character
4137+ // offset of b is 3 since `𐐀` is represented using two code units in UTF-16.
4138+ // Since 3.17 clients and servers can agree on a different string encoding
4139+ // representation (e.g. UTF-8). The client announces it's supported encoding
4140+ // via the client capability [`general.positionEncodings`](https://microsoft.github.io/language-server-protocol/specifications/specification-current/#clientCapabilities).
4141+ // The value is an array of position encodings the client supports, with
4142+ // decreasing preference (e.g. the encoding at index `0` is the most preferred
4143+ // one). To stay backwards compatible the only mandatory encoding is UTF-16
4144+ // represented via the string `utf-16`. The server can pick one of the
4145+ // encodings offered by the client and signals that encoding back to the
4146+ // client via the initialize result's property
4147+ // [`capabilities.positionEncoding`](https://microsoft.github.io/language-server-protocol/specifications/specification-current/#serverCapabilities). If the string value
4148+ // `utf-16` is missing from the client's capability `general.positionEncodings`
4149+ // servers can safely assume that the client supports UTF-16. If the server
4150+ // omits the position encoding in its initialize result the encoding defaults
4151+ // to the string value `utf-16`. Implementation considerations: since the
4152+ // conversion from one encoding into another requires the content of the
4153+ // file / line the conversion is best done where the file is read which is
4154+ // usually on the server side.
4155+ //
4156+ // Positions are line end character agnostic. So you can not specify a position
4157+ // that denotes `\r|\n` or `\n|` where `|` represents the character offset.
4158+ //
4159+ // @since 3.17.0 - support for negotiated position encoding.
4160+ //
4161+ // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#position
4162+ Position struct {
4163+ // Line position in a document (zero-based).
4164+ //
4165+ // If a line number is greater than the number of lines in a document, it defaults back to the number of lines in the document.
4166+ // If a line number is negative, it defaults to 0.
4167+ Line uint32 `json:"line"`
4168+ // Character offset on a line in a document (zero-based).
4169+ //
4170+ // The meaning of this offset is determined by the negotiated
4171+ // `PositionEncodingKind`.
4172+ //
4173+ // If the character value is greater than the line length it defaults back to the
4174+ // line length.
4175+ Character uint32 `json:"character"`
4176+ }
4177+)
41494178
41504179// A set of predefined position encoding kinds.
41514180//
@@ -4174,8 +4203,10 @@ type PrepareRenamePlaceholder struct {
41744203}
41754204
41764205// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#prepareRenameResult
4177−type PrepareRenameResult = Or_PrepareRenameResult // (alias)
4178−type PrepareSupportDefaultBehavior uint32
4206+type (
4207+ PrepareRenameResult = Or_PrepareRenameResult // (alias)
4208+ PrepareSupportDefaultBehavior uint32
4209+)
41794210
41804211// A previous result id in a workspace pull request.
41814212//
@@ -4185,7 +4216,7 @@ type PrepareSupportDefaultBehavior uint32
41854216type PreviousResultID struct {
41864217 // The URI for which the client knowns a
41874218 // result id.
4188− URI DocumentUri `json:"uri"`
4219+ URI DocumentURI `json:"uri"`
41894220 // The value of the previous result id.
41904221 Value string `json:"value"`
41914222}
@@ -4198,7 +4229,7 @@ type PreviousResultID struct {
41984229type PreviousResultId struct {
41994230 // The URI for which the client knowns a
42004231 // result id.
4201− URI DocumentUri `json:"uri"`
4232+ URI DocumentURI `json:"uri"`
42024233 // The value of the previous result id.
42034234 Value string `json:"value"`
42044235}
@@ -4212,25 +4243,27 @@ type ProgressParams struct {
42124243}
42134244
42144245// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#progressToken
4215−type ProgressToken = Or_ProgressToken // (alias)
4216−// The publish diagnostic client capabilities.
4217−//
4218−// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#publishDiagnosticsClientCapabilities
4219−type PublishDiagnosticsClientCapabilities struct {
4220− // Whether the client interprets the version property of the
4221− // `textDocument/publishDiagnostics` notification's parameter.
4222− //
4223− // @since 3.15.0
4224− VersionSupport bool `json:"versionSupport,omitempty"`
4225− DiagnosticsCapabilities
4226−}
4246+type (
4247+ ProgressToken = Or_ProgressToken // (alias)
4248+ // The publish diagnostic client capabilities.
4249+ //
4250+ // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#publishDiagnosticsClientCapabilities
4251+ PublishDiagnosticsClientCapabilities struct {
4252+ // Whether the client interprets the version property of the
4253+ // `textDocument/publishDiagnostics` notification's parameter.
4254+ //
4255+ // @since 3.15.0
4256+ VersionSupport bool `json:"versionSupport,omitempty"`
4257+ DiagnosticsCapabilities
4258+ }
4259+)
42274260
42284261// The publish diagnostic notification's parameters.
42294262//
42304263// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#publishDiagnosticsParams
42314264type PublishDiagnosticsParams struct {
42324265 // The URI for which diagnostic information is reported.
4233− URI DocumentUri `json:"uri"`
4266+ URI DocumentURI `json:"uri"`
42344267 // Optional the version number of the document the diagnostics are published for.
42354268 //
42364269 // @since 3.15.0
@@ -4322,18 +4355,20 @@ type RegistrationParams struct {
43224355}
43234356
43244357// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#regularExpressionEngineKind
4325−type RegularExpressionEngineKind = string // (alias)
4326−// Client capabilities specific to regular expressions.
4327−//
4328−// @since 3.16.0
4329−//
4330−// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#regularExpressionsClientCapabilities
4331−type RegularExpressionsClientCapabilities struct {
4332− // The engine's name.
4333− Engine RegularExpressionEngineKind `json:"engine"`
4334− // The engine's version.
4335− Version string `json:"version,omitempty"`
4336−}
4358+type (
4359+ RegularExpressionEngineKind = string // (alias)
4360+ // Client capabilities specific to regular expressions.
4361+ //
4362+ // @since 3.16.0
4363+ //
4364+ // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#regularExpressionsClientCapabilities
4365+ RegularExpressionsClientCapabilities struct {
4366+ // The engine's name.
4367+ Engine RegularExpressionEngineKind `json:"engine"`
4368+ // The engine's version.
4369+ Version string `json:"version,omitempty"`
4370+ }
4371+)
43374372
43384373// A full diagnostic report with a set of related documents.
43394374//
@@ -4348,7 +4383,7 @@ type RelatedFullDocumentDiagnosticReport struct {
43484383 // a.cpp and result in errors in a header file b.hpp.
43494384 //
43504385 // @since 3.17.0
4351− RelatedDocuments map[DocumentUri]interface{} `json:"relatedDocuments,omitempty"`
4386+ RelatedDocuments map[DocumentURI]interface{} `json:"relatedDocuments,omitempty"`
43524387 FullDocumentDiagnosticReport
43534388}
43544389
@@ -4365,7 +4400,7 @@ type RelatedUnchangedDocumentDiagnosticReport struct {
43654400 // a.cpp and result in errors in a header file b.hpp.
43664401 //
43674402 // @since 3.17.0
4368− RelatedDocuments map[DocumentUri]interface{} `json:"relatedDocuments,omitempty"`
4403+ RelatedDocuments map[DocumentURI]interface{} `json:"relatedDocuments,omitempty"`
43694404 UnchangedDocumentDiagnosticReport
43704405}
43714406
@@ -4417,9 +4452,9 @@ type RenameFile struct {
44174452 // A rename
44184453 Kind string `json:"kind"`
44194454 // The old (existing) location.
4420− OldURI DocumentUri `json:"oldUri"`
4455+ OldURI DocumentURI `json:"oldUri"`
44214456 // The new location.
4422− NewURI DocumentUri `json:"newUri"`
4457+ NewURI DocumentURI `json:"newUri"`
44234458 // Rename options.
44244459 Options *RenameFileOptions `json:"options,omitempty"`
44254460 ResourceOperation
@@ -5337,20 +5372,22 @@ type TextDocumentClientCapabilities struct {
53375372// it is considered to be the full content of the document.
53385373//
53395374// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocumentContentChangeEvent
5340−type TextDocumentContentChangeEvent = Or_TextDocumentContentChangeEvent // (alias)
5341−// @since 3.18.0
5342−//
5343−// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocumentContentChangePartial
5344−type TextDocumentContentChangePartial struct {
5345− // The range of the document that changed.
5346− Range *Range `json:"range,omitempty"`
5347− // The optional length of the range that got replaced.
5375+type (
5376+ TextDocumentContentChangeEvent = Or_TextDocumentContentChangeEvent // (alias)
5377+ // @since 3.18.0
53485378 //
5349− // @deprecated use range instead.
5350− RangeLength uint32 `json:"rangeLength,omitempty"`
5351− // The new text for the provided range.
5352− Text string `json:"text"`
5353−}
5379+ // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocumentContentChangePartial
5380+ TextDocumentContentChangePartial struct {
5381+ // The range of the document that changed.
5382+ Range *Range `json:"range,omitempty"`
5383+ // The optional length of the range that got replaced.
5384+ //
5385+ // @deprecated use range instead.
5386+ RangeLength uint32 `json:"rangeLength,omitempty"`
5387+ // The new text for the provided range.
5388+ Text string `json:"text"`
5389+ }
5390+)
53545391
53555392// @since 3.18.0
53565393//
@@ -5390,7 +5427,7 @@ type TextDocumentContentOptions struct {
53905427// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocumentContentParams
53915428type TextDocumentContentParams struct {
53925429 // The uri of the text document.
5393− URI DocumentUri `json:"uri"`
5430+ URI DocumentURI `json:"uri"`
53945431}
53955432
53965433// Parameters for the `workspace/textDocumentContent/refresh` request.
@@ -5401,7 +5438,7 @@ type TextDocumentContentParams struct {
54015438// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocumentContentRefreshParams
54025439type TextDocumentContentRefreshParams struct {
54035440 // The uri of the text document to refresh.
5404− URI DocumentUri `json:"uri"`
5441+ URI DocumentURI `json:"uri"`
54055442}
54065443
54075444// Text document content provider registration options.
@@ -5453,22 +5490,24 @@ type TextDocumentEdit struct {
54535490// @since 3.17.0
54545491//
54555492// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocumentFilter
5456−type TextDocumentFilter = Or_TextDocumentFilter // (alias)
5457−// A document filter where `language` is required field.
5458−//
5459−// @since 3.18.0
5460−//
5461−// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocumentFilterLanguage
5462−type TextDocumentFilterLanguage struct {
5463− // A language id, like `typescript`.
5464− Language string `json:"language"`
5465− // A Uri {@link Uri.scheme scheme}, like `file` or `untitled`.
5466− Scheme string `json:"scheme,omitempty"`
5467− // A glob pattern, like **​/*.{ts,js}. See TextDocumentFilter for examples.
5493+type (
5494+ TextDocumentFilter = Or_TextDocumentFilter // (alias)
5495+ // A document filter where `language` is required field.
54685496 //
5469− // @since 3.18.0 - support for relative patterns.
5470− Pattern *GlobPattern `json:"pattern,omitempty"`
5471−}
5497+ // @since 3.18.0
5498+ //
5499+ // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocumentFilterLanguage
5500+ TextDocumentFilterLanguage struct {
5501+ // A language id, like `typescript`.
5502+ Language string `json:"language"`
5503+ // A Uri {@link Uri.scheme scheme}, like `file` or `untitled`.
5504+ Scheme string `json:"scheme,omitempty"`
5505+ // A glob pattern, like **​/*.{ts,js}. See TextDocumentFilter for examples.
5506+ //
5507+ // @since 3.18.0 - support for relative patterns.
5508+ Pattern *GlobPattern `json:"pattern,omitempty"`
5509+ }
5510+)
54725511
54735512// A document filter where `pattern` is required field.
54745513//
@@ -5507,7 +5546,7 @@ type TextDocumentFilterScheme struct {
55075546// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocumentIdentifier
55085547type TextDocumentIdentifier struct {
55095548 // The text document's uri.
5510− URI DocumentUri `json:"uri"`
5549+ URI DocumentURI `json:"uri"`
55115550}
55125551
55135552// An item to transfer a text document from the client to the
@@ -5516,7 +5555,7 @@ type TextDocumentIdentifier struct {
55165555// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocumentItem
55175556type TextDocumentItem struct {
55185557 // The text document's uri.
5519− URI DocumentUri `json:"uri"`
5558+ URI DocumentURI `json:"uri"`
55205559 // The text document's language identifier.
55215560 LanguageID LanguageKind `json:"languageId"`
55225561 // The version number of this document (it will increase after each
@@ -5605,8 +5644,10 @@ type TextEdit struct {
56055644 // empty string.
56065645 NewText string `json:"newText"`
56075646}
5608−type TokenFormat string
5609−type TraceValue string
5647+type (
5648+ TokenFormat string
5649+ TraceValue string
5650+)
56105651
56115652// created for Tuple
56125653type Tuple_ParameterInformation_label_Item1 struct {
@@ -5670,7 +5711,7 @@ type TypeHierarchyItem struct {
56705711 // More detail for this item, e.g. the signature of a function.
56715712 Detail string `json:"detail,omitempty"`
56725713 // The resource identifier of this item.
5673− URI DocumentUri `json:"uri"`
5714+ URI DocumentURI `json:"uri"`
56745715 // The range enclosing this symbol not including leading/trailing whitespace
56755716 // but everything else, e.g. comments and code.
56765717 Range Range `json:"range"`
@@ -5795,14 +5836,16 @@ type VersionedTextDocumentIdentifier struct {
57955836 Version int32 `json:"version"`
57965837 TextDocumentIdentifier
57975838}
5798−type WatchKind = uint32 // The parameters sent in a will save text document notification.
5799−// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#willSaveTextDocumentParams
5800−type WillSaveTextDocumentParams struct {
5801− // The document that will be saved.
5802− TextDocument TextDocumentIdentifier `json:"textDocument"`
5803− // The 'TextDocumentSaveReason'.
5804− Reason TextDocumentSaveReason `json:"reason"`
5805−}
5839+type (
5840+ WatchKind = uint32 // The parameters sent in a will save text document notification.
5841+ // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#willSaveTextDocumentParams
5842+ WillSaveTextDocumentParams struct {
5843+ // The document that will be saved.
5844+ TextDocument TextDocumentIdentifier `json:"textDocument"`
5845+ // The 'TextDocumentSaveReason'.
5846+ Reason TextDocumentSaveReason `json:"reason"`
5847+ }
5848+)
58065849
58075850// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#windowClientCapabilities
58085851type WindowClientCapabilities struct {
@@ -6012,43 +6055,45 @@ type WorkspaceDiagnosticReportPartialResult struct {
60126055// @since 3.17.0
60136056//
60146057// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspaceDocumentDiagnosticReport
6015−type WorkspaceDocumentDiagnosticReport = Or_WorkspaceDocumentDiagnosticReport // (alias)
6016−// A workspace edit represents changes to many resources managed in the workspace. The edit
6017−// should either provide `changes` or `documentChanges`. If documentChanges are present
6018−// they are preferred over `changes` if the client can handle versioned document edits.
6019−//
6020−// Since version 3.13.0 a workspace edit can contain resource operations as well. If resource
6021−// operations are present clients need to execute the operations in the order in which they
6022−// are provided. So a workspace edit for example can consist of the following two changes:
6023−// (1) a create file a.txt and (2) a text document edit which insert text into file a.txt.
6024−//
6025−// An invalid sequence (e.g. (1) delete file a.txt and (2) insert text into file a.txt) will
6026−// cause failure of the operation. How the client recovers from the failure is described by
6027−// the client capability: `workspace.workspaceEdit.failureHandling`
6028−//
6029−// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspaceEdit
6030−type WorkspaceEdit struct {
6031− // Holds changes to existing resources.
6032− Changes map[DocumentUri][]TextEdit `json:"changes,omitempty"`
6033− // Depending on the client capability `workspace.workspaceEdit.resourceOperations` document changes
6034− // are either an array of `TextDocumentEdit`s to express changes to n different text documents
6035− // where each text document edit addresses a specific version of a text document. Or it can contain
6036− // above `TextDocumentEdit`s mixed with create, rename and delete file / folder operations.
6037− //
6038− // Whether a client supports versioned document edits is expressed via
6039− // `workspace.workspaceEdit.documentChanges` client capability.
6040− //
6041− // If a client neither supports `documentChanges` nor `workspace.workspaceEdit.resourceOperations` then
6042− // only plain `TextEdit`s using the `changes` property are supported.
6043− DocumentChanges []DocumentChange `json:"documentChanges,omitempty"`
6044− // A map of change annotations that can be referenced in `AnnotatedTextEdit`s or create, rename and
6045− // delete file / folder operations.
6046− //
6047− // Whether clients honor this property depends on the client capability `workspace.changeAnnotationSupport`.
6048− //
6049− // @since 3.16.0
6050− ChangeAnnotations map[ChangeAnnotationIdentifier]ChangeAnnotation `json:"changeAnnotations,omitempty"`
6051−}
6058+type (
6059+ WorkspaceDocumentDiagnosticReport = Or_WorkspaceDocumentDiagnosticReport // (alias)
6060+ // A workspace edit represents changes to many resources managed in the workspace. The edit
6061+ // should either provide `changes` or `documentChanges`. If documentChanges are present
6062+ // they are preferred over `changes` if the client can handle versioned document edits.
6063+ //
6064+ // Since version 3.13.0 a workspace edit can contain resource operations as well. If resource
6065+ // operations are present clients need to execute the operations in the order in which they
6066+ // are provided. So a workspace edit for example can consist of the following two changes:
6067+ // (1) a create file a.txt and (2) a text document edit which insert text into file a.txt.
6068+ //
6069+ // An invalid sequence (e.g. (1) delete file a.txt and (2) insert text into file a.txt) will
6070+ // cause failure of the operation. How the client recovers from the failure is described by
6071+ // the client capability: `workspace.workspaceEdit.failureHandling`
6072+ //
6073+ // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspaceEdit
6074+ WorkspaceEdit struct {
6075+ // Holds changes to existing resources.
6076+ Changes map[DocumentURI][]TextEdit `json:"changes,omitempty"`
6077+ // Depending on the client capability `workspace.workspaceEdit.resourceOperations` document changes
6078+ // are either an array of `TextDocumentEdit`s to express changes to n different text documents
6079+ // where each text document edit addresses a specific version of a text document. Or it can contain
6080+ // above `TextDocumentEdit`s mixed with create, rename and delete file / folder operations.
6081+ //
6082+ // Whether a client supports versioned document edits is expressed via
6083+ // `workspace.workspaceEdit.documentChanges` client capability.
6084+ //
6085+ // If a client neither supports `documentChanges` nor `workspace.workspaceEdit.resourceOperations` then
6086+ // only plain `TextEdit`s using the `changes` property are supported.
6087+ DocumentChanges []DocumentChange `json:"documentChanges,omitempty"`
6088+ // A map of change annotations that can be referenced in `AnnotatedTextEdit`s or create, rename and
6089+ // delete file / folder operations.
6090+ //
6091+ // Whether clients honor this property depends on the client capability `workspace.changeAnnotationSupport`.
6092+ //
6093+ // @since 3.16.0
6094+ ChangeAnnotations map[ChangeAnnotationIdentifier]ChangeAnnotation `json:"changeAnnotations,omitempty"`
6095+ }
6096+)
60526097
60536098// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspaceEditClientCapabilities
60546099type WorkspaceEditClientCapabilities struct {
@@ -6154,7 +6199,7 @@ type WorkspaceFoldersServerCapabilities struct {
61546199// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspaceFullDocumentDiagnosticReport
61556200type WorkspaceFullDocumentDiagnosticReport struct {
61566201 // The URI for which diagnostic information is reported.
6157− URI DocumentUri `json:"uri"`
6202+ URI DocumentURI `json:"uri"`
61586203 // The version number for which the diagnostics are reported.
61596204 // If the document is not marked as open `null` can be provided.
61606205 Version int32 `json:"version"`
@@ -6266,7 +6311,7 @@ type WorkspaceSymbolRegistrationOptions struct {
62666311// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspaceUnchangedDocumentDiagnosticReport
62676312type WorkspaceUnchangedDocumentDiagnosticReport struct {
62686313 // The URI for which diagnostic information is reported.
6269− URI DocumentUri `json:"uri"`
6314+ URI DocumentURI `json:"uri"`
62706315 // The version number for which the diagnostics are reported.
62716316 // If the document is not marked as open `null` can be provided.
62726317 Version int32 `json:"version"`
@@ -6306,7 +6351,7 @@ type XInitializeParams struct {
63066351 // `rootUri` wins.
63076352 //
63086353 // @deprecated in favour of workspaceFolders.
6309− RootURI DocumentUri `json:"rootUri"`
6354+ RootURI DocumentURI `json:"rootUri"`
63106355 // The capabilities provided by the client (editor or tool)
63116356 Capabilities ClientCapabilities `json:"capabilities"`
63126357 // User provided initialization options.
@@ -6349,7 +6394,7 @@ type _InitializeParams struct {
63496394 // `rootUri` wins.
63506395 //
63516396 // @deprecated in favour of workspaceFolders.
6352− RootURI DocumentUri `json:"rootUri"`
6397+ RootURI DocumentURI `json:"rootUri"`
63536398 // The capabilities provided by the client (editor or tool)
63546399 Capabilities ClientCapabilities `json:"capabilities"`
63556400 // User provided initialization options.
internal/lsp/protocol/uri.go+15−15
@@ -17,7 +17,7 @@ import (
1717 "unicode"
1818)
1919
20−// A DocumentUri is the URI of a client editor document.
20+// A DocumentURI is the URI of a client editor document.
2121//
2222// According to the LSP specification:
2323//
@@ -38,8 +38,8 @@ import (
3838// file:///C%3A/project/readme.md
3939//
4040// This is done during JSON unmarshalling;
41−// see [DocumentUri.UnmarshalText] for details.
42−type DocumentUri string
41+// see [DocumentURI.UnmarshalText] for details.
42+type DocumentURI string
4343
4444// A URI is an arbitrary URL (e.g. https), not necessarily a file.
4545type URI = string
@@ -60,8 +60,8 @@ type URI = string
6060//
6161// Non-empty DocumentUris are valid "file"-scheme URIs.
6262// The empty DocumentUri is valid.
63−func (uri *DocumentUri) UnmarshalText(data []byte) (err error) {
64− *uri, err = ParseDocumentUri(string(data))
63+func (uri *DocumentURI) UnmarshalText(data []byte) (err error) {
64+ *uri, err = ParseDocumentURI(string(data))
6565 return
6666}
6767
@@ -70,7 +70,7 @@ func (uri *DocumentUri) UnmarshalText(data []byte) (err error) {
7070// DocumentUri("").Path() returns the empty string.
7171//
7272// Path panics if called on a URI that is not a valid filename.
73−func (uri DocumentUri) Path() string {
73+func (uri DocumentURI) Path() string {
7474 filename, err := filename(uri)
7575 if err != nil {
7676 // e.g. ParseRequestURI failed.
@@ -85,7 +85,7 @@ func (uri DocumentUri) Path() string {
8585}
8686
8787// Dir returns the URI for the directory containing the receiver.
88−func (uri DocumentUri) Dir() DocumentUri {
88+func (uri DocumentURI) Dir() DocumentURI {
8989 // This function could be more efficiently implemented by avoiding any call
9090 // to Path(), but at least consolidates URI manipulation.
9191 return URIFromPath(uri.DirPath())
@@ -93,11 +93,11 @@ func (uri DocumentUri) Dir() DocumentUri {
9393
9494// DirPath returns the file path to the directory containing this URI, which
9595// must be a file URI.
96−func (uri DocumentUri) DirPath() string {
96+func (uri DocumentURI) DirPath() string {
9797 return filepath.Dir(uri.Path())
9898}
9999
100−func filename(uri DocumentUri) (string, error) {
100+func filename(uri DocumentURI) (string, error) {
101101 if uri == "" {
102102 return "", nil
103103 }
@@ -137,9 +137,9 @@ slow:
137137 return u.Path, nil
138138}
139139
140−// ParseDocumentUri interprets a string as a DocumentUri, applying VS
141−// Code workarounds; see [DocumentUri.UnmarshalText] for details.
142−func ParseDocumentUri(s string) (DocumentUri, error) {
140+// ParseDocumentURI interprets a string as a DocumentUri, applying VS
141+// Code workarounds; see [DocumentURI.UnmarshalText] for details.
142+func ParseDocumentURI(s string) (DocumentURI, error) {
143143 if s == "" {
144144 return "", nil
145145 }
@@ -169,12 +169,12 @@ func ParseDocumentUri(s string) (DocumentUri, error) {
169169 path = path[:1] + strings.ToUpper(string(path[1])) + path[2:]
170170 }
171171 u := url.URL{Scheme: fileScheme, Path: path}
172− return DocumentUri(u.String()), nil
172+ return DocumentURI(u.String()), nil
173173}
174174
175175// URIFromPath returns DocumentUri for the supplied file path.
176176// Given "", it returns "".
177−func URIFromPath(path string) DocumentUri {
177+func URIFromPath(path string) DocumentURI {
178178 if path == "" {
179179 return ""
180180 }
@@ -192,7 +192,7 @@ func URIFromPath(path string) DocumentUri {
192192 Scheme: fileScheme,
193193 Path: path,
194194 }
195− return DocumentUri(u.String())
195+ return DocumentURI(u.String())
196196}
197197
198198const fileScheme = "file"
internal/lsp/transport.go+1−1
@@ -12,7 +12,7 @@ import (
1212 "github.com/charmbracelet/crush/internal/config"
1313)
1414
15−// Write writes an LSP message to the given writer
15+// WriteMessage writes an LSP message to the given writer
1616func WriteMessage(w io.Writer, msg *Message) error {
1717 data, err := json.Marshal(msg)
1818 if err != nil {
internal/lsp/util/edit.go+1−1
@@ -10,7 +10,7 @@ import (
1010 "github.com/charmbracelet/crush/internal/lsp/protocol"
1111)
1212
13−func applyTextEdits(uri protocol.DocumentUri, edits []protocol.TextEdit) error {
13+func applyTextEdits(uri protocol.DocumentURI, edits []protocol.TextEdit) error {
1414 path := uri.Path()
1515
1616 // Read the file content
internal/lsp/watcher/watcher.go+7−7
@@ -77,7 +77,7 @@ func (w *WorkspaceWatcher) AddRegistrations(ctx context.Context, id string, watc
7777 switch u := v.BaseURI.Value.(type) {
7878 case string:
7979 slog.Debug("BaseURI", "baseURI", u)
80− case protocol.DocumentUri:
80+ case protocol.DocumentURI:
8181 slog.Debug("BaseURI", "baseURI", u)
8282 default:
8383 slog.Debug("BaseURI", "baseURI", u)
@@ -514,8 +514,8 @@ func matchesGlob(pattern, path string) bool {
514514// matchesSimpleGlob handles glob patterns with ** wildcards
515515func matchesSimpleGlob(pattern, path string) bool {
516516 // Handle special case for **/*.ext pattern (common in LSP)
517− if strings.HasPrefix(pattern, "**/") {
518− rest := strings.TrimPrefix(pattern, "**/")
517+ if after, ok := strings.CutPrefix(pattern, "**/"); ok {
518+ rest := after
519519
520520 // If the rest is a simple file extension pattern like *.go
521521 if strings.HasPrefix(rest, "*.") {
@@ -607,7 +607,7 @@ func (w *WorkspaceWatcher) matchesPattern(path string, pattern protocol.GlobPatt
607607 }
608608
609609 // For relative patterns
610− basePath = protocol.DocumentUri(basePath).Path()
610+ basePath = protocol.DocumentURI(basePath).Path()
611611 basePath = filepath.ToSlash(basePath)
612612
613613 // Make path relative to basePath for matching
@@ -650,9 +650,9 @@ func (w *WorkspaceWatcher) debounceHandleFileEvent(ctx context.Context, uri stri
650650// handleFileEvent sends file change notifications
651651func (w *WorkspaceWatcher) handleFileEvent(ctx context.Context, uri string, changeType protocol.FileChangeType) {
652652 // If the file is open and it's a change event, use didChange notification
653− filePath := protocol.DocumentUri(uri).Path()
653+ filePath := protocol.DocumentURI(uri).Path()
654654 if changeType == protocol.FileChangeType(protocol.Deleted) {
655− w.client.ClearDiagnosticsForURI(protocol.DocumentUri(uri))
655+ w.client.ClearDiagnosticsForURI(protocol.DocumentURI(uri))
656656 } else if changeType == protocol.FileChangeType(protocol.Changed) && w.client.IsFileOpen(filePath) {
657657 err := w.client.NotifyChange(ctx, filePath)
658658 if err != nil {
@@ -680,7 +680,7 @@ func (w *WorkspaceWatcher) notifyFileEvent(ctx context.Context, uri string, chan
680680 params := protocol.DidChangeWatchedFilesParams{
681681 Changes: []protocol.FileEvent{
682682 {
683− URI: protocol.DocumentUri(uri),
683+ URI: protocol.DocumentURI(uri),
684684 Type: changeType,
685685 },
686686 },
internal/tui/components/core/status/status.go−2
@@ -6,7 +6,6 @@ import (
66
77 "github.com/charmbracelet/bubbles/v2/help"
88 tea "github.com/charmbracelet/bubbletea/v2"
9− "github.com/charmbracelet/crush/internal/session"
109 "github.com/charmbracelet/crush/internal/tui/styles"
1110 "github.com/charmbracelet/crush/internal/tui/util"
1211 "github.com/charmbracelet/lipgloss/v2"
@@ -23,7 +22,6 @@ type statusCmp struct {
2322 info util.InfoMsg
2423 width int
2524 messageTTL time.Duration
26− session session.Session
2725 help help.Model
2826 keyMap help.KeyMap
2927}
internal/tui/components/logo/logo.go−36
@@ -233,42 +233,6 @@ func letterR(stretch bool) string {
233233 )
234234}
235235
236−// letterS renders the letter S in a stylized way. It takes an integer that
237−// determines how many cells to stretch the letter. If the stretch is less than
238−// 1, it defaults to no stretching.
239−func letterS(stretch bool) string {
240− // Here's what we're making:
241− //
242− // ▄▀▀▀▀
243− // ▀▀▀▄
244− // ▀▀▀▀
245−
246− left := heredoc.Doc(`
247− ▄
248−
249− ▀
250− `)
251− center := heredoc.Doc(`
252− ▀
253− ▀
254− ▀
255− `)
256− right := heredoc.Doc(`
257− ▀
258− ▄
259− `)
260− return joinLetterform(
261− left,
262− stretchLetterformPart(center, letterformProps{
263− stretch: stretch,
264− width: 3,
265− minStretch: 7,
266− maxStretch: 12,
267− }),
268− right,
269− )
270−}
271−
272236// letterSStylized renders the letter S in a stylized way, more so than
273237// [letterS]. It takes an integer that determines how many cells to stretch the
274238// letter. If the stretch is less than 1, it defaults to no stretching.
internal/tui/exp/diffview/diffview.go+1−2
@@ -9,7 +9,6 @@ import (
99 "github.com/alecthomas/chroma/v2"
1010 "github.com/alecthomas/chroma/v2/lexers"
1111 "github.com/aymanbagabas/go-udiff"
12− "github.com/aymanbagabas/go-udiff/myers"
1312 "github.com/charmbracelet/lipgloss/v2"
1413 "github.com/charmbracelet/x/ansi"
1514)
@@ -210,7 +209,7 @@ func (dv *DiffView) computeDiff() error {
210209 return dv.err
211210 }
212211 dv.isComputed = true
213− dv.edits = myers.ComputeEdits( //nolint:staticcheck
212+ dv.edits = udiff.Strings(
214213 dv.before.content,
215214 dv.after.content,
216215 )
internal/tui/exp/diffview/testdata/TestDiffView/Unified/Narrow/DarkMode.golden+2−2
@@ -1,7 +1,7 @@
11 …  …  @@ -1,3 +1,3 @@  
22 1    - a 
3− 2    - b 
4− 3    - c 
53    1 + d 
4+ 2    - b 
65    2 + e 
6+ 3    - c 
77    3 + f 
internal/tui/exp/diffview/testdata/TestDiffView/Unified/Narrow/LightMode.golden+2−2
@@ -1,7 +1,7 @@
11 …  …  @@ -1,3 +1,3 @@  
22 1    - a 
3− 2    - b 
4− 3    - c 
53    1 + d 
4+ 2    - b 
65    2 + e 
6+ 3    - c 
77    3 + f 
internal/tui/exp/diffview/udiff_test.go+1−2
@@ -6,7 +6,6 @@ import (
66 "testing"
77
88 "github.com/aymanbagabas/go-udiff"
9− "github.com/aymanbagabas/go-udiff/myers"
109 "github.com/charmbracelet/x/exp/golden"
1110)
1211
@@ -39,7 +38,7 @@ func TestUdiff(t *testing.T) {
3938
4039 t.Run("ToUnifiedDiff", func(t *testing.T) {
4140 toUnifiedDiff := func(t *testing.T, before, after string, contextLines int) udiff.UnifiedDiff {
42− edits := myers.ComputeEdits(before, after) //nolint:staticcheck
41+ edits := udiff.Strings(before, after)
4342 unifiedDiff, err := udiff.ToUnifiedDiff("main.go", "main.go", before, edits, contextLines)
4443 if err != nil {
4544 t.Fatalf("ToUnifiedDiff failed: %v", err)
internal/tui/exp/list/list.go−2
@@ -21,8 +21,6 @@ type list struct {
2121
2222 items []Item
2323
24− renderedView string
25−
2624 // Filter options
2725 filterable bool
2826 filterPlaceholder string
internal/tui/page/chat/chat.go+14−13
@@ -591,11 +591,11 @@ func (p *chatPage) Bindings() []key.Binding {
591591 return bindings
592592}
593593
594−func (a *chatPage) Help() help.KeyMap {
594+func (p *chatPage) Help() help.KeyMap {
595595 var shortList []key.Binding
596596 var fullList [][]key.Binding
597597 switch {
598− case a.isOnboarding && !a.splash.IsShowingAPIKey():
598+ case p.isOnboarding && !p.splash.IsShowingAPIKey():
599599 shortList = append(shortList,
600600 // Choose model
601601 key.NewBinding(
@@ -617,7 +617,7 @@ func (a *chatPage) Help() help.KeyMap {
617617 for _, v := range shortList {
618618 fullList = append(fullList, []key.Binding{v})
619619 }
620− case a.isOnboarding && a.splash.IsShowingAPIKey():
620+ case p.isOnboarding && p.splash.IsShowingAPIKey():
621621 shortList = append(shortList,
622622 // Go back
623623 key.NewBinding(
@@ -634,7 +634,7 @@ func (a *chatPage) Help() help.KeyMap {
634634 for _, v := range shortList {
635635 fullList = append(fullList, []key.Binding{v})
636636 }
637− case a.isProjectInit:
637+ case p.isProjectInit:
638638 shortList = append(shortList,
639639 key.NewBinding(
640640 key.WithKeys("ctrl+c"),
@@ -646,7 +646,7 @@ func (a *chatPage) Help() help.KeyMap {
646646 fullList = append(fullList, []key.Binding{v})
647647 }
648648 default:
649− if a.editor.IsCompletionsOpen() {
649+ if p.editor.IsCompletionsOpen() {
650650 shortList = append(shortList,
651651 key.NewBinding(
652652 key.WithKeys("tab", "enter"),
@@ -666,12 +666,12 @@ func (a *chatPage) Help() help.KeyMap {
666666 }
667667 return core.NewSimpleHelp(shortList, fullList)
668668 }
669− if a.app.CoderAgent != nil && a.app.CoderAgent.IsBusy() {
669+ if p.app.CoderAgent != nil && p.app.CoderAgent.IsBusy() {
670670 cancelBinding := key.NewBinding(
671671 key.WithKeys("esc"),
672672 key.WithHelp("esc", "cancel"),
673673 )
674− if a.isCanceling {
674+ if p.isCanceling {
675675 cancelBinding = key.NewBinding(
676676 key.WithKeys("esc"),
677677 key.WithHelp("esc", "press again to cancel"),
@@ -686,12 +686,12 @@ func (a *chatPage) Help() help.KeyMap {
686686 }
687687 globalBindings := []key.Binding{}
688688 // we are in a session
689− if a.session.ID != "" {
689+ if p.session.ID != "" {
690690 tabKey := key.NewBinding(
691691 key.WithKeys("tab"),
692692 key.WithHelp("tab", "focus chat"),
693693 )
694− if a.focusedPane == PanelTypeChat {
694+ if p.focusedPane == PanelTypeChat {
695695 tabKey = key.NewBinding(
696696 key.WithKeys("tab"),
697697 key.WithHelp("tab", "focus editor"),
@@ -715,7 +715,7 @@ func (a *chatPage) Help() help.KeyMap {
715715 key.WithHelp("ctrl+s", "sessions"),
716716 ),
717717 )
718− if a.session.ID != "" {
718+ if p.session.ID != "" {
719719 globalBindings = append(globalBindings,
720720 key.NewBinding(
721721 key.WithKeys("ctrl+n"),
@@ -728,7 +728,8 @@ func (a *chatPage) Help() help.KeyMap {
728728 )
729729 fullList = append(fullList, globalBindings)
730730
731− if a.focusedPane == PanelTypeChat {
731+ switch p.focusedPane {
732+ case PanelTypeChat:
732733 shortList = append(shortList,
733734 key.NewBinding(
734735 key.WithKeys("up", "down"),
@@ -773,7 +774,7 @@ func (a *chatPage) Help() help.KeyMap {
773774 ),
774775 },
775776 )
776− } else if a.focusedPane == PanelTypeEditor {
777+ case PanelTypeEditor:
777778 newLineBinding := key.NewBinding(
778779 key.WithKeys("shift+enter", "ctrl+j"),
779780 // "ctrl+j" is a common keybinding for newline in many editors. If
@@ -781,7 +782,7 @@ func (a *chatPage) Help() help.KeyMap {
781782 // to reflect that.
782783 key.WithHelp("ctrl+j", "newline"),
783784 )
784− if a.keyboardEnhancements.SupportsKeyDisambiguation() {
785+ if p.keyboardEnhancements.SupportsKeyDisambiguation() {
785786 newLineBinding.SetHelp("shift+enter", newLineBinding.Help().Desc)
786787 }
787788 shortList = append(shortList, newLineBinding)
internal/version/version.go+1
@@ -3,6 +3,7 @@ package version
33import "runtime/debug"
44
55// Build-time parameters set via -ldflags
6+
67var Version = "unknown"
78
89// A user may install crush using `go install github.com/charmbracelet/crush@latest`.