summaryrefslogtreecommitdiff
path: root/lua/lsp/kotlin-ls.lua
diff options
context:
space:
mode:
authorMarek Filipowicz <[email protected]>2021-04-16 19:08:48 +0200
committerGitHub <[email protected]>2021-04-16 13:08:48 -0400
commit1afd5aa5921e0bd51de716f5c13ef5c670d1719d (patch)
tree7caee33aee22457e089412d9b180055b336ab490 /lua/lsp/kotlin-ls.lua
parent4a797b59bdafaca916bb228b5c9c0ef3c332f074 (diff)
Add kotlin lsp support, and :LspInstall kotlin (#263)
Diffstat (limited to 'lua/lsp/kotlin-ls.lua')
-rw-r--r--lua/lsp/kotlin-ls.lua36
1 files changed, 36 insertions, 0 deletions
diff --git a/lua/lsp/kotlin-ls.lua b/lua/lsp/kotlin-ls.lua
new file mode 100644
index 00000000..0a92696e
--- /dev/null
+++ b/lua/lsp/kotlin-ls.lua
@@ -0,0 +1,36 @@
+--- 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.
+
+local util = require 'lspconfig/util'
+
+local bin_name = DATA_PATH .. "/lspinstall/kotlin/language-server/server/build/install/server/bin/kotlin-language-server"
+if vim.fn.has('win32') == 1 then
+ bin_name = bin_name..".bat"
+end
+
+local root_files = {
+ 'settings.gradle', -- Gradle (multi-project)
+ 'settings.gradle.kts', -- Gradle (multi-project)
+ 'build.xml', -- Ant
+ 'pom.xml', -- Maven
+}
+
+local fallback_root_files = {
+ 'build.gradle', -- Gradle
+ 'build.gradle.kts', -- Gradle
+}
+
+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
+}
+