kotlin.lua 1.1 KB

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