-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvimrc
More file actions
219 lines (192 loc) · 6.97 KB
/
Copy pathvimrc
File metadata and controls
219 lines (192 loc) · 6.97 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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
" vim: et ts=2 sw=2 ft=vim
" Basic options. Keep them before loading plugins.
set hidden " Allow to switch buffers without saving
set number " Show line numbers
set cursorline " Highlight cursor line
set mouse= " Disable mouse
set nowrap " Do not wrap text
set splitbelow " Open hsplits below
set splitright " Open vsplits at right
set scrolloff=999 " Keep cursorline mostly in the middle of the screen
set noswapfile " Disable swap files by default.
set textwidth=72 " Default text width.
set tabpagemax=15 " Set a max number of tabs
set background=dark " Prefer dark colors
set hlsearch " Highlight the last used search pattern
set incsearch " Do incremental searching
set nojoinspaces " Only one space are added when joining lines
set ignorecase " Ignore case when searching
set smartcase " Case-sensitive if any uppercase char
set nowrapscan " Do not wrap around when searching
set foldenable " Turn on folding
set foldmethod=indent " Make folding indent sensitive
set foldlevel=100 " Do not autofold anything
set foldopen-=search " Do not open folds when you search into them
set foldopen-=undo " Do not open folds when you undo stuff
set et
set sw=2
" Enconding
scriptencoding utf-8
set encoding=utf-8
if has('persistent_undo')
set undofile " Enable persistent undo history
set undolevels=1000 " Max number of changes that can be undone
set undoreload=10000 " Max number lines to save for undo on a buffer reload
endif
" Basic key bindings
let mapleader=","
" Indent (keeping in visual mode)
vnoremap > >gv
" Deindent (keeping in visual mode)
vnoremap < <gv
" Space to fold/unfold in normal mode
nnoremap <space> za
" Clear highlighted search
nnoremap <leader><space> :noh<cr>:call clearmatches()<cr>
" Leader-ss to find/replace word under cursor
nnoremap <leader>ss :%s,\<<C-r><C-w>\>,
" Leader-sw to save as root
nnoremap <leader>sw :w !sudo tee %<CR>
" F5 to reload file from disk
nnoremap <silent><F5> :e!<CR>
if filereadable(expand("~/.vim/local.vim"))
source ~/.vim/local.vim
endif
" Load plugins
if !has('nvim') || exists("g:use_legacy_config")
source ~/.vim/plugins.vim
else
lua require('config.lazy')
endif
" Enconding
scriptencoding utf-8
set encoding=utf-8
if has('persistent_undo')
set undofile " Enable persistent undo history
set undolevels=1000 " Max number of changes that can be undone
set undoreload=10000 " Max number lines to save for undo on a buffer reload
endif
" Other custom settings
let g:disable_arrow_keys = 1
let g:use_space_instead_of_tabs = 1
let g:default_tabsize = 2
if has('cmdline_info')
set ruler " show the cursor position all the time
set rulerformat=%30(%=\:b%n%y%m%r%w\ %l,%c%V\ %P%) " a ruler on steroids"
set showcmd " display partial commands
endif
" Editing configs
set backspace=indent,eol,start " backspacing over everything in insert mode
set autoread " auto reread file when changed outside Vim
set autowrite " write a modified buffer on each :next, etc.
filetype plugin indent on
if g:disable_arrow_keys
noremap <left> <nop>
noremap <up> <nop>
noremap <down> <nop>
noremap <right> <nop>
endif
autocmd FileType Makefile set g:use_space_instead_of_tabs = 0
if g:use_space_instead_of_tabs
set expandtab " tabs are spaces, not tabs"
endif
if !g:default_tabsize
let g:default_tabsize = 2
endif
" number of spaces to use for each step of indent
execute "set shiftwidth=".g:default_tabsize
" number of spaces that a <Tab> counts for
execute "set tabstop=".g:default_tabsize
" let backspace delete indent
execute "set softtabstop=".g:default_tabsize
" Status line config
if has('statusline')
set laststatus=2
" Broken down into easily includeable segments
set statusline=%<%f\ " Filename
set statusline+=%w%h%m%r " Optios
set statusline+=%{fugitive#statusline()} " Git Hotness
set statusline+=\ [%{&ff}/%Y] " filetype
set statusline+=%=%-14.(%l,%c%V%)\ %p%% " Right aligned file nav info
endif
if has("autocmd")
autocmd BufNewFile,BufRead *.aidl set filetype=java
autocmd BufNewFile,BufRead *.qbs set filetype=qml
endif
" Stupid shift key fixes
if has("user_commands")
command! -bang -nargs=* -complete=file E e<bang> <args>
command! -bang -nargs=* -complete=file W w<bang> <args>
command! -bang -nargs=* -complete=file Wq wq<bang> <args>
command! -bang -nargs=* -complete=file WQ wq<bang> <args>
command! -bang Wa wa<bang>
command! -bang WA wa<bang>
command! -bang Q q<bang>
command! -bang QA qa<bang>
command! -bang Qa qa<bang>
endif
" Python interpreter settings
let g:python3_host_prog = '/bin/python3'
let g:python2_host_prog = '/bin/python2'
" Syntax highlight and colorscheme setup
" Enable syntax highlight when the env supports it and
" loads base16 settings if any.
if &t_Co > 2 || has("gui_running")
" Force 256 colors
set t_Co=256
set t_ut=
set termguicolors
" Switch syntax highlighting on
syntax on
endif
" Vim-specifics (too old?)
if version >= 730 && version < 800
if has("autocmd")
" Autosave & Load Views.
autocmd BufWritePost,WinLeave,BufWinLeave ?* if MakeViewCheck() | mkview | endif
autocmd BufWinEnter ?* if MakeViewCheck() | silent! loadview | endif
endif
else
" When editing a file, always jump to the last known cursor position.
" Don't do it when the position is invalid or when inside an event handler
" (happens when dropping a file on gvim).
if has("autocmd")
autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
endif " has("autocmd")
endif
" NeoVim-specifics
if !has('nvim')
set ttymouse=xterm2
endif
if exists(':tnoremap')
tnoremap <Esc> <C-\><C-n>
endif
" Navigation-related keybindings
nnoremap <silent> <C-j> :tabprevious<CR>
nnoremap <silent> <C-k> :tabnext<CR>
if !g:disable_arrow_keys
nnoremap <silent> <C-Up> :tabprevious<CR>
nnoremap <silent> <C-Down> :tabnext<CR>
endif
" TODO: find alt for these ones, <C-L> already used for LPS commands
nnoremap <silent> <C-Left> :execute 'silent! tabmove ' . (tabpagenr()-2)<CR>
nnoremap <silent> <C-Right> :execute 'silent! tabmove ' . (tabpagenr()+1)<CR>
" LSP and completion
if !has('nvim') || exists("g:use_legacy_config")
source ~/.vim/legacy.vim
else
lua require('config.basics')
lua require('config.lsp')
lua require('config.completion')
lua require('config.picker')
lua require('config.statusline')
endif
" Alt+<directional> to switch among splits
let g:tmux_navigator_no_mappings = 1
nnoremap <silent> <A-h> :TmuxNavigateLeft<cr>
nnoremap <silent> <A-j> :TmuxNavigateDown<cr>
nnoremap <silent> <A-k> :TmuxNavigateUp<cr>
nnoremap <silent> <A-l> :TmuxNavigateRight<cr>