java-ls.lua 695 B

12345678910111213141516171819
  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. require('jdtls').start_or_attach({
  16. on_attach = require'lsp'.common_on_attach,
  17. cmd = {JAVA_LS_EXECUTABLE},
  18. root_dir = require('jdtls.setup').find_root({'gradle.build', 'pom.xml'})
  19. })