-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc
90 lines (77 loc) · 2.93 KB
/
vimrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
set nocompatible " Choose no compatibility with legacy vi
syntax enable
set encoding=utf-8
set showcmd " display incomplete commands
set relativenumber " switch line numbering
let mapleader="," " Replace the leader from \ to ,
"" Load vim-plug (plugin manager) and all its plugins
if empty(glob("~/.vim/autoload/plug.vim"))
execute 'mkdir -p ~/.vim/plugged ~/.vim/autoload'
execute '!curl -fLo ~/.vim/autoload/plug.vim https://raw.github.com/junegunn/vim-plug/master/plug.vim'
endif
source ~/.vim/plug.vim
"" Default Whitespace
set nowrap " don't wrap lines
set tabstop=2 shiftwidth=2 " a tab is two spaces (or set this to 4)
set softtabstop=2
set expandtab " use spaces, not tabs (optional)
set backspace=indent,eol,start " backspace through everything in insert mode
set smartindent
set cindent
set pastetoggle=<f5>
" Enable file type detection
filetype on
filetype plugin on
" Syntax of these languages is fussy over tabs Vs spaces
autocmd FileType make setlocal ts=4 sts=4 sw=4 noexpandtab
" Wrap long lines in text files
autocmd FileType text setlocal wrap linebreak
" If vimrc file is written, apply the changes
autocmd BufWritePost .vimrc source $MYVIMRC
"" Searching
set hlsearch " highlight matches
set incsearch " incremental searching
set ignorecase smartcase " searches are case insensitive unless they contain at least one capital letter
"" Enable autocompletion
setlocal omnifunc=syntaxcomplete#Complete
autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS
"" Plugin supertab
let g:SuperTabDefaultCompletionType="context"
"" Plugin syntastic
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 0
let g:syntastic_check_on_wq = 0
let g:syntastic_javascript_checkers = ['eslint']
"" Plugin typescript-vim
let g:typescript_compiler_binary = 'ntsc' " tsc or ntsc
"" Plugin vim-go
" Use goimports for formatting
let g:go_fmt_command = "goimports"
" Turn highlighting on
let g:go_highlight_functions = 1
let g:go_highlight_methods = 1
let g:go_highlight_structs = 1
let g:go_highlight_operators = 1
let g:go_highlight_build_constraints = 1
" Syntax checkers
let g:syntastic_go_checkers = ['go', 'golint']
" Open go doc in horizontal
autocmd Filetype go nnoremap <leader>d :sp <CR>:exe "GoDef" <CR>
"" Plugin vim-airline
"set noshowmode " The vim mode is provided by airline
set laststatus=2 " Force status line even with only one window
"" Maps
" Edit vimrc in a tab
nmap <leader>v :tabedit $MYVIMRC<CR>
" Change window
nmap <leader><leader> <C-w>w
" Switch nerdtree
nmap <leader>n :NERDTreeToggle<CR>
" Search current word in project files
nnoremap <leader>f :grep! "\b<C-R><C-W>\b"<CR>
" Write date
nnoremap <leader>d :r! date "+\%Y/\%m/\%d"<CR>A