Skip to content

Instantly share code, notes, and snippets.

@abhiche
Forked from celso/init.vim
Last active August 18, 2020 05:20
Show Gist options
  • Save abhiche/73dbc851b6b5376668a3ac0cd3581eee to your computer and use it in GitHub Desktop.
Save abhiche/73dbc851b6b5376668a3ac0cd3581eee to your computer and use it in GitHub Desktop.
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 rnu " Set relative number
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=2 shiftwidth=2 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
" resize window SHIFT+(h|j|k|l)
nnoremap <S-j> :resize +1<CR>
nnoremap <S-k> :resize -1<CR>
nnoremap <S-l> :vertical resize -20<CR>
nnoremap <S-h> :vertical resize +20<CR>
" Search and Replace
nmap <Leader>sg :%s//g<Left><Left>
nmap <Leader>sc :%s//gc<Left><Left><Left>
" fzf
nnoremap <C-p> :GFiles<CR>
" Leader key is like a command prefix.
let mapleader='z'
let maplocalleader='\'
let g:python3_host_prog = '/usr/local/bin/python3'
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'
" intellisense
Plug 'neoclide/coc.nvim', {'branch': 'release'}
" Search files
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'Chiel92/vim-autoformat'
Plug 'scrooloose/nerdtree'
Plug 'terryma/vim-multiple-cursors'
" vscode like theme
" Plug 'tomasiser/vim-code-dark'
Plug 'dracula/vim', { 'name': 'dracula' }
" Word search plugin
Plug 'dyng/ctrlsf.vim'
" js, jsx, tsx
Plug 'pangloss/vim-javascript' " JavaScript support
Plug 'leafgarland/typescript-vim' " TypeScript syntax
Plug 'peitalin/vim-jsx-typescript'
Plug 'elixir-editors/vim-elixir'
"Plug 'maxmellon/vim-jsx-pretty' " JS and JSX syntax
" Plug 'jparise/vim-graphql' " GraphQL syntax
call plug#end()
" fzf config
let g:fzf_layout = { 'window': { 'width': 0.9, 'height': 0.9 } }
let $FZF_DEFAULT_OPTS='--ansi --height=70% --layout reverse --info inline --preview="~/.config/nvim/plugged/fzf.vim/bin/preview.sh {}" --preview-window=right:60%:wrap --color "fg:#bbccdd,fg+:#ddeeff,bg:#334455,preview-bg:#223344,border:#778899"'
" deoplete config
let g:deoplete#enable_at_startup = 1
" UltiSnips config
inoremap <silent><expr><TAB> pumvisible() ? "\<C-n>" : "\<TAB>"
let g:UltiSnipsExpandTrigger="<nop>"
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='codedark'
" 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>'
" Other
set mouse=
set list
" Theme
set termguicolors
" colorscheme codedark
colorscheme dracula
highlight SignColumn guibg=#272822
let g:rehash256 = 1
let NERDTreeIgnore = ['_site']
let NERDTreeShowHidden=1
" set filetypes as typescript.tsx
autocmd BufNewFile,BufRead *.tsx,*.jsx set filetype=typescript.tsx
noremap <C-f> :Autoformat<CR>
au BufWrite * :Autoformat
let g:autoformat_autoindent = 0
" set folding, 99 to unfold by default, za to toggle folds
set foldmethod=syntax
set foldlevel=99
" CtrlSF
nmap <C-S>f <Plug>CtrlSFPrompt
nmap <C-S>w <Plug>CtrlSFCwordPath
nmap <C-S>p <Plug>CtrlSFPwordPath
" Remap keys for gotos
nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references)
inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
" Buffer handling
" nmap L :let &number=1-&number<CR>
nmap <c-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'
@abhiche
Copy link
Author

abhiche commented Jun 13, 2020

:CocInstall coc-tsserver coc-html coc-css coc-eslint coc-prettier

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment