Wow! finally, a comprehensive guide to setting up Python with Neovim! Your tutorial is incredibly helpful. I would greatly appreciate it if you could delve deeper into LSP integration related to Python virtual environments. Your insights are invaluable!
for python envs i currently use conda and dynamically just grab the path variable on lsp attach. I just always have the correct env activated before opening nvim. works well for me
@@jeffrey5602 yes I understood that part, and looks like mason installs the binary into its data directory. My question was concerned handling multiple virtual envs, but I think I understand it now
This was really cool, thanks man I am glad I watched this even though it is a python setup and I work on full-stack with node I can now make my own version and extend it when needed. Really appreciate this tutorial ❤
Thats cool, so you reference a relative path in your neovim config or something like that? I dont really understand. The way I do it now is to activate my virtual env first then open neovim.
Atm I just have a line in my zshrc that automatically enters a venv when the .venv folder is present in the cwd. I didn't know that you can directly configure the path for your LSP (like you did at 23:28). So made me think maybe its possible to just use a relative path in the config (./.venv)
I love the overlaying of the relevant information with you talking in the background. Overall, it was great editing. The subtitles placed right in the middle of the screen confused me. And great office setup.
You don’t need to do all this complicated setup to get Python autocompletion. I don’t know about pyright, but if you install Jedi instead, all you need is to make sure your Python environment is activated before launching nvim. Jedi will automatically inspect your activated environment and provide autocompletion and hover for your installed modules.
Very nice video. It really helped me get started and also finally use virtualenvs inside vim. There is a small issue I cannot find how to solve. I would also like to add CNTRL + Space to act as CNTRL + n, basically to select suggestions of the autocomplete. Can you give me a hint how to do it? I have tried different things but nothing seems to work. Thank you very much.
thank you for awesome video! i'm very noob on neovim. by the way i have one question for you from 22:47 on video. actually i want to connect with my conda env so i did 138 line as like ( env_path.join(vim.env.HOME, "/opt/homebrew/anaconda3/envs", "lab", "bin", "python") (lab is for my conda env name). but it seems like not working for me. i made test directory like as you did, and made test.py (also i ensured that i have been installed numpy in my conda env). when i import numpy, there are some error (Unable to import 'numpy' (import-error), Import 'numpy' could not be resolved). can you help me?
Thank you. I dont believe conda envs should be a problem. In the code you wrote you start your path with vim.env.HOME - remove that part. /opt/hormbrew/… is an absolute path. Also try without using the path.join utility function and just use a string that has the absolute path to your environment
Hi thank you for your video continue it's very good work :), I want to know , with which key did you replace ESC to activate the different modes (insert,visual,ect ....), because the esc key is rather difficult to reach I don't find it practical do you have any ideas? thx :)
For some reason, pyright can't recognize pandas dataframes, even though it(maybe not pyright but something) is providing code suggestions. This has been a well documented issue in reddit by many people and I'm facing this too. How did you solve that?
Hmm I’m not sure it never gave me a problem. Try installing a new virtual environment then pip install pyright and pandas and activating it, then run vim and see if that works
Follow the installation instructions on be GitHub repository for the plugin. Then try :NvimTreeOpen and if that doesn’t work it means it was not installed properly
I am going to do python programing with neovim, but my working is mostly relevant to AI development, and anaconda is a important tool of package management for me, is the neovim works well with anaconda
Hmm I'm not sure. You could try using regular vim buffer commands (":bn" or ":bp"). This will let you know if they are opening but just not being rendered by the plugin. You can also check the install/usage instructions for "bufferline.nvim" on github. Another plugin you could try is "lualine.nvim" which gives tab info at the bottom of the window, I believe.
But thats not how you would use python for a real world project, you would use diff interpretor per project most likely. So how would you configure neovim to use diff venv for each project?
23:13 - Instead of this why not just setup a virtual environment in the python project you are working on, enter it using source myvenv/bin/activate, pip install pyright and then open up neovim?
@@ZazenCodes Thanks, yes you are right, pip install pyright is not required. This LSP can be provided by NodeJS using npm commands in the terminal. I managed to simplify your setup by discarding mason and mason-lspconfig (seemed overkill) and using the following lines in lua to get C++ and Python LSP stuff working. -- LSP Stuff require'lspconfig'.pyright.setup{} require'lspconfig'.clangd.setup{} require'cmp'.setup() local cmp = require('cmp') cmp.setup({ sources = { {name = 'nvim_lsp'}, }, mapping = cmp.mapping.preset.insert({ -- Enter key confirms completion item [''] = cmp.mapping.confirm({select = false}), -- Ctrl + space triggers completion menu [''] = cmp.mapping.complete(), -- Use tab to select next item [''] = cmp.mapping.select_next_item(), }), snippet = { expand = function(args) require('luasnip').lsp_expand(args.body) end, }, })
Hey there, didn't see you running the code, as of now this is more of a Text Editor setup right? You didn't show any debugging, environment selection or unit testing, or did I miss something?
Not to criticize or anything, but would like to know if it is possible to do such things in NVIM, I tried using nvim-dap-python, with Anaconda + unittesting some cases, but to no avail.
@@rzimmerdev No worries! Its true this setup doesn't include any help for unit testing or interactive debugging, for example. There are nvim plugins for these things that you can add to your lazy.lua file. I configure my python env in neovim at 23:10 - you can see how I'm telling neovim what python to look for on my computer to provide proper linting. You can write more complicated lua code to automatically find the appropriate python, e.g. if you have a virtual env running. I have not tried this with conda, but you can find see my "dotfiles" repository on github (link in comments) and find my lsp.lua file and look for a function "get_python_path" that might help you
Good video. By the way you dont really need to specify to neovim which interpreter to use. It will use the one available to it. Ie if you activate and env then start neovim and do `:! which python` you will see you are using the python from your venv. So I have a venv for each project and in theat I have my linteres like mypy for example (and black). Now it will use mypy and black and better yet mypy will use the libs in the venv for getting the types and checking exports. This is prob the best and simplest way to do it. Otherwise if you use a mypy in a different env it wont know about the types in the libs you import. I use pylsp with flake8 and mypy because it is a touch more standard than pyright and not everyone I work with is using neovim :)
Friend how will “it” know which venv to use for the project, is there a standard naming convention for the venv in the project root say .venv or .env? Appreciate the help, a noob here.
@@Sam-rb1id Thank you for replying so what one should do is activate a venv in your shell and then run neovim from that shell so that it knows which venv it is in?
Hi alex i'm in windows and i want to know how you do for install your IDE in Windows . I create a alias for change nvim in vim but for this stape -> mkdir ~/.config cp -r .config/nvim ~/.config/nvim i don't know how i can do , in windows the neovim path is C:\Program Files\Neovim do you have an idea . thank you :)
I would pay an obscene amount of $$$ for a web dev course, from html and css on up to fullstack and modern stuff, that included setting up Neovim and then using it exclusively to build things on my Linux machine. Obscene $$$!!! 👍
I'm not sure. Looks similar to conda for python? I don't use conda with neovim myself but there is probably a way to configure conda env with LSP - if that's what you mean
It is a package manager but much faster than conda. Setting up lsp pyright is cumbersome. Perhaps it had to do with mason being in the middle. It works so much better in viscode.
No, trying to edit a neovim distro to your liking is the opposite of simple. Better of building from scratch so you actually know the config and actually learning the basics of neovim.
I've never gotten a good answer to this question yet, but I'll ask in the hopes that you can answer. Why NeoVim over vanilla Vim? If you want to use Lua for configuration you can still do that for vanilla Vim if you build it manually with Lua support, and you can do the same with Python, Perl, Ruby and some other languages. Most of what you do here with plugins I can do in vanilla Vim with just editing my ~/.vimrc, and some of it I have already been doing for a while. Although, I use regular tabs instead of buffers, and you can open multiple files from the command line into separate tabs with `vim -p foo bar baz`. If you've never built it from source then let me reassure you that it's easy to do. I have to enable mouse support every time I update and I've yet to find a distro that enables that in their build. The only other questions I have are why use space for your leader and do you use a different leader for insert mode?
I probably won't give you the answer you're looking for. I went with neovim because that seemed to be where the most development / community support was. I believe that having lua builtin and standard for neovim if a big upside. For me it's time consuming enough to set all this up without any extra work and I want to make it as easy as I can while still getting that awesome vim experience. I'm not sure why I use space for leader but I like that I can use my thumb for it. Do you use the default key? In insert mode its still space for me, I just leave insert mode with before I use leader
@@ZazenCodes I'm not sure I remember what the default key is. If it's \ then yes. As for setup, I just keep pulling my same ~/.vimrc forward onto new systems and as long as I've configured the build right, which you can easily put into a bash script and carry as well, then it's just a matter of make -j8 and wait. I only use 8 cores because I have it running in the background. As for using the leader in code, it introduces a visual delay when I have to type an escape in some string, but it doesn't prevent me from continuing to type, so I don't really need to handle it specially. I can't imagine how space has affected your speed. For that matter, I kind of wonder how much time you spend on configuring when you move to a new system. For me, since my home drive is separate I can just keep going and simply use it. If I need a fresh install I clone the repository, configure, make, copy over my config and done.
There may never be a benefit for you. There are some out of the box like startup time, integration with tmux, native vs emulated vim motions etc. but nothing game changing. Then you need nvim plugins to get up to the baseline of what vscodium offers. Then vscodium extensions and nvim plugins stay pretty neck and neck for offering additional functionality. Then nvim pulls ahead with the last 10% or so of customization because its more flexible IF you want to put the work in. It's little things like luasnips offering more powerful snippet functionality because you can perform function evaluations in the snippet itself, or being able to custom keybind execution of your personal scripts and small programs. For the majority of people vscodium vs nvim will be gui vs terminal. And you'll see more benefit from learning your tool very well then just using another tool. Heck, I might be wrong about that last 10% simply because I don't know vscodium well enough to know there are extensions or built in functionality to do the same things in vscodium that I want to do in nvim.
Great information, terrible presentation. It took me 3 hours to follow your video, with 2 hours of rewinding. You are pressing too many keys in the same time.
you have a really good talent at explaining things really simple yet informative ; really beginner friendly. great job and keep it up!
Thanks! I appreciate you taking a moment to let me know
Wow! finally, a comprehensive guide to setting up Python with Neovim! Your tutorial is incredibly helpful. I would greatly appreciate it if you could delve deeper into LSP integration related to Python virtual environments. Your insights are invaluable!
Thanks very much!
Thank you for showing pyright from scratch, I have been struggling with this for a few days and I think this will get me over the wall
Your videos are great! I expect your channel to really take off soon:)
Thank you for the video. Definitely need to watch it multiple times.
Awesome video, thanks! As a long-time Neovim user, I recently moved to Helix. It still has a ways to go for full maturity, but it's very productive.
for python envs i currently use conda and dynamically just grab the path variable on lsp attach. I just always have the correct env activated before opening nvim. works well for me
That makes sense, one thing I didn't understand in the video is do you install the language server in the venv or globally?
@you install language servers with the mason nvim plugin
@@jeffrey5602 yes I understood that part, and looks like mason installs the binary into its data directory. My question was concerned handling multiple virtual envs, but I think I understand it now
23:00
If it's active in the shell it should be active in neovim.
So just activate it with source venv/bin/activate and then enter neovim
thank you!!
Great video! May I ask what terminal you use? Looks so clean. I've started my journey on neovim but haven't found a terminal I like personally.
Thanks for the tutorial. Very informative.
This was really cool, thanks man I am glad I watched this even though it is a python setup and I work on full-stack with node I can now make my own version and extend it when needed. Really appreciate this tutorial ❤
Awesome, thanks!
I typically put my virtual environments as .venv/ in the project dir, that way the local path is the same for all my projects
Thats cool, so you reference a relative path in your neovim config or something like that? I dont really understand.
The way I do it now is to activate my virtual env first then open neovim.
Atm I just have a line in my zshrc that automatically enters a venv when the .venv folder is present in the cwd. I didn't know that you can directly configure the path for your LSP (like you did at 23:28). So made me think maybe its possible to just use a relative path in the config (./.venv)
I love the overlaying of the relevant information with you talking in the background. Overall, it was great editing. The subtitles placed right in the middle of the screen confused me. And great office setup.
Haha noted! Thank you
hi there
Sadly markdown-preview is not supported anymore
so I receive some failures
You don’t need to do all this complicated setup to get Python autocompletion. I don’t know about pyright, but if you install Jedi instead, all you need is to make sure your Python environment is activated before launching nvim. Jedi will automatically inspect your activated environment and provide autocompletion and hover for your installed modules.
Any of you guys got an error when loading the Markdownpreview on lazy?
Very nice video. It really helped me get started and also finally use virtualenvs inside vim. There is a small issue I cannot find how to solve. I would also like to add CNTRL + Space to act as CNTRL + n, basically to select suggestions of the autocomplete. Can you give me a hint how to do it? I have tried different things but nothing seems to work. Thank you very much.
How do you get your moonlander to actually keeep its tilt? The wrist wrest doesn’t lock right?
mate, but what about change venvs for each project? Do u have any automatic solution for that?
I tried something, but never could get it working. I activate the virtual environment before going into vim- that works
thank you for awesome video! i'm very noob on neovim. by the way i have one question for you from 22:47 on video. actually i want to connect with my conda env so i did 138 line as like ( env_path.join(vim.env.HOME, "/opt/homebrew/anaconda3/envs", "lab", "bin", "python") (lab is for my conda env name). but it seems like not working for me. i made test directory like as you did, and made test.py (also i ensured that i have been installed numpy in my conda env). when i import numpy, there are some error (Unable to import 'numpy' (import-error), Import 'numpy' could not be resolved). can you help me?
Thank you. I dont believe conda envs should be a problem. In the code you wrote you start your path with vim.env.HOME - remove that part. /opt/hormbrew/… is an absolute path. Also try without using the path.join utility function and just use a string that has the absolute path to your environment
do you have a tutorial on how to setup and configure obsidian within vim?
Yup
Hi thank you for your video continue it's very good work :), I want to know , with which key did you replace ESC to activate the different modes (insert,visual,ect ....), because the esc key is rather difficult to reach I don't find it practical do you have any ideas? thx :)
Thanks! I use ctrl+c (command on mac, I think) to go from insert to visual mode. It works by default
Just brilliant!
How do you get your sound so clear with the mic so far away? I also have blue yeti, but it sounds like trash wherever I put it 😅
I did some post processing. Also use the cardioid mode
For some reason, pyright can't recognize pandas dataframes, even though it(maybe not pyright but something) is providing code suggestions. This has been a well documented issue in reddit by many people and I'm facing this too. How did you solve that?
Hmm I’m not sure it never gave me a problem. Try installing a new virtual environment then pip install pyright and pandas and activating it, then run vim and see if that works
There are always some packages that just don't budge. Life of python dev. Sometimes even in VScode packages like opencv refuses to give intellisense
Super cool. I tried your configs, and kinda starting to like it. Can I know which terminal you're using?
Nice! I’m using alactritty
hey in File tree i installed it sucessfully but when i use space e it says that command as not an editor command . Can you please help me with that
Follow the installation instructions on be GitHub repository for the plugin. Then try :NvimTreeOpen and if that doesn’t work it means it was not installed properly
I am going to do python programing with neovim, but my working is mostly relevant to AI development, and anaconda is a important tool of package management for me, is the neovim works well with anaconda
Sure, but I dont use anaconda anymore so I haven’t tried it. Im sure you can find resources online to help
Thank you!!!
Thanks, I’m glad you liked it
I’m unable to reproduce the buffer tabs, it replaces current tab with new one when I open any other file from the tree
Hmm I'm not sure. You could try using regular vim buffer commands (":bn" or ":bp"). This will let you know if they are opening but just not being rendered by the plugin. You can also check the install/usage instructions for "bufferline.nvim" on github. Another plugin you could try is "lualine.nvim" which gives tab info at the bottom of the window, I believe.
But thats not how you would use python for a real world project, you would use diff interpretor per project most likely. So how would you configure neovim to use diff venv for each project?
How I do it now is just activate the virtual environment before opening nvim
Thanks for effort, Man, But you make a tutorial for windows please
23:13 - Instead of this why not just setup a virtual environment in the python project you are working on, enter it using source myvenv/bin/activate, pip install pyright and then open up neovim?
This is what I’ve started doing. I haven’t needed to install pyright in the venvs though
@@ZazenCodes Thanks, yes you are right, pip install pyright is not required.
This LSP can be provided by NodeJS using npm commands in the terminal.
I managed to simplify your setup by discarding mason and mason-lspconfig (seemed overkill) and using the following lines in lua to get C++ and Python LSP stuff working.
-- LSP Stuff
require'lspconfig'.pyright.setup{}
require'lspconfig'.clangd.setup{}
require'cmp'.setup()
local cmp = require('cmp')
cmp.setup({
sources = {
{name = 'nvim_lsp'},
},
mapping = cmp.mapping.preset.insert({
-- Enter key confirms completion item
[''] = cmp.mapping.confirm({select = false}),
-- Ctrl + space triggers completion menu
[''] = cmp.mapping.complete(),
-- Use tab to select next item
[''] = cmp.mapping.select_next_item(),
}),
snippet = {
expand = function(args)
require('luasnip').lsp_expand(args.body)
end,
},
})
Hey there, didn't see you running the code, as of now this is more of a Text Editor setup right? You didn't show any debugging, environment selection or unit testing, or did I miss something?
Not to criticize or anything, but would like to know if it is possible to do such things in NVIM, I tried using nvim-dap-python, with Anaconda + unittesting some cases, but to no avail.
@@rzimmerdev No worries! Its true this setup doesn't include any help for unit testing or interactive debugging, for example. There are nvim plugins for these things that you can add to your lazy.lua file. I configure my python env in neovim at 23:10 - you can see how I'm telling neovim what python to look for on my computer to provide proper linting. You can write more complicated lua code to automatically find the appropriate python, e.g. if you have a virtual env running. I have not tried this with conda, but you can find see my "dotfiles" repository on github (link in comments) and find my lsp.lua file and look for a function "get_python_path" that might help you
Good video. By the way you dont really need to specify to neovim which interpreter to use. It will use the one available to it. Ie if you activate and env then start neovim and do `:! which python` you will see you are using the python from your venv. So I have a venv for each project and in theat I have my linteres like mypy for example (and black). Now it will use mypy and black and better yet mypy will use the libs in the venv for getting the types and checking exports. This is prob the best and simplest way to do it. Otherwise if you use a mypy in a different env it wont know about the types in the libs you import. I use pylsp with flake8 and mypy because it is a touch more standard than pyright and not everyone I work with is using neovim :)
Friend how will “it” know which venv to use for the project, is there a standard naming convention for the venv in the project root say .venv or .env? Appreciate the help, a noob here.
@@JazzBrown-ym8ku it uses whichever venv is currently active. Just in the same way the terminal does
@@Sam-rb1id Thank you for replying so what one should do is activate a venv in your shell and then run neovim from that shell so that it knows which venv it is in?
@@JazzBrown-ym8ku exactly that :)
@@Sam-rb1id Thank you, bro. Appreciate the help.
Hi alex i'm in windows and i want to know how you do for install your IDE in Windows . I create a alias for change nvim in vim but for this stape ->
mkdir ~/.config
cp -r .config/nvim ~/.config/nvim
i don't know how i can do , in windows the neovim path is C:\Program Files\Neovim do you have an idea . thank you :)
I would pay an obscene amount of $$$ for a web dev course, from html and css on up to fullstack and modern stuff, that included setting up Neovim and then using it exclusively to build things on my Linux machine. Obscene $$$!!! 👍
lol thank you. I'm working on ML courses that just have light frontend- I'm not a web dev
@@ZazenCodes Even better! I found your Patreon. See you there!
Does this work with mamba as package manager and environments?
I'm not sure. Looks similar to conda for python? I don't use conda with neovim myself but there is probably a way to configure conda env with LSP - if that's what you mean
It is a package manager but much faster than conda. Setting up lsp pyright is cumbersome. Perhaps it had to do with mason being in the middle. It works so much better in viscode.
Very good video
☺️
sir do you still use yank to clipboard now?
Hell yea love that one
y u no use mason for lsp installation?
I believe this setup does include mason - but true, I didn't use it for the demo
For a "simple" setup, wouldn't you just install LazyVim (that has the plugins and configurations)? And then edit that to your liking?
No, trying to edit a neovim distro to your liking is the opposite of simple. Better of building from scratch so you actually know the config and actually learning the basics of neovim.
22:00
Hmm human music, i like it.
Peace among worlds ✌️
this guy is too attractive to be using vim. Is this AI generated?
Lol
Just found this. Decent vid. However the git source does not match the vid at all. Still its useful.
debugger?
I've never gotten a good answer to this question yet, but I'll ask in the hopes that you can answer. Why NeoVim over vanilla Vim? If you want to use Lua for configuration you can still do that for vanilla Vim if you build it manually with Lua support, and you can do the same with Python, Perl, Ruby and some other languages. Most of what you do here with plugins I can do in vanilla Vim with just editing my ~/.vimrc, and some of it I have already been doing for a while. Although, I use regular tabs instead of buffers, and you can open multiple files from the command line into separate tabs with `vim -p foo bar baz`. If you've never built it from source then let me reassure you that it's easy to do. I have to enable mouse support every time I update and I've yet to find a distro that enables that in their build.
The only other questions I have are why use space for your leader and do you use a different leader for insert mode?
I probably won't give you the answer you're looking for. I went with neovim because that seemed to be where the most development / community support was. I believe that having lua builtin and standard for neovim if a big upside. For me it's time consuming enough to set all this up without any extra work and I want to make it as easy as I can while still getting that awesome vim experience.
I'm not sure why I use space for leader but I like that I can use my thumb for it. Do you use the default key? In insert mode its still space for me, I just leave insert mode with before I use leader
@@ZazenCodes I'm not sure I remember what the default key is. If it's \ then yes. As for setup, I just keep pulling my same ~/.vimrc forward onto new systems and as long as I've configured the build right, which you can easily put into a bash script and carry as well, then it's just a matter of make -j8 and wait. I only use 8 cores because I have it running in the background. As for using the leader in code, it introduces a visual delay when I have to type an escape in some string, but it doesn't prevent me from continuing to type, so I don't really need to handle it specially. I can't imagine how space has affected your speed. For that matter, I kind of wonder how much time you spend on configuring when you move to a new system. For me, since my home drive is separate I can just keep going and simply use it. If I need a fresh install I clone the repository, configure, make, copy over my config and done.
The keyboard sound is so annoying 🙉
Debugger? Sike
Experts dont use Chrome!
No AI huh
Didn't see any benefit over VSCodium yet, a lot of friction for nothing
That's fair. The friction is real!
There may never be a benefit for you. There are some out of the box like startup time, integration with tmux, native vs emulated vim motions etc. but nothing game changing. Then you need nvim plugins to get up to the baseline of what vscodium offers. Then vscodium extensions and nvim plugins stay pretty neck and neck for offering additional functionality. Then nvim pulls ahead with the last 10% or so of customization because its more flexible IF you want to put the work in. It's little things like luasnips offering more powerful snippet functionality because you can perform function evaluations in the snippet itself, or being able to custom keybind execution of your personal scripts and small programs. For the majority of people vscodium vs nvim will be gui vs terminal. And you'll see more benefit from learning your tool very well then just using another tool. Heck, I might be wrong about that last 10% simply because I don't know vscodium well enough to know there are extensions or built in functionality to do the same things in vscodium that I want to do in nvim.
@@badluckprophet9103 I have 2-5 extensions and color theme, for last 5 years worked perfectly and did the job.
Great information, terrible presentation. It took me 3 hours to follow your video, with 2 hours of rewinding. You are pressing too many keys in the same time.
Jj
black is slow, use ruff instead
👀
I love python and it's libraries
As the libraries age turn to rust the tooling gets faster 😊
Python is slow, use c++ instead
@@Cowboydjrobot compilation is bloat, code in assembly