Skip to content

Instantly share code, notes, and snippets.

@renatoliveira
Last active May 24, 2024 14:43
Show Gist options
  • Save renatoliveira/ad04b6f5b8459ee513acea5b7a106beb to your computer and use it in GitHub Desktop.
Save renatoliveira/ad04b6f5b8459ee513acea5b7a106beb to your computer and use it in GitHub Desktop.
Nvim's Init script for setting up the Apex language server
-- Get the file path to the language server file provided by Salesforce.
local apex_jorje_lsp_file_path = vim.fn.expand("~/Downloads/apex-jorje-lsp.jar")
-- Set up the language server configuration for the Apex language, associating
-- it with the three main file types by extension, disabling telemetry, and
-- specifying the command.
require"lspconfig".apex_ls.setup {
apex_jar_setup = apex_jorje_lsp_file_path,
apex_enable_semantic_errors = false,
apex_enable_completion_statistics = false,
filetypes = { 'cls', 'trigger', 'apex' },
cmd = {
"java",
"-jar",
apex_jorje_lsp_file_path,
"apex_language_server"
}
}
-- Associate .cls, .trigger and .apex files with the 'apex' filetype.
vim.cmd("autocmd BufNewFile,BufRead,BufReadPost *.cls,*.trigger,*.apex :set filetype=apex")
@renatoliveira
Copy link
Author

This works for the NvChad setup. To enable syntax highlighting for the language, use TSInstall apex, which is the command for the Treesitter plugin (that comes with NvChad).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment