-
Notifications
You must be signed in to change notification settings - Fork 1
/
.vimrc
132 lines (111 loc) · 4.27 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
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('~/.vim/plugged')
Plug 'joshdick/onedark.vim'
Plug 'pangloss/vim-javascript'
Plug 'rust-lang/rust.vim'
Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' }
call plug#end()
" vim-javascript config
let g:javascript_plugin_jsdoc = 1
filetype on
filetype plugin on
filetype indent on
syntax on
colorscheme onedark
" Enable 24-bit true colors if your terminal supports it.
if (has("termguicolors"))
" https://github.com/vim/vim/issues/993#issuecomment-255651605
let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
set termguicolors
endif
" Use a line cursor within insert mode and a block cursor everywhere else.
"
" Using iTerm2? Go-to preferences / profile / colors and disable the smart bar
" cursor color. Then pick a cursor and highlight color that matches your theme.
" That will ensure your cursor is always visible within insert mode.
"
" 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"
" -----------------------------------------------------------------------------
" 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()
" Common things: https://vimdoc.sourceforge.net/htmldoc/options.html
"set paste
set ruler " Ruler in the right down corner
set autoindent
"set colorcolumn=80
set cursorline
set directory=/tmp//,. " .swp directory
set encoding=utf-8
set incsearch " Shows the matching search pattern incrementally as you type
set ic " Ignore case
set hlsearch " Highlight search
set nocompatible
set backspace=2
set guifont=Consolas:h1
set nu
set relativenumber
set laststatus=2
set smartcase " Makes searching case-sensitive only if the search pattern contains uppercase characters
set ttyfast " wroom wrrooom, redraw text much faster
set undodir=/tmp " undo things, yaaah
set undofile " enable undo persistent, yaaaaaaaah
set scrolloff=8
set cursorcolumn
set matchpairs+={:} " Highlight matching pairs of brackets. Use the '%' character to jump between them.
set clipboard=unnamedplus
" Remaps
"
"
" Map space to search in command mode
nnoremap <Space> /
" Use <C-L> to clear the highlighting of :set hlsearch.
nnoremap <C-L> :nohlsearch<CR>
" Press * to search for the term under the cursor or a visual selection and
" then press a key below to replace all instances of it in the current file.
nnoremap <Leader>r :%s///g<Left><Left>
nnoremap <Leader>rc :%s///gc<Left><Left><Left>
" Select some text in visual mode and remove \n in the selection
vnoremap <Leader>n :s/\%V\n//g<Left><Left>
" Commands
"
" Open terminal in vertical - ctrl-w shift-N to use it as a buffer - press i
" again to jump into it again
command Terminal vert term
" Show all spaces and line endings
command! -nargs=0 ShowAll execute "set list" | execute "set lcs+=space:·"
" Hides all the line endings and spaces
command! -nargs=0 HideAll set nolist
" Remove all new lines in the file
command! -nargs=0 RemoveNewLines execute '%s/\\$//e | %s/\n//g'
" :W sudo saves the file
" (useful for handling the permission-denied error)
command! W execute 'w !sudo tee % > /dev/null' <bar> edit!
autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab
autocmd FileType javascript setlocal ts=2 sts=2 sw=2 expandtab
autocmd FileType html setlocal ts=2 sts=2 sw=2 expandtab