summaryrefslogtreecommitdiff
path: root/ftplugin/java.lua
blob: 0b151b6609b2bb9c44e0c89d8fed52e3874988bc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
local util = require 'lspconfig/util'
-- In Vimscript
-- augroup lsp
--   au!
--   au FileType java lua require('jdtls').start_or_attach({cmd = {'java-linux-ls'}})
-- augroup end
-- find_root looks for parent directories relative to the current buffer containing one of the given arguments.
-- require'lspconfig'.jdtls.setup {cmd = {'java-linux-ls'}}
-- if vim.fn.has("mac") == 1 then
--     JAVA_LS_EXECUTABLE = 'java-mac-ls'
-- elseif vim.fn.has("unix") == 1 then
--     JAVA_LS_EXECUTABLE = 'java-linux-ls'
-- else
--     print("Unsupported system")
-- end

-- local bundles = {
--     vim.fn.glob(
--         CONFIG_PATH.."/.debuggers/java-debug/com.microsoft.java.debug.plugin/target/com.microsoft.java.debug.plugin-*.jar")
-- };

local on_attach = function(client, bufr)
    -- require('jdtls').setup_dap()
    require'lsp'.common_on_attach(client, bufr)
end

require'lspconfig'.jdtls.setup {
    on_attach = on_attach,
    cmd = {DATA_PATH .. "/lspinstall/java/jdtls.sh"},
    filetypes = { "java" },
    root_dir = util.root_pattern({'.git', 'build.gradle', 'pom.xml'}),
    -- init_options = {bundles = bundles}
    -- on_attach = require'lsp'.common_on_attach
}

-- require('jdtls').start_or_attach({
--     on_attach = on_attach,
--     cmd = {DATA_PATH .. "/lspinstall/java/jdtls.sh"},
--     root_dir = require('jdtls.setup').find_root({'build.gradle', 'pom.xml', '.git'}),
--     init_options = {bundles = bundles}
-- })

-- TODO setup autoformat stuff later
    -- _java = {
    --     -- {'FileType', 'java', 'luafile '..CONFIG_PATH..'/lua/lsp/java-ls.lua'},
    --     {
    --         'FileType', 'java',
    --         'nnoremap ca <Cmd>lua require(\'jdtls\').code_action()<CR>'
    --     }
    -- }