kotlin.lua 1.6 KB

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