Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lsp-sample is not auto activated in VS Code 1.74 #807

Closed
jozefizso opened this issue Jan 14, 2023 · 4 comments · Fixed by #808
Closed

lsp-sample is not auto activated in VS Code 1.74 #807

jozefizso opened this issue Jan 14, 2023 · 4 comments · Fixed by #808
Assignees
Milestone

Comments

@jozefizso
Copy link

I'm learning to write an VS Code language server from the https://code.visualstudio.com/api/language-extensions/language-server-extension-guide documentation. I tried to run several lsp samples from https://github.com/microsoft/vscode-extension-samples repository.

Running the lsp-multi-server-sample will activate the code and I can use breakpoints to debug the code.

The simple lsp-sample project will not activate the extension code automatically despite supporting VS Code 1.74 with auto activation of extension contributions (see https://code.visualstudio.com/updates/v1_74#_implicit-activation-events-for-declared-extension-contributions).

Environment

Version: 1.74.3 (user setup)
Commit: 97dec172d3256f8ca4bfb2143f3f76b503ca0534
Date: 2023-01-09T16:59:02.252Z
Electron: 19.1.8
Chromium: 102.0.5005.167
Node.js: 16.14.2
V8: 10.2.154.15-electron.0
OS: Windows_NT x64 10.0.19045
Sandboxed: No

Steps to Reproduce

  1. Open the lsp-sample project
  2. Build the project
  3. Set breakpoint in client's activate() method in client/src/extension.ts file
  4. Run the code with F5
  5. The breakpoint will not be hit

I have to add the activation manualy to package.json file to fix this and activate the extension.

	"activationEvents": [
+		"onLanguage:plaintext"
	],

Expected behavior

According the documentation, the extension should be auto activated without setting the onLanguage:plaintext activation event.

@gjsjohnmurray
Copy link
Contributor

I guess that the auto activation will only happen for languages that the extension declares it contributes.

@gjsjohnmurray
Copy link
Contributor

/assign @joyceerhl

@jozefizso
Copy link
Author

The documentation does not make it apparent that language is not defined. Eg. there is this code in the client which can be assumed that the client is always activated and it sets the language programatically:

  // Options to control the language client
  let clientOptions: LanguageClientOptions = {
    // Register the server for plain text documents
    documentSelector: [{ scheme: 'file', language: 'plaintext' }],
    synchronize: {
      // Notify the server about file changes to '.clientrc files contained in the workspace
      fileEvents: workspace.createFileSystemWatcher('**/.clientrc')
    }
  };

@gjsjohnmurray
Copy link
Contributor

AFAIK activation has to be driven by the contents of package.json alone, because until it gets activated none of the code of the extension can have any effect in VS Code.

@roblourens roblourens removed their assignment Jan 17, 2023
@joyceerhl joyceerhl transferred this issue from microsoft/vscode Jan 20, 2023
@joyceerhl joyceerhl added this to the January 2023 milestone Jan 20, 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 a pull request may close this issue.

4 participants