lsp-config.vim 1.8 KB

123456789101112131415161718192021222324252627282930313233343536
  1. " LSP config (the mappings used in the default file don't quite work right)
  2. nnoremap <silent> gd <cmd>lua vim.lsp.buf.definition()<CR>
  3. nnoremap <silent> gD <cmd>lua vim.lsp.buf.declaration()<CR>
  4. nnoremap <silent> gr <cmd>lua vim.lsp.buf.references()<CR>
  5. nnoremap <silent> gi <cmd>lua vim.lsp.buf.implementation()<CR>
  6. nnoremap <silent> ca :Lspsaga code_action<CR>
  7. " nnoremap <silent> K <cmd>lua vim.lsp.buf.hover()<CR>
  8. nnoremap <silent> K :Lspsaga hover_doc<CR>
  9. nnoremap <silent> <C-k> <cmd>lua vim.lsp.buf.signature_help()<CR>
  10. " nnoremap <silent> <C-p> <cmd>lua vim.lsp.diagnostic.goto_prev()<CR>
  11. " nnoremap <silent> <C-n> <cmd>lua vim.lsp.diagnostic.goto_next()<CR>
  12. nnoremap <silent> <C-p> :Lspsaga diagnostic_jump_prev<CR>
  13. nnoremap <silent> <C-n> :Lspsaga diagnostic_jump_next<CR>
  14. " autoformat
  15. autocmd BufWritePre *.js lua vim.lsp.buf.formatting_sync(nil, 100)
  16. autocmd BufWritePre *.jsx lua vim.lsp.buf.formatting_sync(nil, 100)
  17. autocmd BufWritePre *.lua lua vim.lsp.buf.formatting_sync(nil, 100)
  18. " autocmd BufWritePre *.py lua vim.lsp.buf.formatting_sync(nil, 100)
  19. " -- `code_action` is a superset of vim.lsp.buf.code_action and you'll be able to
  20. " -- use this mapping also with other language servers
  21. autocmd FileType java nnoremap ca <Cmd>lua require('jdtls').code_action()<CR>
  22. " -- If using nvim-dap
  23. " -- This requires java-debug and vscode-java-test bundles, see install steps in this README further below.
  24. " nnoremap <leader>df <Cmd>lua require'jdtls'.test_class()<CR>
  25. " nnoremap <leader>dn <Cmd>lua require'jdtls'.test_nearest_method()<CR>
  26. command! -buffer JdtCompile lua require('jdtls').compile()
  27. command! -buffer JdtUpdateConfig lua require('jdtls').update_project_config()
  28. command! -buffer JdtJol lua require('jdtls').jol()
  29. command! -buffer JdtBytecode lua require('jdtls').javap()
  30. command! -buffer JdtJshell lua require('jdtls').jshell()