Theme: duskfox
micropython_nvim is a plugin that aims to make it easier and more enjoyable to work on MicroPython projects in Neovim. It uses mpremote, the official MicroPython remote control tool.
See the quickstart section to get started.
N.B. If you open an existing project that has a .micropython configuration file in the root directory, the plugin will automatically configure the port and baud rate for you.
IMPORTANT This plugin assumes you are opening Neovim at the root of the project. Some commands will not behave in the expected way if you choose not to do this.
- Run and upload python files directly to your micro-controller from Neovim
- Easy multi-file project support with recursive directory upload
- Live development with filesystem mounting
- General file management on device
- Easy management of port, baudrate, and other settings
- Easy project environment setup
- Built-in REPL access
- Run local python files on your micro-controller
- Upload local python files to your micro-controller (including recursive directory upload)
- Sync mount local directory for live development without uploading
- REPL access via mpremote
- File management - list, delete files on device
- Device management - list connected devices, reset
- Project initialization
- Neovim >= 0.9
- snacks.nvim
- mpremote
- uv (for dependency management, Unix-only)
Install uv (Unix/macOS):
curl -LsSf https://astral.sh/uv/install.sh | shInstall mpremote (will be installed automatically by uv sync, or manually):
uv tool install mpremote
# or
pip install mpremotelazy.nvim
{
"jim-at-jibba/micropython.nvim",
dependencies = { "folke/snacks.nvim" },
}packer
use {
"jim-at-jibba/micropython.nvim",
requires = { "folke/snacks.nvim" },
}- Install micropython_nvim using your preferred package manager
- Add a keybind to
runfunction:
vim.keymap.set("n", "<leader>mr", require("micropython_nvim").run)- Follow the project setup steps to create the necessary files for a new project.
Next steps
- Add a statusline component
- See the examples directory for multi-file project examples
| Command | Description |
|---|---|
:MPRun |
Run current buffer on the micro-controller |
:MPRunMain |
Run main.py on the device |
:MPUpload |
Upload current buffer to the micro-controller |
:MPUploadAll |
Upload all project files (recursive) |
:MPRepl |
Open MicroPython REPL |
| Command | Description |
|---|---|
:MPSync |
Mount local directory on device for live development |
:MPReset |
Soft reset the device |
:MPHardReset |
Hard reset the device |
| Command | Description |
|---|---|
:MPListFiles |
List files on device |
:MPEraseOne |
Delete single file or folder from device |
:MPEraseAll |
Delete all files from device |
| Command | Description |
|---|---|
:MPInit |
Initialize MicroPython project (creates pyproject.toml, selects board) |
:MPInstall |
Install project dependencies with uv |
:MPSetPort |
Set the device port |
:MPSetBaud |
Set the baud rate (optional, mpremote auto-detects) |
:MPSetStubs |
Set MicroPython stubs for your board |
:MPListDevices |
List connected MicroPython devices |
Commands that open a terminal (:MPRun, :MPRepl, etc.) use snacks.nvim terminal:
| Key | Mode | Action |
|---|---|---|
<Esc><Esc> |
Terminal | Exit to normal mode |
q |
Normal | Close terminal |
:MPUploadAll accepts file or folder names to ignore: :MPUploadAll test.py unused
Default ignore list:
{
'.git', 'pyproject.toml', 'uv.lock', '.ampy', '.micropython', '.vscode',
'.gitignore', 'project.pymakr', 'env', 'venv', '.venv', '__pycache__',
'.python-version', '.micropy/', 'micropy.json', '.idea',
'README.md', 'LICENSE', 'requirements.txt'
}Steps to initialize a project:
-
Create a new directory for your project
-
Open Neovim in the project directory
-
Run
:MPInit- this will:- Prompt you to select your target board (RP2, ESP32, etc.)
- Create
pyproject.tomlwith dependencies and stubs - Create
main.py- starter blink program - Create
.micropython- device configuration - Create
pyrightconfig.json- LSP configuration - Create
.gitignore - Optionally run
uv syncto install dependencies
-
If you skipped the install prompt, run
:MPInstallto install dependencies -
Run
:MPSetPortto set the port (or useautofor auto-detection)
| Board | Stub Package |
|---|---|
| Raspberry Pi Pico (RP2) | micropython-rp2-stubs |
| ESP32 | micropython-esp32-stubs |
| ESP8266 | micropython-esp8266-stubs |
| STM32 / Pyboard | micropython-stm32-stubs |
| SAMD (Wio Terminal) | micropython-samd-stubs |
The .micropython file stores project configuration:
PORT=auto
BAUD=115200
Port options:
auto- Auto-detect first USB serial port/dev/ttyUSB0- Specific port pathid:<serial>- Connect by USB serial number
For projects with multiple files and directories, see the examples/led_button directory.
Key features for multi-file projects:
:MPUploadAllrecursively uploads directories:MPSyncmounts local directory for live development:MPRunMainruns main.py after upload
The :MPSync command mounts your local project directory on the device as /remote. This allows you to:
- Edit files locally
- Changes are immediately available on device (no upload needed)
- Import modules from your local directory
- Rapidly iterate without waiting for uploads
:MPSync " Mount current directory
:MPRepl " Open REPL
>>> import main " Run your code
A statusline component shows the current port configuration.
require("lualine").setup({
sections = {
lualine_b = {
{
require("micropython_nvim").statusline,
cond = package.loaded["micropython_nvim"] and require("micropython_nvim").exists,
},
}
}
})This plugin now uses mpremote instead of ampy. If you have existing projects with .ampy configuration files:
- The plugin will still read
.ampyfiles but will show a deprecation warning - Run
:MPInitto create a new.micropythonconfiguration - Your
.ampyfile can be safely deleted after migration
Key differences:
- No need for rshell - mpremote has built-in REPL
- Auto-detection of devices with
PORT=auto - Recursive directory upload with
:MPUploadAll - Live development with
:MPSync(filesystem mounting)
See the examples directory for complete project examples:
- led_button - Multi-file project with LED and button modules



