1 - Plugin Manager Install
curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
2 - vimrc (vim setting file)
- ~/.vimrc ($HOME/.vimrc) for linux
- ~/_vimrc for windows
더보기
filetype off
call plug#begin()
" git
Plug 'airblade/vim-gitgutter' " git change status
Plug 'tpope/vim-fugitive' " vim git wrapper
" airline
Plug 'vim-airline/vim-airline' " vim status bar
" nerdtree
Plug 'preservim/nerdtree' " directory tree
Plug 'tiagofumo/vim-nerdtree-syntax-highlight'
Plug 'Xuyuanp/nerdtree-git-plugin' " nerd tree git plugin
"let g:NERDTreeGitStatusIndicatorMapCustom = {
" \ 'Modified' :'✹',
" \ 'Staged' :'✚',
" \ 'Untracked' :'✭',
" \ 'Renamed' :'➜',
" \ 'Unmerged' :'═',
" \ 'Deleted' :'✖',
" \ 'Dirty' :'✗',
" \ 'Ignored' :'☒',
" \ 'Clean' :'✔︎',
" \ 'Unknown' :'?',
" \ }
" search
Plug 'ctrlpvim/ctrlp.vim' " ctrl p search
" auto pair
Plug 'jiangmiao/auto-pairs' " pairs quotes or braket
" dev icon
Plug 'ryanoasis/vim-devicons' " dev icons for vim
"tagbar
Plug 'preservim/tagbar' " ctags: code database (class func var ...)
":Files :Rg :Tags
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } " fzf needs 2 plugin (this & below)
Plug 'junegunn/fzf.vim' " fuzzy finder
" vim tags
"Plugin 'ludovicchabant/vim-gutentags' " auto 'ctags -R' every storation (with git; so need .git directory)
" scrollbar in statusline
Plug 'gcavallanti/vim-noscrollbar' " scrollbar at statusline 'set statusline=~~~\ [%{noscrollbar#statusline()}]'
" tabline
Plug 'mkitt/tabline.vim' " config tab title
" indent
Plug 'Yggdroot/indentLine'
" smooth scroll
"Plug 'terryma/vim-smooth-scroll'
" multi cursor
"Plug 'terryma/vim-multiple-cursors'
" vim surround
Plug 'tpope/vim-surround'
" vim theme
Plug 'mhartington/oceanic-next'
" for auto complete
Plug 'neoclide/coc.nvim', {'branch': 'release'}
":CocInstall coc-rust-analyzer
":CocInstall coc-clangd
":CocInstall coc-pyright
":CocInstall coc-flutter[-tools]
"Plug 'dense-analysis/ale'
" language specific
Plug 'rust-lang/rust.vim'
Plug 'ziglang/zig.vim'
Plug 'dart-lang/dart-vim-plugin'
call plug#end()
filetype plugin indent on
" syntax on
if has('syntax')
syntax on
endif
" Brief help
" :PluginList - lists configured plugins
" :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean - confirms removal of unused plugins; append `!` to au
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" let "
"""""""
" default: '\'
let g:mapleader = ' '
let g:maplocalleader = ' '
"" NERDTree
let g:NERDTreeDirArrowExpandable = '▸'
let g:NERDTreeDirArrowCollapsible = '▾'
let NERDTreeShowHidden=1
" let NERDTreeMapOpenInTab='<space>'
" let NERDTreeQuitOnOpen=1
let g:ctrlp_custom_ignore = {
\ 'dir': '\.git$\|vendor$',
\ 'file': '\v\.(exe|so|dll)$'
\ }
"" tabline
let g:tablineclosebutton=1
"" indent line
let g:indentLine_char_list = ['|', '¦', '┆', '┊']
"" rust
let g:rustfmt_autosave = 1
let g:rustfmt_emit_files = 1
let g:rustfmt_fail_silently = 0
"" multiple cursor
"let g:multi_cursor_use_default_mapping=-1
"let g:multi_cursor_next_key='<C-n>'
"let g:multi_cursor_prev_key='<C-p>'
"let g:multi_cursor_skip_key='<C-x>'
"let g:multi_cursor_quit_key='<Esc>'
"" Termdebug
" :packadd termdebug
" :Termdebug file
" :Winbar
" :Run
" :Arguments argu
" :Break :Clear
" :Step :Over :Finish :Continue :Stop : Evaulate
if v:version >= 801
packadd termdebug
let g:termdebug_wide = 1 " vertical split
"let g:termdebugger='/usr/bin/gdb-multiarch'
endif
" Theme
syntax enable
colorscheme OceanicNext
let g:airline_theme='oceanicnext'
" cursor line setting
" Ps = 0 -> blinking block.
" Ps = 1 -> blinking block (default).
" Ps = 2 -> steady block.
" Ps = 3 -> blinking underline.
" Ps = 4 -> steady underline.
" Ps = 5 -> blinking bar (xterm).
" Ps = 6 -> steady bar (xterm).
let &t_SI = "\e[6 q"
let &t_EI = "\e[2 q"
""end-let""
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" map "
"""""""
"" mapleader
nmap \ <Space>
"" NERDTree
"map <Leader>nt <ESC>:NERDTree<CR>
map <Leader>nd <ESC>:NERDTreeToggle<CR>
"" Tagbar
map <Leader>tg <ESC>:Tagbar<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) " go back with <C-o>
nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references)
"" vim smooth scroll
"noremap <silent> <c-b> :call smooth_scroll#up(&scroll*2, 10, 5)<CR>
"noremap <silent> <c-f> :call smooth_scroll#down(&scroll*2, 10, 5)<CR>
"noremap <silent> <c-u> :call smooth_scroll#up(&scroll, 10, 3)<CR>
"noremap <silent> <c-d> :call smooth_scroll#down(&scroll, 10, 3)<CR>
"" tab
nmap <tab> gt
nmap <S-tab> gT
nmap <leader>1 1gt
nmap <leader>2 2gt
nmap <leader>3 3gt
nmap <leader>4 4gt
nmap <leader>5 5gt
nmap <leader>6 6gt
nmap <leader>7 7gt
nmap <leader>8 8gt
nmap <leader>9 9gt
nmap <leader>0 :tablast<cr>
nmap <leader><tab> :tabnew<cr>
"" insert mode: imap
imap <C-L> <Delete>
"" dec/inc height/width
" horizontal
map _ <ESC>:res -1<CR>
map + <ESC>:res +1<CR>
" vertical
map - <ESC><C-W><
map = <ESC><C-W>>
map <F5> <ESC>:set mouse-=a<CR>
map <F6> <ESC>:set mouse+=a<CR>
map <F4> <ESC>:w<CR>
map <F8> <ESC>:q!<CR>
map <F9> <ESC>:qa!<CR>
"" coc.nvim
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>"
""end-map""
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" set "
"""""""
set mouse+=a " use mouse mode
set autoread " file change => auto read change
set fileformats=unix,dos,mac " fmt applying order
set encoding=utf-8 " encoding for showing
set termencoding=utf-8 " encoding for writing
set nu " line number
set ruler " show current cursor position
set title " title of window
set showmatch " bracket match ({} and jump next to })
"set laststatus=2
"set statusline=\ [%{noscrollbar#statusline(20,'-','#')}\ %P]\ %<%l:%v\ %h%m%r\ %=%a%F\
" set statusline=\ %<%l:%v\ [%P]%=%a\ %h%m%r\ %F\
set cursorline " show cursor line
set colorcolumn=80 " show column line
set autoindent
set tabstop=4 " tab key --> 4 spaces size
set softtabstop=4
set shiftwidth=4 " << or >> --> 4 spaces size
set expandtab " change tab to spaces
set ignorecase " when search, ignore letter case
"set nohlsearch
set hlsearch " wgeb search, highlight. (:noh = off it)
" copy-paste
" vim --version => if +clipboard, then (visual mode & '"+y'), ('"+p') work
" 'clipboard' needs vim-gtk
if has('clipboard')
" set the vim clipboard into the system clipboard
set clipboard=unnamedplus " linux: unamedplus, windows/macos: unamed
endif
"set splitright " vertical split
"set splitbelow " (horizontal) split
set belloff=all " bell sound/visual off
set backspace=indent,eol,start " can delete with backspace in indent, eol, ..
set guifont=D2Coding\ Nerd " for gvim
" color
"colorscheme torte
"set t_Co=256 " 256 colors
"set notermguicolors "gui X cterm O
"highlight Normal ctermfg=LightGrey ctermbg=235 guifg=Grey80 guibg=#3a3a3a
" set term=screen-256color
if (has("termguicolors"))
set termguicolors
endif
""end-set""
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" autocmd "
"""""""""""
" put cursor on the last updated position
au BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "norm g`\"" |
\ endif
" automatic NERDTree mirroring on tab switching
" when having just one window in the tab
"function MirrorNerdTreeIfOneWindow()
" if winnr("$") < 2
" NERDTreeMirror
"
" " hack to move the focus from the NERDTree to the main window
" wincmd p
" wincmd l
" endif
"endfunction
"
"autocmd GuiEnter * silent NERDTree
"autocmd VimEnter * silent NERDTree
"autocmd TabEnter * silent exe MirrorNerdTreeIfOneWindow()
""end-autocmd""
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
2.1 - coc.nvim
- 위 setting에 추가로 https://github.com/neoclide/coc.nvim 의 "Example Vim configuration" 세팅 참조해서 적용
(추가로 vimrc를 세팅하지 않아도 coc 플러그인 사용은 가능) - coc 플러그인을 사용하기 위해서는 nodejs 14버전 이상이 필요
- Plugin install 후, vim으로 아무 파일을 열고 :CocInstall coc-clangd 로 원하는 언어에 맞게 설치
- python3: coc-pyright
- rust: coc-rust-analyzer
- c: coc-clangd
- flutter: coc-flutter
3 - D2Coding Nerd font setting
NERDTree의 아이콘을 사용하기위해서 font를 새로 설치할 필요가 있습니다.
3.1 - font download
git clone https://github.com/kelvinks/D2Coding_Nerd
3.2 - font install
- ubuntu
- 방법2) use gui
- D2Coding_Nerd 디렉토리에서 .ttf 파일 찾아서 열기
- 오른쪽 위에 있는 install 버튼 클릭
- 방법1) cp -r D2Coding_Nerd ~/.local/share/fonts
- ~/.local/share/fonts 가 없으면 mkdir로 만들어서 사용
- 방법2) use gui
- windows (wsl)
-
- find .ttf file in D2Coding_Nerd forder and 2) open it and 3) click install button
-
3.3 - change font settings
- vim을 사용하는 경우, 즉 터미널을 사용한다면 터미널의 font를 위에서 설치한 D2Coding Nerd로 변경
- 변경하는 방법은 사용하는 터미널마다 조금씩 다름 (설정 메뉴 혹은 configuration 파일로 조작)
- gvim을 사용하는 경우
- .vimrc 파일에 아래 내용을 추가 (위 세팅을 사용한다면 이미 적혀 있다)
- set guifont=D2Coding\ Nerd
- .vimrc 파일에 아래 내용을 추가 (위 세팅을 사용한다면 이미 적혀 있다)
4 - Install Plugins
- open ~/.vimrc
- 아래 내용을 타이핑한다.
- :PlugInstall