Skip to content

Instantly share code, notes, and snippets.

@hardianlawi
Last active August 25, 2018 00:54
Show Gist options
  • Save hardianlawi/67cc6ef083da3c2765011669fb816e19 to your computer and use it in GitHub Desktop.
Save hardianlawi/67cc6ef083da3c2765011669fb816e19 to your computer and use it in GitHub Desktop.
Vim Customization for Python User

Vim Customization

Step-by-step Vim Customization for Ubuntu 16.04 for Python user.

Remove vim if it is already installed

Use the command below to remove vim:

sudo apt-get remove vim vim-runtime

Install from source (Compiling VIM with python, and clipboard)

Vim has to be compiled with Python interpreter during installation for Auto-completion to work. Thus, install the requirements below:

sudo apt-get install libncurses5-dev libgnome2-dev libgnomeui-dev \
    libgtk2.0-dev libatk1.0-dev libbonoboui2-dev \
    libcairo2-dev libx11-dev libxpm-dev libxt-dev python-dev python-pip\
    python3-dev python3-pip libx11-dev libxtst-dev git \
    build-essential cmake rake

Then, compile Vim with interpreter you would like to use:

cd ~
git clone https://github.com/vim/vim.git
cd vim
./configure --with-features=huge \
            --enable-multibyte \
            --enable-pythoninterp=yes \
	    --with-python3-config-dir=/usr/lib/python3.6/config-3.6m-x86_64-linux-gnu \
            --enable-cscope \
	    --enable-gui=auto \
	    --enable-gtk2-check \
	    --enable-gnome-check \
	    --with-x
sudo make install

Your config directory might have a machine-specific name (e.g. config-3.5m-x86_64-linux-gnu). Check in /usr/lib/python[2/3/3.5] to find yours, and change the python-config-dir and/or python3-config-dir arguments accordingly. On Ubuntu 16.04, Python support was not working due to enabling both Python2 and Python3. Hope this answer could help.

Add Janus Plugins

It provides minimal working environment using the most popular plug-ins for Vim.

curl -L https://bit.ly/janus-bootstrap | bash

Add Sublime Interface

For those who prefer to have sublime-like interface.

sudo pip install powerline
cd ~
mkdir .vim/colors
cd .vim/colors
wget https://github.com/sickill/vim-monokai/blob/master/colors/monokai.vim
cd ~
mkdir .janus/
cd .janus/
git clone https://github.com/Raimondi/delimitMate.git 
git clone https://github.com/Valloric/YouCompleteMe.git

cd YouCompleteMe/
git submodule update --init --recursive
./install.py --clang-completer --java-completer

.vimrc.after file

cd ~

touch .vimrc.after

Add below lines to .vimrc.after

syntax enable
colorscheme monokai

python from powerline.vim import setup as powerline_setup
python powerline_setup
python del powerline_setup

set laststatus=2

set tabstop=4
set mouse=a
set wrap

set clipboard=unnamedplus

" Auto Close Brackets and Quotes
let delimitMate_nesting_quotes = ['"','`']
au FileType python let b:delimitMate_nesting_quotes = ['"']

" Syntastic (Syntax Checkers)
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*

let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 0
let g:syntastic_check_on_wq = 0
let g:syntastic_python_checkers = ["flake8"]
let g:syntastic_mode_map = {
    \ "mode": "active",
    \ "active_filetypes": ["python"]}

" YCM Completion
let g:ycm_python_binary_path = 'python'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment