vim plugins

one way of many ways

December 05, 2024



Download a vim package manager

curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim

The above will download and create ~/.vim/autoload/plug.vim.

The example vim plugin is going to be: jedi-vim, an autocomplete plugin that can be used with python.

In ~/.vimrc:

call plug#begin()
Plug 'davidhalter/jedi-vim'
call plug#end()

As you can see, Plug knows vim plugins stored on Github (https://github.com/davidhalter/jedi-vim).
It is also possible to use full URLs with Plug.

Installation of a vim plugin

:PlugInstall  " Install all plugins defined in '~/.vimrc'.
:PlugUpdate  " Update all plugins.
:PlugUpdate jedi-vim  " Update a specific plugin only.

Configuration and usage

Configuration and usage options can be checked here:

Possible configuration in ~/.vimrc:

call plug#begin()
Plug 'davidhalter/jedi-vim'
call plug#end()

let g:jedi#auto_initialization = 1  " Enable auto initializing.
let g:jedi#completions_enabled = 1  " Enable completion.
let g:jedi#auto_vim_configuration = 0  " Disable auto configuraiton.
let g:jedi#smart_auto_mappings = 0  " When typing 'from module.name<space>' automatically add the "import" statement and trigger the autocompletion popup.
let g:jedi#popup_on_dot = 0  " Disable auto jedi invocation when typing '.'.
let g:jedi#show_call_signatures = 1  " Show small window detailing the arguments of the currently completed function.
let g:jedi#show_call_signatures_delay = 0
let g:jedi#show_call_signatures_modes = 'i'  " ni = also in normal mode
let g:jedi#use_tabs_not_buffers = 1  " Use tabs not buffers when going to definitions.
let g:jedi#use_splits_not_buffers = "left"  " Use splits not buffers.
let g:jedi#popup_select_first = 1  " Enable autoselecting first option.

Usage:

" 'C' means 'Ctrl'
" 'leader' is '\'

" jedi-vim
"    Completion <C-Space>
"    Goto assignment <leader>g (typical goto function)
"    Goto definition <leader>d (follow identifier as far as possible, includes imports and statements)
"    Goto (typing) stub <leader>s
"    Show Documentation/Pydoc K (shows a popup with assignments)
"    Renaming <leader>r
"    Usages <leader>n (shows all the usages of a name)
"    Open module, e.g. :Pyimport os (opens the os module)
"