Skip to content

Instantly share code, notes, and snippets.

@huynhminhtufu huynhminhtufu/init.vim
Last active Nov 21, 2019

Embed
What would you like to do?
nvim
call plug#begin('~/.config/nvim/bundle')
Plug 'rking/ag.vim'
Plug 'ryanoasis/vim-devicons'
Plug 'herringtondarkholme/yats.vim'
Plug 'styled-components/vim-styled-components', { 'branch': 'main' }
Plug 'Yggdroot/indentLine'
"Plug 'yuttie/comfortable-motion.vim'
Plug 'scrooloose/nerdtree'
Plug 'alvan/vim-closetag'
Plug 'honza/vim-snippets'
Plug 'SirVer/ultisnips'
Plug 'qpkorr/vim-bufkill'
Plug 'tiagofumo/vim-nerdtree-syntax-highlight'
Plug 'scrooloose/syntastic'
Plug 'airblade/vim-gitgutter'
Plug 'junegunn/vim-emoji'
Plug 'easymotion/vim-easymotion'
Plug 'kien/ctrlp.vim'
Plug 'scrooloose/nerdcommenter'
Plug 'morhetz/gruvbox'
Plug 'haya14busa/incsearch.vim'
Plug 'jiangmiao/auto-pairs'
Plug 'christoomey/vim-tmux-navigator'
Plug 'tpope/vim-surround'
Plug 'terryma/vim-multiple-cursors'
Plug 'pangloss/vim-javascript'
Plug 'mattn/emmet-vim'
Plug 'sheerun/vim-polyglot'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'w0rp/ale'
Plug 'prettier/vim-prettier', { 'do': 'yarn install' }
Plug 'galooshi/vim-import-js'
Plug 'neomake/neomake'
Plug 'sjl/gundo.vim'
" Plugin for typescrip
Plug 'mhartington/nvim-typescript', {'do': './install.sh'}
Plug 'ianks/vim-tsx', { 'for': 'typescript.tsx' }
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
Plug 'Shougo/denite.nvim'
Plug 'Valloric/YouCompleteMe', { 'do': './install.py --tern-completer' }
" call PlugInstall to install new plugins
call plug#end()
"set encoding=UTF-8
autocmd BufEnter * :set scroll=10
set completefunc=emoji#complete
let g:ctrlp_custom_ignore = {
\ 'dir': '\v[\/](node_modules|build|lib|dist)|(\.(git|svn))$',
\ 'file': 'tags\|tags.lock\|tags.temp',
\ }
" syntastic setting
let g:prettier#autoformat = 0
autocmd BufWritePre *.js,*.jsx,*.mjs,*.ts,*.tsx,*.css,*.less,*.scss,*.json,*.graphql,*.md,*.vue,*.yaml,*.html PrettierAsync
set guifont=FuraMoco\ Nerd\ Font:h13
let g:NERDTreeFileExtensionHighlightFullName = 1
let g:NERDTreeExactMatchHighlightFullName = 1
let g:NERDTreePatternMatchHighlightFullName = 1
let g:NERDTreeHighlightFolders = 1 " enables folder icon highlighting using exact match
let g:NERDTreeHighlightFoldersFallName = 1 " highlights the folder name
let g:NERDTreePatternMatchHighlightColor = {} " this line is needed to avoid error<Paste>
let g:webdevicons_enable_unite = 1
let g:webdevicons_enable_nerdtree = 1
let g:webdevicons_conceal_nerdtree_brackets = 1
let g:webdevicons_enable_airline_tabline = 1
let g:airline_powerline_fonts = 1
let g:EasyMotion_smartcase = 1
nmap s <Plug>(easymotion-overwin-f2)
" Move to line
"map <Leader>L <Plug>(easymotion-bd-jk)
"nmap <Leader>L <Plug>(easymotion-overwin-line)
"map <Leader>w <Plug>(easymotion-bd-w)
"nmap <Leader>w <Plug>(easymotion-overwin-w)
"map <Leader>l <Plug>(easymotion-lineforward)
"map <Leader>j <Plug>(easymotion-j)
"map <Leader>k <Plug>(easymotion-k)
"map <Leader>h <Plug>(easymotion-linebackward)
let g:indentLine_char = '¦'
let g:indentLine_first_char = '¦'
let g:indentLine_showFirstIndentLevel = 1
let g:indentLine_setColors = 0
let g:closetag_filenames = '*.html,*.jsx,*.tsx,*.js'
let g:closetag_xhtml_filenames = '*.xhtml,*.jsx,*.js'
let g:closetag_filetypes = 'html,js,xhtml,phtml,jsx,tsx'
let g:closetag_xhtml_filetypes = 'xhtml,jsx,tsx,js'
let g:closetag_emptyTags_caseSensitive = 1
let g:closetag_shortcut = '>'
let g:NERDDefaultAlign = 'left'
let g:NERDCustomDelimiters = { 'c': { 'left': '/**','right': '*/' } }
" end auto close tag
" set up for vim
au FileType go set shiftwidth=4
au FileType go set softtabstop=4
au FileType go set tabstop=4
let g:go_highlight_build_constraints = 1
let g:go_highlight_extra_types = 1
let g:go_highlight_fields = 1
let g:go_highlight_functions = 1
let g:go_highlight_methods = 1
let g:go_highlight_operators = 1
let g:go_highlight_structs = 1
let g:go_highlight_types = 1
let g:go_auto_sameids = 1
let g:go_fmt_command = "goimports"
" end go
if has("mouse")
set mouse=a
endif
let g:ag_working_path_mode="r"
set hidden
" Ulti snippets
let g:UltiSnipsExpandTrigger="<c-j>"
let g:UltiSnipsJumpForwardTrigger="<c-b>"
let g:UltiSnipsJumpBackwardTrigger="<c-z>"
function! Multiple_cursors_before()
if exists(':NeoCompleteLock')==2
exe 'NeoCompleteLock'
endif
if has('nvim')
call deoplete#disable()
endif
if !has('nvim')
exe 'NeoCompleteDisable'
endif
endfunction
function! Multiple_cursors_after()
if exists(':NeoCompleteUnlock')==2
exe 'NeoCompleteUnlock'
endif
if has('nvim')
call deoplete#enable()
endif
if !has('nvim')
exe 'NeoCompleteEnable'
endif
endfunction
nnoremap <silent> <Leader>ag :Ag <C-R><C-W><CR>
autocmd BufEnter *.tsx set filetype=typescript
" copy/paste
function! ClipboardYank()
call system('xclip -i -selection clipboard', @@)
endfunction
function! ClipboardPaste()
let @@ = system('xclip -o -selection clipboard')
endfunction
" Start autocompletion after 4 chars
let g:enable_italic_font = 1
let g:enable_bold_font = 1
let bclose_multiple = 0
" Don't show YCM's preview window [ I find it really annoying ]
set completeopt-=preview
let g:loaded_youcompleteme = 1
let g:ycm_add_preview_to_completeopt = 0
let g:ycm_min_num_of_chars_for_completion = 4
let g:ycm_min_num_identifier_candidate_chars = 4
let g:ycm_enable_diagnostic_highlighting = 0
" end
let g:python_host_prog = '/Users/admin/.pyenv/versions/neovim2/bin/python'
let g:python3_host_prog = '/Users/admin/.pyenv/versions/neovim3/bin/python'
" use STab
" basics
filetype plugin indent on
syntax on
set number
set relativenumber
set incsearch
set ignorecase
set smartcase
set nohlsearch
set tabstop=4
set softtabstop=0
set shiftwidth=4
set expandtab
set nobackup
set noswapfile
set nowrap
let g:multi_cursor_select_all_word_key = '<c-a>'
" comfortable scrol Airline
"noremap <silent> <ScrollWheelDown> :call comfortable_motion#flick(60)<CR>
"noremap <silent> <ScrollWheelUp> :call comfortable_motion#flick(-60)<CR>
"let g:comfortable_motion_no_default_key_mappings = 1
"let g:comfortable_motion_scroll_down_key = j
"let g:comfortable_motion_scroll_up_key =k
"nnoremap <silent> <C-d> :call comfortable_motion#flick(70)<CR>
"nnoremap <silent> <C-u> :call comfortable_motion#flick(-70)<CR>
"nnoremap <C-p> :FZF<CR>
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#left_sep = ' '
let g:airline#extensions#tabline#left_alt_sep = '|'
inoremap jk <ESC>
let mapleader = "\<Space>"
set pastetoggle=<F10>
" j/k will move virtual lines (lines that wrap)
noremap <silent> <expr> j (v:count == 0 ? 'gj' : 'j')
noremap <silent> <expr> k (v:count == 0 ? 'gk' : 'k')
" Stay in visual mode when indenting. You will never have to run gv after
" performing an indentation.
vnoremap < <gv
vnoremap > >gv
" Make Y yank everything from the cursor to the end of the line. This makes Y
" act more like C or D because by default, Y yanks the current line (i.e. the
" same as yy).
noremap Y y$
" navigate split screens easily
nmap <silent> <c-k> :wincmd k<CR>
nmap <silent> <c-j> :wincmd j<CR>
nmap <silent> <c-h> :wincmd h<CR>
nmap <silent> <c-l> :wincmd l<CR>
" change spacing for language specific
autocmd Filetype javascript setlocal ts=2 sts=2 sw=2
" plugin settings
" deoplete
let g:deoplete#enable_at_startup = 1
"copy/paste
function! ClipboardYank()
call system('pbcopy', @@)
endfunction
function! ClipboardPaste()
let @@ = system('pbpaste')
endfunction
vnoremap <silent> y y:call ClipboardYank()<cr>
vnoremap <silent> d d:call ClipboardYank()<cr>
nnoremap <silent> p :call ClipboardPaste()<cr>p
"end
" use tab to forward cycle
inoremap <silent><expr><Tab> pumvisible() ? "\<C-N>" : "\<Tab>"
" use tab to backward cycle
inoremap <silent><expr><S-Tab> pumvisible() ? "\<C-P>" : "\<S-Tab>"
" Close the documentation window when completion is done
autocmd InsertLeave,CompleteDone * if pumvisible() == 0 | pclose | endif
" Theme
syntax enable
set background=dark
highlight Normal ctermbg=None
"let ayucolor="dark"
let ayucolor="mirage"
colorscheme gruvbox
let g:airline_theme='gruvbox'
set termguicolors
nnoremap <silent> [oh :call gruvbox#hls_show()<CR>
nnoremap <silent> ]oh :call gruvbox#hls_hide()<CR>
nnoremap <silent> coh :call gruvbox#hls_toggle()<CR>
nnoremap * :let @/ = ""<CR>:call gruvbox#hls_show()<CR>*
nnoremap / :let @/ = ""<CR>:call gruvbox#hls_show()<CR>/
nnoremap ? :let @/ = ""<CR>:call gruvbox#hls_show()<CR>?
if (empty($TMUX))
if (has("nvim"))
let $NVIM_TUI_ENABLE_TRUE_COLOR=1
endif
if (has("termguicolors"))
set termguicolors
endif
endif
" Search
"NERDTree
" How can I close vim if the only window left open is a NERDTree?
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
" toggle NERDTree
map <C-b> :NERDTreeToggle<CR>
map <C-f> :NERDTreeFind<CR>
let NERDTreeShowHidden=1
let g:NERDTreeChDirMode=2
let g:NERDTreeIgnore=['\.rbc$', '\~$', '\.pyc$', '\.db$', '\.sqlite$', '__pycache__', 'node_modules']
let g:NERDTreeSortOrder=['^__\.py$', '\/$', '*', '\.swp$', '\.bak$', '\~$']
let g:NERDTreeShowBookmarks=1
let g:nerdtree_tabs_focus_on_files=1
let g:NERDTreeMapOpenInTabSilent = '<RightMouse>'
set wildignore+=*/tmp/*,*.so,*.swp,*.zip,*.pyc,*.db,*.sqlite
" jsx
let g:jsx_ext_required = 0
let g:user_emmet_leader_key='<C-Z>'
let g:user_emmet_settings = {
\ 'javascript.jsx' : {
\ 'extends' : 'jsx',
\ }
\}
let g:jsx_ext_required = 1
let g:jsx_pragma_required = 1
" ale prettier-eslint
set hlsearch
let g:incsearch#auto_nohlsearch = 1
nnoremap <Esc><Esc> :<C-u>nohlsearch<CR>
map n <Plug>(incsearch-nohl-n)
map N <Plug>(incsearch-nohl-N)
hi MatchParen ctermbg=blue guibg=lightblue
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.