Last active
April 26, 2020 02:00
-
-
Save codercodingthecode/1a79f8a68ca7dd318c73691f5bd7b02b to your computer and use it in GitHub Desktop.
nvim config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
call plug#begin("~/.vim/plugged") | |
" Theme | |
" Plug 'dracula/vim' | |
Plug 'rakr/vim-one' | |
" Random | |
Plug 'tpope/vim-surround' | |
Plug 'jiangmiao/auto-pairs' | |
Plug 'mileszs/ack.vim' | |
Plug 'preservim/nerdcommenter' | |
" Language Client | |
Plug 'neoclide/coc.nvim', {'branch': 'release'} | |
let g:coc_global_extensions = ['coc-emmet', 'coc-css', 'coc-html', 'coc-json', 'coc-prettier', 'coc-tsserver'] | |
Plug 'vim-airline/vim-airline' | |
" TypeScript Highlighting | |
Plug 'leafgarland/typescript-vim' | |
Plug 'peitalin/vim-jsx-typescript' | |
" File Explorer with Icons | |
Plug 'scrooloose/nerdtree' | |
Plug 'ryanoasis/vim-devicons' | |
" File Search | |
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } | |
Plug 'junegunn/fzf.vim' | |
if has('nvim') | |
Plug 'Shougo/denite.nvim', { 'do': ':UpdateRemotePlugins' } | |
else | |
Plug 'Shougo/denite.nvim' | |
Plug 'roxma/nvim-yarp' | |
Plug 'roxma/vim-hug-neovim-rpc' | |
endif | |
call plug#end() | |
filetype plugin on | |
if (has("termguicolors")) | |
set termguicolors | |
endif | |
colorscheme one | |
set background=dark | |
set relativenumber | |
set incsearch | |
set nohlsearch | |
syntax enable | |
" Spaces & Tabs {{{ | |
set tabstop=4 " number of visual spaces per TAB | |
set softtabstop=4 " number of spaces in tab when editing | |
set shiftwidth=4 " number of spaces to use for autoindent | |
set expandtab " tabs are space | |
set autoindent | |
set copyindent " copy indent from the previous line | |
set cursorline | |
set splitbelow | |
set splitright | |
set clipboard=unnamedplus | |
let g:NERDTreeShowHidden = 1 | |
let g:NERDTreeMinimalUI = 1 | |
let g:NERDTreeIgnore = [] | |
let g:NERDTreeStatusline = '' | |
" Automaticaly close nvim if NERDTree is only thing left open | |
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif | |
" Toggle | |
nnoremap <silent> <C-b> :NERDTreeToggle<CR> | |
" FZF | |
map <C-f> <Esc><Esc>:GFiles!<CR> | |
map <C-g> <Esc><Esc>:Rg!<CR> | |
inoremap <C-f> <Esc><Esc>:BLines!<CR> | |
" map <C-g> <Esc><Esc>:BCommits!<CR> | |
" To use `ALT+{h,j,k,l}` to navigate windows from any mode: > | |
:tnoremap <c-h> <C-\><C-N><C-w>h | |
:tnoremap <c-j> <C-\><C-N><C-w>j | |
:tnoremap <c-k> <C-\><C-N><C-w>k | |
:tnoremap <c-l> <C-\><C-N><C-w>l | |
:nnoremap <c-h> <C-w>h | |
:nnoremap <c-j> <C-w>j | |
:nnoremap <c-k> <C-w>k | |
:nnoremap <c-l> <C-w>l | |
:nnoremap <Up> :resize +2 <CR> | |
:nnoremap <Down> :resize -2 <CR> | |
:nnoremap <Left> :vertical resize -2 <CR> | |
:nnoremap <Right> :vertical resize +2 <CR> | |
:xnoremap K :move '<-2<CR> gv-gv | |
:xnoremap J :move '>+1<CR> gv-gv | |
" let $FZF_PREVIEW_COMMAND = 'nl {} || cat {}' | |
"command! -nargs=* Rg | |
"\ call fzf#vim#grep( | |
"\ 'rg --column --line-number --no-heading --color=always --smart-case '.shellescape(<q-args>), | |
"\ 1, | |
"\ fzf#vim#with_preview('right:50%')) | |
" FZF.vim now supports this command out of the box | |
" so this code is no longer needed. | |
command! -bang -nargs=* Rg | |
\ call fzf#vim#grep( | |
\ 'rg --column --line-number --hidden --ignore-case --no-heading --color=always '.shellescape(<q-args>), 1, | |
\ <bang>0 ? fzf#vim#with_preview({'options': '--delimiter : --nth 4..'}, 'up:80%') | |
\ : fzf#vim#with_preview({'options': '--delimiter : --nth 4.. -e'}, 'right:50%:hidden', '?'), | |
\ <bang>0) | |
" Use <TAB> for selections ranges. | |
" NOTE: Requires 'textDocument/selectionRange' support from the language server. | |
" coc-tsserver, coc-python are the examples of servers that support it. | |
inoremap <silent><expr> <TAB> | |
\ pumvisible() ? "\<C-n>" : | |
\ <SID>check_back_space() ? "\<TAB>" : | |
\ coc#refresh() | |
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>" | |
function! s:check_back_space() abort | |
let col = col('.') - 1 | |
return !col || getline('.')[col - 1] =~# '\s' | |
endfunction | |
" Use <c-space> to trigger completion. | |
inoremap <silent><expr> <c-space> coc#refresh() | |
" Use <cr> to confirm completion, `<C-g>u` means break undo chain at current | |
" position. Coc only does snippet and additional edit on confirm. | |
if has('patch8.1.1068') | |
" Use `complete_info` if your (Neo)Vim version supports it. | |
inoremap <expr> <cr> complete_info()["selected"] != "-1" ? "\<C-y>" : "\<C-g>u\<CR>" | |
else | |
imap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>" | |
endif | |
" Use `[g` and `]g` to navigate diagnostics | |
nmap <silent> [g <Plug>(coc-diagnostic-prev) | |
nmap <silent> ]g <Plug>(coc-diagnostic-next) | |
" GoTo code navigation. | |
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) | |
" Use K to show documentation in preview window. | |
nnoremap <silent> K :call <SID>show_documentation()<CR> | |
function! s:show_documentation() | |
if (index(['vim','help'], &filetype) >= 0) | |
execute 'h '.expand('<cword>') | |
else | |
call CocAction('doHover') | |
endif | |
endfunction | |
" Highlight the symbol and its references when holding the cursor. | |
autocmd CursorHold * silent call CocActionAsync('highlight') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment