java.lua 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. if require("lv-utils").check_lsp_client_active "jdtls" then
  2. return
  3. end
  4. local util = require "lspconfig/util"
  5. -- In Vimscript
  6. -- augroup lsp
  7. -- au!
  8. -- au FileType java lua require('jdtls').start_or_attach({cmd = {'java-linux-ls'}})
  9. -- augroup end
  10. -- find_root looks for parent directories relative to the current buffer containing one of the given arguments.
  11. -- require'lspconfig'.jdtls.setup {cmd = {'java-linux-ls'}}
  12. -- if vim.fn.has("mac") == 1 then
  13. -- JAVA_LS_EXECUTABLE = 'java-mac-ls'
  14. -- elseif vim.fn.has("unix") == 1 then
  15. -- JAVA_LS_EXECUTABLE = 'java-linux-ls'
  16. -- else
  17. -- print("Unsupported system")
  18. -- end
  19. -- local bundles = {
  20. -- vim.fn.glob(
  21. -- CONFIG_PATH.."/.debuggers/java-debug/com.microsoft.java.debug.plugin/target/com.microsoft.java.debug.plugin-*.jar")
  22. -- };
  23. local on_attach = function(client, bufr)
  24. -- require('jdtls').setup_dap()
  25. require("lsp").common_on_attach(client, bufr)
  26. end
  27. require("lspconfig").jdtls.setup {
  28. on_attach = on_attach,
  29. cmd = { DATA_PATH .. "/lspinstall/java/jdtls.sh" },
  30. filetypes = { "java" },
  31. root_dir = util.root_pattern { ".git", "build.gradle", "pom.xml" },
  32. -- init_options = {bundles = bundles}
  33. -- on_attach = require'lsp'.common_on_attach
  34. }
  35. -- require('jdtls').start_or_attach({
  36. -- on_attach = on_attach,
  37. -- cmd = {DATA_PATH .. "/lspinstall/java/jdtls.sh"},
  38. -- root_dir = require('jdtls.setup').find_root({'build.gradle', 'pom.xml', '.git'}),
  39. -- init_options = {bundles = bundles}
  40. -- })
  41. -- TODO setup autoformat stuff later
  42. -- _java = {
  43. -- -- {'FileType', 'java', 'luafile '..CONFIG_PATH..'/lua/lsp/java-ls.lua'},
  44. -- {
  45. -- 'FileType', 'java',
  46. -- 'nnoremap ca <Cmd>lua require(\'jdtls\').code_action()<CR>'
  47. -- }
  48. -- }