diff options
| author | Andrew Jackson <andrewderekjackson@gmail.com> | 2025-09-20 09:32:41 +1200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-09-19 14:32:41 -0700 |
| commit | d51b2c9044a5625002e4fb9a37c5fd752eb058a1 (patch) | |
| tree | 161fad2a3fbf0e102bd22c2b3dd0f4785a22d45f /lsp | |
| parent | refactor!: deprecate old framework/configs, Nvim 0.10 #4077 (diff) | |
| download | nvim-lspconfig-d51b2c9044a5625002e4fb9a37c5fd752eb058a1.tar nvim-lspconfig-d51b2c9044a5625002e4fb9a37c5fd752eb058a1.tar.gz nvim-lspconfig-d51b2c9044a5625002e4fb9a37c5fd752eb058a1.tar.bz2 nvim-lspconfig-d51b2c9044a5625002e4fb9a37c5fd752eb058a1.tar.lz nvim-lspconfig-d51b2c9044a5625002e4fb9a37c5fd752eb058a1.tar.xz nvim-lspconfig-d51b2c9044a5625002e4fb9a37c5fd752eb058a1.tar.zst nvim-lspconfig-d51b2c9044a5625002e4fb9a37c5fd752eb058a1.zip | |
feat(apex_ls): add vim.lsp.config support #4081
Diffstat (limited to 'lsp')
| -rw-r--r-- | lsp/apex_ls.lua | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/lsp/apex_ls.lua b/lsp/apex_ls.lua new file mode 100644 index 00000000..01616c9e --- /dev/null +++ b/lsp/apex_ls.lua @@ -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', + }, +} |
