Commit Graph

43 Commits

Author SHA1 Message Date
Alex Hoppen
14cfd50582 If sourcekitd or clangd don’t respond to a request for 5 minutes, terminate them and use crash recovery to restore behavior
This should be a last stop-gap measure in case sourcekitd or clangd get stuck, don’t respond to any requests anymore and don’t honor cancellation either. In that case we can restore SourceKit-LSP behavior by killing them and using the crash recovery logic to restore functionality.

rdar://149492159
2025-05-07 13:43:28 +02:00
Alex Hoppen
5fba1699bd Generalize PollIndexRequest and BarrierRequest into a single SynchronizeRequest
This new request also allows us to wait for build system updates without waiting for background indexing to finish.
2025-03-12 14:25:50 -07:00
Alex Hoppen
cde206c017 Allow specifying toolsets for SwiftPM projects
Equivalent to SwiftPM’s `--toolset` option, implemented in https://github.com/swiftlang/swift-package-manager/pull/8051.

Fixes #2047
rdar://146557424
2025-03-11 13:21:54 -07:00
Alex Hoppen
8aa8fa0ff8 Remove offensive terms from the codebase 2025-03-07 13:58:02 -08:00
Alex Hoppen
2a1fd10295 Add an experimental LSP request to return the output paths for all files in a target 2025-03-06 08:30:47 -08:00
Alex Hoppen
655a93f05a Add structure to the index logs
When the client supports it, communicate the structure of tasks that were stared during background indexing or by the build server to the client. If there are multiple operations happening in parallel, this allows the client to display them in separate log tracks instead of interspersing them with the emoji prefixes like we do today.
2025-03-04 16:36:26 -08:00
Alex Hoppen
6a1d923f5b Add a request to check if SourceKit-LSP is currently performing any indexing 2025-02-27 12:52:28 -08:00
Alex Hoppen
f4e015b3c0 Merge pull request #1988 from ahoppen/sourcekitoptions
Add an experimental request to return the build settings that SourceKit-LSP uses to process a file
2025-02-26 16:06:20 -08:00
Alex Hoppen
9496b49c72 Add an experimental request to return the build settings that SourceKit-LSP uses to process a file
This can be useful to IDEs that want to perform some additional semantic processing of source files, which requires knowledge of a file’s build settings.
2025-02-26 09:12:47 -08:00
Alex Hoppen
628ce3cc63 If a build server doesn’t specify -index-store-path in the SourceKit options, add it during background indexing 2025-02-25 22:46:32 -08:00
Alex Hoppen
f1aeb6c196 Add an experimental request to pause background indexing
This request allows IDEs to disable SourceKit-LSP’s background indexing functionality when it requires all compute resources for other, more interactive, tasks.
2025-02-21 08:09:34 -08:00
Ben Barham
cea30e54b0 Add a couple missing SwiftPM options 2025-02-17 19:11:30 -08:00
Alex Hoppen
4ec669f834 Hide internal options from SourceKit-LSP configuration file documentation 2025-02-17 13:09:05 -08:00
Ben Barham
84f7931d82 Re-generate the configuration file documentation
The verification for this was only merged after the plugin changes.
2025-01-15 21:25:55 -08:00
Alex Hoppen
5330795404 Add option to generate an output mirror file that contains the exact data sent from SourceKit-LSP to the client
This could help us debug low-level issues of SourceKit-LSP to client communication such as https://github.com/swiftlang/sourcekit-lsp/issues/1890.
2025-01-02 19:12:50 +01:00
Yuta Saito
90dc733542 Keep the original order of privacyLevel enum cases 2024-12-09 02:12:19 +09:00
Yuta Saito
7597945e38 Use an enum for backgroundPreparationMode in the configuration file instead of a string 2024-12-09 02:12:12 +09:00
Yuta Saito
96b582c189 Remove duplicate possible values from defaultWorkspaceType 2024-12-08 15:03:45 +09:00
Yuta Saito
cbf04eafaf Replace newlines with spaces in property descriptions 2024-12-08 14:53:53 +09:00
Yuta Saito
227083654f Add missing periods to doc comment sentences for SourceKitLSPOptions 2024-12-08 14:19:22 +09:00
Yuta Saito
9b07134f76 Generate JSON Schema and Markdown doc for .sourcekit-lsp/config.json
Providing a JSON schema for the configuration file should improve the
developer experience thanks to better auto-completion and diagnostics
support provided by some editors.

Additionally, we have been manually maintaining the configuration file
format documentation in `Documentation/Configuration File.md`, but it's
easy for the documentation to get out of sync with the actual schema.

This change introduces a new tool, `ConfigSchemaGen`, that generates a
JSON schema and a Markdown document for the configuration file based on
the Swift type definitions in the `SKOptions` module by using
swift-syntax.
2024-12-01 14:48:16 +09:00
MahdiBM
a2eb7b9b2c Handle on-type formatting requests 2024-11-21 16:07:22 +03:30
Yuta Saito
184fa12389 Allow scratchPath to be relative paths
Interpret it as relative to the project root directory if it's a
relative path.
2024-11-19 11:19:54 +09:00
Alex Hoppen
c1acdf54a8 Switch Configuration File.md to consistently use 2 spaces for indentation in list 2024-11-01 12:30:04 -07:00
Alex Hoppen
d9132223ba Merge pull request #1799 from ahoppen/input-mirror
Add a logging option to record all notifications received by SoruceKit-LSP
2024-11-01 12:28:31 -07:00
kudinovdenis
8aa928a1dd Update Configuration File.md
Minor markdown changes
2024-11-01 13:03:13 +03:00
Herman Berdnikov
a696962134 Fix swiftPublishDiagnosticsDebounceDuration documentation (#1756) 2024-10-31 15:23:59 -07:00
Alex Hoppen
98c44f89eb Add a logging option to record all notifications received by SoruceKit-LSP
This allows us to record the communication between SourceKit-LSP and the editor on a very low level to inspect any transfer issues. It also allows us to record an entire SourceKit-LSP session and replay it using

```
cat /path/to/mirror.log - | path/to/sourcekit-lsp
```
2024-10-31 11:35:13 -07:00
Alex Hoppen
5bae73fca8 Use fallback build settings if build system doesn’t provide build settings within a timeout
When we receive build settings after hitting the timeout, we call `fileBuildSettingsChanged` on the delegate, which should cause the document to get re-opened in sourcekitd and diagnostics to get refreshed.

rdar://136332685
Fixes #1693
2024-10-16 10:55:29 -07:00
Alex Hoppen
38ac399b58 Reduce the debounce duration to publish diagnostics to 1s
We received two feedbacks that the 2s timeout is too long. 2s was a somewhat arbitrary choice, let’s reduce it to 1s.

Fixes #1753
2024-10-14 09:51:43 -07:00
Alex Hoppen
794d4936fe Revert "Use fallback build settings if build system doesn’t provide build settings within a timeout"
This reverts commit 78217ec6a6.
2024-09-27 12:32:47 -07:00
Alex Hoppen
78217ec6a6 Use fallback build settings if build system doesn’t provide build settings within a timeout
When we receive build settings after hitting the timeout, we call `fileBuildSettingsChanged` on the delegate, which should cause the document to get re-opened in sourcekitd and diagnostics to get refreshed.

rdar://136332685
2024-09-26 17:50:58 -07:00
Alex Hoppen
0f56e5f32e Simplify FallbackBuildSystem to a free function returning fallback arguments 2024-09-16 10:12:09 -07:00
Alex Hoppen
1e409c97e2 Implicitly cancel text document requests when the document is edited or closed
As a user makes an edit to a file, these requests are most likely no longer relevant. It also makes sure that a long-running sourcekitd request can't block the entire language server if the client does not cancel all requests. For example, consider the following sequence of requests:
 - `textDocument/semanticTokens/full` for document A
 - `textDocument/didChange` for document A
 - `textDocument/formatting` for document A

If the editor is not cancelling the semantic tokens request on edit (like VS Code does), then the `didChange` notification is blocked on the semantic tokens request finishing. Hence, we also can't run the `textDocument/formatting` request. Cancelling the semantic tokens on the edit fixes the issue.

rdar://133987424
2024-08-15 15:32:26 -07:00
Alex Hoppen
4a10d3dc1b Merge pull request #1615 from ahoppen/adjustable-log-linux
Add configuration options to adjust log level and log privacy level on non-Apple platforms
2024-08-07 08:45:14 -07:00
Alex Hoppen
1f74b83854 Add configuration options to adjust log level and log privacy level on non-Apple platforms
Also adjust the log privacy level on non-Apple platforms to `public` and don’t log potentially sensitive information by default.

rdar://132525691
Resolves #1591
2024-08-06 18:09:38 -07:00
Alex Hoppen
7e2d12a7a0 Add configuration option to disable the sandbox for SwiftPM operations
Disabling the sandbox is needed to run tests for the Swift VS Code extension in a sandbox.
2024-08-01 09:24:17 -07:00
Alex Hoppen
7654627801 Add option to allow SourceKit-LSP to prepare a target without lazy type checking
rdar://130333458
2024-07-24 16:27:38 -07:00
Alex Hoppen
16e4f83ec3 Merge pull request #1534 from ahoppen/configuration-improvements
Allow specification of SourceKitLSPOptions in the initialize request and look for SourceKit-LSP options in `$XDG_CONFIG_HOME/sourcekit-lsp`
2024-06-28 22:18:45 +02:00
Alex Hoppen
bfe1a24110 Support using SourceKit-LSP for projects that are cross-compiled
We previously always assumed that the project was being built for the host.

Fixes #786
Fixes #1475
rdar://129662080
rdar://113099964
2024-06-28 10:28:46 +02:00
Alex Hoppen
2c21284ff8 Look for SourceKit-LSP options in $XDG_CONFIG_HOME/sourcekit-lsp
The reverse-DNS notation is macOS style and doesn’t feel at home on Linux.
2024-06-28 10:25:37 +02:00
Alex Hoppen
ddbad85c28 Allow specification of SourceKitLSPOptions in the initialize request
This allows editors to provide UI elements to toggle SourceKit-LSP options.
2024-06-28 10:25:37 +02:00
Alex Hoppen
d1cddb8c41 Allow configuring of SourceKit-LSP’s options using .sourcekit-lsp configuration files
The idea here is to unify the different ways in which we can currently set options on SourceKit-LSP in a scalable way: Environment variables, command line arguments to `sourcekit-lsp` and initialization options.

The idea is that a user can define a `~/.sourcekit-lsp/.sourcekit-lsp` file (we store logs in `~/.sourcekit-lsp/logs` on non-Darwin platforms), which will be used as the default configuration for all SourceKit-LSP instances. They can also place a `.sourcekit-lsp` file in the root of a workspace to configure SourceKit-LSP for that project specifically, eg. setting arguments that need to be passed to `swift build` for that project and which thus also need to be set on SourceKit-LSP.

For compatibility reasons, I’m mapping the existing command line options into the new options structure for now. I hope to delete the command line arguments in the future and solely rely on `.sourcekit-lsp` configuration files.

Environment variable will be migrated to `.sourcekit-lsp` in a follow-up commit.
2024-06-27 17:36:16 +02:00