summaryrefslogtreecommitdiff
path: root/ftplugin/kotlin.lua
diff options
context:
space:
mode:
authorchristianchiarulli <[email protected]>2021-07-01 23:42:26 -0400
committerchristianchiarulli <[email protected]>2021-07-01 23:42:26 -0400
commit20ed47e21e966a5b857ef9970ae6171b3a504ce1 (patch)
tree92bdefc7589545f4429a55b53e4493ad7832e632 /ftplugin/kotlin.lua
parent9bb4f8a085644914c79343b48c808509311ee203 (diff)
lsp in ftplugin austonautomoy
Diffstat (limited to 'ftplugin/kotlin.lua')
-rw-r--r--ftplugin/kotlin.lua36
1 files changed, 36 insertions, 0 deletions
diff --git a/ftplugin/kotlin.lua b/ftplugin/kotlin.lua
new file mode 100644
index 00000000..fcbb736b
--- /dev/null
+++ b/ftplugin/kotlin.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/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
+}
+