-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc
149 lines (112 loc) · 4.26 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
" from https://gist.github.com/gosukiwi/080d1d3f87f861a15c44
"
" ---------------------- USABILITY CONFIGURATION ----------------------
" Basic and pretty much needed settings to provide a solid base for
" source code editting
" don't make vim compatible with vi
set nocompatible
set noswapfile
" turn on syntax highlighting
syntax on
" and show line numbers
set number
" always show 5 lines around the cursor
set scrolloff=5
" open vsplits to the right
set splitright
" Highlight current line but on current window only
augroup CursorLine
au!
au VimEnter,WinEnter,BufWinEnter * setlocal cursorline
au WinLeave * setlocal nocursorline
augroup END
" make vim try to detect file types and load plugins for them
filetype on
filetype plugin on
filetype indent on
" reload files changed outside vim
set autoread
" encoding is utf 8
set encoding=utf-8
set fileencoding=utf-8
" enable matchit plugin which ships with vim and greatly enhances '%'
runtime macros/matchit.vim
" by default, in insert mode backspace won't delete over line breaks, or
" automatically-inserted indentation, let's change that
set backspace=indent,eol,start
" dont't unload buffers when they are abandoned, instead stay in the
" background
set hidden
" set unix line endings
set fileformat=unix
" when reading files try unix line endings then dos, also use unix for new
" buffers
set fileformats=unix,dos
" save up to 100 marks, enable capital marks
set viminfo='100,f1
" screen will not be redrawn while running macros, registers or other
" non-typed comments
set lazyredraw
" move backup and swaps to /tmp
set backup
set backupdir=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp
set backupskip=/tmp/*,/private/tmp/*
set directory=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp
set writebackup
" ------------ Usability ---------------------------------------
set tabstop=2 " number of visual spaces per TAB
set softtabstop=2 " number of spaces in tab when editing
set expandtab " tabs are spaces
set shiftwidth=2
set showcmd " show command in bottom bar
" set cursorline " highlight current line
set wildmenu " visual autocomplete for command menu
" strip trailing whitespace from specific file types
autocmd FileType javascript,ruby,scss,bash,typescript autocmd BufWritePre <buffer> :%s/\s\+$//e
" Fastfile is used by fastlane. Let vim know it's a ruby file
autocmd BufNewFile,BufRead Fastfile set syntax=ruby
" Set the filetype based on the file's extension, but only if
" " 'filetype' has not already been set
au BufRead,BufNewFile *.ejs setfiletype html
" Disable comments continuing when hit enter for new line
set formatoptions-=cro
" Remove hidden fugitive buffers
autocmd BufReadPost fugitive://* set bufhidden=delete
" ----------- Searching ----------------------------------------
set incsearch " search as characters are entered
set hlsearch " highlight matches
" Taylor = split diffs vertically
:set diffopt+=vertical
" Triger `autoread` when files changes on disk
" https://unix.stackexchange.com/questions/149209/refresh-changed-content-of-file-opened-in-vim/383044#383044
" https://vi.stackexchange.com/questions/13692/prevent-focusgained-autocmd-running-in-command-line-editing-mode
autocmd FocusGained,BufEnter,CursorHold,CursorHoldI * if mode() != 'c' | checktime | endif
" Notification after file change
" https://vi.stackexchange.com/questions/13091/autocmd-event-for-autoread
autocmd FileChangedShellPost *
\ echohl WarningMsg | echo "File changed on disk. Buffer reloaded." | echohl None
" Format json with a simple function
" (will format entire file)
com! FormatJSON %!python -m json.tool
" filetypes for jsx, tsx
autocmd BufNewFile,BufRead *.tsx,*.jsx set filetype=typescript.tsx
let g:syntastic_typescript_checkers = ['tslint', 'tsuquyomi']
" set path to search based on current directory with gf
:set path+=**
" Taylor - colorscheme
" for truecolor:
"set termguicolors
colo molokai
"colo neotrix
"let g:neotrix_dark_contrast = "medium"
" toggle line numbers based on mode
:set number relativenumber
function Solarize()
set background=light
colorscheme solarized
endfunction
:augroup numbertoggle
: autocmd!
: autocmd BufEnter,FocusGained,InsertLeave * set relativenumber
: autocmd BufLeave,FocusLost,InsertEnter * set norelativenumber
:augroup END