diff --git a/internal/lsp/cmd/format.go b/internal/lsp/cmd/format.go index 79403b08..32f64688 100644 --- a/internal/lsp/cmd/format.go +++ b/internal/lsp/cmd/format.go @@ -67,11 +67,13 @@ func (f *format) Run(ctx context.Context, args ...string) error { if err != nil { return err } - p := protocol.DocumentRangeFormattingParams{ - TextDocument: protocol.TextDocumentIdentifier{URI: loc.URI}, - Range: loc.Range, + if loc.Range.Start != loc.Range.End { + return fmt.Errorf("only full file formatting supported") } - edits, err := server.RangeFormatting(ctx, &p) + p := protocol.DocumentFormattingParams{ + TextDocument: protocol.TextDocumentIdentifier{URI: loc.URI}, + } + edits, err := server.Formatting(ctx, &p) if err != nil { return fmt.Errorf("%v: %v", spn, err) } diff --git a/internal/lsp/format.go b/internal/lsp/format.go index 409d048a..f591ae1b 100644 --- a/internal/lsp/format.go +++ b/internal/lsp/format.go @@ -20,20 +20,6 @@ func (s *Server) formatting(ctx context.Context, params *protocol.DocumentFormat return formatRange(ctx, view, spn) } -func (s *Server) rangeFormatting(ctx context.Context, params *protocol.DocumentRangeFormattingParams) ([]protocol.TextEdit, error) { - uri := span.NewURI(params.TextDocument.URI) - view := s.findView(ctx, uri) - _, m, err := newColumnMap(ctx, view, uri) - if err != nil { - return nil, err - } - spn, err := m.RangeSpan(params.Range) - if err != nil { - return nil, err - } - return formatRange(ctx, view, spn) -} - // formatRange formats a document with a given range. func formatRange(ctx context.Context, v source.View, s span.Span) ([]protocol.TextEdit, error) { f, m, err := newColumnMap(ctx, v, s.URI()) diff --git a/internal/lsp/general.go b/internal/lsp/general.go index ade4cf54..0f8f663e 100644 --- a/internal/lsp/general.go +++ b/internal/lsp/general.go @@ -78,13 +78,12 @@ func (s *Server) initialize(ctx context.Context, params *protocol.InitializePara CompletionProvider: &protocol.CompletionOptions{ TriggerCharacters: []string{"."}, }, - DefinitionProvider: true, - DocumentFormattingProvider: true, - DocumentRangeFormattingProvider: true, - DocumentSymbolProvider: true, - HoverProvider: true, - DocumentHighlightProvider: true, - DocumentLinkProvider: &protocol.DocumentLinkOptions{}, + DefinitionProvider: true, + DocumentFormattingProvider: true, + DocumentSymbolProvider: true, + HoverProvider: true, + DocumentHighlightProvider: true, + DocumentLinkProvider: &protocol.DocumentLinkOptions{}, SignatureHelpProvider: &protocol.SignatureHelpOptions{ TriggerCharacters: []string{"(", ","}, }, diff --git a/internal/lsp/server.go b/internal/lsp/server.go index d94bd934..71a3d489 100644 --- a/internal/lsp/server.go +++ b/internal/lsp/server.go @@ -231,7 +231,7 @@ func (s *Server) Formatting(ctx context.Context, params *protocol.DocumentFormat } func (s *Server) RangeFormatting(ctx context.Context, params *protocol.DocumentRangeFormattingParams) ([]protocol.TextEdit, error) { - return s.rangeFormatting(ctx, params) + return nil, notImplemented("RangeFormatting") } func (s *Server) OnTypeFormatting(context.Context, *protocol.DocumentOnTypeFormattingParams) ([]protocol.TextEdit, error) {