Neovim LSP, Treesitter, and Plugins

Language-aware development workflows in Neovim with built-in LSP, Treesitter, and plugin managers.

View
StandardDetailedCompact
Export
Copy the compact sheet, download it, or print it.
Download
`D` dense toggle · `C` copy all
## Built-in LSP workflows
Go to definition
vim.keymap.set("n", "gd", vim.lsp.buf.definition)

# Jump to the definition of the symbol under cursor.

Find references
vim.keymap.set("n", "gr", vim.lsp.buf.references)

# List all references to a symbol.

Show hover docs
vim.keymap.set("n", "K", vim.lsp.buf.hover)

# Display hover information from the language server.

Rename a symbol
vim.keymap.set("n", "<leader>rn", vim.lsp.buf.rename)

# Perform a semantic rename through LSP.

## Treesitter
Configure nvim-treesitter
require("nvim-treesitter.configs").setup({
  ensure_installed = { "lua", "vim", "javascript", "typescript" },
  highlight = { enable = true },
  indent = { enable = true },
})

# Install parsers and enable syntax-aware modules.

Use Treesitter textobjects
-- usually configured via nvim-treesitter-textobjects

# Select functions and classes structurally.

## Plugins and health checks
Bootstrap lazy.nvim
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath })
end
vim.opt.rtp:prepend(lazypath)

# Clone lazy.nvim automatically if missing.

Declare plugins with lazy.nvim
require("lazy").setup({
  { "nvim-treesitter/nvim-treesitter" },
  { "neovim/nvim-lspconfig" },
  { "nvim-telescope/telescope.nvim", dependencies = { "nvim-lua/plenary.nvim" } },
})

# Register plugins and dependencies in Lua.

Run :checkhealth
:checkhealth

# Inspect provider and plugin setup issues.

Recommended next

No recommendations yet.