UNPKG

colson-nvim

Version:

Colson Nvim: Neovim Code Editor/IDE for Software Engineers!

405 lines (319 loc) โ€ข 11.9 kB
# ๐ŸŽน Complete Java Keybindings Reference > **Leader Key = `<Space>`** (Already configured in your setup) --- ## ๐Ÿ“ฆ Build & Run Operations | Keybinding | Mode | Action | Description | |------------|------|--------|-------------| | `<Space>jb` | Normal | Build Workspace | Compile entire Java workspace | | `<Space>jc` | Normal | Clean Workspace | Clean and rebuild project | | `<Space>jr` | Normal | Run Main | Execute main class | | `<Space>jR` | Normal | Run with Args | Run main class with custom arguments (prompts) | | `<Space>js` | Normal | Stop Application | Stop running Java application | | `<Space>jl` | Normal | Toggle Logs | Show/hide application logs | **Mnemonic**: `j` = Java, `b` = Build, `r` = Run, `c` = Clean, `s` = Stop, `l` = Logs --- ## ๐Ÿงช Testing Operations (Built-in) | Keybinding | Mode | Action | Description | |------------|------|--------|-------------| | `<Space>jt` | Normal | Run Test Class | Run all tests in current file | | `<Space>jm` | Normal | Run Test Method | Run single test at cursor | | `<Space>jT` | Normal | View Test Report | Show last test execution results | **Mnemonic**: `j` = Java, `t` = Test, `m` = Method --- ## ๐Ÿ”ฌ Testing Operations (Neotest - Advanced) | Keybinding | Mode | Action | Description | |------------|------|--------|-------------| | `<Space>jtn` | Normal | Test Nearest | Run nearest test to cursor | | `<Space>jtf` | Normal | Test File | Run all tests in current file | | `<Space>jts` | Normal | Test Summary | Toggle test summary panel | | `<Space>jto` | Normal | Test Output | Open test output window | | `<Space>jtw` | Normal | Test Watch | Toggle watch mode (auto-run on save) | **Mnemonic**: `jt` = Java Test, `n` = Nearest, `f` = File, `s` = Summary, `o` = Output, `w` = Watch --- ## ๐Ÿ› Debugging Operations ### Java Debug Controls | Keybinding | Mode | Action | Description | |------------|------|--------|-------------| | `<Space>jdc` | Normal | Debug Test Class | Debug all tests in current file | | `<Space>jdm` | Normal | Debug Test Method | Debug single test at cursor | | `<Space>jdd` | Normal | Configure DAP | Reconfigure debug adapter | **Mnemonic**: `jd` = Java Debug, `c` = Class, `m` = Method, `d` = DAP ### General Debug Controls | Keybinding | Mode | Action | Description | |------------|------|--------|-------------| | `<Space>db` | Normal | Toggle Breakpoint | Set/remove breakpoint at current line | | `<Space>dB` | Normal | Conditional Breakpoint | Set breakpoint with condition (prompts) | | `<Space>dlp` | Normal | Log Point | Set log point (prints without stopping) | | `<F5>` | Normal | Continue | Start debugging or continue execution | | `<F10>` | Normal | Step Over | Execute current line, skip function calls | | `<F11>` | Normal | Step Into | Step into function call | | `<F12>` | Normal | Step Out | Step out of current function | | `<Space>dr` | Normal | REPL | Open debug REPL console | | `<Space>dl` | Normal | Run Last | Repeat last debug configuration | | `<Space>du` | Normal | Toggle Debug UI | Show/hide debug panels | | `<Space>de` | Normal | Evaluate | Evaluate expression under cursor | **Mnemonic**: `d` = Debug, `b` = Breakpoint, `r` = REPL, `l` = Last, `u` = UI, `e` = Eval --- ## ๐Ÿ”ง Refactoring Operations | Keybinding | Mode | Action | Description | |------------|------|--------|-------------| | `<Space>jrv` | Visual | Extract Variable | Extract selection into variable | | `<Space>jra` | Visual | Extract All | Extract all occurrences into variable | | `<Space>jrc` | Visual | Extract Constant | Extract selection into constant | | `<Space>jrm` | Visual | Extract Method | Extract selection into method | | `<Space>jrf` | Normal | Extract Field | Extract value into class field | **Mnemonic**: `jr` = Java Refactor, `v` = Variable, `a` = All, `c` = Constant, `m` = Method, `f` = Field **Usage**: Select code in Visual mode first, then press keybinding --- ## ๐ŸŒฑ Spring Boot Operations | Keybinding | Mode | Action | Description | |------------|------|--------|-------------| | `<Space>jn` | Normal | New Project | Create new Spring Boot project (Initializr) | | `<Space>ju` | Normal | Update Versions | Update Spring Boot version list | **Mnemonic**: `j` = Java, `n` = New, `u` = Update --- ## โ˜• JDK Management | Keybinding | Mode | Action | Description | |------------|------|--------|-------------| | `<Space>jv` | Normal | Change Version | Switch JDK version/runtime | **Mnemonic**: `jv` = Java Version --- ## ๐Ÿ” LSP Features (Already in your config) | Keybinding | Mode | Action | Description | |------------|------|--------|-------------| | `gd` | Normal | Go to Definition | Jump to symbol definition | | `gD` | Normal | Go to Declaration | Jump to symbol declaration | | `K` | Normal | Hover Info | Show documentation popup | | `<Space>vws` | Normal | Workspace Symbols | Search symbols in workspace | | `<Space>vd` | Normal | View Diagnostic | Show diagnostic float | | `<Space>sd` | Normal | Show Diagnostic | Show diagnostic float (alias) | | `<Space>dd` | Normal | Show Diagnostic | Show diagnostic float (alias) | | `[d` | Normal | Next Diagnostic | Jump to next error/warning | | `]d` | Normal | Previous Diagnostic | Jump to previous error/warning | | `<Space>vca` | Normal | Code Actions | Show available code actions | | `<Space>vrr` | Normal | References | Show all references | | `<Space>vrn` | Normal | Rename | Rename symbol | | `<Ctrl-h>` | Insert | Signature Help | Show function signature | **Mnemonic**: `v` = View, `ws` = Workspace, `d` = Diagnostic, `ca` = Code Action, `rr` = References, `rn` = Rename --- ## ๐Ÿ“Š Quick Summary Tables ### ๐ŸŽฏ Top 10 Most Used (Memorize These First!) | # | Keybinding | What It Does | When to Use | |---|------------|--------------|-------------| | 1 | `<Space>jr` | Run main class | After writing code | | 2 | `<Space>jb` | Build project | Before running | | 3 | `<Space>jt` | Run all tests | Test entire class | | 4 | `<Space>jm` | Run single test | Test one method | | 5 | `gd` | Go to definition | Navigate code | | 6 | `K` | Show docs | Learn about method | | 7 | `<Space>vca` | Code actions | Quick fixes | | 8 | `<Space>db` | Toggle breakpoint | Debugging | | 9 | `<F5>` | Start/continue debug | Debugging | | 10 | `<Space>jn` | New Spring project | Start new project | --- ### ๐Ÿ”ค All Keybindings by Category #### Build Category (`j` prefix) ``` <Space>jb โ†’ Build <Space>jc โ†’ Clean <Space>jr โ†’ Run <Space>jR โ†’ Run with args <Space>js โ†’ Stop <Space>jl โ†’ Logs <Space>jv โ†’ Version (JDK) <Space>jn โ†’ New (Spring project) <Space>ju โ†’ Update (Spring versions) ``` #### Test Category (`jt` prefix) ``` <Space>jt โ†’ Test class <Space>jm โ†’ Test method <Space>jT โ†’ Test report <Space>jtn โ†’ Test nearest <Space>jtf โ†’ Test file <Space>jts โ†’ Test summary <Space>jto โ†’ Test output <Space>jtw โ†’ Test watch ``` #### Debug Category (`jd` and `d` prefix) ``` <Space>jdc โ†’ Debug class <Space>jdm โ†’ Debug method <Space>jdd โ†’ Debug DAP config <Space>db โ†’ Breakpoint <Space>dB โ†’ Conditional breakpoint <Space>dlp โ†’ Log point <Space>dr โ†’ REPL <Space>dl โ†’ Last config <Space>du โ†’ UI toggle <Space>de โ†’ Eval <F5> โ†’ Continue <F10> โ†’ Step over <F11> โ†’ Step into <F12> โ†’ Step out ``` #### Refactor Category (`jr` prefix, Visual mode) ``` <Space>jrv โ†’ Extract variable <Space>jra โ†’ Extract all occurrences <Space>jrc โ†’ Extract constant <Space>jrm โ†’ Extract method <Space>jrf โ†’ Extract field ``` #### LSP Category (`v` prefix) ``` gd โ†’ Go to definition K โ†’ Hover info <Space>vws โ†’ Workspace symbols <Space>vd โ†’ View diagnostic <Space>vca โ†’ Code actions <Space>vrr โ†’ References <Space>vrn โ†’ Rename [d โ†’ Next diagnostic ]d โ†’ Previous diagnostic ``` --- ## ๐ŸŽจ Visual Guide ### Prefix Meanings ``` <Space>j โ†’ Java operations <Space>jt โ†’ Java Testing <Space>jd โ†’ Java Debugging <Space>jr โ†’ Java Refactoring <Space>d โ†’ General Debugging <Space>v โ†’ View/LSP operations <F-keys> โ†’ Debug execution control ``` ### Mnemonic System ``` b = Build r = Run c = Clean s = Stop t = Test m = Method n = New/Nearest f = File d = Debug u = UI/Update v = Variable a = All e = Eval l = Logs/Last w = Watch o = Output ``` --- ## ๐ŸŽฏ Workflow Examples ### Example 1: Run Your Application ``` 1. <Space>jb โ†’ Build the project 2. <Space>jr โ†’ Run main class 3. <Space>jl โ†’ View logs if needed 4. <Space>js โ†’ Stop when done ``` ### Example 2: Test-Driven Development ``` 1. Write a test method 2. <Space>jm โ†’ Run the test (it fails) 3. Write implementation code 4. <Space>jm โ†’ Run test again (passes!) 5. <Space>jt โ†’ Run all tests to verify ``` ### Example 3: Debug a Test ``` 1. <Space>db โ†’ Set breakpoint on line 2. <Space>jdm โ†’ Debug test method 3. <F11> โ†’ Step into method 4. <Space>de โ†’ Evaluate variable 5. <F5> โ†’ Continue execution 6. <Space>du โ†’ Close debug UI ``` ### Example 4: Refactor Code ``` 1. Select code in Visual mode (v or V) 2. <Space>jrm โ†’ Extract into method 3. Type new method name 4. <Space>vca โ†’ Show code actions 5. Choose "Generate JavaDoc" ``` ### Example 5: Create Spring Boot Project ``` 1. <Space>jn โ†’ Open Spring Initializr 2. Select: Gradle, Java, Spring Boot 3.4.1 3. Add dependencies (type to search): - Spring Web - Spring Data JPA - PostgreSQL Driver 4. Press Enter to generate 5. Project opens automatically! ``` --- ## ๐Ÿš€ Pro Tips ### Speed Typing - Type `sysout` then Tab โ†’ `System.out.println()` - Type `psvm` then Tab โ†’ `public static void main(String[] args)` - Type `fori` then Tab โ†’ `for (int i = 0; i < ; i++)` ### Quick Navigation - `<Space>ff` โ†’ Find files (Telescope) - `<Space>fg` โ†’ Find in files (grep) - `<Space>fb` โ†’ Find buffers ### Code Actions (`<Space>vca`) When you press this, you can: - Generate constructor - Generate getters/setters - Generate toString() - Generate equals() and hashCode() - Organize imports - Add JavaDoc - Override methods - Implement interface methods - Suppress warnings ### Watch Mode Testing ``` <Space>jtw โ†’ Enable watch mode Now every time you save a Java file: โœ“ Tests run automatically โœ“ See results instantly โœ“ Perfect for TDD! ``` --- ## ๐ŸŽ“ Learning Path ### Week 1: Master These ``` <Space>jr (Run) <Space>jb (Build) gd (Go to definition) K (Hover docs) ``` ### Week 2: Add These ``` <Space>jt (Test class) <Space>jm (Test method) <Space>vca (Code actions) <Space>vrn (Rename) ``` ### Week 3: Add These ``` <Space>db (Breakpoint) <F5> (Debug) <Space>jrm (Extract method) <Space>jn (New Spring project) ``` ### Month 1+: Master Everything! By this point, your fingers will know all keybindings automatically! --- ## ๐Ÿ“ File Location This file is located at: ``` ~/.config/nvim/JAVA_KEYBINDINGS.md ``` All keybindings are defined in: ``` ~/.config/nvim/after/plugin/java.lua ``` Lines 481-655 contain all the keybinding definitions. --- ## ๐ŸŽ‰ Quick Command Reference Need to run Vim commands? Here are common ones: ```vim :JavaRestart " Restart JDTLS :Mason " Manage packages :LspInfo " Show LSP status :JavaProjectInfo " Show project info :checkhealth java " Health check :Springtime " Same as <Space>jn :JavaBuildBuildWorkspace " Same as <Space>jb :JavaRunnerRunMain " Same as <Space>jr ``` --- **Pro Tip**: Print this page and keep it next to your keyboard for the first week! After that, the keybindings will be muscle memory! ๐Ÿ’ช