Conditionally start jdtls on java buffers

pull/1/head
Ensar Sarajčić 2021-06-11 13:00:32 +02:00
parent ff9241b096
commit 2ad912368f
4 changed files with 25 additions and 7 deletions

View File

@ -0,0 +1,4 @@
augroup lsp
au!
au FileType java lua require('jdtls').start_or_attach({cmd = {'jdtls-startup.sh'}; on_attach = require'lsp.servers'.jdtls_on_attach})
augroup end

View File

@ -25,7 +25,7 @@ local on_attach = function(client, bufnr)
end
-- Lsp default language servers
local servers = { "bashls", "clangd", "jsonls", "pyright", "rust_analyzer", "kotlin_language_server", "vimls", "clojure_lsp", "gopls", "gdscript" }
local servers = { "bashls", "clangd", "jsonls", "pyright", "rust_analyzer", "kotlin_language_server", "vimls", "clojure_lsp", "gopls", "gdscript", "tsserver" }
for _, lsp in ipairs(servers) do
lspconfig[lsp].setup { on_attach = on_attach }
end
@ -54,7 +54,8 @@ lspconfig.omnisharp.setup {
}
-- JDTLS (Java)
local jdstls_on_attach = function(client, bufnr)
-- Can't be local currently, because autocommand has to be used
jdtls_on_attach = function(client, bufnr)
local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end
local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end
@ -67,8 +68,3 @@ local jdstls_on_attach = function(client, bufnr)
buf_set_keymap('n', '<A-CR>', "<cmd>lua require('jdtls').code_action()<CR>", default_opts)
buf_set_keymap('n', '<Leader>ac', "<cmd>lua require('jdtls').code_action()<CR>", default_opts)
end
require('jdtls').start_or_attach {
cmd = {'jdtls-startup.sh'};
on_attach = jdstls_on_attach;
}

View File

@ -22,6 +22,24 @@ dap.configurations.python = {
},
}
local netcoredbg_bin = vim.fn.glob('$HOME') .. "/dap/netcoredbg/netcoredbg"
dap.adapters.netcoredbg = {
type = 'executable',
command = netcoredbg_bin,
args = {'--interpreter=vscode'}
}
dap.configurations.cs = {
{
type = "netcoredbg",
name = "launch - netcoredbg",
request = "launch",
program = function()
return vim.fn.input('Path to dll', vim.fn.getcwd() .. '/bin/Debug/', 'file')
end,
},
}
-- Nvim DAP Treesitter integration
vim.g.dap_virtual_text = true