Config

~/.vimrc

Rina Kawakita 2018. 6. 24. 12:17
* neovim
 $ ln -s ~/.vimrc ~/.nvimrc

" Initial Setting {{{
    " Note: Skip initialization for vim-tiny or vim-small.
    if !1 | finish | endif

    if has('vim_starting')
        if &compatible
            set nocompatible
        endif

        " Required:
        set runtimepath+=~/.vim/bundle/neobundle.vim/
    endif

    " use  for mapleader & localleader
    let mapleader = "\"
    let localleader = "\"

    " encoding
    scriptencoding utf8
    set fileencoding=utf-8
    set fileencodings=utf-8,euc-kr,iso-2022-jp,euc-jp,sjis 

    "" Using the clipboard s the default register
    " + register, X Window clipbaord
    "set clipboard=unnamed           " * (PRIMARY, on select), unnamedplus + (CLIPBOARD, ^C"
    if has('clipboard')
        if has('unnamedplus')       " When possible use + register for copy-paste
            set clipboard=unnamed,unnamedplus
        else                        " On mac and Windows, use * register for copy-paste
            set clipboard=unnamed
        endif
    endif


    " copy
    vnoremap  :w !xclip -i -sel c
    " paste
    "noremap  :r !xclip -o -sel -c
    noremap  :r !xclip -o -sel -c

    " copy and paste  with vim --version (+clipboard)
    "vmap  "+yi
    "vmap  "+c
    "vmap  c"+p
    "imap  "+pa
    "set paste                      " Paste from a windows or from vim
    "set go+=a                      " Visual selection automatically copied to the clipboard
" }}}"

" Pluging Settings {{{
" A minimalist Vim plugin manager: https://github.com/junegunn/vim-plug
    call plug#begin('~/.vim/plugged')
    Plug 'morhetz/gruvbox'
    Plug 'vim-airline/vim-airline'
    Plug 'vim-airline/vim-airline-themes'
    Plug 'ryanoasis/vim-devicons'
    Plug 'dylanaraps/wal.vim'
    Plug 'tpope/vim-sensible'
    " Shorthand notation; fetches https://github.com/junegunn/vim-easy-align
    Plug 'junegunn/vim-easy-align'
    " Any valid git URL is allowed
    Plug 'https://github.com/junegunn/vim-github-dashboard.git'
    " Group dependencies, vim-snippets depends on ultisnips
    Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets'
    " On-demand loading
    Plug 'scrooloose/nerdtree', { 'on':  'NERDTreeToggle' }
    Plug 'tpope/vim-fireplace', { 'for': 'clojure' }
    " Using a non-master branch
    Plug 'rdnetto/YCM-Generator', { 'branch': 'stable' }
    " Using a tagged release; wildcard allowed (requires git 1.9.2 or above)
    Plug 'fatih/vim-go', { 'tag': '*' }
    " Plugin options
    Plug 'nsf/gocode', { 'tag': 'v.20150303', 'rtp': 'vim' }
    " Plugin outside ~/.vim/plugged with post-update hook
    Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
    " Unmanaged plugin (manually installed and updated)
    Plug '~/my-prototype-plugin'
    call plug#end()
" }}}"

" Basic Settings {{{
" These settings need to be setup first to setup plugins and other settings
" correctly
    set t_Co=256                    " 
    syntax on                       " Syntax highlighting
    "colorscheme gruvbox             " Set color scheme
    colorscheme  wal                " Set color scheme
    "colorscheme  desert             " Set color scheme
    set background=dark             " Assume a dark background
    set colorcolumn=109             " Color the column to mark end of line
    set numberwidth=5
    set textwidth=79                " 
    set formatoptions=qrnl          " This is a sequence of letters which describes how
                                    " automatic formatting is to be done.
                                    "
                                    " letter    meaning when present in 'formatoptions'
                                    " ------    ---------------------------------------
                                    " c         Auto-wrap comments using textwidth, inserting
                                    "           the current comment leader automatically.
                                    " q         Allow formatting of comments with "gq".
                                    " r         Automatically insert the current comment leader
                                    "           after hitting  in Insert mode. 
                                    " t         Auto-wrap text using textwidth (does not apply
                                    "           to comments)
    set cursorline                  " Show curosr line
    set cursorcolumn                " Show cursorcolumn line
    if version >= 703
        if exists('+colorccolum')
            set colorcolumn=80
        endif
    endif

    highlight ColorColumn ctermbg=4
    hi Normal ctermfg=7 ctermbg=none
    hi Comment ctermfg=241 ctermbg=none   "8
    hi VertSplit ctermfg=5 ctermbg=5
    "hi LineNr ctermfg=8 ctermbg=none
    hi LineNr ctermfg=241 ctermbg=none
    hi CursorLineNr ctermfg=7 ctermbg=5
    hi Folded ctermfg=0 ctermbg=8
    highlight DiffAdd    cterm=bold ctermfg=10 ctermbg=5
    highlight DiffDelete cterm=bold ctermfg=10 ctermbg=5
    highlight DiffChange cterm=bold ctermfg=7  ctermbg=4
    highlight DiffText   cterm=bold ctermfg=7  ctermbg=5

    "Backup and undo
    set backup                      " Backups are nice ...
    set backupdir=~/.vim/backup/
    set directory=~/.vim/swap/
    set undodir=~/.vim/undo/
    if has('persistent_undo')
        set undofile                " So is persistent undo ...
        set undolevels=1000         " Maximum number of changes that can be undone
        set undoreload=10000        " Maximum number lines to save for undo on a buffer reload
    endif

" }}}" 

" Airline Setting {{{
" https://github.com/vim-airline/vim-airline/blob/master/doc/airline.txt
    let g:airline#extensions#tabline#enabled = 0            " 상단 탭라인 활성화
    let g:airline#extensions#tabline#left_sep = ' '         " 
    let g:airline#extensions#tabline#left_alt_sep = '|'     " 
    let g:airline_powerline_fonts = 1                       " powserline font 화살표 생김
    let g:Powerline_symbols = 'unicode'
    let g:airline#extensions#whitespace#enabled = 0         " 상태바 우측 오른족 whitespace disable
    "let g:airline_theme='ubaryd'                           " airline 테마 지정
    let g:airline_theme='gruvbox'                          " airline 테마 지정
    "let g:airline_theme='bubblegum'                         " airline 테마 지정

    if !exists('g:airline_symbols')
        let g:airline_symbols = {}
    endif

    " unicode symbols " http://unicode-table.com/en/#block-elements
    let g:airline_left_sep = '»'
    let g:airline_left_sep = '▶'
    let g:airline_right_sep = '«'
    let g:airline_right_sep = '◀'
    "let g:airline_symbols.crypt = '🔒'
    "let g:airline_symbols.linenr = '␊'
    "let g:airline_symbols.linenr = '␤'
     let g:airline_symbols.linenr = '¶'
    "let g:airline_symbols.maxlinenr = '☰'
    let g:airline_symbols.maxlinenr = ''
    "let g:airline_symbols.branch = '⎇'
    "let g:airline_symbols.paste = 'ρ'
    let g:airline_symbols.paste = 'Þ'
    "let g:airline_symbols.paste = '∥'
    let g:airline_symbols.spell = 'Ꞩ'
    let g:airline_symbols.notexists = '∄'
    let g:airline_symbols.whitespace = 'Ξ'

    " powerline symbols
    "let g:airline_left_sep = ''
    let g:airline_left_sep = '░'       "   ''▓░'▊''■▬''■''☛'
    let g:airline_left_alt_sep = ''
    "let g:airline_right_sep = ''
    let g:airline_right_sep = ''       "  ■ '▬■''☚'
    let g:airline_right_alt_sep = ''
    let g:airline_symbols.branch = ''
    let g:airline_symbols.readonly = ''
    let g:airline_symbols.linenr = ''

    " old vim-powerline symbols
    "let g:airline_left_sep = '⮀'
    "let g:airline_left_alt_sep = '⮁'
    "let g:airline_right_sep = '⮂'
    "let g:airline_right_alt_sep = '⮃'
    "let g:airline_symbols.branch = '⭠'
    "let g:airline_symbols.readonly = '⭤'
    "let g:airline_symbols.linenr = '⭡'
" }}}"

" Formatting {{{
    set number                      " Show line numbers.
    set relativenumber              " Display line relative number
    "set nowrap                     " Do not wrap long lines
    set linebreak                   " he end of the screen.
    "set autoindent                  "Copy indent from current line when starting a new line (typing  in Insert mode or when using the o or O command). Indent at the same level of the previous line
    set noautoindent                " Disable autoindent behaviour. No more pasting in code and having it look like a goddamned staircase.
    set shiftwidth=4                " Use indents of 4 spaces
    set expandtab                   " Tabs are spaces, not tabs
    set tabstop=4                   " An indentation every four columns
    set softtabstop=4               " Let backspace delete indent
    set nojoinspaces                " Prevents inserting two spaces after punctuation on a join (J)
    set splitright                  " Puts new vsplit windows to the right of the current
    set splitbelow                  " Puts new split windows to the bottom of the current
    set pastetoggle=           " pastetoggle (sane indentation on pastes)
    set hlsearch                    " 검색어 하이라이팅
    set incsearch                   " Enable incremental search. Start searching before pressing enter.
    set wildmode=longest,list
    set bs=eol,start,indent
    set laststatus=2                " Always display powerline in all windows 하단 Airline 상태바 표시 항상
    set showmatch                   " 일치하는 괄호 하이라이팅
    set smarttab
    set smartindent
    set cindent
    set softtabstop=4
    set tabstop=4
    set ruler                       " Show the line and column number of the cursor position, 현재 커서 위치 표시
    set ignorecase                  " 검색시 대소문자 구별 안함
    set smartcase                   " Enable smartcase searching 검색시 대소문자 구별
    set nocompatible                " Disable vi-compatibility. be iMproved, required
    set noshowmode                  " Hide the default mode text
    set visualbell
    set noerrorbells
    set showbreak=\ ↪
    set hidden                      " Hide current buffer when switching to another (to keep undo history)
    set showcmd                     " Show (partial) command in status line.
    set mouse=a                     " Enable the use of the mouse.
    set list 
    set listchars=tab:\▌\ ,trail:~  " ▸ Makes :set list (visible whitespace) prettier.
    filetype off                    " required
    filetype plugin indent on       " required
    "filetype plugin on             " To ignore plugin indent changes, insteada  use:
    "set backspace                  " Backspace through anything in insert mode.
    "set listchars
    "set list                       "
    "set scrolloff                  " Scroll off

    " SET language for encoding autodetection
    " https://github.com/s3rvac/AutoFenc
    let g:autofenc_ext_prog_args = '-L czech -i'
" }}}"

" Restore cursor {{{
" to file position in previous editing session 
" http://vim.wikia.com/wiki/Restore_cursor_to_file_position_in_previous_editing_session
" Tell vim to remember certain things when we exit
"   '10  :  marks will be remembered for up to 10 previously edited files
"   "100 :  will save up to 100 lines for each register
"   :20  :  up to 20 lines of command-line history will be remembered
"   %    :  saves and restores the buffer list
"   n... : awhere to save the viminfo files
"
" If you are on Unix, the viminfo example above is probably fine as is (but
" check up on Vim's help for viminfo to see if you like the settings above).
" For Windows you will need to change thei "n" suboption to something like:
"
" set viminfo='10,\"100,:20,%,nc:\\some\\place\\under\\Windows\\_viminfo
    set viminfo='10,\"100,:20,%,n~/.viminfo
    function! ResCur()
        if line("'\"") <= line("$")
            normal! g`"
        return 1
        endiif
    endfunction

    augroup resCur
        autocmd!
        autocmd BufWinEnter * call ResCur()
    augroup END

    " Partial Foldlevel Restore
    if has("folding")
        function! UnfoldCur()
            if !&foldenable
                return
            endif
            let cl = line(".")
            if cl <= 1
                return
            endif
            let cf  = foldlevel(cl)
            let uf  = foldlevel(cl - 1)
            let min = (cf > uf ? uf : cf)
            if min
                execute "normal!" min . "zo"
                return 1
            endif
        endfunction
    endif

    augroup resCur
        autocmd!
        if has("folding")
            autocmd BufWinEnter * if ResCur() | call UnfoldCur() | endif
        else
            autocmd BufWinEnter * call ResCur()
        endif
    augroup END 
" }}}"

" Map {{{
" Faster buffer manipulation 
nnoremap   :bn:echo
nnoremap   :bp:echo
"nnoremap   :bd:echo
"
" Space to turn off ihghlighting
nnoremap   :nohlsearch:echo
"}}}

" Open same position {{{
" Uncomment the following to have Vim jump to the last position when reopening a file
    if has("autocmd")
        au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$")
        \   | exe "normal! g'\"" | endif
    endif
" }}}"

" vim:foldmethod=marker:foldlevel=0