diff options
| author | Michael Lingelbach <m.j.lbach@gmail.com> | 2021-01-30 09:36:12 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-01-30 09:36:12 -0800 |
| commit | fff935b542e17e3ec1b3e480b55a1dc68d8a6b46 (patch) | |
| tree | 7f67d320a51f405b3cad503b31864a56fbafa2a6 /lua | |
| parent | [docgen] Update CONFIG.md (diff) | |
| parent | JDT LS: Add callback for language/status (diff) | |
| download | nvim-lspconfig-fff935b542e17e3ec1b3e480b55a1dc68d8a6b46.tar nvim-lspconfig-fff935b542e17e3ec1b3e480b55a1dc68d8a6b46.tar.gz nvim-lspconfig-fff935b542e17e3ec1b3e480b55a1dc68d8a6b46.tar.bz2 nvim-lspconfig-fff935b542e17e3ec1b3e480b55a1dc68d8a6b46.tar.lz nvim-lspconfig-fff935b542e17e3ec1b3e480b55a1dc68d8a6b46.tar.xz nvim-lspconfig-fff935b542e17e3ec1b3e480b55a1dc68d8a6b46.tar.zst nvim-lspconfig-fff935b542e17e3ec1b3e480b55a1dc68d8a6b46.zip | |
Merge pull request #370 from HiPhish/jdtls
JDT LS: general improvements
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/lspconfig/jdtls.lua | 43 |
1 files changed, 41 insertions, 2 deletions
diff --git a/lua/lspconfig/jdtls.lua b/lua/lspconfig/jdtls.lua index 6b4b909e..67b4de3d 100644 --- a/lua/lspconfig/jdtls.lua +++ b/lua/lspconfig/jdtls.lua @@ -25,6 +25,38 @@ local cmd = { "--add-opens java.base/java.lang=ALL-UNNAMED", } + +--- The presence of one of these files indicates a root directory. +-- +-- We search for configuration files of the most common Java build systems. We +-- could add more build systems, such as Make, but let's keep things simple for +-- now. +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'}, +} + + +--- Callback function for the `language/status` notification. +-- +-- The server sends a non-standard notification when the status of the language +-- server changes. This can be used to display progress as the server is +-- starting up. +local function on_language_status(_, _, result) + local command = vim.api.nvim_command + command('echohl ModeMsg') + command(string.format('echo "%s"', result.message)) + command('echohl None') +end + + configs[server_name] = { default_config = { cmd = cmd, @@ -33,7 +65,13 @@ configs[server_name] = { GRADLE_HOME=vim.fn.getenv("GRADLE_HOME"), }, filetypes = { "java" }; - root_dir = util.root_pattern('.git'); + 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 + return vim.fn.getcwd() + end; init_options = { workspace = path.join { vim.loop.os_homedir(), "workspace" }; jvm_args = {}; @@ -62,7 +100,8 @@ configs[server_name] = { end handlers['textDocument/codeAction'](a, b, actions) - end + end; + ['language/status'] = vim.schedule_wrap(on_language_status) }; }; docs = { |
