Introduce dein.vim and include jedi-vim

It used to be plain Vim, but finally introduced plugin management. Note of time

dein.vim https://github.com/Shougo/dein.vim NeoBundle seems to support only bug fixes, so use dein.vim.

Installation

$ curl https://raw.githubusercontent.com/Shougo/dein.vim/master/bin/installer.sh > installer.sh
$ sh ./installer.sh {Install Directory}

When you execute installer.sh, the following code will be displayed, so you can add vimrc.

Please add the following settings for dein to the top of your vimrc (Vim) or init.vim (NeoVim) file:


"dein Scripts-----------------------------
if &compatible
  set nocompatible               " Be iMproved
endif

" Required:
set runtimepath+=~/.vim/dein/repos/github.com/Shougo/dein.vim

" Required:
if dein#load_state('~/.vim/dein/')
  call dein#begin('~/.vim/dein/')

  " Let dein manage dein
  " Required:
  call dein#add('~/.vim/dein/repos/github.com/Shougo/dein.vim')

  " Add or remove your plugins here:
  call dein#add('Shougo/neosnippet.vim')
  call dein#add('Shougo/neosnippet-snippets')

  " You can specify revision/branch/tag.
  call dein#add('Shougo/vimshell', { 'rev': '3787e5' })

  " Required:
  call dein#end()
  call dein#save_state()
endif

" Required:
filetype plugin indent on
syntax enable

" If you want to install not installed plugins on startup.
"if dein#check_install()
"  call dein#install()
"endif

"End dein Scripts-------------------------


Done.
Complete setup dein!

After that, comment on " Add or remove your plugins here: as below call dein # add ('plugin GitHub repository') It seems OK if you write the plugin, but it seems that you can manage the plugin with a toml file, so I will create a file that manages the plugin separately from vimrc and load it.

Creating a plugin list

This time, the installation directory of dein.vim is set to ~ / .vim / dein /, so create ʻuserconfig` under this and write toml under it.

$ cd ~/.vim/dein
$ mkdir userconfig

plugins.toml
Specify the plug-in to be loaded at startup.

toml:~/.vim/dein/userconfig/plugins.toml


[[plugins]]
 repo = 'Shougo/dein.vim'

[[plugins]]
repo = 'Shougo/vimproc.vim'

plugins_lazy.toml
Load the plugin under certain conditions. For example, you can load a python plugin only when writing python.

toml:~/.vim/dein/userconfig/plugins_lazy.toml


[[plugins]]
repo   = 'Shougo/unite.vim'

# unite.If you load vim, load it together
[[plugins]]
repo      = 'Shougo/neomru.vim'
on_source = ['unite.vim']

[[plugins]]
repo = "davidhalter/jedi-vim"
on_ft = ['python']

[[plugins]]
repo = 'fatih/vim-go'
on_ft = ['go']

Details such as condition specification can be confirmed by starting vim and using : h dein-options.

fix vimrc

Fixed vimrc to be able to load plugins from toml. By the way, if you don't have dein.vim, you can install it automatically.

vimrc


"dein Scripts-----------------------------
if &compatible
  set nocompatible               " Be iMproved
endif

let s:dein_path = expand('~/.vim/dein')
let s:dein_repo_path = s:dein_path . '/repos/github.com/Shougo/dein.vim'

" dein.clone from github without vim
if &runtimepath !~# '/dein.vim'
  if !isdirectory(s:dein_repo_path)
    execute '!git clone https://github.com/Shougo/dein.vim' s:dein_repo_path
  endif
  execute 'set runtimepath^=' . fnamemodify(s:dein_repo_path, ':p')
endif

if dein#load_state(s:dein_path)
  call dein#begin(s:dein_path)

  let g:config_dir  = expand('~/.vim/dein/userconfig')
  let s:toml        = g:config_dir . '/plugins.toml'
  let s:lazy_toml   = g:config_dir . '/plugins_lazy.toml'

  "Read TOML
  call dein#load_toml(s:toml,      {'lazy': 0})
  call dein#load_toml(s:lazy_toml, {'lazy': 1})

  call dein#end()
  call dein#save_state()
endif


" Required:
filetype plugin indent on
syntax enable

"Install any plugins that are not installed
" If you want to install not installed plugins on startup.
if dein#check_install()
  call dein#install()
endif
"End dein Scripts-------------------------

Check the installation list

Check the plugins installed on vim. Open test.py and

test.py


# -*- coding: utf-8 -*-

print('hello')

When you run : Unite dein

  Shougo/dein.vim
# cespare/vim-toml
  Shougo/vimproc.vim
# fatih/vim-go
  Shougo/neomru.vim
  Shougo/unite.vim
  davidhalter/jedi-vim

The list is displayed like this Plugins specified in specific conditions in plugins_lazy.toml are comments. Since I have a python file open, jedi-vim is launched and vim-go and vim-toml are comments.

jedi-vim If the following help screen is displayed with : h dedi etc., you can confirm that it is installed.

jedi-vim.txt - For Vim version 7.3 - Last change: 2014/07/29
       __   _______  _______   __       ____    ____  __  .___  ___.
      |  | |   ____||       \ |  |      \   \  /   / |  | |   \/   |
      |  | |  |__   |  .--.  ||  |  _____\   \/   /  |  | |  \  /  |
.--.  |  | |   __|  |  |  |  ||  | |______\      /   |  | |  |\/|  |
|  `--'  | |  |____ |  '--'  ||  |         \    /    |  | |  |  |  |
 \______/  |_______||_______/ |__|          \__/     |__| |__|  |__|

          jedi-vim - awesome Python autocompletion with Vim

==============================================================================
Contents                                jedi-vim-contents

1. Introduction                         jedi-vim-introduction
2. Installation                         jedi-vim-installation
    2.0. Requirements                   jedi-vim-installation-requirements
    2.1. Manually                       jedi-vim-installation-manually
    2.2. Using Pathogen                 jedi-vim-installation-pathogen
    2.3. Using Vundle                   jedi-vim-installation-vundle
    2.4. Installing from Repositories   jedi-vim-installation-repos
3. Supported Python features            jedi-vim-support
4. Usage                                jedi-vim-usage
5. Mappings                             jedi-vim-keybindings
    5.1. Start completion               g:jedi#completions_command
    5.2. Go to definition               g:jedi#goto_command
    5.3. Go to assignment               g:jedi#goto_assignments_command
    5.4  Go to definition (deprecated)  g:jedi#goto_definitions_command
    5.5. Show documentation             g:jedi#documentation_command

Addictive point

Jedi-vim didn't install properly when Vim started, probably because I was switching versions with pyenv. After investigating, it seems that python needs to be recompiled https://rcmdnk.com/blog/2014/12/25/computer-vim/

approach

##Return python version to system
$ pyenv global system
$ pyenv versions
* system (set by /Users/suyong/.pyenv/version)
  3.6.2

##Reinstall vim
$ brew reinstall vim --HEAD

Reference site

The story of how fast it was when I switched from NeoBundle to dein.vim Moving to dein.vim [Python environment maintenance] De-NeoBundle. Prepare the environment of the super convenient complementary plug-in jedi-vim with dein and set it to be comfortable [Vim note: Python input completion with jedi-vim](http://wonderwall.hatenablog.com/entry/2017/01/29/213052#docstring pop-up disabled) Install and use Dein.vim. Vim plugin management with dein.vim Make vim a Python development environment on Mac.

Recommended Posts

Introduce dein.vim and include jedi-vim
[Day 7] Template inheritance and include
Introduce errBot and work with Slack