java-ls.lua 1.4 KB

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