I love to use vscode. Lately I love nvim editor as well. The initial configuration for neovim was a steep learning curve. Thanks to kickstart.nvim which helped me at last. Now I have put Neovim and my configuration in dockerfile so that this environment can be used as devbox.
Prepare your python development environment in container. This devbox contains neovim with kickstarter.nvim config I have added python debug support and neotree as extra
# Build your devbox image
docker build -t devbox -f devbox.Dockerfile .
# To run the container in background
docker run -td --name mydevbox -v $(pwd):/workspaces devbox
# -v $(pwd) is used to create volume inside container . IF you run from the folder where your source code is available then your container will have source code in it. You can use this as development box
# To enter into devbox
docker exec -it mydevbox /bin/bash
# You can do debug using standard keys used in vscode
F5 - to start debug
F9 - to toggle debug breakpointer
F10 - step over
F11 - step into
shift + F11 - step out
F7 - to toggle the DapUI. Using this last debug session result can be seen
# Below are some more options frequently used
Space + gd = Go to definition
Space + gr = Find references
Space + rn - Rename a variable - Equal to F2 in vscode
Space + ds - Display symbols (functions/variable etc)
Space + sf - Search files( Fuzzy finder) equal to Ctrl+p in vscode
Space + sw - Search words in file (Equal to Ctrl+shift+f in vscode)
zR - Expand all fold
zM - Collapse all folds (we can also use mouse as ufo plugin is installed)
gp - goto preview in floating window
gP - close the goto preview floating window
Ctrl+e - to open file explorer (Neotree)
:NeoTree will open the file tree (or) Ctrl+b
:Format will format the python file with black format (Need to install black using command :MasonInstall black)
:only this will close other except current file
git clone https://github.com/SamPosh/PyDevbox ~/.config/nvim --depth 1 && nvim
rm -rf ~/.config/nvim
rm -rf ~/.local/share/nvim
rm -rf ~/.cache/nvim
This repo is forked from Kickstarter.nvim For nvim configuration refer : https://github.com/nvim-lua/kickstart.nvim
- It is inside container. So this devbox can act like devcontainer (vscode)
- Code block can be collapsed/expanded like vscode
- Debugging can be done for python/Pytest. Also added sample configuration for profiler as well.
The reason why this Pydevbox is created to solve the problem of installing debugpy inside virtual env. I tried other NEOVIM distro but always stuck at the point where i have to use debugpy. But thankfully with the kickstarter.nvim inside container doesn't need debugpy to be installed inside venv
I am using Termius terminal emulator.
Using Fira code font
Debugger key binding are like vscode`
Ctrl+j will toggle terminal (using toggleterm)
Debug configuration is available in this file https://github.com/SamPosh/PyDevbox/blob/master/lua/kickstart/plugins/dap/handler/python.lua If you want to add additional configuration then you can add it here
Paste into nvim works fine. But copy from neovim to outside doesn't work. I could not figure out any solution till now. So for copying contents i am using alternate solution like cat it and copy it from terminal. This is a minor problem
https://medium.com/free-code-camp/how-not-to-be-afraid-of-vim-anymore-ec0b7264b0ae