Nvim
todo
- gemini CLI /review
- it would be amazing if while doing reviews it look into the codebase for components or functions that already exists and the person could reuse
- sidekick.nvim can't input newline in CLI agents inside nvim in warp
- lazyvim
- try gh for pull request reviewing
- git-conflict.nvim
Installing and dependencies
- install a nerd font for terminal (I like the JetBrains Mono or hack font)
- install ripgrep, fzf, git-delta, fd with a package manager. rust cargo
- a c compiler it should be
make. windows:choco intall mingw.
npm install -g neovim- make sure python3 is in env. install python
python3 -m pip install --user --upgrade pynvim
- clone my dotenv repo
- make symlinks, make nvim look for files to the correct directory with
command here. default windows dir isC:/Users/User/AppData/Local/nvim
or run thedev.shscript and it will create a sym link from the default nvim config folder to wherever I cloned the repo
troubleshooting
shada file error
go to nvim-data shada folder and delete it's contents
debugging
java
- JAVA JDTLS. el auto setup de mason-lspconfig ta necio. borra manualmente el script de Mason que lo inicializa en el root de mason/jdtls.
svelte
- on svelte projects, tsserver LSP and svelteLSP might conflict on some files. might need to uninstall tsserver while working with the svelte LSP.
also I might or might not need the svelteLSP to attach to .js and .ts files on svelte projects. to do this uncomment the svelte filetypes line onlsp.lua. this might create a double diagnostic of conflict situation tho... - for eslint to work with svelte I need to add it's plugin on the eslintrc file
npm install eslint eslint-plugin-svelte
same formatting with prettier. adding a svelte plugin to prettier is necessary.npm install prettier prettier-plugin-svelte
the svelte language server comes with linting and formatting out the box
KEYMAPS and COMMANDS
- https://www.lazyvim.org/keymaps
- remaps.lua
gitsigns and hunks
- (whichkey) leader h
- https://www.lazyvim.org/plugins/editor#gitsignsnvim
commands
:w :q :q! :wq save, quit, quit without save
ZZ = :xa
:nmap _    gives me all mappings on whatever mode I'm in
:vsp and :terminal.  quit terminal with ctrl+\ + ctrl + n
:so refresh lua source
cmd + + zoom in
cmd + - zoom out
NAVIGATION
| keys | Description |
|---|---|
| _ / 0 / Home | place cursor at start of line |
| $ / = / End | place cursor at end of line |
| ge | go back to end of word. |
| w W | go forward by start of word |
| shift [,] | jump over blocks |
| ( { [ or % | to go to matching closing |
| * or # | find next/previous occurence of word under cursor |
| 2G | go to line 2 |
| keys | description |
|---|---|
| f F | move to next/previous char in line. Then use ';' and ',' to go back and forth finds |
| t T | move to but not on the char in line (like f) |
- you can combine editing functions (d,c, y, v) with navigation (w,b,e, p) or with (i (inside, exclusive) , a (all, inclusive)) and limiting chars that surround the block ( (), {}, "", '', [])
p is for parragraph, or contiguos text
| shortcut | Description |
|---|---|
| zz | move current line to center of screen |
| zt | move curr line to top of screen |
| zb | move curr line to bottom os screen |
| ctrl + y | scroll up |
| ctrl + e | scroll down |
[t [b [q [l   go to previous tab, buffer, q?, l?     with shift go to first/last
]t ]b ...
]m go to next method
[ + delimiter [,{,( go to start of block
]+ delimiter ],},) go to end of block
leap navigation
press s in normal mode
marks and `
m_Â Â Â Â Â set a mark named with any letter/number. Upper case letters are global marks (project wide?
`_Â Â Â Â Â Â go to a set mark named with any letter/number.
`` go to position before jump
`. go to position when last edited
:marks     see marks
mx       Set mark x
m,       Set the next available alphabetical (lowercase) mark
m;Â Â Â Â Â Â Â Toggle the next available mark at the current line
dmx       Delete mark x
dm-Â Â Â Â Â Â Â Delete all marks on the current line
dm <space>Â Â Â Â Delete all marks in the current buffer
m]Â Â Â Â Â Â Â Move to next mark
m[Â Â Â Â Â Â Â Move to previous mark
m:Â Â Â Â Â Â Â Preview mark. This will prompt you for a specific mark to
preview; press <cr> to preview the next mark.
m[0-9]Â Â Â Â Â Add a bookmark from bookmark group[0-9].
dm[0-9]Â Â Â Â Â Delete all bookmarks from bookmark group[0-9].
m}Â Â Â Â Â Â Â Move to the next bookmark having the same type as the bookmark under the cursor. Works across buffers.
m{Â Â Â Â Â Â Â Move to the previous bookmark having the same type as the bookmark under the cursor. Works across buffers.
dm=Â Â Â Â Â Â Â Delete the bookmark under the cursor.
editing
~ switch case
R replace 'mode'.
. repeat previous command
MACROS
q+_Â Â Â Â Â Â Â the next key after key is where the macro is saved
record key presses
press q again
@_Â Â Â Â Â Â Â Â execute the macro stored at _
HIGHLIGHTING and selecting mutliple character
ctrl+v vertical edit, combine with I to insert at start of every line
o toggle jump cursor to end of selected text
v > u U change to lower/upper case
:noh remove highlighting of seaerch matches
:%Â Â Â Â refer to current buffer. I can combine with 'y' or 'd'Â Â Â Â delete entire page
highlight some area > ':s/myvar/yourvar'Â Â Â Â substitue mode
MOVING BY SCREENS
Ctrl + b – move back one full screen
Ctrl + f – move forward one full screen
Ctrl + d – move forward 1/2 a screen
Ctrl + u – move back 1/2 a screen
Ctrl + e – move screen down one line (without moving the cursor)
Ctrl + y – move screen up one line (without moving the cursor)
Ctrl + o – move backward through the jump history
Ctrl + i – move forward through the jump history
FOLDING
za ZAÂ Â Â Toggle a fold under cursor
zM Close all open folds
zm Increase the foldlevel by one
zR Decrease the foldlevel to zero—all folds will be open
zr Decrease the foldlevel by one
zf#j Create a fold from the cursor down # lines
zf/ String creates a fold from the cursor to string
zj Move the cursor to the next fold
zk Move the cursor to the previous fold
zd Delete the fold at the cursor
zE Delete all folds
[z Move to start of open fold
]z Move to end of open fold
INDENTATION
<< or >> indent one shift
find and replace
finding
apart from / and ? searching that I already know there is also * and # that look for next/previous instance of the current word I'm on. I tend to just use brackets for symbol finding with lsp.
replacing
lsp renaming has done a good job for me for renaming symbols even across multiple files. but in the cases that what I want to find and replace is not a symbol I could do the following:
-
I have a keymap on
<leader> sthat runs:
:%s/\<router\>/router2/gI -
manually:
go into cmd mode
:%s/<wordToFind>/<replacementWord>/<options>
%s searches every single line
s searches for current line
options:
- i ignores case
- I is for iteractive replace
- c conditional (like I I think)
- g at the end of the command for global find (current file)
what about global project wide?
TABS
Ctrl-c    close window and repeat
[]t move to the next/prev tab
#gt move to tab number #
:tabo[nly] - close all tabs except for the current one
:tabdo command - run the command on all tabs (e.g. :tabdo q - closes all opened tabs)
< >to or :tabnew {page.words.file} open a file in a new tab
WORKING WITH MULTIPLE FILES
Ctrl + T open current window in a tab
Ctrl + h - move cursor to the left window (vertical split)
Ctrl + l - move cursor to the right window (vertical split)
Ctrl + j - move cursor to the window below (horizontal split)
Ctrl + k - move cursor to the window above (horizontal split)
ctrl arrow keys resize the windows
buffers
:bd[elete] - delete a buffer (close a file)
:b[uffer] file - go to a buffer by file
:sp[lit] file, <M-s> - open a file in a new buffer and split window
:vs[plit] file , <C-s> - open a file in a new buffer and vertically split window
:tab ba[ll] - edit all buffers as tabs
tags
tags are ...
gb - pop tag, go back to previous tag
Ctrl-o - go back prev tag
Ctrl + wt - duplicate current buffer in new tab
Ctrl + wT - move the current split window into its own tab
Ctrl + ws - split window
Ctrl + wv - split window vertically
Ctrl + ww - switch windows
Ctrl + wq - quit a window
ctrl + wc    - close windows
ctrl + c close window (global, works for all/ most plugins)
Ctrl + wx - exchange current window with next one
Ctrl + w= - make all windows equal height & width
Ctrl + wH - make current window full height at far left (leftmost vertical window)
Ctrl + wL - make current window full height at far right (rightmost vertical window)
Ctrl + wJ - make current window full width at the very bottom (bottommost horizontal window)
Ctrl + wK - make current window full width at the very top (topmost horizontal window)
Ctrl + wo - make current window the only open window
SURROUND
Add surrounding with sa (in visual mode or on motion).
Delete surrounding with sd.
Replace surrounding with sr.
Find surrounding with sf or sF (move cursor right or left).
Highlight surrounding with sh.
Change number of neighbor lines with sn (see :h MiniSurround-algorithm).
Surrounding is identified by a single character as both "input" (in delete and replace start, find, and highlight) and "output" (in add and replace end):
'f' - function call (string of alphanumeric symbols or '' or '.' followed by balanced '()'). In "input" finds function call, in "output" prompts user to enter function name.
't' - tag. In "input" finds tag with same identifier, in "output" prompts user to enter tag name.
All symbols in brackets '()', '[]', '{}', '<>". In "input' represents balanced brackets (open - with whitespace pad, close - without), in "output" - left and right parts of brackets.
'?' - interactive. Prompts user to enter left and right parts.
All other single character identifiers (supported by getcharstr()) represent surrounding with identical left and right parts.
AUTO PAIRS
"" some text     if I press alt+e in this case the " will travel thro every word
alt+p    toggle plugin itself
CUSTOM
<>u   undo tree
<leader>nh", ":nohl<CR>"
<>m toggle treesitter join: joins blocks of code like arrays, and maps. collapse, expand.
Telescope / Snacks picker
< >pf  fuzy find files by name
<>pg   git files finder
<>ps    grep all files
<>pa     open telescope
<>pp search past yanks on clipboard
<>pq search recorded macros
? fuzzy find current buffer
ctrl-u/d  scroll up/down preview
ctrl j/k  selec next/prev file
n, j/k delect next/prev file
tab/S-tab select/deselect file
ctrl s    open vertical split
alt s    open horizontal spli
ctrl t      open tab
ctrl c      close
:Telescope git_Â Â view git related things like branches
<>pb open buffers
<c-S-c> delete/close buffer
DEBUGGING
f5, <>du    UI toggles
<>b, Â Â Â toggle breakpoint
<>B, Â Â Â set conditional breakpoint
f9, <>dc    launch debugger / continue
f10, <>dj   step out
f11, <>dl   step over
f12, <>dk    step in
f6Â Â Â Â Â ui eval()
f7, <>dh    ui evaluate expression. trigger again to go to window
f8, <>dr    repl toggle
<>da attach debugger
<>ds variable scopes window
<>db breakpoints window
<>dw watches window
<>dt stacks window
on DAP-ui on the breakpoints window I can press o to go the breakpoint or t to toggle it on and off.
I can also insert what variables to watch with i on the watch window and repl
GIT
lazy git and gitsigns
fugitive
:G any git command
< >g      open fugitive. Git
'-' and s    stages a file change
=  or dv   shows diffs. dq to quit
u    unstage file
XÂ Â Â Â Â delete changes
cc commit pane
zzz stash changes
]] move between changes
]c     jump to next tongue(conflict) ?
[c     jump to prev change
o OÂ Â Â see changes in a split or new tab
coo checkout commit
conflicts
https://www.reddit.com/r/vim/comments/leo0ji/comment/gmhqbj9/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button
in a file with merge conflicts I can :Gvdiffsplit!.
gf, d2o  choose from left window
gj, d3o  choose from right window
if doesn't work use diffget
merge-conflict plugin:
co — choose ours
ct — choose theirs
cb — choose both
c0 — choose none
]x — move to previous conflict
[x — move to next conflict
:Gvdiffsplit (branch-name)   see changes of curr file compared to last commit
:G difftool -y     see changes of all files open in different tabs
git signs
git info in buffers
<leader>hd (gitsigns) current file git dif (turned it into a toggle)
<>gb checkout branch
<>gc checkout commit
<>gd Git Diff
<>gj next hunk
<>gk prev hunk
<>gl blame

view file history diff
with fugitive
:Gdiff :0 current file and index
:Gdiff [revision] current file and some other revision
:Gdiff ~3 current file file 3 commits ago.
:Glog behaves different from git log
git log shows a list of commit msgs for the entire project, Glog loads all previous revisions of current file into quickfix list.
https://stackoverflow.com/a/28916959/14318987
with diffview:
Git Worktrees
<>gn create work tree
<>gt       open worktree. telescope
(believe don't have to do this with the create worktree command)
couldn't get the plugin to work but I could still use git commands to do this.
git clone --bare URL git-worktree.nvim
git worktree add <branch_name>
Troubles
<>xq open trouble, window showing all problems on the file/ project?
<>xa workspace troubles
<>x   document diagnostics
<>xx trouble toggle
MASON
:Mason package manager for LSP, DAP (debugger protocols), linters and formatters
:LspInstall
lsp autocomplete
normal mode
(normal) K, (insert) C-h   hover info, documentation
gd   go to definition
gDÂ Â go to declaration
gr  go to references
gi   go to implementations
go jumps to definition of the type of symbol under cursor
gs buffer symbols
gS workspace symbols
<>rn rename/replace all ocurrences
<>ca code actions
gl line diagnostics
[d ,]d prev/next diagnostic
<>ws view workspace symbol (queries and finds all instances of a symbol, i.e classes functions, etc...)
<>wa add workspace folder
<>wr remove workspace folder
Tab, S-Tab snippet forward/backwards
C-k, C-h signature help
in insert mode
C-h show signature.
ctrl e    toggle cmp
ctrl n trigger autocomplete suggestions
tab      show suggestions even inside words. next/prev suggestion
ctrl < > starts completion
ctrl p/n previous and next option
ctrl u/f      scroll up and down in items documentation.
ctrl h/l    go to next/prev placeholder in snippet
ctrl k open signature help.
ctrl y confirm
COMMENTING
gcc toggle comment current line
gc toggle comment highlited text
gb toggle comment blockwise
gc navigation toggle commenting navigation input
neotree FILE TREE
? help?
< >e open file tree
<>eb open buffer list
<>eg open git status files
<, > switch source
s,
bd     delete buffer
a new file
AÂ Â Â Â Â Â Â Â new dir
d delete file
PÂ Â Â Â Â Â Â preview
Y copy file path options
y copy file
x cut file
p paste from clipboard
GITHUB COPILOT
- Alt+y              accept
- alt+ n             next suggestion
- alt+p             prev suggestion
- alt+ e            dismiss suggestion
- alt+a             copilot panel. 10 suggestions
- alt+l accept line
AI
sidekick.nvim integrates all CLI coding agents in nvim
<leader>aa toggle chat
<leader>af send file to context
<leader>av send selected to context
<leader>at send this to context
<leader>ad detach CLI session
<leader>as select CLI