mirror of
https://github.com/Rainyy21/framework_note.git
synced 2026-10-11 00:30:29 -04:00
vault backup: 2026-05-30 16:02:33
This commit is contained in:
@@ -0,0 +1,111 @@
|
||||
---
|
||||
tags: [neovim, lazyvim, coding-tools, ide, tutorial]
|
||||
created: 2026-05-29
|
||||
status: complete
|
||||
type: lesson
|
||||
---
|
||||
|
||||
# Master Class: In-Depth Guide to LazyVim
|
||||
|
||||
LazyVim is not just a configuration; it is a **Neovim setup framework** designed to provide a high-performance, IDE-like experience while remaining modular and easy to customize. It leverages the power of `lazy.nvim` to ensure that your editor starts instantly by loading components only when they are needed.
|
||||
|
||||
---
|
||||
|
||||
## 1. The Core Philosophy
|
||||
LazyVim is built on three pillars:
|
||||
1. **Speed:** Everything is lazy-loaded. If you aren't editing a Python file, the Python LSP doesn't load.
|
||||
2. **Sane Defaults:** It comes pre-configured with industry-standard settings for UI, indentation, and search.
|
||||
3. **Modularity:** It separates its core logic from your user configuration, allowing you to update the framework without breaking your personal tweaks.
|
||||
|
||||
---
|
||||
|
||||
## 2. The Integrated Toolbox
|
||||
LazyVim integrates several powerful tools into a cohesive workflow:
|
||||
|
||||
### A. **lazy.nvim (The Engine)**
|
||||
The heart of the system. It manages plugin installation, updates, and lazy-loading.
|
||||
- **Command:** `:Lazy`
|
||||
- **Capabilities:** Check for updates, profile startup time, and manage plugin states.
|
||||
|
||||
### B. **Mason.nvim (The Tool Manager)**
|
||||
A "package manager" for your external dependencies.
|
||||
- **Command:** `:Mason`
|
||||
- **Capabilities:** Easily install and manage LSP servers, DAP (debuggers), linters, and formatters directly from within Neovim.
|
||||
|
||||
### C. **nvim-treesitter (The Parser)**
|
||||
Provides high-performance syntax highlighting and code understanding.
|
||||
- **Command:** `:TSUpdate`
|
||||
- **Capabilities:** Better highlighting, indentation, and "incremental selection" (selecting code blocks logically).
|
||||
|
||||
### D. **Telescope.nvim / fzf-lua (The Searcher)**
|
||||
A fuzzy finder that allows you to find anything in your project.
|
||||
- **Keybinds:** `<leader>ff` (files), `<leader>/` (live grep), `<leader>sk` (keymaps).
|
||||
|
||||
---
|
||||
|
||||
## 3. Essential Keybindings & Workflow
|
||||
LazyVim uses the `<Space>` key as the **Leader**. One of its best features is `which-key.nvim`, which displays a popup showing available commands whenever you press your leader key.
|
||||
|
||||
### **Navigation**
|
||||
- `<leader>e`: Toggle **Neo-tree** (File Explorer).
|
||||
- `H` / `L`: Quickly cycle through open buffers (tabs).
|
||||
- `<leader>bb`: Switch between open buffers.
|
||||
- `<leader>fT`: Open a floating terminal.
|
||||
|
||||
### **Coding & LSP**
|
||||
- `K`: Hover documentation (show what a function/variable does).
|
||||
- `gd`: Go to definition.
|
||||
- `gr`: Go to references.
|
||||
- `<leader>ca`: **Code Actions** (Fixes, imports, refactors).
|
||||
- `<leader>cr`: Rename the symbol under the cursor project-wide.
|
||||
- `[d` / `]d`: Jump to previous/next error or warning.
|
||||
|
||||
### **Git Integration**
|
||||
- `<leader>gg`: Open **LazyGit** (a full TUI for Git).
|
||||
- `<leader>gj`: Next Git hunk.
|
||||
- `<leader>gk`: Previous Git hunk.
|
||||
|
||||
---
|
||||
|
||||
## 4. Customizing Your Setup
|
||||
LazyVim's structure is designed to be clean:
|
||||
- `lua/config/options.lua`: Global Neovim settings (e.g., line numbers, tab widths).
|
||||
- `lua/config/keymaps.lua`: Your custom keyboard shortcuts.
|
||||
- `lua/plugins/`: Any `.lua` file created here is automatically loaded as a plugin configuration.
|
||||
|
||||
### **Adding a Plugin**
|
||||
Create `lua/plugins/example.lua`:
|
||||
```lua
|
||||
return {
|
||||
"username/plugin-name",
|
||||
opts = {
|
||||
-- plugin configuration goes here
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
### **Enabling "Extras"**
|
||||
LazyVim provides "Packs" for specific needs. You can enable them in `lua/config/lazy.lua`:
|
||||
```lua
|
||||
require("lazyvim.util").plugin.setup({
|
||||
spec = {
|
||||
{ "LazyVim/LazyVim", import = "lazyvim.plugins" },
|
||||
-- Enable extras like Python, Docker, or Copilot:
|
||||
{ import = "lazyvim.plugins.extras.lang.python" },
|
||||
{ import = "lazyvim.plugins.extras.ui.mini-animate" },
|
||||
{ import = "lazyvim.plugins.extras.coding.copilot" },
|
||||
{ import = "lua.plugins" },
|
||||
},
|
||||
})
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 5. Why LazyVim?
|
||||
Unlike building a config from scratch (which can take months to perfect) or using a "thick" distro like LunarVim (which can feel bloated), LazyVim gives you a professional-grade starting point that feels like **your** config. It provides the "glue" that makes LSP, completion, and UI tools work together seamlessly.
|
||||
|
||||
---
|
||||
**Next Steps:**
|
||||
- Run `:LazyHealth` to check your environment.
|
||||
- Install `lazygit` on your system to enable the `<leader>gg` shortcut.
|
||||
- Explore the [Official LazyVim Docs](https://www.lazyvim.org).
|
||||
@@ -0,0 +1,82 @@
|
||||
---
|
||||
tags: [neovim, treesitter, mason, telescope, coding-tools, tutorial]
|
||||
created: 2026-05-29
|
||||
status: complete
|
||||
type: lesson
|
||||
---
|
||||
|
||||
# Deep Dive: The Power Trio (Tree-sitter, Mason, & Telescope)
|
||||
|
||||
While LazyVim provides the framework, its "superpowers" come from three specific plugins that redefine how you interact with code. Understanding these tools in-depth will allow you to master your editor.
|
||||
|
||||
---
|
||||
|
||||
## 1. Tree-sitter: The Syntactic Engine
|
||||
Traditional editors use "Regex" (Regular Expressions) to highlight code. Regex is just fancy pattern matching. **Tree-sitter** is different: it is a **parser**. It builds a concrete syntax tree (CST) of your source file.
|
||||
|
||||
### Why it matters:
|
||||
- **Semantic Awareness:** It knows the difference between a variable, a function, and a type, even if they have the same name.
|
||||
- **Incremental Parsing:** It updates the tree instantly as you type, making it incredibly fast.
|
||||
- **Language-Agnostic:** One engine powers hundreds of languages.
|
||||
|
||||
### Key Modules:
|
||||
- **Highlighting:** Precise, context-aware colors.
|
||||
- **Incremental Selection:** Logical selection (select word -> select expression -> select function).
|
||||
- **Indentation:** Uses the tree structure to know exactly where a line should start.
|
||||
|
||||
### Pro Commands:
|
||||
- `:TSInstall <lang>`: Install a specific language parser.
|
||||
- `:InspectTree`: Opens a side window showing the actual tree structure of your code.
|
||||
- `:EditQuery`: Advanced tool to create custom highlights or behavior.
|
||||
|
||||
---
|
||||
|
||||
## 2. Mason.nvim: The Tool Manager
|
||||
In the past, installing an LSP (Language Server) or a Formatter was a nightmare. You had to use `npm`, `pip`, `go install`, and `cargo` manually. **Mason** abstracts all of this.
|
||||
|
||||
### The Architecture:
|
||||
- **Isolated Binaries:** Mason installs tools in `~/.local/share/nvim/mason/bin/`. It does **not** pollute your system global PATH.
|
||||
- **The "Bridge":** Mason only *downloads* the tools. Plugins like `mason-lspconfig` are needed to connect those downloads to Neovim's internal LSP client.
|
||||
|
||||
### Essential Workflow:
|
||||
1. Open `:Mason`.
|
||||
2. Find your tool (e.g., `ruff` for Python, `gopls` for Go).
|
||||
3. Press `i` to install.
|
||||
4. Use `ensure_installed` in your config to automate this across machines.
|
||||
|
||||
---
|
||||
|
||||
## 3. Telescope.nvim: The Central Nervous System
|
||||
Telescope is a highly extendable fuzzy finder. It is the primary way you find and jump to information.
|
||||
|
||||
### The "Picker" Concept:
|
||||
Everything in Telescope is a **Picker**. A picker consists of three parts:
|
||||
1. **Finder:** Where the data comes from (files, git, buffers).
|
||||
2. **Sorter:** How it ranks the results (FZF, native).
|
||||
3. **Previewer:** Shows you the content before you click.
|
||||
|
||||
### Advanced Mappings (Inside Telescope):
|
||||
- `<C-j>` / `<C-k>`: Move through results.
|
||||
- `<Tab>`: Select multiple items.
|
||||
- `<C-q>`: Send all selected items to the **Quickfix List** (powerful for mass refactoring).
|
||||
- `<C-/>`: Show all keybindings for the current picker.
|
||||
|
||||
### Must-Have Extensions:
|
||||
- **`fzf-native`:** Uses a C-port of FZF for blazing fast sorting.
|
||||
- **`ui-select`:** Makes *all* Neovim selection menus (like Code Actions) use the Telescope UI.
|
||||
- **`undo`:** A visual search for your file's history.
|
||||
|
||||
---
|
||||
|
||||
## How They Work Together
|
||||
Imagine you are editing a file:
|
||||
1. **Mason** has installed the `Pyright` LSP server.
|
||||
2. **Tree-sitter** is providing beautiful syntax highlighting and logical selection.
|
||||
3. You realize you need to find where a function is used. You trigger **Telescope** (`lsp_references`).
|
||||
4. Telescope uses the LSP (installed by **Mason**) to find the references and displays them in its UI.
|
||||
|
||||
---
|
||||
**Next Steps:**
|
||||
- Try `:InspectTree` on a complex file to see how Tree-sitter "sees" your code.
|
||||
- Run `:Mason` and check if you have any outdated tools.
|
||||
- Experiment with `live_grep` in Telescope to find text across your entire project.
|
||||
Reference in New Issue
Block a user