-
Notifications
You must be signed in to change notification settings - Fork 1
/
.vimrc
189 lines (145 loc) · 4.48 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
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
182
183
184
185
186
187
188
189
" Make vim more useful than vi.
set nocompatible
" Add Vlug and add some plugins.
if empty(glob('~/.vim/autoload/plug.vim'))
silent !curl -sfLo ~/.vim/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/bundle')
Plug 'catppuccin/vim', { 'as': 'catppuccin' }
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-surround'
Plug 'romainl/vim-cool'
Plug 'w0rp/ale'
Plug 'airblade/vim-gitgutter'
Plug 'editorconfig/editorconfig-vim'
Plug 'pangloss/vim-javascript'
Plug 'mxw/vim-jsx'
Plug 'elzr/vim-json'
Plug 'gabrielelana/vim-markdown'
call plug#end()
" Set theme and enable syntax highlighting.
colorscheme catppuccin_mocha
syntax on
" Theme adjustments: Enable italics for comments.
let &t_ZH="\e[3m"
let &t_ZR="\e[23m"
highlight Comment cterm=italic
" Optimize for fast terminal connections.
set ttyfast
" Use the OS clipboard by default (on versions compiled with `+clipboard`).
set clipboard=unnamed
" Enable per-directory .vimrc files and disable unsafe commands in them.
set exrc
set secure
" Centralize backups, swap files and undo history.
set backupdir=~/.vim/backups
set directory=~/.vim/swaps
if exists("&undodir")
set undodir=~/.vim/undo
endif
" Do not create backups when editing files in certain directories.
set backupskip=/tmp/*,/private/tmp/*
" Automatically reload files when changed outside vim.
set autoread
" Enhance command-line completion.
set wildmenu
" Allow cursor keys in insert mode.
set esckeys
" Allow backspace in insert mode.
set backspace=indent,eol,start
" Use UTF-8 without BOM.
set encoding=utf-8 nobomb
" Change mapleader.
let mapleader=","
" Respect modeline in files.
set modeline
set modelines=4
" Make tabs as wide as four spaces.
set tabstop=4
set softtabstop=4
set shiftwidth=4
set expandtab
" When opening a new line and no filetype-specific indenting is enabled, keep
" the same indent as the line you are currently on. Useful for READMEs, etc.
set autoindent
" Show “invisible” characters
set lcs=tab:▸\ ,trail:·,eol:¬,nbsp:_
set list
" Highlight searches.
set hlsearch
" Ignore case of searches (except when using capital letters).
set ignorecase
set smartcase
" Highlight dynamically as pattern is typed.
set incsearch
" Add the g flag to search/replace by default.
set gdefault
" Enable line numbers.
set number
" Highlight current line.
set cursorline
" Enable mouse in all modes.
set mouse=a
" Disable error bells (beep or screen flash).
set noerrorbells
" Do not reset cursor to start of line when moving around.
set nostartofline
" Always show the sign column.
set signcolumn=yes
" Do not show the intro message and the file path when starting vim.
set shortmess=atIF
" Do not show status line since we use vim-airline.
set laststatus=0
" Do not show the cursor position since we use vim-airline.
set noruler
" Do not show the current mode since we use vim-airline.
set noshowmode
" Show the filename in the window title bar.
set title
" Show the (partial) command as it is being typed.
set showcmd
" Start scrolling three lines before the horizontal window border.
set scrolloff=3
" Save a file as root (,W).
noremap <leader>W :w !sudo tee % > /dev/null<CR>
" Strip trailing whitespace (,ss).
function! StripWhitespace()
let save_cursor=getpos(".")
let old_query=getreg('/')
:%s/\s\+$//e
call setpos('.', save_cursor)
call setreg('/', old_query)
endfunction
noremap <leader>ss :call StripWhitespace()<CR>
" Automatic commands.
if has("autocmd")
" Enable file type detection.
filetype on
" Treat .json files as JavaScript.
autocmd BufNewFile,BufRead *.json setfiletype json syntax=javascript
" Treat .md files as Markdown.
autocmd BufNewFile,BufRead *.md setlocal filetype=markdown
endif
" Use ag instead of ack.
if executable('ag')
let g:ackprg='ag --vimgrep'
endif
let g:ackhighlight=1
" Use JSX highlighting on JSX files only.
let g:jsx_ext_required = 1
" Configure Airline.
let g:airline_theme = 'catppuccin_mocha'
let g:airline_powerline_fonts=1
let g:airline_statusline_ontop=1
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#hunks#non_zero_only=1
function! AirlineInit()
call airline#parts#define_raw('modified', '%{&modified ? " (modified)" : ""}')
call airline#parts#define_accent('modified', 'red')
let g:airline_section_c = airline#section#create(['%f', 'modified'])
endfunction
autocmd VimEnter * call AirlineInit()