Repository navigation
Expand file tree
/
Copy pathvimrc
More file actions
181 lines (153 loc) · 6.23 KB
/
Copy pathvimrc
File metadata and controls
181 lines (153 loc) · 6.23 KB
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
# DEPRECATED: This legacy Vim config is kept only as a fallback for environments
# where nvim isn't available. Primary editor is Neovim (config/nvim/init.lua).
# vi and vim are aliased to nvim in zshrc. Consider removing this file entirely
# if you never use Vim without the alias.
" Legacy Vim configuration (primary editor is Neovim)
" Automatically install vim-plug on first run
let data_dir = '~/.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
set nocompatible
filetype off
set rtp+=/opt/homebrew/opt/fzf
call plug#begin('~/.vim/bundle')
Plug 'nanotech/jellybeans.vim'
Plug 'tpope/vim-fugitive'
Plug 'bling/vim-airline'
Plug 'Lokaltog/vim-easymotion'
Plug 'junegunn/vim-easy-align'
Plug 'vim-scripts/closetag.vim'
Plug 'othree/html5.vim'
Plug 'rstacruz/sparkup'
Plug 'scrooloose/nerdtree'
Plug 'fatih/vim-go'
Plug 'junegunn/fzf.vim'
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-repeat'
Plug 'editorconfig/editorconfig-vim'
Plug 'christoomey/vim-tmux-navigator'
call plug#end()
filetype plugin indent on " detect file type and load indents and plugins
syntax on " turn on syntax highlighting
silent! colorscheme jellybeans " syntax highlighting colours
" OLED: force pure black background
if has('termguicolors')
set termguicolors
endif
highlight Normal guibg=#000000
highlight NonText guibg=#000000
highlight LineNr guibg=#000000 guifg=#3a3a3a
highlight SignColumn guibg=#000000
highlight VertSplit guibg=#000000 guifg=#1a1a1a
highlight StatusLine guibg=#000000 guifg=#b0b0b0
highlight StatusLineNC guibg=#000000 guifg=#3a3a3a
highlight EndOfBuffer guibg=#000000 guifg=#000000
set autoread " auto reload buffer when file modified externally
set clipboard=unnamed " yank and paste using system clipboard
set encoding=utf-8 " default character encoding
set hidden " do not unload buffers that get hidden
set noswapfile " do not use a swap file for buffers
set nowritebackup " do not make backup before overwriting file
set laststatus=2 " always show the status line
set nowrap " do not wrap text
set number " show line numbers
set scrolloff=3 " keep minimal number of lines above/below cursor
set showcmd " show command line at bottom of screen
set sidescroll=3 " scroll sideways 3 characters at a time
set signcolumn=yes " always show sign column for visual stability
set splitright " open vertical split right of current window
set mouse=a " enable mouse support (scrolling, selection, etc.)
set visualbell " use visual bell instead of beeping
set wildmenu " tab auto-complete for commands
set wildignore=*.pyc " stuff for auto-complete to ignore
set backspace=2 " make backspace behave normally
set expandtab " insert tabs as spaces
set shiftwidth=4 " number of spaces for auto indent and line shift
set cindent " syntax-aware auto indent
set smarttab " <BS> deletes a shiftwidth worth of space
set softtabstop=4 " number of spaces pressing <Tab> counts for
set tabstop=4 " number of spaces a <Tab> in the file counts for
" Smaller indents on css and html files
augroup web_indent
autocmd!
autocmd Syntax css,html,htmldjango,js setlocal shiftwidth=2 tabstop=2 softtabstop=2
augroup END
set showmatch " briefly jump to matching bracket
set ignorecase " ignore case when pattern matching
set smartcase " only if all characters are lower case
set incsearch " highlight matches while typing search
set hlsearch " keep previous search highlighted
" Turn off highlighting of previous search
noremap <C-n> :nohlsearch<CR>
let mapleader = ","
let g:mapleader = ","
let g:user_emmet_leader_key = '<C-e>'
imap jk <Esc>
noremap ; :
" Prevent overwriting default register (system clipboard) when inconvenient
vnoremap x "_x
vnoremap c "_c
vnoremap p "_dP
" Fuzzy finder (fzf)
noremap <C-p> :Files<CR>
noremap <Leader>b :Buffers<CR>
noremap <Leader>f :Rg<CR>
" Move between open buffers
noremap [b :bp<CR>
noremap ]b :bn<CR>
noremap <Leader>d :bd!<CR>:bp<CR>
" Git/fugitive shortcuts
nnoremap <Leader>gs :Git<CR>
nnoremap <Leader>gd :Gdiff<CR>
nnoremap <Leader>gf <C-W>h<C-W>czR
nnoremap <Leader>gp :Git push<CR>
" Mappings for misc plugins
map <SPACE> <Plug>(easymotion-s2)
map <Leader>a <Plug>(EasyAlign)
map <Leader>n :NERDTreeToggle<CR>
" Shortcuts to edit and reload vim config
nnoremap <Leader>r :edit ~/.vimrc<CR>
nnoremap <Leader>R :source ~/.vimrc<CR>
set guioptions=
set guifont=Menlo:h14
" Airline customizations
if !exists("g:airline_symbols")
let g:airline_symbols = {}
endif
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.whitespace = 'Ξ'
autocmd VimEnter * if exists('*airline#section#create') |
\ let g:airline_section_y = airline#section#create(['%p', '%%']) |
\ let g:airline_section_z = airline#section#create_right(['%l', '%c']) |
\ endif
" Gitcommit messsages
autocmd Filetype gitcommit setlocal spell textwidth=72
" Closetag settings
let g:closetag_html_style=1
autocmd! FileType html,htmldjango source ~/.vim/bundle/closetag.vim/plugin/closetag.vim
" Highlight characters when lines get too long
augroup long_lines
autocmd!
autocmd BufWinEnter *.py,*.vim,vimrc match ErrorMsg '\%>79v.\+'
autocmd BufWinEnter *.html match ErrorMsg '\%>100v.\+'
augroup END
" Automatically wrap text while typing in Markdown and rST documents
augroup markdown_settings
autocmd!
autocmd BufNewFile,BufReadPost *.md set filetype=markdown
autocmd Filetype markdown,rst set textwidth=79
augroup END
" Remove trailing whitespace and empty lines at end of file
augroup whitespace
autocmd!
autocmd BufWritePre * :%s/\s\+$//e
autocmd BufWritePre * :%s/\($\n\s*\)\+\%$//e
augroup END