# ✅ Checkpoint: LSP, Telescope và Treesitter

By 3T1C



## Quiz

1. Trong một thiết lập LSP trên Neovim 0.11+, `vim.lsp.config` và `vim.lsp.enable` khác nhau ở điểm nào?
   - `vim.lsp.enable` khai báo capabilities, `vim.lsp.config` bật server.
   - Hai hàm tương đương nhau, chỉ khác tên gọi.
   - `vim.lsp.config` chỉ khai báo cấu hình cho server, `vim.lsp.enable` mới thật sự bật server theo filetype.
   - `vim.lsp.config` cài server binary, `vim.lsp.enable` bật autocomplete.
2. Bạn mở file `.ts` nhưng `:lua =vim.lsp.get_clients({ bufnr = 0 })` trả về bảng rỗng, dù `:Mason` báo server đã cài. Bạn nên kiểm tra gì trước tiên?
   - Bật `vim.lsp.set_log_level("debug")` rồi sửa config ngay.
   - Xoá `%LOCALAPPDATA%\nvim-data` để Mason cài lại.
   - Cài lại toàn bộ Neovim từ đầu.
   - Filetype của buffer (`:set ft?`) và việc plugin khai báo `vim.lsp.enable` đã thật sự load chưa.
3. Vì sao nên khai báo keymap LSP bên trong callback của `LspAttach` thay vì đặt ở `init.lua` gốc?
   - Để keymap chỉ tồn tại trong buffer thật sự có server, tránh lỗi khó hiểu ở buffer không có LSP.
   - Vì `LspAttach` tự động sinh keymap cho mọi server.
   - Vì đặt trong `LspAttach` giúp keymap chạy nhanh hơn.
   - Vì `init.lua` không cho phép gọi `vim.keymap.set`.
4. Trong Telescope, `file_ignore_patterns` phải viết theo cú pháp nào để loại `node_modules` khỏi kết quả?
   - Glob kiểu shell, ví dụ `**/node_modules/*`.
   - Danh sách tên file chính xác, phân tách bằng dấu phẩy.
   - Lua pattern, ví dụ `node_modules/` hoặc `%.git/` cho thư mục `.git`.
   - Regex quen thuộc, ví dụ `\.git/`.
5. Chọn tất cả phát biểu đúng về Telescope trong cấu hình capstone.
   - `live_grep` cần binary `rg` (ripgrep) có trong PATH của tiến trình Neovim.
   - `find_files` ưu tiên `fd`; không có `fd` thì Telescope tự quét thư mục nên chậm hơn.
   - Nên cài `telescope-fzf-native.nvim` ngay từ đầu vì nó không cần compiler trên Windows 11.
   - `plenary.nvim` là dependency bắt buộc của `telescope.nvim`.
   - `lsp_document_symbols` quét toàn workspace, còn `lsp_dynamic_workspace_symbols` chỉ quét file hiện tại.
6. Chọn tất cả phát biểu đúng về Treesitter và folding theo cú pháp.
   - `ensure_installed` nhận tên filetype, ví dụ `typescriptreact` cho file `.tsx`.
   - Để folding theo cú pháp hoạt động cần cả `foldmethod = "expr"` và `foldexpr = v:lua.vim.treesitter.foldexpr()`.
   - Lỗi `incompatible ABI version` xảy ra vì thiếu `plenary.nvim`.
   - Treesitter chạy parser thật của từng ngôn ngữ, sinh AST và cập nhật tăng dần theo buffer.
   - `:InspectTree` mở cửa sổ cây cú pháp của buffer hiện tại.
7. Trên Windows 11, Mason thường cài language server thất bại vì `npm` không nằm trong ____ của tiến trình Neovim, dù terminal ngoài vẫn chạy được.
8. Sau khi nâng cấp Neovim và gặp lỗi `incompatible ABI version`, lệnh bạn chạy để rebuild toàn bộ parser đã cài là ____.
9. Trong Telescope, builtin dùng để mở lại picker vừa dùng mà không phải gõ lại pattern là ____.
10. Hãy tự đánh giá khả năng ghép LSP, Telescope và Treesitter vào cấu hình capstone của bạn. Mở một dự án thật, chạy thử và trả lời theo rubric bên dưới.


---

## Contents

Part of [🛠️ Config neovim trên win 11](https://everwise.study/courses/config-neovim-tren-win-11.md)

- **🧱 Nền tảng cấu hình bằng Lua và plugin manager**
  - [📁 Bộ khung init.lua và cách tổ chức file cấu hình trên Windows 11](https://everwise.study/courses/config-neovim-tren-win-11/bo-khung-init-lua-tren-windows-11.md)
  - [📦 Quản lý plugin với lazy.nvim và hướng mở rộng với vim.pack](https://everwise.study/courses/config-neovim-tren-win-11/quan-ly-plugin-lazy-nvim-va-vim-pack.md) (sign-in required)
  - [⌨️ Keybinding, leader key và workflow làm việc hiệu quả](https://everwise.study/courses/config-neovim-tren-win-11/keybinding-leader-key-va-workflow.md)
  - [✅ Checkpoint: Nền tảng cấu hình Lua và plugin manager](https://everwise.study/courses/config-neovim-tren-win-11/checkpoint-nen-tang-cau-hinh-lua.md)
- **🧠 Đưa Neovim lên mức IDE: LSP, Telescope, Treesitter**
  - [🔍 LSP, autocomplete và diagnostics](https://everwise.study/courses/config-neovim-tren-win-11/lsp-autocomplete-va-diagnostics.md)
  - [🔭 Telescope: tìm file và grep trong dự án](https://everwise.study/courses/config-neovim-tren-win-11/telescope-tim-file-va-grep.md)
  - [🌳 Treesitter: cú pháp, highlight và folding](https://everwise.study/courses/config-neovim-tren-win-11/treesitter-cu-phap-va-folding.md)
  - [✅ Checkpoint: LSP, Telescope và Treesitter](https://everwise.study/courses/config-neovim-tren-win-11/checkpoint-lsp-telescope-treesitter.md) — this lesson
- **🚀 Capstone: cấu hình hoàn chỉnh dùng cho công việc thật**
  - [🌿 Tích hợp Git và terminal trong Neovim](https://everwise.study/courses/config-neovim-tren-win-11/tich-hop-git-va-terminal.md)
  - [🩺 Khắc phục lỗi đặc thù trên Windows 11](https://everwise.study/courses/config-neovim-tren-win-11/khac-phuc-loi-dac-thu-tren-windows-11.md)
  - [🏗️ Capstone: đóng gói cấu hình Neovim cho công việc thật](https://everwise.study/courses/config-neovim-tren-win-11/capstone-dong-goi-cau-hinh-neovim.md) (premium content)
  - [✅ Checkpoint: Capstone và xử lý sự cố trên Windows](https://everwise.study/courses/config-neovim-tren-win-11/checkpoint-capstone-windows.md) (premium content)
- [Course cheatsheet](https://everwise.study/courses/config-neovim-tren-win-11/cheatsheet.md) (premium content)
