Skip to content

Instantly share code, notes, and snippets.

@celso celso/init.vim
Last active Jul 15, 2019

Embed
What would you like to do?
Neovim setup for OSX users

Neovim setup for OSX users

This gist is a list of options and tricks to make the amazing neovim work on OSX, from a former long time vim user.

syntax on
set ruler " Show the line and column numbers of the cursor.
set formatoptions+=o " Continue comment marker in new lines.
set textwidth=0 " Hard-wrap long lines as you type them.
set modeline " Enable modeline.
set esckeys " Cursor keys in insert mode.
set linespace=0 " Set line-spacing to minimum.
set nojoinspaces " Prevents inserting two spaces after punctuation on a join (J)
" More natural splits
set splitbelow " Horizontal split below current.
set splitright " Vertical split to right of current.
if !&scrolloff
set scrolloff=3 " Show next 3 lines while scrolling.
endif
if !&sidescrolloff
set sidescrolloff=5 " Show next 5 columns while side-scrolling.
endif
set display+=lastline
set nostartofline " Do not jump to first character with page commands.
set noerrorbells " No beeps
set backspace=indent,eol,start " Makes backspace key more powerful.
set showcmd " Show me what I'm typing
set showmode " Show current mode.
set noswapfile " Don't use swapfile
set nobackup " Don't create annoying backup files
set encoding=utf-8 " Set default encoding to UTF-8
set autowrite " Automatically save before :next, :make etc.
set autoread " Automatically reread changed files without asking me anything
set laststatus=2
set fileformats=unix,dos,mac " Prefer Unix over Windows over OS 9 formats
set showmatch " Do not show matching brackets by flickering
set incsearch " Shows the match while typing
set hlsearch " Highlight found searches
set ignorecase " Search case insensitive...
set smartcase " ... but not when search pattern contains upper case characters
set autoindent
set tabstop=4 shiftwidth=4 expandtab
set gdefault " Use 'g' flag by default with :s/foo/bar/.
set magic " Use 'magic' patterns (extended regular expressions).
" Use <C-L> to clear the highlighting of :set hlsearch.
if maparg('<C-L>', 'n') ==# ''
nnoremap <silent> <C-L> :nohlsearch<CR><C-L>
endif
" Search and Replace
nmap <Leader>s :%s//g<Left><Left>
" Leader key is like a command prefix.
let mapleader='z'
let maplocalleader='\'
let g:python_host_prog="/usr/local/bin/python2.7"
let g:session_autosave = 'yes'
let g:session_autoload = 'yes'
let g:session_default_to_last = 1
" set cursorcolumn
nmap <Space> <PageDown>
vmap <BS> x
" cd ~/.config/nvim/spell
" wget http://ftp.vim.org/vim/runtime/spell/pt.utf-8.spl
" set spell spelllang=pt_pt
" zg to add word to word list
" zw to reverse
" zug to remove word from word list
" z= to get list of possibilities
" set spellfile=~/.config/nvim/spellfile.add
set nospell
" Plugins here
call plug#begin('~/.config/nvim/plugged')
Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets'
" Plug 'Shougo/deoplete.nvim'
Plug 'Valloric/YouCompleteMe'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'Chiel92/vim-autoformat'
Plug 'scrooloose/nerdtree'
Plug 'terryma/vim-multiple-cursors'
call plug#end()
" deoplete config
let g:deoplete#enable_at_startup = 1
let g:deoplete#disable_auto_complete = 1
if has("gui_running")
inoremap <silent><expr><C-Space> deoplete#mappings#manual_complete()
else
inoremap <silent><expr><C-@> deoplete#mappings#manual_complete()
endif
" UltiSnips config
inoremap <silent><expr><TAB> pumvisible() ? "\<C-n>" : "\<TAB>"
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<tab>"
let g:UltiSnipsJumpBackwardTrigger="<s-tab>"
" Tell Vim which characters to show for expanded TABs,
" trailing whitespace, and end-of-lines. VERY useful!
if &listchars ==# 'eol:$'
" set listchars=tab:>\ ,trail:-,extends:>,precedes:<,nbsp:+
set listchars=tab:>\ ,extends:>,precedes:<,nbsp:+
endif
" nerdtree config
map <C-n> :NERDTreeToggle<CR>
" airline settings
let g:airline#extensions#tabline#enabled = 2
let g:airline#extensions#tabline#fnamemod = ':t'
let g:airline#extensions#tabline#left_sep = ' '
let g:airline#extensions#tabline#left_alt_sep = '|'
let g:airline#extensions#tabline#right_sep = ' '
let g:airline#extensions#tabline#right_alt_sep = '|'
let g:airline_powerline_fonts=1
let g:airline_left_sep = ' '
let g:airline_left_alt_sep = '|'
let g:airline_right_sep = ' '
let g:airline_right_alt_sep = '|'
let g:airline_powerline_fonts=1
let g:airline_theme='molokai'
" Multicursor
let g:multi_cursor_use_default_mapping=0
let g:multi_cursor_next_key='<C-e>'
let g:multi_cursor_quit_key='<Esc>'
let g:multi_cursor_quit_key='<Esc>'
" YouCompleteMe
let g:ycm_autoclose_preview_window_after_completion = 1
let g:ycm_min_num_of_chars_for_completion = 1
" Other
set mouse=
set list
" Theme
colorscheme molokai256
highlight SignColumn guibg=#272822
let g:rehash256 = 1
let g:molokai_original=1
let NERDTreeIgnore = ['_site']
" Buffer handling
nmap L :let &number=1-&number<CR>
nmap <leader>l :bnext<CR>
nmap <c-h> :bprevious<CR>
nmap <leader>bq :bp <BAR> bd #<CR>
nmap <leader>bl :ls<CR>
nmap <leader>0 :set invnumber<CR>
" map :q to byffer delete
" http://stackoverflow.com/questions/7513380/vim-change-x-function-to-delete-buffer-instead-of-save-quit
cnoreabbrev <expr> q getcmdtype() == ":" && (getcmdline() == 'q' && len(filter(range(1, bufnr('$')), 'buflisted(v:val)')) > 1) ? 'bd' : 'q'
@celso

This comment has been minimized.

Copy link
Owner Author

commented Oct 1, 2016

Make sure your iTerm settings look like this:

46cda68a-9dc2-11e5-9388-7b3597cd3e48

@celso

This comment has been minimized.

Copy link
Owner Author

commented Oct 22, 2016

Install neovim

brew install neovim/neovim/neovim

Install vim-plug

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

Enable python support

Some plugins require this. It's important.

brew install python
/usr/local/bin/pip install neovim
/usr/local/bin/pip install --upgrade neovim

Fix problems with iTerm

christoomey/vim-tmux-navigator#71

put this in your ~/.bash_profile

infocmp $TERM | sed 's/kbs=^[hH]/kbs=\177/' > $TERM.ti
tic $TERM.ti

Put this in your ~/.config/nvim/init.vim

neovim/neovim#3702

set mouse=

To compile YouCompleteMe

cd .config/nvim/plugged/YouCompleteMe
./install.py --clang-completer

from ycm-core/YouCompleteMe#1707

@celso

This comment has been minimized.

Copy link
Owner Author

commented Oct 22, 2016

image

@justinmk

This comment has been minimized.

Copy link

commented Oct 22, 2016

To trim a few lines from the init.vim, check :help nvim-defaults.

It's also a good idea to run :CheckHealth after a new install or upgrade.

@celso

This comment has been minimized.

Copy link
Owner Author

commented Oct 22, 2016

@justinmk done. tks

@EstebanMarin

This comment has been minimized.

Copy link

commented Dec 19, 2018

@celso Many thanks for this. It is working like a charm. I have a question for line 53 are you setting this to work only for 2.7 python version? Is this a configuration that I need to take into account and update soon?

@anhdv817

This comment has been minimized.

Copy link

commented Feb 19, 2019

@celso Sorry but what is the font you use in your image?

@amadeu01

This comment has been minimized.

Copy link

commented Jul 15, 2019

@celso Cannot found molokai256. Could u share how did you setup molokai256?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.