Chris 4 years ago
parent
commit
cd3ac0c6f8
4 changed files with 60 additions and 2 deletions
  1. 14 2
      lua/lsp/java-ls.lua
  2. 0 0
      lua/nv-nvim-dap/init.lua
  3. 33 0
      vimscript/functions.vim
  4. 13 0
      vimscript/nv-whichkey/init.vim

+ 14 - 2
lua/lsp/java-ls.lua

@@ -12,8 +12,20 @@ elseif vim.fn.has("unix") == 1 then
 else
     print("Unsupported system")
 end
+
+local bundles = {
+    vim.fn.glob(
+        "~/.config/nvim/.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('jdtls').start_or_attach({
-    on_attach = require'lsp'.common_on_attach,
+    on_attach = on_attach,
     cmd = {JAVA_LS_EXECUTABLE},
-    root_dir = require('jdtls.setup').find_root({'gradle.build', 'pom.xml'})
+    root_dir = require('jdtls.setup').find_root({'build.gradle', 'pom.xml', '.git'}),
+    init_options = {bundles = bundles}
 })

+ 0 - 0
lua/nv-nvim-dap/init.lua


+ 33 - 0
vimscript/functions.vim

@@ -25,3 +25,36 @@ command! PreviewHunk lua require 'nv-utils'.preview_hunk()
 command! BlameLine lua require 'nv-utils'.blame_line()
 command! W noa w
 
+" Debugging
+command! DebugToggleBreakpoint lua require'dap'.toggle_breakpoint()
+command! DebugStart lua require'dap'.continue()
+command! DebugContinue lua require'dap'.continue()
+command! DebugStepOver lua require'dap'.step_over()
+command! DebugStepOut lua require'dap'.step_out()
+command! DebugStepInto lua require'dap'.step_into()
+command! DebugToggleRepl lua require'dap'.repl.toggle()
+command! DebugGetSession lua require'dap'.session()
+
+" Available Debug Adapters:
+"   https://microsoft.github.io/debug-adapter-protocol/implementors/adapters/
+" 
+" Adapter configuration and installation instructions:
+"   https://github.com/mfussenegger/nvim-dap/wiki/Debug-Adapter-installation
+" 
+" Debug Adapter protocol:
+"   https://microsoft.github.io/debug-adapter-protocol/
+
+" TODO Add full support later
+" nnoremap <silent> <F5> :lua require'dap'.continue()<CR>
+" nnoremap <silent> <F10> :lua require'dap'.step_over()<CR>
+" nnoremap <silent> <F11> :lua require'dap'.step_into()<CR>
+" nnoremap <silent> <F12> :lua require'dap'.step_out()<CR>
+" nnoremap <silent> <leader>b :lua require'dap'.toggle_breakpoint()<CR>
+" nnoremap <silent> <leader>B :lua require'dap'.set_breakpoint(vim.fn.input('Breakpoint condition: '))<CR>
+" nnoremap <silent> <leader>lp :lua require'dap'.set_breakpoint(nil, nil, vim.fn.input('Log point message: '))<CR>
+" nnoremap <silent> <leader>dr :lua require'dap'.repl.open()<CR>
+" nnoremap <silent> <leader>dl :lua require'dap'.run_last()<CR>
+
+" TODO find out why this thing follows me everywhere in java
+let blacklist = ['java']
+autocmd CursorHold,CursorHoldI * if index(blacklist, &ft) < 0 | lua require'nvim-lightbulb'.update_lightbulb()

+ 13 - 0
vimscript/nv-whichkey/init.vim

@@ -85,6 +85,19 @@ let g:which_key_map.b = {
       \ '?' : ['Buffers'                , 'fzf-buffer'],
       \ }
 
+" d is for debug
+let g:which_key_map.d = {
+      \ 'name' : '+debug' ,
+      \ 'b' : ['DebugToggleBreakpoint '        , 'toggle breakpoint'],
+      \ 'c' : ['DebugContinue'                 , 'continue'],
+      \ 'i' : ['DebugStepInto'                 , 'step into'],
+      \ 'o' : ['DebugStepOver'                 , 'step over'],
+      \ 'r' : ['DebugToggleRepl'               , 'toggle repl'],
+      \ 's' : ['DebugStart'                    , 'start'],
+      \ }
+      " \ 'O' : ['DebugStepOut'                  , 'next-buffer'],
+      " \ 'S' : ['DebugGetSession '              , 'fzf-buffer'],
+
 
 " F is for fold
 let g:which_key_map.F = {