Skip to content

Instantly share code, notes, and snippets.

@NicolasPio
Last active December 10, 2020 11:57
Show Gist options
  • Save NicolasPio/5f8d27494acc35a5f239292a91062d3c to your computer and use it in GitHub Desktop.
Save NicolasPio/5f8d27494acc35a5f239292a91062d3c to your computer and use it in GitHub Desktop.
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""" ## ## #### ## ## ######## ######
""" ## ## ## ### ### ## ## ## ##
""" ## ## ## #### #### ## ## ##
""" ## ## ## ## ### ## ######## ##
""" ## ## ## ## ## ## ## ##
""" ## ## ## ## ## ## ## ## ##
""" ### #### ## ## ## ## ######
"""
""" Author: Nicolas Pio
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Without backup
set nobackup
set nowritebackup
set noswapfile
" This must be first, because it changes other options as a side effect.
set nocompatible
" Switch syntax highlighting on
syntax on
set t_Co=256
" Cursor line
set cursorline
" Fix backspace
set backspace=indent,eol,start
" Enable file type detection and do language-dependent indenting.
filetype plugin on
filetype plugin indent on
" Omni completion
set omnifunc=syntaxcomplete#Complete
" reload files changed outside vim
set autoread
" search settings
set incsearch " find the next match as we type the search
set hlsearch " hilight searches by default
set ignorecase
" use ESC to remove search higlight
nnoremap <esc> :noh<return><esc>
" make a mark for column 120
set colorcolumn=120
" share clipboard
set clipboard=unnamedplus
" identation
set autoindent
set smartindent
" Wildmenu
set wildmenu
set wildmode=longest,full
" Visual
set ttyfast
set lazyredraw
set encoding=UTF-8
" Leader key
let mapleader = ','
" Keybinding
" Close current buffer
nmap <Leader>c :bd<CR>
nmap <c-s> :w<CR>
cmap W w
" Better display for messages
set cmdheight=2
" Auto remove trailing whitespace
autocmd BufWritePre * %s/\s\+$//e
" Ignore files
set wildignore+=*/tmp/*,*.so,*.swp,*.zip,*/vendor/*,*/public/*,*/cache/*,*/node_module/*
if (has("termguicolors"))
set termguicolors
endif
"" Pesistent undo
set undofile
set undodir=~/.vim/undodir
""" change update time
set updatetime=300
set shortmess+=c
set signcolumn=yes
set encoding=utf-8
set nowrap
" ↑ base config ===============================================================
" Plugins =====================================================================
call plug#begin('~/.vim/plugged')
if empty(glob('~/.vim/autoload/plug.vim'))
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
Plug 'Shougo/vimproc.vim', {'do' : 'make'}
Plug 'easymotion/vim-easymotion'
Plug 'editorconfig/editorconfig-vim'
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-fugitive'
Plug 'airblade/vim-gitgutter'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'sheerun/vim-polyglot'
Plug 'terryma/vim-multiple-cursors'
Plug 'posva/vim-vue'
Plug 'mattn/emmet-vim'
Plug 'scrooloose/nerdtree'
Plug 'xuyuanp/nerdtree-git-plugin'
Plug 'mileszs/ack.vim'
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
Plug 'chriskempson/base16-vim'
Plug 'yuttie/comfortable-motion.vim'
Plug 'junegunn/goyo.vim'
Plug 'nathanaelkane/vim-indent-guides'
Plug 'pangloss/vim-javascript'
Plug 'ryanoasis/vim-devicons'
Plug 'jiangmiao/auto-pairs'
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
Plug 'phpactor/phpactor' , {'do': 'composer install', 'for': 'php'}
Plug 'kristijanhusak/deoplete-phpactor'
Plug 'tbodt/deoplete-tabnine', { 'do': './install.sh' }
Plug 'dense-analysis/ale'
call plug#end()
" Plugins Settings = ==========================================================
set background=dark
let base16colorspace=256
colorscheme base16-eighties
"""" Goyo
let g:goyo_width=120
let g:goyo_height="100%"
let g:goyo_linenr=1
nmap <Leader>gy :Goyo<CR>
"""" Airline
let g:airline_theme='base16_spacemacs'
let g:airline_detect_modified = 0
let g:airline_powerline_fonts = 1
let g:airline_skip_empty_sections = 1
let g:airline_section_a = airline#section#create_left(['﮸ %{toupper(mode())}'])
let g:airline_section_b = airline#section#create_left(['branch'])
let g:airline_section_c = airline#section#create_left(['%r %F %m'])
let g:airline_section_z = airline#section#create_right(['%l', '%L'])
"""" Deoplete
let g:deoplete#enable_at_startup = 1
inoremap <expr><TAB> pumvisible() ? "\<C-n>" : "\<TAB>"
"""" Easymotion
map <Leader> <Plug>(easymotion-prefix)
nmap <Leader><Leader> <Plug>(easymotion-s2)
map <SPACE> <Plug>(easymotion-sn)
omap <SPACE> <Plug>(easymotion-tn)
map n <Plug>(easymotion-next)
map N <Plug>(easymotion-prev)
""" FZF
nnoremap <Leader>b :Buffers<CR>
nnoremap <Leader>o :Files<CR>
nnoremap <Leader>a :Ag<CR>
nnoremap <Leader>t :BTags<CR>
command! -bang -nargs=* Ag call fzf#vim#ag(<q-args>, {'options': '--delimiter : --nth 4..'}, <bang>)
"""" Fugitive
nmap <Leader>gs :Gstatus<CR>
nmap <Leader>gl :Gpull<CR>
nmap <Leader>gp :Gpush<CR>
nmap <Leader>gc :Gcommit<CR>
" Enable omni completion.
autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS
autocmd FileType html,markdown,blade,vue setlocal omnifunc=htmlcomplete#CompleteTags
autocmd FileType javascript,vue setlocal omnifunc=javascriptcomplete#CompleteJS
""" File explorer
let g:webdevicons_enable_nerdtree = 1
nmap <Leader>n :NERDTreeToggle<CR>
let g:NERDTreeWinPos = "right"
let NERDTreeMinimalUI=1
""" Emmet
let g:user_emmet_install_global = 0
autocmd FileType html,css,vue,blade,js,jsx,javascript,javascriptreact EmmetInstall
let g:user_emmet_leader_key='<C-E>'
""" Vue
autocmd FileType vue syntax sync fromstart
let g:vue_pre_processors = 'detect_on_enter'
"""" Auto indent after save ==========
" Restore cursor position, window position, and last search after running a
" command.
function! Preserve(command)
" Save the last search.
let search = @/
" Save the current cursor position.
let cursor_position = getpos('.')
" Save the current window position.
normal! H
let window_position = getpos('.')
call setpos('.', cursor_position)
" Execute the command.
execute a:command
" Restore the last search.
let @/ = search
" Restore the previous window position.
call setpos('.', window_position)
normal! zt
" Restore the previous cursor position.
call setpos('.', cursor_position)
endfunction
" Re-indent the whole buffer.
function! Indent()
call Preserve('normal gg=G')
endfunction
" Indent on save hook
autocmd BufWritePre <buffer> call Indent()
""" Indent Guides
let g:indent_guides_enable_on_vim_startup = 0
let g:indent_guides_start_level = 2
let g:indent_guides_guide_size = 1
set ts=4 sw=4 et
""" Ale
let g:ale_fix_on_save = 1
let b:ale_linters = ['eslint', 'phpcs', 'vls', 'flake8', 'jsonlint']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment