kotlin.lua 1.6 KB

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