kotlin-ls.lua 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. --- default config for gradle-projects of the
  2. --- kotlin-language-server: https://github.com/fwcd/kotlin-language-server
  3. ---
  4. --- This server requires vim to be aware of the kotlin-filetype.
  5. --- You could refer for this capability to:
  6. --- https://github.com/udalov/kotlin-vim (recommended)
  7. --- Note that there is no LICENSE specified yet.
  8. local util = require 'lspconfig/util'
  9. local bin_name = DATA_PATH .. "/lspinstall/kotlin/language-server/server/build/install/server/bin/kotlin-language-server"
  10. if vim.fn.has('win32') == 1 then
  11. bin_name = bin_name..".bat"
  12. end
  13. local root_files = {
  14. 'settings.gradle', -- Gradle (multi-project)
  15. 'settings.gradle.kts', -- Gradle (multi-project)
  16. 'build.xml', -- Ant
  17. 'pom.xml', -- Maven
  18. }
  19. local fallback_root_files = {
  20. 'build.gradle', -- Gradle
  21. 'build.gradle.kts', -- Gradle
  22. }
  23. require'lspconfig'.kotlin_language_server.setup {
  24. cmd = {bin_name},
  25. on_attach = require'lsp'.common_on_attach,
  26. root_dir = function(fname)
  27. return util.root_pattern(unpack(root_files))(fname) or
  28. util.root_pattern(unpack(fallback_root_files))(fname)
  29. end
  30. }