-
Couldn't load subscription status.
- Fork 2.4k
feat(apex_ls): add vim.lsp.config support #4081
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| --- @brief | ||
| --- | ||
| --- https://github.com/forcedotcom/salesforcedx-vscode | ||
| --- | ||
| --- Language server for Apex. | ||
| --- | ||
| --- For manual installation, download the JAR file from the [VSCode | ||
| --- extension](https://github.com/forcedotcom/salesforcedx-vscode/tree/develop/packages/salesforcedx-vscode-apex) and adjust the `apex_jar_path` appropriately. | ||
| --- | ||
| --- ```lua | ||
| --- vim.lsp.config('apex_ls', { | ||
| --- apex_jar_path = '/path/to/apex-jorje-lsp.jar', | ||
| --- apex_enable_semantic_errors = false, -- Whether to allow Apex Language Server to surface semantic errors | ||
| --- apex_enable_completion_statistics = false, -- Whether to allow Apex Language Server to collect telemetry on code completion usage | ||
| --- } | ||
| ---``` | ||
| --- | ||
| --- Example configuration using Mason: | ||
| --- | ||
| ---```lua | ||
| --- vim.lsp.config('apex_ls', { | ||
| --- apex_jar_path = vim.fn.stdpath('data') .. '/mason/share/apex-language-server/apex-jorje-lsp.jar', | ||
| --- } | ||
| ---``` | ||
| --- | ||
| --- For a complete experience, you may need to ensure the treesitter parsers for 'apex' are installed (:TSInstall apex) as well as configure the filetype for apex (*.cls) files: | ||
| --- | ||
| --- ```lua | ||
| --- vim.filetype.add({ | ||
| --- pattern = { | ||
| --- ['.*/*.cls'] = 'apex', | ||
| --- }, | ||
| --- }) | ||
| --- ``` | ||
|
|
||
| ---@type vim.lsp.Config | ||
| return { | ||
| cmd = function(dispatchers, config) | ||
| local local_cmd = { | ||
| vim.env.JAVA_HOME and (vim.env.JAVA_HOME .. '/bin/java') or 'java', | ||
| '-cp', | ||
| config.apex_jar_path, | ||
| '-Ddebug.internal.errors=true', | ||
| '-Ddebug.semantic.errors=' .. tostring(config.apex_enable_semantic_errors or false), | ||
| '-Ddebug.completion.statistics=' .. tostring(config.apex_enable_completion_statistics or false), | ||
| '-Dlwc.typegeneration.disabled=true', | ||
| } | ||
| if config.apex_jvm_max_heap then | ||
| table.insert(local_cmd, '-Xmx' .. config.apex_jvm_max_heap) | ||
| end | ||
| table.insert(local_cmd, 'apex.jorje.lsp.ApexLanguageServerLauncher') | ||
|
|
||
| return vim.lsp.rpc.start(local_cmd, dispatchers) | ||
| end, | ||
| filetypes = { 'apex', 'apexcode' }, | ||
| root_markers = { | ||
| 'sfdx-project.json', | ||
| }, | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting approach. And since
cmd()gained theconfigarg, this is much more ergonomic. We should keep this is mind for other configs.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't take any credit for that I'm afraid - the approach was shamefully pillaged from the biome config.