local lspconfig = require 'lspconfig' local configs = require 'lspconfig.configs' local util = require 'lspconfig.util' local env = { HOME = vim.loop.os_homedir(), XDG_CACHE_HOME = os.getenv 'XDG_CACHE_HOME', JDTLS_JVM_ARGS = os.getenv 'JDTLS_JVM_ARGS', } local function get_cache_dir() return env.XDG_CACHE_HOME and env.XDG_CACHE_HOME or lspconfig.util.path.join(env.HOME, '.cache') end local function get_jdtls_cache_dir() return lspconfig.util.path.join(get_cache_dir(), 'jdtls') end local function get_jdtls_workspace_dir() return lspconfig.util.path.join(get_jdtls_cache_dir(), 'workspace') end local root_files = { -- Single-module projects { 'build.xml', -- Ant 'pom.xml', -- Maven 'settings.gradle', -- Gradle 'settings.gradle.kts', -- Gradle }, -- Multi-module projects { 'build.gradle', 'build.gradle.kts' }, } if not configs.camel then configs.camel = { default_config = { cmd = { "java", "-jar", "/Users/nige/.local/share/lsp/camel-lsp-server/camel-lsp-server-1.5.0.jar" }, filetypes = { 'java' }, root_dir = function(fname) for _, patterns in ipairs(root_files) do local root = util.root_pattern(unpack(patterns))(fname) if root then return root end end end, single_file_support = true, init_options = { workspace = get_jdtls_workspace_dir(), jvm_args = {}, os_config = nil, }, settings = {}, }, docs = { description = "Language server for ApacheCamel" } } end lspconfig.camel.setup {}