123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226 |
- " -----------------------------------------------------------------------------
- " Status line
- " -----------------------------------------------------------------------------
- " Heavily inspired by: https://github.com/junegunn/dotfiles/blob/master/vimrc
- function! s:statusline_expr()
- let mod = "%{&modified ? '[+] ' : !&modifiable ? '[x] ' : ''}"
- let ro = "%{&readonly ? '[RO] ' : ''}"
- let ft = "%{len(&filetype) ? '['.&filetype.'] ' : ''}"
- let fug = "%{exists('g:loaded_fugitive') ? fugitive#statusline() : ''}"
- let sep = ' %= '
- let pos = ' %-12(%l : %c%V%) '
- let pct = ' %P'
- return '[%n] %f %<'.mod.ro.ft.fug.sep.pos.'%*'.pct
- endfunction
- let &statusline = s:statusline_expr()
- " Use a line cursor within insert mode and a block cursor everywhere else.
- "
- " Reference chart of values:
- " 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"
- set rtp+=/usr/share/vim/addons/plugin/powerline.vim
- set t_Co=256
- syntax on
- set autoindent
- set smartindent
- set autoread
- set backspace=indent,eol,start
- set backupdir=/tmp//,.
- set clipboard=unnamedplus,unnamed
- set complete+=kspell
- set completeopt=menuone,longest
- set cursorline
- set directory=/tmp//,.
- set encoding=utf-8
- set expandtab
- set smarttab
- set formatoptions=tcqrn1
- set hidden
- set hlsearch
- set ignorecase
- set incsearch
- set laststatus=2
- set matchpairs+=<:> " Use % to jump between pairs
- set mmp=5000
- set modelines=2
- set mouse=a
- set nocompatible
- set noerrorbells visualbell t_vb=
- set noshiftround
- set nospell
- set nostartofline
- set number relativenumber
- set regexpengine=1
- set ruler
- set scrolloff=0
- set shiftwidth=2
- set showcmd
- set showmatch
- set shortmess+=c
- set showmode
- set smartcase
- set softtabstop=2
- set spelllang=en_us
- set splitbelow
- set splitright
- set tabstop=2
- set history=1000
- set updatetime=500
- " WSL yank support
- " Ref: https://superuser.com/questions/1291425/windows-subsystem-linux-make-vim-use-the-clipboard
- let s:clip = '/mnt/c/Windows/System32/clip.exe' " change this path according to your mount point
- if executable(s:clip)
- augroup WSLYank
- autocmd!
- autocmd TextYankPost * if v:event.operator ==# 'y' | call system(s:clip, @0) | endif
- augroup END
- endif
- " --[ Plug-vim
- let data_dir = has('nvim') ? stdpath('data') . '/site' : '~/.vim'
- if empty(glob(data_dir . '/autoload/plug.vim'))
- silent execute '!curl -fLo '.data_dir.'/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
- autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
- endif
- call plug#begin()
- " Syntastic is a syntax checking plugin for Vim
- Plug 'vim-syntastic/syntastic'
- " Fugitive is the premier Vim plugin for Git.
- Plug 'tpope/vim-fugitive'
- " Lean & mean status/tabline for vim that's light as air.
- Plug 'vim-airline/vim-airline'
- Plug 'vim-airline/vim-airline-themes'
- " Sometimes, it's useful to line up text.
- Plug 'https://github.com/godlygeek/tabular'
- " Go plug in
- Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' }
- " Go plug in
- " Plug 'govim/govim'
- " If you've ever tried using the . command after a plugin map
- Plug 'tpope/vim-repeat'
- " EasyClip is a plugin for Vim which contains a collection of clipboard related functionality
- " Plug 'svermeulen/vim-easyclip'
- " Powerline for vim
- Plug 'powerline/powerline'
- " Terraform
- Plug 'hashivim/vim-terraform'
- " Comment lines
- Plug 'tpope/vim-commentary'
- " Completion
- Plug 'ervandew/supertab'
- " Markdown TOC
- Plug 'mzlogin/vim-markdown-toc'
- " Nerdtree
- Plug 'preservim/nerdtree'
- " Theme Iceberg
- Plug 'cocopon/iceberg.vim'
- " Theme Nord
- Plug 'arcticicestudio/nord-vim'
- " Theme Solarized8
- Plug 'lifepillar/vim-solarized8'
- " Them Hybrid
- Plug 'w0ng/vim-hybrid'
- " NERDTree plugin that highlights all visible nodes
- " Plug 'PhilRunninger/nerdtree-buffer-ops'
- " Buffergator is a plugin for listing, navigating between buffers
- Plug 'jeetsukumaran/vim-buffergator'
- " A plugin of NERDTree showing git status flags
- Plug 'Xuyuanp/nerdtree-git-plugin'
- " Git diff display tools
- Plug 'airblade/vim-gitgutter'
- " Conventional git message
- Plug 'jmauro/vim-conventional-commits'
- call plug#end()
- " --[ NERDTree
- " Start NERDTree. If a file is specified, move the cursor to its window.
- autocmd StdinReadPre * let s:std_in=1
- autocmd VimEnter * NERDTree | if argc() > 0 || exists("s:std_in") | wincmd p | endif
- " Exit Vim if NERDTree is the only window remaining in the only tab.
- autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif
- " Show hidden files by default with NERDTree
- let NERDTreeShowHidden=1
- let g:NERDTreeWinSize = 35
- " Map NERDTree mapping
- nnoremap <leader>n :NERDTreeFocus<CR>
- nnoremap <C-n> :NERDTree<CR>
- " --[ Airline
- " let g:airline_theme='cobalt2'
- let g:airline_theme='molokai'
- let g:buffergator_viewport_split_policy = "B"
- " --[ Solarized Theme
- set background=dark
- colorscheme solarized8
- " --[ Powerline
- let g:airline_powerline_fonts = 1
- " --[ Syntastic
- " Display configuration
- let g:syntastic_always_populate_loc_list = 1
- let g:syntastic_auto_loc_list = 1
- let g:syntastic_check_on_open = 1
- let g:syntastic_check_on_wq = 0
- " Language checker
- "let g:syntastic_go_checkers = ['golangci-lint', 'gofmt']
- "let g:syntastic_go_golangci_lint_args = ['run']
- let g:syntastic_yaml_checkers = [ "yamllint" ]
- " let g:syntastic_terraform_checkers = ['terragrunt']
- " let g:syntastic_terraform_terragrunt_lint_args = ['hclfmt']
- " --[ gitgutter
- let g:gitgutter_preview_win_floating = 1
- " --[ Terraform
- let g:hcl_align = 1
- let g:terraform_align = 1
- let g:terraform_fmt_on_save = 1
- " --[ Shortcut remap
- " Autoformat F12
- map <F12> gg=C<C-o><C-o>
- let g:go_auto_sameids = 1
- let g:go_highlight_array_whitespace_error = 1
- let g:go_highlight_chan_whitespace_error = 1
- let g:go_highlight_extra_types = 1
- let g:go_highlight_space_tab_error = 1
- let g:go_highlight_trailing_whitespace_error = 0
- let g:go_highlight_operators = 1
- let g:go_highlight_functions = 1
- let g:go_highlight_function_parameters = 1
- let g:go_highlight_function_calls = 1
- let g:go_highlight_types = 1
- let g:go_highlight_fields = 1
- let g:go_highlight_build_constraints = 1
- let g:go_highlight_generate_tags = 1
- let g:go_highlight_string_spellcheck = 1
- let g:go_highlight_format_strings = 1
- let g:go_highlight_variable_declarations = 1
- let g:go_highlight_variable_assignments = 1
- let g:go_fmt_experimental = 1
- let g:go_metalinter_autosave=1
- let g:go_metalinter_autosave_enabled=['golint', 'govet']
|