kotlin.lua 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. local M = {}
  2. M.config = function()
  3. O.lang.kotlin = {}
  4. end
  5. M.format = function()
  6. -- TODO: implement formatter for language
  7. return "No formatter available!"
  8. end
  9. M.lint = function()
  10. -- TODO: implement linters (if applicable)
  11. return "No linters configured!"
  12. end
  13. M.lsp = function()
  14. if require("lv-utils").check_lsp_client_active "kotlin_language_server" then
  15. return
  16. end
  17. --- default config for gradle-projects of the
  18. --- kotlin-language-server: https://github.com/fwcd/kotlin-language-server
  19. ---
  20. --- This server requires vim to be aware of the kotlin-filetype.
  21. --- You could refer for this capability to:
  22. --- https://github.com/udalov/kotlin-vim (recommended)
  23. --- Note that there is no LICENSE specified yet.
  24. local util = require "lspconfig/util"
  25. local bin_name = DATA_PATH .. "/lspinstall/kotlin/server/bin/kotlin-language-server"
  26. if vim.fn.has "win32" == 1 then
  27. bin_name = bin_name .. ".bat"
  28. end
  29. local root_files = {
  30. "settings.gradle", -- Gradle (multi-project)
  31. "settings.gradle.kts", -- Gradle (multi-project)
  32. "build.xml", -- Ant
  33. "pom.xml", -- Maven
  34. }
  35. local fallback_root_files = {
  36. "build.gradle", -- Gradle
  37. "build.gradle.kts", -- Gradle
  38. }
  39. require("lspconfig").kotlin_language_server.setup {
  40. cmd = { bin_name },
  41. on_attach = require("lsp").common_on_attach,
  42. root_dir = function(fname)
  43. return util.root_pattern(unpack(root_files))(fname) or util.root_pattern(unpack(fallback_root_files))(fname)
  44. end,
  45. }
  46. end
  47. M.dap = function()
  48. -- TODO: implement dap
  49. return "No DAP configured!"
  50. end
  51. return M