2021-07-08 18:35:41 +02:00
|
|
|
if require("lv-utils").check_lsp_client_active "kotlin_language_server" then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2021-04-16 19:08:48 +02:00
|
|
|
--- default config for gradle-projects of the
|
|
|
|
--- kotlin-language-server: https://github.com/fwcd/kotlin-language-server
|
|
|
|
---
|
|
|
|
--- This server requires vim to be aware of the kotlin-filetype.
|
|
|
|
--- You could refer for this capability to:
|
|
|
|
--- https://github.com/udalov/kotlin-vim (recommended)
|
|
|
|
--- Note that there is no LICENSE specified yet.
|
|
|
|
|
2021-07-05 03:14:01 +02:00
|
|
|
local util = require "lspconfig/util"
|
2021-04-16 19:08:48 +02:00
|
|
|
|
2021-06-26 20:25:20 +02:00
|
|
|
local bin_name = DATA_PATH .. "/lspinstall/kotlin/server/bin/kotlin-language-server"
|
2021-07-05 03:14:01 +02:00
|
|
|
if vim.fn.has "win32" == 1 then
|
|
|
|
bin_name = bin_name .. ".bat"
|
2021-04-16 19:08:48 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
local root_files = {
|
2021-07-05 03:14:01 +02:00
|
|
|
"settings.gradle", -- Gradle (multi-project)
|
|
|
|
"settings.gradle.kts", -- Gradle (multi-project)
|
|
|
|
"build.xml", -- Ant
|
|
|
|
"pom.xml", -- Maven
|
2021-04-16 19:08:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
local fallback_root_files = {
|
2021-07-05 03:14:01 +02:00
|
|
|
"build.gradle", -- Gradle
|
|
|
|
"build.gradle.kts", -- Gradle
|
2021-04-16 19:08:48 +02:00
|
|
|
}
|
|
|
|
|
2021-07-05 03:14:01 +02:00
|
|
|
require("lspconfig").kotlin_language_server.setup {
|
|
|
|
cmd = { bin_name },
|
|
|
|
on_attach = require("lsp").common_on_attach,
|
|
|
|
root_dir = function(fname)
|
|
|
|
return util.root_pattern(unpack(root_files))(fname) or util.root_pattern(unpack(fallback_root_files))(fname)
|
|
|
|
end,
|
2021-04-16 19:08:48 +02:00
|
|
|
}
|