mirror of
https://github.com/LunarVim/LunarVim.git
synced 2025-07-24 04:34:42 +02:00
beiginning java support
This commit is contained in:
parent
b68ac7c7b1
commit
d16093b422
8 changed files with 98 additions and 1 deletions
5
init.vim
5
init.vim
|
@ -61,6 +61,7 @@ else
|
||||||
luafile ~/.config/nvim/lua/lsp/lua-ls.lua
|
luafile ~/.config/nvim/lua/lsp/lua-ls.lua
|
||||||
luafile ~/.config/nvim/lua/lsp/python-ls.lua
|
luafile ~/.config/nvim/lua/lsp/python-ls.lua
|
||||||
luafile ~/.config/nvim/lua/lsp/bash-ls.lua
|
luafile ~/.config/nvim/lua/lsp/bash-ls.lua
|
||||||
|
autocmd FileType java luafile ~/.config/nvim/lua/lsp/java-ls.lua
|
||||||
luafile ~/.config/nvim/lua/lsp/css-ls.lua
|
luafile ~/.config/nvim/lua/lsp/css-ls.lua
|
||||||
luafile ~/.config/nvim/lua/lsp/docker-ls.lua
|
luafile ~/.config/nvim/lua/lsp/docker-ls.lua
|
||||||
luafile ~/.config/nvim/lua/lsp/graphql-ls.lua
|
luafile ~/.config/nvim/lua/lsp/graphql-ls.lua
|
||||||
|
@ -84,3 +85,7 @@ endif
|
||||||
" fix space and tab triggering completion all the time
|
" fix space and tab triggering completion all the time
|
||||||
" Provide diagnostics for nvim tree
|
" Provide diagnostics for nvim tree
|
||||||
" port everything possible to lua
|
" port everything possible to lua
|
||||||
|
" augroup lsp
|
||||||
|
" au!
|
||||||
|
" au FileType java lua require('jdtls').start_or_attach({cmd = {'java-linux-ls'}})
|
||||||
|
" augroup end
|
||||||
|
|
|
@ -138,6 +138,29 @@ let g:which_key_map.f = {
|
||||||
\ 'p' : [':Farr --source=rgnvim' , 'project'],
|
\ 'p' : [':Farr --source=rgnvim' , 'project'],
|
||||||
\ }
|
\ }
|
||||||
|
|
||||||
|
" command! -buffer JdtCompile lua require('jdtls').compile()
|
||||||
|
" command! -buffer JdtUpdateConfig lua require('jdtls').update_project_config()
|
||||||
|
" command! -buffer JdtJol lua require('jdtls').jol()
|
||||||
|
" command! -buffer JdtBytecode lua require('jdtls').javap()
|
||||||
|
" command! -buffer JdtJshell lua require('jdtls').jshell()
|
||||||
|
|
||||||
|
" j is for java
|
||||||
|
let g:which_key_map.j = {
|
||||||
|
\ 'name' : '+java' ,
|
||||||
|
\ 'c' : [':AsyncTask file-compile' , 'compile file'],
|
||||||
|
\ 'b' : [':AsyncTask project-build' , 'build project'],
|
||||||
|
\ 'e' : [':AsyncTaskEdit' , 'edit local tasks'],
|
||||||
|
\ 'f' : [':AsyncTaskFzf' , 'find task'],
|
||||||
|
\ 'g' : [':AsyncTaskEdit!' , 'edit global tasks'],
|
||||||
|
\ 'h' : [':AsyncTaskList!' , 'list hidden tasks'],
|
||||||
|
\ 'l' : [':CocList tasks' , 'list tasks'],
|
||||||
|
\ 'm' : [':AsyncTaskMacro' , 'macro help'],
|
||||||
|
\ 'o' : [':copen' , 'open task view'],
|
||||||
|
\ 'r' : [':AsyncTask file-run' , 'run file'],
|
||||||
|
\ 'p' : [':AsyncTask project-run' , 'run project'],
|
||||||
|
\ 'x' : [':cclose' , 'close task view'],
|
||||||
|
\ }
|
||||||
|
|
||||||
" k is for task
|
" k is for task
|
||||||
let g:which_key_map.k = {
|
let g:which_key_map.k = {
|
||||||
\ 'name' : '+task' ,
|
\ 'name' : '+task' ,
|
||||||
|
@ -147,7 +170,6 @@ let g:which_key_map.k = {
|
||||||
\ 'f' : [':AsyncTaskFzf' , 'find task'],
|
\ 'f' : [':AsyncTaskFzf' , 'find task'],
|
||||||
\ 'g' : [':AsyncTaskEdit!' , 'edit global tasks'],
|
\ 'g' : [':AsyncTaskEdit!' , 'edit global tasks'],
|
||||||
\ 'h' : [':AsyncTaskList!' , 'list hidden tasks'],
|
\ 'h' : [':AsyncTaskList!' , 'list hidden tasks'],
|
||||||
\ 'l' : [':CocList tasks' , 'list tasks'],
|
|
||||||
\ 'm' : [':AsyncTaskMacro' , 'macro help'],
|
\ 'm' : [':AsyncTaskMacro' , 'macro help'],
|
||||||
\ 'o' : [':copen' , 'open task view'],
|
\ 'o' : [':copen' , 'open task view'],
|
||||||
\ 'r' : [':AsyncTask file-run' , 'run file'],
|
\ 'r' : [':AsyncTask file-run' , 'run file'],
|
||||||
|
|
|
@ -25,3 +25,13 @@ command! LspShowLineDiagnostics lua require 'lsp-wrapper'.show_line_diagnostics(
|
||||||
" command! LspIncomingCalls lua require 'lsp-wrapper'.incoming_calls()
|
" command! LspIncomingCalls lua require 'lsp-wrapper'.incoming_calls()
|
||||||
" command! LspOutGoingCalls lua require 'lsp-wrapper'.outgoing_calls()
|
" command! LspOutGoingCalls lua require 'lsp-wrapper'.outgoing_calls()
|
||||||
" command! LspDocumentHighlight lua require 'lsp-wrapper'.document_highlight()
|
" command! LspDocumentHighlight lua require 'lsp-wrapper'.document_highlight()
|
||||||
|
|
||||||
|
" Java
|
||||||
|
|
||||||
|
" command! FileType java LspCodeAction <Esc><Cmd>lua require('jdtls').code_action(true)<CR>
|
||||||
|
" command! FileType java LspCodeAction <Esc><Cmd>lua require('jdtls').code_action(false, 'refactor')<CR>
|
||||||
|
|
||||||
|
" nnoremap <A-o> <Cmd>lua require'jdtls'.organize_imports()<CR>
|
||||||
|
" nnoremap crv <Cmd>lua require('jdtls').extract_variable()<CR>
|
||||||
|
" vnoremap crv <Esc><Cmd>lua require('jdtls').extract_variable(true)<CR>
|
||||||
|
" vnoremap crm <Esc><Cmd>lua require('jdtls').extract_method(true)<CR>
|
||||||
|
|
8
lua/lsp/java-ls.lua
Normal file
8
lua/lsp/java-ls.lua
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
-- 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'}}
|
||||||
|
require('jdtls').start_or_attach({cmd = {'java-linux-ls'}, root_dir = require('jdtls.setup').find_root({'gradle.build', 'pom.xml'})})
|
|
@ -17,3 +17,20 @@ autocmd BufWritePre *.jsx lua vim.lsp.buf.formatting_sync(nil, 100)
|
||||||
autocmd BufWritePre *.lua lua vim.lsp.buf.formatting_sync(nil, 100)
|
autocmd BufWritePre *.lua lua vim.lsp.buf.formatting_sync(nil, 100)
|
||||||
" autocmd BufWritePre *.py lua vim.lsp.buf.formatting_sync(nil, 100)
|
" autocmd BufWritePre *.py lua vim.lsp.buf.formatting_sync(nil, 100)
|
||||||
|
|
||||||
|
" -- `code_action` is a superset of vim.lsp.buf.code_action and you'll be able to
|
||||||
|
" -- use this mapping also with other language servers
|
||||||
|
|
||||||
|
autocmd FileType java nnoremap ca <Cmd>lua require('jdtls').code_action()<CR>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
" -- If using nvim-dap
|
||||||
|
" -- This requires java-debug and vscode-java-test bundles, see install steps in this README further below.
|
||||||
|
" nnoremap <leader>df <Cmd>lua require'jdtls'.test_class()<CR>
|
||||||
|
" nnoremap <leader>dn <Cmd>lua require'jdtls'.test_nearest_method()<CR>
|
||||||
|
|
||||||
|
command! -buffer JdtCompile lua require('jdtls').compile()
|
||||||
|
command! -buffer JdtUpdateConfig lua require('jdtls').update_project_config()
|
||||||
|
command! -buffer JdtJol lua require('jdtls').jol()
|
||||||
|
command! -buffer JdtBytecode lua require('jdtls').javap()
|
||||||
|
command! -buffer JdtJshell lua require('jdtls').jshell()
|
||||||
|
|
|
@ -30,3 +30,14 @@ dir
|
||||||
efm
|
efm
|
||||||
LuaRocks
|
LuaRocks
|
||||||
LuaFormatter
|
LuaFormatter
|
||||||
|
SDKMAN
|
||||||
|
sdkman
|
||||||
|
Gradle
|
||||||
|
JVM
|
||||||
|
java
|
||||||
|
gradle
|
||||||
|
kotlin
|
||||||
|
springboot
|
||||||
|
jdtls
|
||||||
|
plugin
|
||||||
|
linux
|
||||||
|
|
Binary file not shown.
24
utils/bin/java-linux-ls
Executable file
24
utils/bin/java-linux-ls
Executable file
|
@ -0,0 +1,24 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# NOTE:
|
||||||
|
# This doesn't work as is on Windows. You'll need to create an equivalent `.bat` file instead
|
||||||
|
#
|
||||||
|
# NOTE:
|
||||||
|
# If you're not using Linux you'll need to adjust the `-configuration` option
|
||||||
|
# to point to the `config_mac' or `config_win` folders depending on your system.
|
||||||
|
|
||||||
|
JAR="$HOME/.config/nvim/eclipse.jdt.ls/org.eclipse.jdt.ls.product/target/repository/plugins/org.eclipse.equinox.launcher_*.jar"
|
||||||
|
GRADLE_HOME=$HOME/gradle $HOME/.sdkman/candidates/java/current/bin/java \
|
||||||
|
-Declipse.application=org.eclipse.jdt.ls.core.id1 \
|
||||||
|
-Dosgi.bundles.defaultStartLevel=4 \
|
||||||
|
-Declipse.product=org.eclipse.jdt.ls.core.product \
|
||||||
|
-Dlog.protocol=true \
|
||||||
|
-Dlog.level=ALL \
|
||||||
|
-Xms1g \
|
||||||
|
-Xmx2G \
|
||||||
|
-jar $(echo "$JAR") \
|
||||||
|
-configuration "$HOME/.config/nvim/eclipse.jdt.ls/org.eclipse.jdt.ls.product/target/repository/config_linux" \
|
||||||
|
-data "${1:-$HOME/workspace}" \
|
||||||
|
--add-modules=ALL-SYSTEM \
|
||||||
|
--add-opens java.base/java.util=ALL-UNNAMED \
|
||||||
|
--add-opens java.base/java.lang=ALL-UNNAMED
|
Loading…
Add table
Add a link
Reference in a new issue