Prerequisites
Install a package manager - scoop
This step is required to simplify subsequent installation steps. Use the Scoop package manager to install various packages. Open a PowerShell terminal and type
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
Invoke-RestMethod -Uri https://get.scoop.sh | Invoke-Expression
Install a terminal - wezterm
This step is necessary for displaying LazyVim and special icons appropriately. Use a terminal that supports LazyVim - wezterm
scoop bucket add extras
scoop install extras/wezterm
Install command line prerequisites
These shell commands are used with LazyVim, a comprehensive list can be found at the official documentation
scoop bucket add main
scoop install main/git main/neovim main/curl main/gcc main/fzf main/fd main/ripgrep main/unzip extras/lazygit
Install NodeJS with a version manager - nvm
Required for mason
- a package manager used by LazyVim to install various packages
scoop install main/nvm
nvm install lts
nvm use lts
Check if it's working
npm --version
Install version manager for your programming language - pyenv
Note, that uv
is not supported currently as a Python provider. Also, uv
does not allow you to use a specify Python version in your PATH
. Follow this open GitHub issue for more information.
Make sure you're using scoop
as an administrator to install pyenv
correctly.
scoop install main/pyenv
pyenv install 3.11.0b4
pyenv global 3.11.0b4
Reference: https://github.com/pyenv-win/pyenv-win/issues/449
Check if it's working
python --version
Ready to Roll! 🚀
At this point, you're ready to install LazyVim and take the first look. For the reference this command is taken from here
Make a backup of your current Neovim files:
# required
Move-Item $env:LOCALAPPDATA\nvim $env:LOCALAPPDATA\nvim.bak
# optional but recommended
Move-Item $env:LOCALAPPDATA\nvim-data $env:LOCALAPPDATA\nvim-data.bak
Clone the starter
git clone https://github.com/LazyVim/starter $env:LOCALAPPDATA\nvim
Remove the .git folder, so you can add it to your own repo later
Remove-Item $env:LOCALAPPDATA\nvim\.git -Recurse -Force
Start Neovim!
nvim
You should see the package manager installing packages, wait until it finishes.
Checking installation
Type :LazyHealth
to open up the window showing package statuses.
Using LazyVim Extras
to install Python IDE
Next type :LazyExtras
to go to the LazyVim Extras
. Type /
python
to search for Python related packages.
Press x
to install related packages (at the cursor, called lang.python
). Do the same for dap.core
, test.core
editor.refactoring
, lang.json
, lang.markdown
, and lang.toml
. Optionally you can install ui.mini-animate
for an animated cursor and coding.yanky
for and advanced clipboard experience.
Press q
to quit LazyExtras
.
Configuring plugins
Your next step will be to configure some of the Python plugins to ensure, that they're working as you expect. Start LazyVim with the following command to edit your configuration:
nvim $env:LOCALAPPDATA\nvim
First thing to do is to configure the Python extra by setting your LSP server + Ruff command. Edit your lua/config/options.lua
file and these lines:
-- LSP Server to use for Python.
-- Set to "basedpyright" to use basedpyright instead of pyright.
vim.g.lazyvim_python_lsp = "pyright"
-- Set to "ruff_lsp" to use the old LSP implementation version.
vim.g.lazyvim_python_ruff = "ruff"
Reference: https://www.lazyvim.org/extras/lang/python#options
Create a test.lua
under nvim/lua/plugins
folder and configure it like the example below:
return {
"nvim-neotest/neotest",
opts = {
adapters = {
["neotest-python"] = {
dap = { justMyCode = false },
args = { "--capture=no" },
pytest_discover_instances = true,
},
},
},
}
This will ensure, that neotest
and neotest-python
allows you to:
- flush output buffer during testing, so
stdout
andstderr
messages are appearing, while tests are running - set breakpoints and debug inside library code
Next you should create a debug.lua
under nvim/lua/plugins
folder and configure it like the example below:
return {
{
"mfussenegger/nvim-dap-python",
opts = {
justMyCode = false,
},
},
}
This will ensure, that nvim-dap
and nvim-dap-python
allows you to set breakpoints and debug inside library code. The end result should look something like this:
Fixing possible debugpy
issues
Ensure, that you're disabling alias for python
and python3
under your Windows settings!
You might require to install debugpy
with Mason again. You can do this with the :MasonInstall debugpy@1.8.12
command
Creating your first python project
We'll use uv
to generate a Python project and create a virtual environment. Also add pytest
package to verify if testing and debugging works well.
mkdir python-sandbox
cd python-sandbox
python -m venv .venv
.venv\Scripts\activate
Install pytest
executables for testing under your local project
pip install pytest
Make sure you have your local project in the PYTHONPATH
on PowerShell. You can start LazyVim now within your project.
$env:PYTHONPATH = $pwd
nvim .
Checking if key features are working
Testing
You need to verify if your Neotest
is interacting properly with neotest-python
.
Create a simple pytest
test-case and use <leader>ts
for showing up all your test functions implemented under the project. Use r
to run one of your tests to ensure, that things are wired together properly.
Debugging
Final thing to verify if nvim-dap
is interacting with nvim-dap-python
correctly. Put a breakpoint in your code, by using <leader>db
on a line. Next, start a test after showing up all the test functions with pressing d
on the test case's name.
Refactoring
Stop on a function and try hitting <leader>rs
for showing the refactoring menu. You should be able to do simple things, like extracting a new function under selection by pressing f
.
Final thoughts
Limited functionality under Windows
I found out, that testing and debugging has several broken features if you run them from Windows natively. I haven't looked at the root cause, but one of the possible issues are inside nvim-dap-python
and neotest-python
libraries providing debugging and testing functionality. These extension libraries have to make distinction between Windows and Linux runtimes as binaries and virtual environments follow a different convention (e.g. venv/bin/python
VS venv/Scripts/pythonw
). These "conditions" and special cases are often getting broken and patched afterwards. I suggest to install WSL first and then neovim
on the top of that. I covered this approach in another tutorial previously.
Using uv
as a Python version manager
Currently it seems like uv
is not supporting global python versions you can see from this GitHub ticket. If you really like the speed and performance of uv
you can try to combine the best of both worlds: Using pyenv
for managing global Python versions and using uv
for managing your project-specific dependencies.
Top comments (0)