Skip to content

Instantly share code, notes, and snippets.

@tuhuynh27
Created March 12, 2019 09:09
Show Gist options
  • Save tuhuynh27/691a69bb20afc033dbe8f00591b5dcdd to your computer and use it in GitHub Desktop.
Save tuhuynh27/691a69bb20afc033dbe8f00591b5dcdd to your computer and use it in GitHub Desktop.
Nvim configuration
call plug#begin('~/.config/nvim/bundle')
Plug 'rking/ag.vim'
Plug 'yuttie/comfortable-motion.vim'
Plug 'scrooloose/nerdtree'
Plug 'mhinz/vim-startify'
Plug 'alvan/vim-closetag'
Plug 'honza/vim-snippets'
Plug 'SirVer/ultisnips'
Plug 'mhartington/oceanic-next'
Plug 'qpkorr/vim-bufkill'
Plug 'prettier/vim-prettier', { 'do': 'yarn install' }
Plug 'trevordmiller/nova-vim'
Plug 'sbdchd/neoformat'
Plug 'scrooloose/syntastic'
Plug 'ludovicchabant/vim-gutentags'
Plug 'autozimu/LanguageClient-neovim', {
\ 'branch': 'next',
\ 'do': 'bash install.sh',
\ }
Plug 'tpope/vim-fugitive'
Plug 'scrooloose/nerdcommenter'
Plug 'othree/eregex.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 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'w0rp/ale'
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 'HerringtonDarkholme/yats.vim'
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()
" auto close tag
let g:closetag_filenames = '*.html,*.xhtml,*.phtml'
let g:closetag_xhtml_filenames = '*.xhtml,*.jsx'
let g:closetag_filetypes = 'html,xhtml,phtml'
let g:closetag_xhtml_filetypes = 'xhtml,jsx'
let g:closetag_emptyTags_caseSensitive = 1
let g:closetag_shortcut = '>'
let g:closetag_close_shortcut = '<leader>>'
" end auto close tag
" set up for vim
au FileType go set noexpandtab
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
let g:LanguageClient_serverCommands = {
\ 'rust': ['~/.cargo/bin/rustup', 'run', 'stable', 'rls'],
\ 'javascript': ['/usr/local/bin/javascript-typescript-stdio'],
\ 'javascript.jsx': ['tcp://127.0.0.1:2089'],
\ 'python': ['/usr/local/bin/pyls'],
\ }
nnoremap <F5> :call LanguageClient_contextMenu()<CR>
nnoremap <silent> K :call LanguageClient#textDocument_hover()<CR>
nnoremap <silent> gd :call LanguageClient#textDocument_definition()<CR>
nnoremap <silent> <F2> :call LanguageClient#textDocument_rename()<CR>
" 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
let g:prettier#config#single_quote = 'true'
let g:prettier#autoformat = 0
autocmd BufWritePre *.js,*.jsx,*.mjs,*.ts,*.tsx,*.css,*.less,*.scss,*.json,*.graphql,*.md,*.vue Prettier
" Start autocompletion after 4 chars
let bclose_multiple = 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
let g:airline_theme='oceanicnext'
" Don't show YCM's preview window [ I find it really annoying ]
set completeopt-=preview
let g:ycm_add_preview_to_completeopt = 0
" end
let g:python_host_prog = '/Users/tiny/.pyenv/versions/neovim2/bin/python'
let g:python3_host_prog = '/Users/tiny/.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 <F8> :TagbarToggle<CR>
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
"let $NVIM_TUI_ENABLE_TRUE_COLOR=1
set termguicolors
set background=dark
colorscheme nova
highlight Normal ctermbg=None
"let g:oceanic_next_terminal_bold = 1
"let g:oceanic_next_terminal_italic = 1
if (empty($TMUX))
if (has("nvim"))
let $NVIM_TUI_ENABLE_TRUE_COLOR=1
endif
if (has("termguicolors"))
set termguicolors
endif
endif
if (has("termguicolors"))
set termguicolors
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 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
autocmd FileType javascript set formatprg=prettier\ --stdin
" ale prettier-eslint
let g:ale_fixers = {
\ 'javascript': ['prettier_eslint'],
\}
let g:ale_fix_on_save = 1
let g:ale_javascript_prettier_eslint_executable = 'prettier-eslint'
let g:ale_javascript_prettier_eslint_use_global = 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment