mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Implement lsp/formatting for Carbon::LanguageServer (#7688)
Implements formatting support within LSP. Current implementation performs while file formatting, we just replace file with output of Carbon::Format() https://github.com/carbon-language/carbon-lang/pull/7687 independently improves formatting so that this output is somewhat decent. Assisted-With: Gemini / Antigravity
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
||||
// Exceptions. See /LICENSE for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
// AUTOUPDATE
|
||||
// TIP: To test this file alone, run:
|
||||
// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/language_server/testdata/formatting/unknown.carbon
|
||||
// TIP: To dump output, run:
|
||||
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/language_server/testdata/formatting/unknown.carbon
|
||||
// CHECK:STDERR: /test.carbon: warning: unknown file requested [LanguageServerFileUnknown]
|
||||
// CHECK:STDERR:
|
||||
|
||||
// --- STDIN
|
||||
[[@LSP-CALL:initialize:"capabilities": {}]]
|
||||
[[@LSP-CALL:textDocument/formatting:
|
||||
"textDocument": {"uri": "file:/test.carbon"},
|
||||
"options": {"tabSize": 2, "insertSpaces": true}
|
||||
]]
|
||||
[[@LSP-CALL:shutdown]]
|
||||
[[@LSP-NOTIFY:exit]]
|
||||
|
||||
// CHECK:STDOUT: Content-Length: 394{{\r}}
|
||||
// CHECK:STDOUT: {{\r}}
|
||||
// CHECK:STDOUT: {
|
||||
// CHECK:STDOUT: "id": 1,
|
||||
// CHECK:STDOUT: "jsonrpc": "2.0",
|
||||
// CHECK:STDOUT: "result": {
|
||||
// CHECK:STDOUT: "capabilities": {
|
||||
// CHECK:STDOUT: "declarationProvider": true,
|
||||
// CHECK:STDOUT: "definitionProvider": true,
|
||||
// CHECK:STDOUT: "documentFormattingProvider": true,
|
||||
// CHECK:STDOUT: "documentSymbolProvider": true,
|
||||
// CHECK:STDOUT: "hoverProvider": true,
|
||||
// CHECK:STDOUT: "positionEncoding": "utf-16",
|
||||
// CHECK:STDOUT: "referencesProvider": true,
|
||||
// CHECK:STDOUT: "textDocumentSync": 2,
|
||||
// CHECK:STDOUT: "typeDefinitionProvider": true
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: }Content-Length: 51{{\r}}
|
||||
// CHECK:STDOUT: {{\r}}
|
||||
// CHECK:STDOUT: {
|
||||
// CHECK:STDOUT: "id": 3,
|
||||
// CHECK:STDOUT: "jsonrpc": "2.0",
|
||||
// CHECK:STDOUT: "result": null
|
||||
// CHECK:STDOUT: }
|
||||
Reference in New Issue
Block a user