LSP, Completion & Diagnostics
Get IDE features (autocomplete, go-to-definition, diagnostics) via LSP.
Code
" --- Neovim native LSP (built-in client) ---
" Install servers: npm i -g typescript-language-server pyright vscode-langservers-extracted
:help lsp
lua << EOF
local lsp = require("lspconfig")
lsp.ts_ls.setup{} -- TypeScript/JavaScript
lsp.pyright.setup{} -- Python
lsp.lua_ls.setup{} -- Lua
lsp.rust_analyzer.setup{} -- Rust
EOF
" Keymaps (set in on_attach)
nnoremap gd <cmd>lua vim.lsp.buf.definition()<CR>
nnoremap K <cmd>lua vim.lsp.buf.hover()<CR>
nnoremap gr <cmd>lua vim.lsp.buf.references()<CR>
nnoremap <leader>rn <cmd>lua vim.lsp.buf.rename()<CR>
nnoremap <leader>ca <cmd>lua vim.lsp.buf.code_action()<CR>
nnoremap <leader>d <cmd>lua vim.diagnostic.open_float()<CR>
" Completion: nvim-cmp or native (Neovim 0.11+)
set completeopt=menuone,noselect
" Diagnostics
lua << EOF
vim.diagnostic.config({
virtual_text = true,
signs = true,
underline = true,
})
EOF
" Format on save (Neovim 0.8+)
autocmd BufWritePre *.lua,*.ts,*.py lua vim.lsp.buf.format({ async = false })Explanation
LSP (Language Server Protocol) gives Vim/Neovim IDE features. Neovim ships a built-in client (vim.lsp); classic Vim needs coc.nvim or ale. You install language servers separately (typescript-language-server, pyright, gopls, rust-analyzer...) and configure each with lspconfig. Core actions: gd (definition), K (hover), gr (references), <leader>ca (code action), <leader>rn (rename). For completion, nvim-cmp with luasnip is the modern stack; Neovim 0.11+ also has a native omnifunc. Diagnostics can show as virtual text, signs, or underlines.
More Vim Snippets
Buffers, Windows & Tabs
Edit multiple files with buffers, split windows, and tab pages.
Search & Substitute
Find text with / and replace with :s, leveraging regex and ranges.
Registers (Multi-Clipboard)
Store yanks/deletes in named registers and paste from them.
Marks (Bookmarks)
Jump back to positions in a file or across files with marks.
Macros (Recorded Keystrokes)
Record a sequence of keys and replay it to automate repetitive edits.
Folding (Collapse Code)
Hide regions of code to focus on structure with fold methods.