"=============================================================================
" init.vim --- Entry file for neovim
" Copyright (c) 2016-2019 Wang Shidong & Contributors
" Author: Wang Shidong < wsdjeg at 163.com >
" URL: https://spacevim.org
" License: GPLv3
"=============================================================================
call plug#begin("~/.vim/plugged")
"Plug 'glepnir/lspsaga.nvim'
"Plug 'sirver/ultisnips' " snippets -_-
"Plug 'blueyed/vim-diminactive' " 투명화일때 비활성의 색상이 깨짐
Plug 'Yggdroot/indentLine'
Plug 'airblade/vim-gitgutter' " Show git status in vim
Plug 'ap/Vim-css-color' " CSS Color Preview
Plug 'christoomey/vim-tmux-navigator'
Plug 'cohama/lexima.vim'
Plug 'ctrlpvim/ctrlp.vim' " 하위 디렉토리 파일 찾기
Plug 'frazrepo/vim-rainbow' " rainbow pairs
Plug 'iamcco/markdown-preview.nvim'
Plug 'isRuslan/vim-es6'
Plug 'jiangmiao/auto-pairs' " Auto pairs ()
Plug 'junegunn/rainbow_parentheses.vim'
Plug 'leafgarland/typescript-vim'
Plug 'majutsushi/tagbar'
Plug 'mtdl9/vim-log-highlighting' " Log Highlight
Plug 'mxw/vim-jsx'
Plug 'nathanaelkane/vim-indent-guides'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'neovim/nvim-lspconfig'
Plug 'norcalli/nvim-colorizer.lua'
Plug 'octol/vim-cpp-enhanced-highlight' " C++ Syntax
Plug 'osyo-manga/vim-anzu'
Plug 'overcache/NeoSolarized' " Theme
Plug 'pangloss/vim-javascript'
Plug 'preservim/nerdcommenter' " CTRL + _ comments
Plug 'ryanoasis/vim-devicons' " Developer Icons
Plug 'scrooloose/nerdtree' " F2 NerdTree
Plug 'scrooloose/syntastic'
Plug 'sheerun/vim-polyglot'
Plug 'tc50cal/vim-terminal' " \t \T Vim Terminal
Plug 'terryma/vim-multiple-cursors' " CTRL + N for multiple cursors
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-markdown'
Plug 'tpope/vim-repeat'
Plug 'tpope/vim-surround' " Surrounding yes
Plug 'vim-airline/vim-airline' " vim status bar
Plug 'vim-scripts/dbext.vim' " SQL Completion
Plug 'OmniSharp/omnisharp-vim'
Plug 'valloric/MatchTagAlways'
call plug#end()
if exists("&termguicolors") && exists("&winblend")
syntax enable
set termguicolors
set winblend=2
set wildoptions=pum
set pumblend=5
set background=dark
let g:neosolarized_termtrans=1
"runtime ./colors/NeoSolarized.vim
colorscheme NeoSolarized
"let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
"let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
endif
lua require('lspconfig').bashls.setup{}
lua require 'colorizer'.setup()
" execute 'source' fnamemodify(expand('<sfile>'), ':h').'/main.vim'
" coc
let g:loaded_perl_provider = 0
let g:loaded_ruby_provider = 0
let g:loaded_python_provider = 0
let g:coc_global_extensions = [
\ 'coc-clang-format-style-options',
\ 'coc-clangd',
\ 'coc-css',
\ 'coc-eslint',
\ 'coc-html',
\ 'coc-html-css-support',
\ 'coc-htmlhint',
\ 'coc-json',
\ 'coc-markdownlint',
\ 'coc-omnisharp',
\ 'coc-pyright',
\ 'coc-react-refactor',
\ 'coc-sh',
\ 'coc-sql',
\ 'coc-styled-components',
\ 'coc-stylelint',
\ 'coc-tslint-plugin',
\ 'coc-tsserver',
\ 'coc-xml',
\ ]
" let g:coc_global_extensions = [
" \ 'coc-cmake',
" \ 'coc-deno',
" \ 'coc-emmet',
" \ 'coc-go',
" \ 'coc-golines',
" \ 'coc-graphql',
" \ 'coc-phpls',
" \ 'coc-php-cs-fixer',
" \ 'coc-prettier',
" \ 'coc-pairs',
" \ 'coc-yaml',
" \ ]
filetype plugin on
" let g:python_host_prog = '/usr/bin/python'
let g:python3_host_prog = '/usr/local/bin/python3'
let g:diminactive_enable_focus = 1
set signcolumn=no
hi coc_err_hi ctermfg=1 ctermbg=15
sign define coc_err numhl=coc_err_hi
sign place 1 line=2 name=coc_err
function! s:show_documentation()
if (index(['vim','help'], &filetype) >= 0)
execute 'h '.expand('<cword>')
elseif (coc#rpc#ready())
call CocActionAsync('doHover')
else
execute '!' . &keywordprg . " " . expand('<cword>')
endif
endfunction
"nnoremap <LEADER>H :call <SID>show_documentation()<CR>
set vb
set nu
set nuw=5 " 줄 번호 표시 너비
set backspace=eol,start,indent
set scrolloff=7 " 스크롤 내릴때 아래에 커서가 7줄 위에 있게
" 편집 기능 설정
set sol
set sm
set km=startsel
" 검색 기능 설정
set hlsearch
set ignorecase
set showmatch
" indent 설정
set cindent
set autoindent
set smartindent
set tabstop=4
set shiftwidth=4
set softtabstop=4
set noet " 탭 -> 공백 변환기능 no
set mouse=nv " 마우스 사용
" Turn off swap
set noswapfile
set nobackup
set nowb
set whichwrap+=<,>,h,l,[,]
" vim-rainbow
let g:rainbow_active = 1
" indent_guides
let g:indent_guides_enable_on_vim_startup = 1
" NERDCommenter
nmap <C-_> <Plug>NERDCommenterToggle
vmap <C-_> <Plug>NERDCommenterToggle<CR>gv
" NERDTree
let NERDTreeQuitOnOpen=1
let g:NERDTreeMinimalUI=1
let NERDTreeWinPos="left"
let NERDTreeShowHidden=1
nmap <F2> :NERDTreeToggle<CR>
"inoremap <silent><expr> <c-space> coc#refresh()
if exists('*complete_info')
inoremap <expr> <cr> complete_info()["selected"] != "-1" ? "\<C-y>" : "\<C-g>u\<CR>"
else
inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
endif
" vim-terminal <Leader> => \
map <Leader>t :term ++close<cr> " vim-powered terminal in split window
tmap <Leader>t <c-w>:term ++close<cr>
map <Leader>T :tab term ++close<cr> " vim-powered terminal in new tab
tmap <Leader>T <c-w>:tab term ++close<cr>
" coc
" Use `[g` and `]g` to navigate diagnostics
" Use `:CocDiagnostics` to get all diagnostics of current buffer in location list.
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 <c-space> to trigger completion.
if has('nvim')
inoremap <silent><expr> <c-space> coc#refresh()
else
inoremap <silent><expr> <[email protected]> coc#refresh()
endif
" 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>')
elseif (coc#rpc#ready())
call CocActionAsync('doHover')
else
execute '!' . &keywordprg . " " . expand('<cword>')
endif
endfunction
" Highlight the symbol and its references when holding the cursor.
autocmd CursorHold * silent call CocActionAsync('highlight')
" Symbol renaming.
nmap <leader>rn <Plug>(coc-rename)
" Formatting selected code.
xmap <leader>f <Plug>(coc-format-selected)
nmap <leader>f <Plug>(coc-format-selected)
augroup mygroup
autocmd!
" Setup formatexpr specified filetype(s).
autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected')
" Update signature help on jump placeholder.
autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
augroup end
" Applying codeAction to the selected region.
" Example: `<leader>aap` for current paragraph
xmap <leader>a <Plug>(coc-codeaction-selected)
nmap <leader>a <Plug>(coc-codeaction-selected)
" Remap keys for applying codeAction to the current buffer.
nmap <leader>ac <Plug>(coc-codeaction)
" Apply AutoFix to problem on the current line.
nmap <leader>qf <Plug>(coc-fix-current)
" Map function and class text objects
" NOTE: Requires 'textDocument.documentSymbol' support from the language server.
xmap if <Plug>(coc-funcobj-i)
omap if <Plug>(coc-funcobj-i)
xmap af <Plug>(coc-funcobj-a)
omap af <Plug>(coc-funcobj-a)
xmap ic <Plug>(coc-classobj-i)
omap ic <Plug>(coc-classobj-i)
xmap ac <Plug>(coc-classobj-a)
omap ac <Plug>(coc-classobj-a)
" Remap <C-f> and <C-b> for scroll float windows/popups.
if has('nvim-0.4.0') || has('patch-8.2.0750')
nnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>"
nnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>"
inoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(1)\<cr>" : "\<Right>"
inoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(0)\<cr>" : "\<Left>"
vnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>"
vnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>"
endif
" Use CTRL-S for selections ranges.
" Requires 'textDocument/selectionRange' support of language server.
nmap <silent> <C-s> <Plug>(coc-range-select)
xmap <silent> <C-s> <Plug>(coc-range-select)
" Add `:Format` command to format current buffer.
command! -nargs=0 Format :call CocAction('format')
" Add `:Fold` command to fold current buffer.
command! -nargs=? Fold :call CocAction('fold', <f-args>)
" Add `:OR` command for organize imports of the current buffer.
command! -nargs=0 OR :call CocActionAsync('runCommand', 'editor.action.organizeImport')
" Add (Neo)Vim's native statusline support.
" NOTE: Please see `:h coc-status` for integrations with external plugins that
" provide custom statusline: lightline.vim, vim-airline.
set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')}
" Mappings for CoCList
" Show all diagnostics.
nnoremap <silent><nowait> <space>a :<C-u>CocList diagnostics<cr>
" Manage extensions.
nnoremap <silent><nowait> <space>e :<C-u>CocList extensions<cr>
" Show commands.
nnoremap <silent><nowait> <space>c :<C-u>CocList commands<cr>
" Find symbol of current document.
nnoremap <silent><nowait> <space>o :<C-u>CocList outline<cr>
" Search workspace symbols.
nnoremap <silent><nowait> <space>s :<C-u>CocList -I symbols<cr>
" Do default action for next item.
nnoremap <silent><nowait> <space>j :<C-u>CocNext<CR>
" Do default action for previous item.
nnoremap <silent><nowait> <space>k :<C-u>CocPrev<CR>
" Resume latest coc list.
nnoremap <silent><nowait> <space>p :<C-u>CocListResume<CR>