Skip to content

Conversation

@adam-fowler
Copy link
Contributor

Useful for attaching to already running sourcekit-lsp executable.

Example of usage.

  1. Build debug version of sourcekit-lsp in VSCode.
  2. Open a SwiftPM project in a second "target" version of VSCode.
  3. Go to settings in "target" VSCode, click to edit workspace settings and set Sourcekit-lsp: server path to the path to your debug version of sourcekit-lsp: <Fullpath>/sourcekit-lsp/.build/debug/sourcekit-lsp.
  4. Restart LSP server as requested.
  5. Go to original VSCode and run debug target Attach sourcekit-lsp.

You are now debugging the sourcekit-lsp server running in the "target" VSCode.

Useful for attaching to already running sourcekit-lsp executable.
"cwd": "${workspaceFolder:sourcekit-lsp}",
"preLaunchTask": "swift: Build Debug sourcekit-lsp"
"preLaunchTask": "swift: Build Debug sourcekit-lsp",
"sourceLanguages": ["swift"]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also set the sourceLanguage to swift so the CodeLLDB on swift throw breakpoint is available.

"type": "lldb",
"request": "attach",
"name": "Attach sourcekit-lsp",
"program": "${workspaceFolder:sourcekit-lsp}/.build/debug/sourcekit-lsp",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a thought: Since you are hard-coding the debug configuration, should the name of this action be “Attach sourcekit-lsp (debug)” or “Attach to debug build of sourcekit-lsp”. Just so nobody gets confused if it’s not attaching properly because you’re running a release build of sourcekit-lsp.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair point. I'll add it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@ahoppen
Copy link
Member

ahoppen commented May 9, 2023

@swift-ci Please test

@ahoppen ahoppen merged commit 872499d into swiftlang:main May 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants