I am getting started with vim , for python.
(edit1 - It's been a while I have been using vim for not only python but C and C++ also.)
(edit2 - It's major upgrade now in my vimrc, will be adding a new file coc-setting.json.)
(Now I know about releases so no more edit updates)
I started using coc.nvim and it's really a game changer.
Added lot of comments to .vimrc file to make it readable and to understand commands.
- If you want to install more plugins just place that plug statement in .vimrc between
call plug#begin()
Plug "--something--"
call plug#end()
After you install coc.nvim you need to run these commands.
- :CocInstall coc-python (This will install python support for your coc.nvim i.e. autocompletion)
- :CocInstall coc-clangd (This will install C and C++ support for coc.nvim i.e. autocompletion)
- :CocInstall coc-highlight (It is for better highlighting of code)
- :CocInstall coc-json (Json - support)
- :CocInstall coc-vimlsp (VimL - support)
Remapped so that it acts like escape that help window is so annoying. Some basic things, I use frequently in vim
- Leader key is set to SPACEBAR.
- Arrow keys are disabled only for insert and normal mode, it will work in command mode.
- While in Insert mode if you want to move to end of the line press CTRL-E and for the top of the line press CTRL-A.
- Most used commenting feature that comes with NERDcommentor.
Press Leader+cs - To comment out the whole line your cursor is on.
Press Leader+c$ - To comment from where your cursor is to the end of the line.
5.fzf.vim ---> Very use full plug, for searching file and inside files.Just :FZF or ff+Enter for files or L for searching lines of the current buffer. It changes workflow entirely.
MAKE SURE TO INSTALL POWERLINE FONTS FOR AIRLINE TO WORK PROPERLY (IF YOU DON'T WANT TO INSTALL JUST REMOVE LINE 64, 65 and 66 FROM VIMRC) Font
Read the official documentation for more efficiency while writing code
fugitive
airline
simpylfold
autopairs
airline-themes
nerdcommenter
vim-surround
stopwatch
indent-line
coc.nvim
coc.python--- Refer to this to understand what's going in coc-setting.json.
coc.clangd
coc.vimlsp
coc.json
coc.highlight
coc-snippets
rainbow
virtualenv
taglist----------I mainly use :Tlist command to see my function and declarations at once.
fzf
vim-repeat
vim-muliple-cursor---Read it's documentation for sure it's amazing.
vim-signature ------It shows your marked lines read documentation.
plasticboy
I have been using a lot of colorschemes-->
codedark
dracula
jellybean
gruvbox
material
seoul
cosmi-latte
palenight
stellarlized
zenburn
nord
coc-settings.json explanation
You can access you coc-setting.json by command :CocConfig or you can find it in vim folder.
- C and C++ see for "clangd" below.
-
"python.autoUpdateLanguageServer": true
(default value is true so you don't need to set this I have done this for my convenience.)
(Make sure you have language server installed for that go to terminal and type)
"pip install python-language-server" -
"python.pythonPath": "/Users/username/.venvs/1env/bin/python"
(This is my path in my virtual envoirment since I don't want to mess with my system's python that's why I am it, using this have an advantage that I don't need to set Virtualenv path it is already using on of my virtualenv.) -
"python.linting.enabled": true (Enabling linting for python)
-
"python.linting.pylintEnabled":true, (Enabling pylint for python)
"python.linting.pylintPath":"/Users/username/.venvs/1env/bin/pylint" (Path to my pylint executable file)
To install pylint "pip install pylint" -
"python.linting.pylamaEnabled":true, (Enabling pylama)
"python.linting.pylamaPath":"/Users/username/.venvs/1env/bin/pylama" (Path to my pylama)
Note: For using pylama you should have atleast pycodestyle.
If you want it to use to full potential install pydocstyle, pyflakes or flake8.Commands:
* pip install pylama
* pip install pycodestyle
* pip install pydocstyle
* pip install pyflakes
* pip install flake8 -
"python.jediEnabled":false, (Default set to false it's just optional)
"python.jediPath" : "/Users/username/.venvs/1env/lib/python3.8/site-packages/jedi" (Path to jedi)Jedi is a completion libarary for python but now I am using MPLS (Microsoft Python Language Server)
If you set "false" coc.nvim will automatically download the latest MPLS for you.
You don't even need to set this to "false" just don't mention that line and path. -
"python.venvFolders": [".venvs"],
(It's just a list for what name folder can be with virtualenv you can add more to it)
"python.venvPath" : "/Users/username" (Path to my virtualenv) -
"python.sortImports.path":"/Users/username/.venvs/1env/bin/isort", (isort for sorting imports)
Commands:
* pip install isort -
"clangd.semanticHighlighting":true, (It is for highlighting vim-cxx-.. plugin)
"clangd.path": "/Users/username/.config/clangd_10.0.0/bin/clangd" (For C and C++ user, it is my path to clangd)
Commands:
* brew install clangd
For html
- "html.enable":true,
"html.validate.scripts": true, "html.format.enable":true,
It's for coc-highlight
- "coc.preferences.colorSupport": true,
"highlight.colors.enable": true
Some extra settings like codelens is also enabled.
Removed lots of plugins making vim slow and added pre-existing alternative for that like NETRW instead of NERDtree.