Repository navigation
Expand file tree
/
Copy path.vimrc
More file actions
330 lines (244 loc) · 9.51 KB
/
Copy path.vimrc
File metadata and controls
330 lines (244 loc) · 9.51 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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
set encoding=utf-8
set visualbell
""""""""""""""""""""""""""
" Vundle - Plugin Manager
""""""""""""""""""""""""""
let s:plug_home = expand('~/.vim/bundle/')
let s:plug_dirs = {
\ 'vundle': s:plug_home . 'Vundle.vim',
\ 'YCM': s:plug_home . 'YouCompleteMe',
\ 'nvim-treesitter': s:plug_home . 'nvim-treesitter',
\ 'syntastic': s:plug_home . 'syntastic',
\ }
function! s:plug_exists(name)
return isdirectory(s:plug_dirs[a:name]) || stridx(&runtimepath, a:name) >= 0
endfunction
" To install vundle and plugins:
" git clone https://github.com/VundleVim/Vundle.vim.git " . s:plug_dirs['vundle']
" ':PluginInstall'"
if s:plug_exists('vundle')
echo "Vundle found"
set nocompatible " be iMproved, required as first command
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
" Keep Plugin commands between vundle#begin/end.
" use :PluginInstall to install listed repos
Plugin 'ycm-core/YouCompleteMe' , { 'oninstall': './install.py --clang-completer --rust-completer' }
" TO INSTALL RUST LSP:
" rustup component add rls rust-analysis rust-src
" ln -s ~/.rustup/toolchains/*x86_64-unknown-linux-gnu/ ./rls
" ALT: ./install.py --rust-completer --rust-toolchain-version stable-x86_64-unknown-linux-gnu
Plugin 'https://github.com/nvim-treesitter/nvim-treesitter' , { 'do': ':TSUpdate' }
" deprecated syntax checker and error display, superseded by treesitter
Plugin 'https://github.com/vim-syntastic/syntastic'
" custom syntax highlighting superseded by treesitter language modules
"Plugin 'https://github.com/LnL7/vim-nix'
Plugin 'https://github.com/rust-lang/rust.vim'
" All of your Plugins must be added before the following line
call vundle#end() " required
endif
""""""""""""""""""""""""""
" Settings
""""""""""""""""""""""""""
set incsearch " interactive search
set nocompatible " disable vi compatibility
set number " show line numbers
set backspace=indent,eol,start " allows BS to delete these characters
set autoindent " use indentation of the previous line
set nocindent nosmartindent " disable dreaded comment unindentation
set history=200
set undolevels=200
set ruler " show cursor position in the lower right
set showcmd " show command while typing
"filetype plugin indent on " recognizing file types, loads plugins (if exit) and detects indentation style
"set spell " spell checker (en)
"set spl=en " spell check language
set smd " show mode (normal, insert, replace, visual) when switching
set verbose=0 " verboselevel to show startup/exit vim processes, default: 11.
set more " show '--more--' in listings
"set eol " puts an eol at the last line in file
"set fixeol " fix missing eol at the end of file
set relativenumber " relative line numbers
set hidden " show hidden buffers
set nomodeline " modelines are autocmd comments in files
" This function delivers the string to be displayed over folded lines
function MyFoldText()
let indent = indent(v:foldstart)
return repeat(' ', indent + &sw-4) . trim(getline(v:foldstart))
endfunction
set foldtext=MyFoldText()
" nvim-treesitter folding or by fold by indentation
"if s:plug_exists('nvim-treesitter')
set foldmethod=syntax
set foldexpr=nvim_treesitter#foldexpr()
"else
" echom "nvim-treesitter plugin not found."
" set foldmethod=indent
"endif
set nofoldenable " dont fold by default
set foldcolumn=3 " shows a fold column on the lest (symbols: +. -, |)
set fillchars=fold:\ " disable 'fillchars' in 'foldtext' lines
set formatoptions=jl " Formating option, see :help fo-table for details
set bs=2 " backspacing behaviour. 2 = backspace over indent, eol, start
set showtabline=2 " always show tabbar
set tabpagemax=10 " max tabs to show. use :next or :last to navigate to exceeding tabs
set nowrap " disable line break
"set sidescroll=10 " number of columns to scroll horizontally, good for slow terminals
set sidescrolloff=10 " number of columns to keep on screen borders while horizontally scrolling
set scrolloff=3 " number of linse that will be kept while vertical scrolling
" User interface
set wildchar=<TAB>
set wildmenu " ':' menu with 'wildchar' (TAB)
set wildmode=full
" tabs/spaces indentation
set tabstop=2 " tabstop = tabwidth
"set shiftwidth=4 " one foldlevel = 4 chars (tab_size=8 wont fold properly)
"set softtabstop=0
set noexpandtab
" disable backups and swaps, just save one file
set nobackup
set nowritebackup
set noswapfile
" show tabs and eol as chars:
scriptencoding utf-8
set listchars=tab:▸\ ,eol:¬,trail:·
set list " display non-printable characters as above
"match ErrorMsg '\%>120v.\+'
match ErrorMsg '\s\+$'
" use enter/backspace in normal mode to move per paragraph
nnoremap <BS> {
onoremap <BS> {
vnoremap <BS> {
nnoremap <expr> <CR> empty(&buftype) ? '}' : '<CR>'
onoremap <expr> <CR> empty(&buftype) ? '}' : '<CR>'
vnoremap <CR> }
" Netrw¬
let g:netrw_liststyle=3
let g:netrw_banner=0
let g:netrw_cursor=3
let g:netrw_sizestyle="H"
"let g:netrw_browse_split=4¬
"let g:netrw_altv=1¬
"let g:netrw_winsize=25
"
""""""""""""""""""""""""""
" Colors
""""""""""""""""""""""""""
" only turn on colors if terminal supports it
if &t_Co > 2 || has('gui_rendering')
" general colors
colorscheme habamax
set background=dark " dark color scheme
set hlsearch " highlight search results
syntax enable " syntax highlighting without overwriting existing settings
" set the color column to show/delimit line length
set colorcolumn=80
"source ~/.vim/my_colorscheme.vim
endif
""""""""""""""""""""""""""
" Plugin Config
""""""""""""""""""""""""""
if s:plug_exists('YCM')
let g:ycm_show_diagnostics_ui = 0 " needed because YCM disables all syntastic checkers by default
let g:ycm_autoclose_preview_window_after_completion = 1
let g:ycm_max_num_candidates = 0 " unlimited autocomplete popup list
endif
if s:plug_exists('syntastic')
let g:syntastic_cpp_compiler = 'g++'
let g:syntastic_cpp_compiler_options = ' -std=c++1z -stdlib=libc++'
" pip3 install neovim pynvim flake8 jedi autopep8
let g:syntastic_python_checkers=['flake8', 'python3']
let g:syntastic_python_flake8_args='--ignore W191,W391,E117,E201,E202,E203,E226,E228,E242,E261,E302,E303,E128,E124,E731,E265,E222,E722,E221,E241,E305,E501'
"general options
let g:syntastic_auto_jump = 3 " jump to first error in file
let g:syntastic_aggregate_errors = 1 " show error from all checkers
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
" dynamic loclist size
" see :h syntastic-loclist-callback
function! SyntasticCheckHook(errors)
if !empty(a:errors)
let g:syntastic_loc_list_height = min([len(a:errors), 10])
endif
endfunction
endif
let g:git_branch = 'non-git'
function! Get_git_branch()
let g_o = systemlist('cd '.expand('%:p:h:S').' && git branch 2>/dev/null')
let g:git_branch = len(g_o) > 0 ? strpart(get(g_o,0,''),2) : 'non-git'
endfunc
autocmd BufEnter,BufWritePost * call Get_git_branch()
if has('statusline')
highlight StatusLineMiddle cterm=underline
set laststatus=2 " always show a status line
set stl=[%Y,%{&fileencoding?&fileencoding:&encoding}] " file type/enc
set stl+=<%{g:git_branch}>
set stl+=%#StatusLineMiddle#%=%0*%l/%L:%c\ %p%% " shows file location stuff, right
endif
""""""""""""""""""""""""""
" MISC
""""""""""""""""""""""""""
" enalbe mouse fetures
if has('mouse')
set mouse=a
set mousefocus
endif
" disable 'python.vim's F#@!%ing space indentation
" let g:python_recommended_style = 0
" au Filetype python set noet
" no success yet ...
" set exrc " vim executes a local .vimrc file for project specific settings
set secure " limit the autoexec feature from "exrc" for security considerations
" you can enter ":make" to execute make in the current directory.
" this specifies a target directory
set makeprg=make\ -C\ ../build\ -j4
"set pastetoggle=<F2>
set clipboard=unnamedplus " Use the system clipboard
noremap <Leader>E :qa!<CR> " quit all windows
" map sort function to a key
vnoremap <Leader>s :sort<CR>
" easier moving/indenting of lines/blocks
vnoremap < <gv " right
vnoremap > >gv " left
" Automatic relaoding of .vimrc
autocmd! bufwritepost ~/.vimrc source %
" Only do this part when compiled with support for autocommands.
if has("autocmd")
" Enable file type detection.
" Use the default filetype settings, so that mail gets 'tw' set to 72,
" 'cindent' is on in C files, etc.
" Also load indent files, to automatically do language-dependent indenting.
filetype plugin indent on
" Put these in an autocmd group, so that we can delete them easily.
augroup vimrcEx
au!
" For all text files set 'textwidth' to 78 characters.
autocmd FileType text setlocal textwidth=0
" 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).
autocmd BufReadPost *
\ if line("'\"") >= 1 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
augroup END
endif
" Convenient command to see the difference between the current buffer and the
" file it was loaded from, thus the changes you made.
" Only define it when not defined already.
if !exists(":DiffOrig")
command DiffOrig vert new | set bt=nofile | r ++edit # | 0d_ | diffthis
\ | wincmd p | diffthis
endif
if has('langmap') && exists('+langnoremap')
" Prevent that the langmap option applies to characters that result from a
" mapping. If unset (default), this may break plugins (but it's backward
" compatible).
set langnoremap
endif