java-ls.lua 1014 B

12345678910111213141516171819202122232425262728293031
  1. -- In Vimscript
  2. -- augroup lsp
  3. -- au!
  4. -- au FileType java lua require('jdtls').start_or_attach({cmd = {'java-linux-ls'}})
  5. -- augroup end
  6. -- find_root looks for parent directories relative to the current buffer containing one of the given arguments.
  7. -- require'lspconfig'.jdtls.setup {cmd = {'java-linux-ls'}}
  8. if vim.fn.has("mac") == 1 then
  9. JAVA_LS_EXECUTABLE = 'java-mac-ls'
  10. elseif vim.fn.has("unix") == 1 then
  11. JAVA_LS_EXECUTABLE = 'java-linux-ls'
  12. else
  13. print("Unsupported system")
  14. end
  15. local bundles = {
  16. vim.fn.glob(
  17. CONFIG_PATH.."/.debuggers/java-debug/com.microsoft.java.debug.plugin/target/com.microsoft.java.debug.plugin-*.jar")
  18. };
  19. local on_attach = function(client, bufr)
  20. require('jdtls').setup_dap()
  21. require'lsp'.common_on_attach(client, bufr)
  22. end
  23. require('jdtls').start_or_attach({
  24. on_attach = on_attach,
  25. cmd = {JAVA_LS_EXECUTABLE},
  26. root_dir = require('jdtls.setup').find_root({'build.gradle', 'pom.xml', '.git'}),
  27. init_options = {bundles = bundles}
  28. })