aboutsummaryrefslogtreecommitdiffstats
path: root/lua
diff options
context:
space:
mode:
authorHiPhish <hiphish@posteo.de>2020-09-29 17:49:12 +0200
committerHiPhish <hiphish@posteo.de>2021-01-30 00:01:05 +0100
commit729ce253fddd6bc90af3c10ce6636dc1e3f44c0a (patch)
tree1ba18c67debe50c9e1a104052d6ccb6fe15be4f0 /lua
parent[docgen] Update CONFIG.md (diff)
downloadnvim-lspconfig-729ce253fddd6bc90af3c10ce6636dc1e3f44c0a.tar
nvim-lspconfig-729ce253fddd6bc90af3c10ce6636dc1e3f44c0a.tar.gz
nvim-lspconfig-729ce253fddd6bc90af3c10ce6636dc1e3f44c0a.tar.bz2
nvim-lspconfig-729ce253fddd6bc90af3c10ce6636dc1e3f44c0a.tar.lz
nvim-lspconfig-729ce253fddd6bc90af3c10ce6636dc1e3f44c0a.tar.xz
nvim-lspconfig-729ce253fddd6bc90af3c10ce6636dc1e3f44c0a.tar.zst
nvim-lspconfig-729ce253fddd6bc90af3c10ce6636dc1e3f44c0a.zip
JDT LS: add more root pattern files
There are three common build systems for Java: Ant, Maven and Gradle. Each has its own configuration file, and this PR adds those files are root directory markers.
Diffstat (limited to 'lua')
-rw-r--r--lua/lspconfig/jdtls.lua21
1 files changed, 20 insertions, 1 deletions
diff --git a/lua/lspconfig/jdtls.lua b/lua/lspconfig/jdtls.lua
index 6b4b909e..a9dd0488 100644
--- a/lua/lspconfig/jdtls.lua
+++ b/lua/lspconfig/jdtls.lua
@@ -25,6 +25,21 @@ 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 = {
+ 'build.xml', -- Ant
+ 'pom.xml', -- Maven
+ 'build.gradle', -- Gradle
+ 'build.gradle.kts', -- Gradle
+ 'settings.gradle', -- Gradle
+ 'settings.gradle.kts', -- Gradle
+}
+
configs[server_name] = {
default_config = {
cmd = cmd,
@@ -33,7 +48,11 @@ configs[server_name] = {
GRADLE_HOME=vim.fn.getenv("GRADLE_HOME"),
},
filetypes = { "java" };
- root_dir = util.root_pattern('.git');
+ root_dir = function(fname)
+ return util.find_git_ancestor(fname)
+ or util.root_pattern(unpack(root_files))(fname)
+ or vim.call('getcwd')
+ end;
init_options = {
workspace = path.join { vim.loop.os_homedir(), "workspace" };
jvm_args = {};