Add kotlin lsp support, and :LspInstall kotlin (#263)

This commit is contained in:
Marek Filipowicz 2021-04-16 19:08:48 +02:00 committed by GitHub
parent 4a797b59bd
commit 1afd5aa592
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 46 additions and 0 deletions

View file

@ -47,3 +47,4 @@ require('lsp.efm-general-ls')
require('lsp.latex-ls')
require('lsp.svelte-ls')
require('lsp.tailwindcss-ls')
require('lsp.kotlin-ls')

36
lua/lsp/kotlin-ls.lua Normal file
View file

@ -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
}

View file

@ -15,4 +15,13 @@ require'lspinstall/servers'.jdtls = vim.tbl_extend('error', config, {
uninstall_script = nil -- can be omitted
})
require'lspinstall/servers'.kotlin = vim.tbl_extend('error', config, {
install_script = [[
git clone https://github.com/fwcd/kotlin-language-server.git language-server
cd language-server
./gradlew :server:installDist
]],
uninstall_script = nil -- can be omitted
})
require'lspinstall'.setup()