update
This commit is contained in:
parent
3d3aa7d6a5
commit
44ed5b0b50
4 changed files with 233 additions and 4 deletions
183
KEYMAPS.md
Normal file
183
KEYMAPS.md
Normal file
|
|
@ -0,0 +1,183 @@
|
||||||
|
# Neovim Keymaps
|
||||||
|
|
||||||
|
**Leader key = `Space`**
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## File & Buffer
|
||||||
|
|
||||||
|
| Key | What it does |
|
||||||
|
|-----|-------------|
|
||||||
|
| `<leader>w` | Save the current file |
|
||||||
|
| `<leader>q` | Quit Neovim |
|
||||||
|
| `<leader>c` | Close the current buffer |
|
||||||
|
| `<leader>bc` | Save all buffers, then close everything except the current one |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Navigation
|
||||||
|
|
||||||
|
| Key | What it does |
|
||||||
|
|-----|-------------|
|
||||||
|
| `e` | Jump to end of line |
|
||||||
|
| `s` | Jump to first non-blank character of line |
|
||||||
|
| `cb` | Go back to previous location (like browser back) |
|
||||||
|
| `cf` | Go forward (undo a `cb`) |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Windows & Splits
|
||||||
|
|
||||||
|
| Key | What it does |
|
||||||
|
|-----|-------------|
|
||||||
|
| `<leader>v` | Open a vertical split |
|
||||||
|
| `<leader>h` | Open a horizontal split |
|
||||||
|
| `Ctrl+h` | Move focus to the left window |
|
||||||
|
| `Ctrl+j` | Move focus to the window below |
|
||||||
|
| `Ctrl+k` | Move focus to the window above |
|
||||||
|
| `Ctrl+l` | Move focus to the right window |
|
||||||
|
| `Ctrl+Up` | Make current window shorter |
|
||||||
|
| `Ctrl+Down` | Make current window taller |
|
||||||
|
| `Ctrl+Left` | Make current window narrower |
|
||||||
|
| `Ctrl+Right` | Make current window wider |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## File Tree (NERDTree)
|
||||||
|
|
||||||
|
| Key | What it does |
|
||||||
|
|-----|-------------|
|
||||||
|
| `<leader>n` | Show/hide the file explorer sidebar |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Fuzzy Finder (Telescope)
|
||||||
|
|
||||||
|
| Key | What it does |
|
||||||
|
|-----|-------------|
|
||||||
|
| `<leader>ff` | Search for files by name |
|
||||||
|
| `<leader>fg` | Search for text inside files (live grep) |
|
||||||
|
| `<leader>fb` | List all open buffers |
|
||||||
|
| `<leader>fh` | Search Neovim help topics |
|
||||||
|
|
||||||
|
**Inside a Telescope window:**
|
||||||
|
|
||||||
|
| Key | What it does |
|
||||||
|
|-----|-------------|
|
||||||
|
| `Ctrl+n` | Move to next result |
|
||||||
|
| `Ctrl+p` | Move to previous result |
|
||||||
|
| `Ctrl+d` | Delete the selected buffer |
|
||||||
|
| `Ctrl+c` | Close Telescope |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Clipboard
|
||||||
|
|
||||||
|
| Key | What it does |
|
||||||
|
|-----|-------------|
|
||||||
|
| `<leader>y` (visual) | Copy selected text to system clipboard |
|
||||||
|
| `<leader>p` | Paste from system clipboard |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Search
|
||||||
|
|
||||||
|
| Key | What it does |
|
||||||
|
|-----|-------------|
|
||||||
|
| `<leader>/` | Clear the search highlight |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## LSP (Code Intelligence)
|
||||||
|
|
||||||
|
| Key | What it does |
|
||||||
|
|-----|-------------|
|
||||||
|
| `gd` | Go to the definition of the symbol under cursor |
|
||||||
|
| `K` | Show documentation for the symbol under cursor |
|
||||||
|
| `<leader>rn` | Rename the symbol under cursor across the project |
|
||||||
|
| `gr` | Show all references to the symbol (opens in Trouble panel) |
|
||||||
|
| `<leader>f` | Format the current file using the LSP |
|
||||||
|
| `<leader>a` | Show code actions (quick fixes, refactors) |
|
||||||
|
| `<leader>d` | Show hover documentation (same as `K`) |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Comments (Comment.nvim)
|
||||||
|
|
||||||
|
| Key | What it does |
|
||||||
|
|-----|-------------|
|
||||||
|
| `<leader>kk` | Toggle comment on the current line |
|
||||||
|
| `<leader>k` + motion | Comment/uncomment everything the motion covers (e.g. `<leader>k3j` comments 3 lines down) |
|
||||||
|
| `<leader>k` (visual) | Comment/uncomment the selected lines |
|
||||||
|
| `<leader>bb` | Toggle block comment on the current line |
|
||||||
|
| `<leader>b` + motion | Block comment everything the motion covers |
|
||||||
|
| `<leader>b` (visual) | Block comment the selection |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Diagnostics Panel (Trouble.nvim)
|
||||||
|
|
||||||
|
Shows all LSP errors and warnings — across every file the language server knows about, like the Problems panel in VSCode.
|
||||||
|
|
||||||
|
| Key | What it does |
|
||||||
|
|-----|-------------|
|
||||||
|
| `<leader>xx` | Toggle workspace diagnostics (all errors across the project) |
|
||||||
|
| `<leader>xd` | Toggle diagnostics for the current file only |
|
||||||
|
| `<leader>xq` | Open the quickfix list in Trouble |
|
||||||
|
| `<leader>xl` | Open the location list in Trouble |
|
||||||
|
|
||||||
|
**Inside the Trouble panel:**
|
||||||
|
|
||||||
|
| Key | What it does |
|
||||||
|
|-----|-------------|
|
||||||
|
| `j` / `k` | Move to next / previous item |
|
||||||
|
| `Enter` or `Tab` | Jump to that error in the file |
|
||||||
|
| `x` | Open the file in a horizontal split |
|
||||||
|
| `v` | Open the file in a vertical split |
|
||||||
|
| `p` | Preview the error location without leaving Trouble |
|
||||||
|
| `r` | Refresh the list |
|
||||||
|
| `za` | Toggle fold for a file group |
|
||||||
|
| `zm` | Collapse all file groups |
|
||||||
|
| `zr` | Expand all file groups |
|
||||||
|
| `q` | Close the Trouble panel |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Terminal
|
||||||
|
|
||||||
|
| Key | What it does |
|
||||||
|
|-----|-------------|
|
||||||
|
| `<leader>t` | Open/close the terminal (toggles a split at the bottom) |
|
||||||
|
| `<leader>t` (inside terminal) | Close the terminal |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Testing (vim-test)
|
||||||
|
|
||||||
|
| Key | What it does |
|
||||||
|
|-----|-------------|
|
||||||
|
| `tn` | Run the test nearest to the cursor |
|
||||||
|
| `tf` | Run all tests in the current file |
|
||||||
|
| `ts` | Run the entire test suite |
|
||||||
|
| `tl` | Re-run the last test that was run |
|
||||||
|
| `tv` | Open the test file that was last run |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Markdown Preview
|
||||||
|
|
||||||
|
| Key | What it does |
|
||||||
|
|-----|-------------|
|
||||||
|
| `<leader>mp` | Open a browser preview of the current Markdown file |
|
||||||
|
| `<leader>ms` | Stop the Markdown preview |
|
||||||
|
| `<leader>mf` | Keep the preview scrolled to where your cursor is |
|
||||||
|
| `<leader>mt` | Toggle the Markdown preview on/off |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Utilities
|
||||||
|
|
||||||
|
| Key | What it does |
|
||||||
|
|-----|-------------|
|
||||||
|
| `<leader>sr` | Search and replace (interactive prompt) |
|
||||||
|
| `<leader>cf` | Create a new Java file |
|
||||||
7
init.lua
7
init.lua
|
|
@ -14,6 +14,7 @@ require("user.autocmds")
|
||||||
require("user.files_utils")
|
require("user.files_utils")
|
||||||
require("user.commands")
|
require("user.commands")
|
||||||
require("user.comment")
|
require("user.comment")
|
||||||
|
require("user.trouble")
|
||||||
require("user.java")
|
require("user.java")
|
||||||
|
|
||||||
return require("packer").startup(function(use)
|
return require("packer").startup(function(use)
|
||||||
|
|
@ -71,6 +72,12 @@ return require("packer").startup(function(use)
|
||||||
-- Comment
|
-- Comment
|
||||||
use 'numToStr/Comment.nvim'
|
use 'numToStr/Comment.nvim'
|
||||||
|
|
||||||
|
-- Trouble: workspace diagnostics panel
|
||||||
|
use {
|
||||||
|
"folke/trouble.nvim",
|
||||||
|
requires = { "nvim-tree/nvim-web-devicons" },
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
-- Telescope FZF native
|
-- Telescope FZF native
|
||||||
use({
|
use({
|
||||||
|
|
|
||||||
|
|
@ -7,11 +7,11 @@ end
|
||||||
|
|
||||||
require("Comment").setup({
|
require("Comment").setup({
|
||||||
toggler = {
|
toggler = {
|
||||||
line = "<leader>k", -- Mapping for toggling comments
|
line = "<leader>kk",
|
||||||
block = "<leader>b", -- Mapping for block comments
|
block = "<leader>bb",
|
||||||
},
|
},
|
||||||
opleader = {
|
opleader = {
|
||||||
line = "<leader>k", -- Mapping for operator-pending comments
|
line = "<leader>k",
|
||||||
block = "<leader>b", -- Mapping for block comments in operator-pending mode
|
block = "<leader>b",
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
|
||||||
39
lua/user/trouble.lua
Normal file
39
lua/user/trouble.lua
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
local status_ok, trouble = pcall(require, "trouble")
|
||||||
|
if not status_ok then
|
||||||
|
vim.notify("trouble.nvim not found!")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
trouble.setup({
|
||||||
|
position = "bottom",
|
||||||
|
height = 15,
|
||||||
|
icons = true,
|
||||||
|
mode = "workspace_diagnostics",
|
||||||
|
severity = nil,
|
||||||
|
fold_open = "",
|
||||||
|
fold_closed = "",
|
||||||
|
action_keys = {
|
||||||
|
close = "q",
|
||||||
|
refresh = "r",
|
||||||
|
jump = { "<cr>", "<tab>" },
|
||||||
|
open_split = "x",
|
||||||
|
open_vsplit = "v",
|
||||||
|
preview = "p",
|
||||||
|
close_folds = "zm",
|
||||||
|
open_folds = "zr",
|
||||||
|
toggle_fold = "za",
|
||||||
|
previous = "k",
|
||||||
|
next = "j",
|
||||||
|
},
|
||||||
|
auto_preview = true,
|
||||||
|
use_diagnostic_signs = true,
|
||||||
|
})
|
||||||
|
|
||||||
|
local map = vim.api.nvim_set_keymap
|
||||||
|
local opts = { noremap = true, silent = true }
|
||||||
|
|
||||||
|
map("n", "<leader>xx", "<cmd>TroubleToggle workspace_diagnostics<CR>", opts)
|
||||||
|
map("n", "<leader>xd", "<cmd>TroubleToggle document_diagnostics<CR>", opts)
|
||||||
|
map("n", "<leader>xq", "<cmd>TroubleToggle quickfix<CR>", opts)
|
||||||
|
map("n", "<leader>xl", "<cmd>TroubleToggle loclist<CR>", opts)
|
||||||
|
map("n", "gr", "<cmd>TroubleToggle lsp_references<CR>", opts)
|
||||||
Loading…
Reference in a new issue