java.lua 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. require("lspconfig").jdtls.setup {
  24. on_attach = require("lsp").common_on_attach,
  25. cmd = { DATA_PATH .. "/lspinstall/java/jdtls.sh" },
  26. filetypes = { "java" },
  27. root_dir = util.root_pattern { ".git", "build.gradle", "pom.xml" },
  28. -- init_options = {bundles = bundles}
  29. -- on_attach = require'lsp'.common_on_attach
  30. }
  31. -- require('jdtls').start_or_attach({
  32. -- on_attach = on_attach,
  33. -- cmd = {DATA_PATH .. "/lspinstall/java/jdtls.sh"},
  34. -- root_dir = require('jdtls.setup').find_root({'build.gradle', 'pom.xml', '.git'}),
  35. -- init_options = {bundles = bundles}
  36. -- })
  37. -- TODO setup autoformat stuff later
  38. -- _java = {
  39. -- -- {'FileType', 'java', 'luafile '..CONFIG_PATH..'/lua/lsp/java-ls.lua'},
  40. -- {
  41. -- 'FileType', 'java',
  42. -- 'nnoremap ca <Cmd>lua require(\'jdtls\').code_action()<CR>'
  43. -- }
  44. -- }