WIP: Not working yet

This commit is contained in:
Marko Korhonen 2022-03-02 20:19:11 +02:00
parent 170fe31f6b
commit 8af3cdd256
3 changed files with 42 additions and 43 deletions

View File

@ -1,7 +1,7 @@
local nvim_local_dir = vim.fn.expand('~/.local/share/nvim') local nvim_local_dir = vim.fn.expand('~/.local/share/nvim')
local project_name = vim.fn.fnamemodify(vim.fn.getcwd(), ':p:h:t') local project_name = vim.fn.fnamemodify(vim.fn.getcwd(), ':p:h:t')
local workspace_dir = nvim_local_dir .. '/jdtls-workspaces/' .. project_name local workspace_dir = nvim_local_dir .. '/jdtls-workspaces/' .. project_name
require('jdtls').start_or_attach({ require('jdtls').start_or_attach({
cmd = { cmd = {
'java', '-Declipse.application=org.eclipse.jdt.ls.core.id1', 'java', '-Declipse.application=org.eclipse.jdt.ls.core.id1',
@ -10,10 +10,11 @@ require('jdtls').start_or_attach({
'-Dlog.protocol=true', '-Dlog.level=ALL', '-Xms1g', '-Dlog.protocol=true', '-Dlog.level=ALL', '-Xms1g',
'--add-modules=ALL-SYSTEM', '--add-opens', '--add-modules=ALL-SYSTEM', '--add-opens',
'java.base/java.util=ALL-UNNAMED', '--add-opens', 'java.base/java.util=ALL-UNNAMED', '--add-opens',
'java.base/java.lang=ALL-UNNAMED', -- 💀 'java.base/java.lang=ALL-UNNAMED', '-jar', nvim_local_dir ..
'-jar', nvim_local_dir ..
'/lsp_servers/jdtls/plugins/org.eclipse.equinox.launcher_1.6.400.v20210924-0641.jar', '/lsp_servers/jdtls/plugins/org.eclipse.equinox.launcher_1.6.400.v20210924-0641.jar',
'-configuration', nvim_local_dir .. '/lsp_servers/jdtls/config_linux', '-configuration', nvim_local_dir .. '/lsp_servers/jdtls/config_linux',
'-data', workspace_dir '-data', workspace_dir
} }
}) })
require('pluginconf.lsp').Lsp_map_keys('jdtls', nil)

View File

@ -1,47 +1,45 @@
local lsp_installer = require("nvim-lsp-installer") local lsp_installer = require("nvim-lsp-installer")
local buf_map_keys = function(server_name, bufnr) Lsp_map_keys = function(server, bufnr)
local function buf_set_keymap(...) print("Lsp_map_keys()")
local function map_key(...)
-- Map to buffer if buffer number is supplied,
-- globally otherwise
if bufnr == nil then
vim.api.nvim_set_keymap(...)
else
vim.api.nvim_buf_set_keymap(bufnr, ...) vim.api.nvim_buf_set_keymap(bufnr, ...)
end end
end
local keymapOpts = {noremap = true, silent = true} local keymapOpts = {noremap = true, silent = true}
buf_set_keymap('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', map_key('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', keymapOpts)
map_key('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', keymapOpts)
map_key('n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', keymapOpts)
map_key('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', keymapOpts)
map_key('n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>',
keymapOpts) keymapOpts)
buf_set_keymap('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', map_key('n', '<space>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>',
keymapOpts) keymapOpts)
buf_set_keymap('n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', keymapOpts) map_key('n', '<space>wr',
buf_set_keymap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', keymapOpts)
keymapOpts) map_key('n', '<space>wl',
buf_set_keymap('n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>',
keymapOpts)
buf_set_keymap('n', '<space>wa',
'<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', keymapOpts)
buf_set_keymap('n', '<space>wr',
'<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>',
keymapOpts)
buf_set_keymap('n', '<space>wl',
'<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>',
keymapOpts) keymapOpts)
buf_set_keymap('n', '<space>D', map_key('n', '<space>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>',
'<cmd>lua vim.lsp.buf.type_definition()<CR>', keymapOpts)
buf_set_keymap('n', '<space>rn', '<cmd>lua vim.lsp.buf.rename()<CR>',
keymapOpts) keymapOpts)
buf_set_keymap('n', '<space>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', map_key('n', '<space>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', keymapOpts)
map_key('n', '<space>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>',
keymapOpts) keymapOpts)
buf_set_keymap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', map_key('n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', keymapOpts)
keymapOpts) map_key('n', '<space>e',
buf_set_keymap('n', '<space>e',
'<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>', '<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>',
keymapOpts) keymapOpts)
buf_set_keymap('n', '[d', '<cmd>lua vim.diagnostic.goto_prev()<CR>', map_key('n', '[d', '<cmd>lua vim.diagnostic.goto_prev()<CR>', keymapOpts)
keymapOpts) map_key('n', ']d', '<cmd>lua vim.diagnostic.goto_next()<CR>', keymapOpts)
buf_set_keymap('n', ']d', '<cmd>lua vim.diagnostic.goto_next()<CR>', map_key('n', '<space>q', '<cmd>lua vim.diagnostic.set_loclist()<CR>',
keymapOpts)
buf_set_keymap('n', '<space>q', '<cmd>lua vim.diagnostic.set_loclist()<CR>',
keymapOpts)
buf_set_keymap('n', '<space>f', '<cmd>lua vim.lsp.buf.formatting()<CR>',
keymapOpts) keymapOpts)
map_key('n', '<space>f', '<cmd>lua vim.lsp.buf.formatting()<CR>', keymapOpts)
end end
-- Add additional capabilities supported by nvim-cmp -- Add additional capabilities supported by nvim-cmp
@ -80,7 +78,7 @@ lsp_installer.on_server_ready(function(server)
} }
end end
opts.on_attach = buf_map_keys opts.on_attach = Lsp_map_keys
opts.capabilities = capabilities opts.capabilities = capabilities
server:setup(opts) server:setup(opts)
end) end)