7.7 KiB
VS Code-like Profile Setup for Neovim
This configuration implements a VS Code-like "profiles" system where language-specific plugins and tools only load when working with their respective file types.
🎯 Architecture
File Structure
~/.config/nvim/
├── init.lua # Main config with shared LSP, Treesitter, etc.
└── lua/
└── custom/
└── plugins/
├── init.lua # Common plugins (Copilot, Neo-tree)
├── flutter.lua # Flutter/Dart profile
├── python.lua # Python profile
└── svelte.lua # Svelte/Web profile
How It Works
- lazy.nvim loads plugins based on file types (
ft = { 'dart', 'python', 'svelte' }) - When you open a
.dartfile → Flutter tools load - When you open a
.pyfile → Python tools load - When you open a
.sveltefile → Svelte tools load - Common plugins (Copilot, Neo-tree) are always available
📦 What's Included
Common (All Profiles)
- GitHub Copilot: AI pair programming
- Neo-tree: File explorer (commented out, enable if desired)
- Telescope: Fuzzy finder
- Treesitter: Syntax highlighting
- blink.cmp: Autocompletion engine
- lua_ls: LSP for Neovim config editing
Flutter Profile (flutter.lua)
Loads on: .dart files
Tools:
flutter-tools.nvim: Flutter development toolsdartls: Dart LSP server- Widget guides, closing tags, hot reload
Keymaps (under <leader>f):
<leader>fr- Flutter run<leader>fq- Flutter quit<leader>fR- Flutter restart<leader>fd- Flutter devices<leader>fe- Flutter emulators<leader>fo- Flutter outline<leader>fc- Copy profiler URL<leader>fl- Restart LSP
Python Profile (python.lua)
Loads on: .py files
Tools:
pyright: Python LSP server with type checkingruff_format: Fast Python formatterruff_organize_imports: Import sorting- Alternative:
black+isort(commented out)
Format on save: Enabled for Python files
Svelte Profile (svelte.lua)
Loads on: .svelte, .ts, .js files
Tools:
svelte-language-server: Svelte LSPts_ls: TypeScript/JavaScript LSPtailwindcss: Tailwind CSS LSP with completionsprettier: Code formatter for web filesemmet-vim: HTML/CSS abbreviation expansion
Keymaps:
<C-e>,- Expand Emmet abbreviation (e.g.,div.container→ full HTML)
Treesitter parsers: svelte, typescript, tsx, javascript, css, html, json
🚀 Installation Steps
1. Restart Neovim
nvim
2. Install Plugins
Once Neovim opens, lazy.nvim should automatically start installing plugins. If not:
:Lazy sync
Wait for all plugins to install. This may take a few minutes.
3. Install LSP Servers & Tools
:Mason
Press g? for help. Verify these are installed:
- Flutter:
dart-language-server(dartls) - Python:
pyright,ruff,black(optional),isort(optional) - Svelte:
svelte-language-server,typescript-language-server,tailwindcss-language-server,prettier - Common:
lua-language-server,stylua
Mason will auto-install most of these via mason-tool-installer.
4. Install Treesitter Parsers
Parsers should auto-install when you open files. To manually install:
:TSInstall dart python svelte typescript tsx javascript css html json
Check status:
:TSInstallInfo
5. Test Each Profile
Test Flutter Profile
nvim test.dart
Inside Neovim:
- Type some Dart code (e.g.,
void main() {) - Check LSP is active:
:LspInfo - Try hot reload keymaps if in a Flutter project:
<leader>fr
Test Python Profile
nvim test.py
Inside Neovim:
- Type some Python code (e.g.,
def hello():) - Check LSP is active:
:LspInfo - Save file to trigger auto-formatting
- Try hover:
Kon a function/variable
Test Svelte Profile
nvim test.svelte
Inside Neovim:
- Type Svelte component code
- Check LSP is active:
:LspInfo - Try Emmet: type
div.container>ul>li*3then<C-e>, - Save file to trigger prettier formatting
🔧 Configuration Details
Node.js for Copilot
Node.js is configured via fnm (Fast Node Manager):
- Path:
~/.local/share/fnm/aliases/default/bin - Version: Currently v24.11.0 LTS
- Auto-update: Using fnm aliases, so updating Node.js via
fnm install --ltswill automatically work
To update Node.js:
fnm install --lts
fnm default lts-latest
Shared LSP Capabilities
All language-specific LSPs use shared capabilities from blink.cmp for consistent completion behavior. This is configured automatically.
Format on Save
Enabled by default for all languages except C/C++. Language-specific formatters are defined in their respective profile files.
To disable for a specific file type, edit init.lua:
local disable_filetypes = { c = true, cpp = true, python = true } -- example
📝 Customization
Adding a New Language Profile
- Create
lua/custom/plugins/mylang.lua:
return {
{
'neovim/nvim-lspconfig',
ft = { 'mylang' }, -- file type trigger
config = function()
local capabilities = require('blink.cmp').get_lsp_capabilities()
require('lspconfig').mylang_ls.setup {
capabilities = capabilities,
}
end,
},
{
'stevearc/conform.nvim',
ft = { 'mylang' },
opts = {
formatters_by_ft = {
mylang = { 'my_formatter' },
},
},
},
{
'nvim-treesitter/nvim-treesitter',
ft = { 'mylang' },
opts = {
ensure_installed = { 'mylang' },
},
},
}
- Restart Neovim and open a
.mylangfile
Enabling Neo-tree
The file tree is currently commented out. To enable:
Edit lua/custom/plugins/init.lua and uncomment the Neo-tree section:
return {
{
'nvim-neo-tree/neo-tree.nvim',
-- ... (uncomment the entire block)
},
}
Then :Lazy sync and use <leader>e to toggle the file tree.
Changing Keymaps
Edit the respective language file in lua/custom/plugins/.
Example: Change Flutter hot reload from <leader>fr to <leader>h:
-- In lua/custom/plugins/flutter.lua
vim.keymap.set('n', '<leader>h', '<cmd>FlutterRun<cr>', { desc = '[H]ot reload' })
🐛 Troubleshooting
Plugins not loading
:Lazy check
:Lazy sync
LSP not working
:LspInfo " Check if LSP is attached
:Mason " Verify servers are installed
:checkhealth lsp " Run LSP diagnostics
Copilot not working
:Copilot setup " Initial setup (if not done)
:Copilot status " Check connection
If Node.js path issues:
# Verify Node.js is in fnm default alias
ls ~/.local/share/fnm/aliases/default/bin/node
Formatter not running on save
Check if formatter is installed:
:Mason
Check if file type has formatter configured:
:ConformInfo
Treesitter parsers missing
:TSInstall <parser_name>
# Or install all at once:
:TSInstall dart python svelte typescript tsx javascript css html json
📚 Resources
- Neovim LSP:
:help lsp - lazy.nvim:
:help lazy.nvim - Telescope:
:help telescope.nvim - Treesitter:
:help nvim-treesitter - conform.nvim:
:help conform.nvim - Mason:
:help mason.nvim
🎉 What's Next?
Your setup is ready! Here are some next steps:
- Explore Copilot: Try getting AI suggestions as you code
- Learn Flutter Tools: Use
<leader>frto run Flutter apps with hot reload - Try Emmet: Speed up HTML/Svelte writing with abbreviations
- Customize: Add more keymaps, plugins, or language profiles as needed
- Consider Neo-tree: Uncomment if you prefer a file explorer sidebar
Enjoy your VS Code-like Neovim setup! 🚀