Hướng dẫn test plugin locally trước khi push lên GitHub.
cd /Users/caongoccuong/Workspaces/Personal/Development/styled-components.nvim
# Run test environment
./test.shKết quả:
- Neovim mở với test config
- Plugin tự động load từ local directory
- Test file
test/example.tsxđược mở - Status information hiển thị
nvim -u test/init_test.lua test/example.tsxKhi test environment mở, verify:
:lua require("styled-components").print_status()Should show:
{
enabled = true,
auto_setup = true,
injection_available = true,
injection_active = true, -- If cursor in template
injected_language = "css", -- If cursor in template
}Move cursor to styled template:
const Button = styled.div`
display: flex; ← Move cursor here
`;Press <leader>t (or :InspectTree)
Should see: (string_fragment) nodes with language "css"
:LspInfoShould show:
csslsclient attached- Filetypes include:
typescriptreact
In styled template, type:
dis<Ctrl-Space>
Should see:
displaydisplay-insidedisplay-list-item- etc.
Move cursor to display and press K
Should see: MDN documentation in floating window
Add a typo:
const Box = styled.div`
colr: red; // Typo!
`;Should see: Error underline or diagnostic message
Nếu bạn muốn test với Neovim config hiện tại (không dùng test config):
Edit plugin config của bạn:
-- ~/.config/nvim/lua/plugins/styled-components.lua
{
-- Comment out GitHub URL, use local path
-- "crafts69guy/styled-components.nvim",
dir = "/Users/caongoccuong/Workspaces/Personal/Development/styled-components.nvim",
dependencies = {
"nvim-treesitter/nvim-treesitter",
"neovim/nvim-lspconfig", -- Optional for Neovim 0.11+
},
ft = { "typescript", "typescriptreact", "javascript", "javascriptreact" },
opts = {
debug = true, -- Enable debug logging
},
}Sau đó:
:Lazy reload styled-components
# hoặc
:Lazy syncThêm vào init.lua:
-- Before loading plugins
vim.opt.runtimepath:prepend("/Users/caongoccuong/Workspaces/Personal/Development/styled-components.nvim"):lua print(vim.inspect(vim.treesitter.query.get("typescript", "injections")))Should show queries with styled, css, etc.
:set runtimepath?Should include plugin directory.
With debug = true:
:messagesShould show:
[styled-components] TreeSitter injection queries loaded successfully
[styled-components] cssls configured for filetypes: ...
" Check injection available
:lua print(require("styled-components.injection").is_injection_available())
" Check injection active
:lua print(require("styled-components.injection").is_injection_active())
" Get injected language at cursor
:lua print(require("styled-components.injection").get_injected_language_at_pos(0, vim.fn.line(".")-1, vim.fn.col(".")-1))
" Full status
:lua require("styled-components").print_status()Khi bạn edit plugin code:
If using test script:
# Exit Neovim (`:q`)
# Run again
./test.shIf using lazy.nvim:
:Lazy reload styled-componentsIf using manual runtimepath:
" Reload modules
:lua package.loaded["styled-components"] = nil
:lua package.loaded["styled-components.injection"] = nil
:lua require("styled-components").setup({ debug = true })Repeat test checklist above.
Khi mọi test pass:
- Remove test config from your Neovim:
-- Change back to GitHub URL
{
"crafts69guy/styled-components.nvim", -- Not `dir`
-- ...
}- Commit changes:
git add .
git commit -m "feat: treesitter injection architecture"
git push origin main- Test from GitHub:
:Lazy syncPlugin sẽ download từ GitHub và hoạt động giống như local!
import styled from 'styled-components';
const Button = styled.div`
display: flex; // Test completion here
`;import styled, { css, createGlobalStyle, keyframes } from 'styled-components';
// Test: styled.element
const Box = styled.div`
color: red;
`;
// Test: styled(Component)
const StyledButton = styled(Button)`
background: blue;
`;
// Test: css helper
const styles = css`
margin: 10px;
`;
// Test: createGlobalStyle
const Global = createGlobalStyle`
body { margin: 0; }
`;
// Test: keyframes
const fadeIn = keyframes`
from { opacity: 0; }
to { opacity: 1; }
`;Check path is correct:
ls /Users/caongoccuong/Workspaces/Personal/Development/styled-components.nvim- Check cssls installed:
:!which vscode-css-language-server - Check LSP attached:
:LspInfo - Check injection active:
:lua require("styled-components").is_injection_working()
Install parsers:
:TSInstall typescript tsx javascript css
:TSUpdate-
Use debug mode during testing:
opts = { debug = true }
-
Check status frequently:
:lua require("styled-components").print_status()
-
Use
:InspectTreeto verify injection:- Should see
csslanguage nodes in templates
- Should see
-
Test all patterns:
styled.divstyled(Component)- `css``
- `createGlobalStyle``
- `keyframes``
-
Watch
:messagesfor errors
- README.md - Full documentation
- QUICKSTART.md - 2-minute setup
- CLAUDE.md - Architecture details
Happy testing! 🎉