-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc
207 lines (166 loc) · 5.56 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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
" AUTHOR: larsaars
" REPOSITORY: https://github.com/larsaars/linux-setup
"+++++++++++++++++++++++++++++++++ Load Plugins +++++++++++++++++++++++++++++++++"
" load vim-plug plugin
call plug#begin('~/.vim/plugged')
" plugins
Plug 'itchyny/lightline.vim'
Plug 'ap/vim-css-color'
Plug 'dense-analysis/ale'
Plug 'KarimElghamry/vim-auto-comment'
Plug 'github/copilot.vim', {'branch': 'release'}
Plug 'Vimjas/vim-python-pep8-indent'
Plug 'numirias/semshi', { 'do': ':UpdateRemotePlugins' }
Plug 'godlygeek/tabular'
Plug 'pangloss/vim-javascript'
call plug#end()
"++++++++++++++++++++++++++++++++ Appearance +++++++++++++++++++++++++++++++++"
" syntax highlighting
syntax on
" display line numbers
set number
" show a visual line under the cursors current line
set cursorline
" lightline settings
set laststatus=2
let g:lightline = {
\ 'colorscheme': 'PaperColor'
\ }
" colorscheme and styling options
colorscheme codedark
set background=dark
highlight Normal ctermbg=black
highlight EndOfBuffer ctermbg=black
highlight colorcolumn ctermbg=234
highlight LineNr ctermbg=black
" function to switch theme between light and dark
let g:ThemeN = 2
function! ChangeTheme()
if g:ThemeN == 1
let g:ThemeN = 2
colorscheme codedark
set background=dark
highlight Normal ctermbg=black
highlight EndOfBuffer ctermbg=black
highlight colorcolumn ctermbg=234
highlight LineNr ctermbg=black
elseif g:ThemeN == 2
let g:ThemeN = 3
colorscheme jummidark
else
let g:ThemeN = 1
colorscheme PaperColor
set background=light
highlight colorcolumn ctermbg=lightgray
endif
endfunction
"+++++++++++++++++++++++++++++++++ Behaviour +++++++++++++++++++++++++++++++++"
" autoread files if reloaded (by versioncontrol for example)
set autoread
" enable autoindent
filetype indent plugin on
" set default indentation
set tabstop=4 softtabstop=0 expandtab shiftwidth=4 smarttab
" auto close brackets and quotes
inoremap ( ()<left>
inoremap [ []<left>
inoremap { {}<left>
" Skipping over closing brackets and quotes
inoremap <expr> ) strpart(getline('.'), col('.')-1, 1) == ")" ? "\<Right>" : ")"
inoremap <expr> ] strpart(getline('.'), col('.')-1, 1) == "]" ? "\<Right>" : "]"
inoremap <expr> } strpart(getline('.'), col('.')-1, 1) == "}" ? "\<Right>" : "}"
inoremap <expr> " strpart(getline('.'), col('.')-1, 1) == "\"" ? "\<Right>" : "\"\"\<Left>"
inoremap <expr> ' strpart(getline('.'), col('.')-1, 1) == "\'" ? "\<Right>" : "\'\'\<Left>"
" when brace + enter is pressed automatically add indent correctly and add
" missing brace
inoremap {<CR> {<CR>}<Esc>ko
inoremap [<CR> [<CR>]<Esc>ko
inoremap (<CR> (<CR>)<Esc>ko
" Other
set nowb
set showcmd
set hlsearch
set nobackup
set incsearch
set smartcase
set noswapfile
set smartindent
set noerrorbells
autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o
" vim will use system clipboard instead of its own
set clipboard=unnamed,unnamedplus
" vim auto comment variables
let g:default_inline_comment="#"
let g:inline_comment_dict = {
\'//': ["js", "ts", "cpp", "c", "dart"],
\'#': ['py', 'sh'],
\'"': ['vim', 'vimrc'],
\}
" function to beautify file automatically on write
function FormatBuffer()
if &modified && !empty(findfile('.clang-format', expand('%:p:h') . ';'))
let cursor_pos = getpos('.')
:%!clang-format
call setpos('.', cursor_pos)
endif
endfunction
autocmd BufWritePre *.h,*.hpp,*.c,*.cpp,*.vert,*.frag,*.java :call FormatBuffer()
" every c and cpp (and other languages) file will be formatted by the program clang-format
" (installed)
autocmd FileType c,cpp,java,cs setlocal equalprg=clang-format
" ale linter options
let g:ale_fix_on_save=1
" Check Python files with flake8 and pylint.
let b:ale_linters = ['flake8', 'pylint']
" Fix Python files with autopep8 and yapf.
let b:ale_fixers = ['autopep8', 'yapf']
" Disable warnings about trailing whitespace for Python files.
let b:ale_warn_about_trailing_whitespace = 0
" file specified auto commands
au BufRead *.pdf sil exe "!xdg-open " . shellescape(expand("%:p")) | bd | let &ft=&ft | redraw!
"+++++++++++++++++++++++++++++++++ Netrw (file menu) +++++++++++++++++++++++++++++++++"
" appearance
let g:netrw_liststyle = 3
let g:netrw_banner = 0
let g:netrw_browse_split = 0
let g:netrw_winsize = 25
" start netrw silent
let g:netrw_silent = 1
" when pressing v open in window on right of tree
let g:netrw_altv=1
" close window after opening file
let g:netrw_fastbrowse=0
" Netrw toggle function
let g:NetrwIsOpen = 0
function! ToggleNetrw()
if g:NetrwIsOpen
let i = bufnr("$")
while (i >= 1)
if (getbufvar(i, "&filetype") == "netrw")
silent exe "bwipeout " . i
endif
let i-=1
endwhile
let g:NetrwIsOpen=0
else
let g:NetrwIsOpen=1
silent Lexplore
endif
endfunction
"+++++++++++++++++++++++++++++++++ Key Bindings +++++++++++++++++++++++++++++++++"
" Change tab bindings (alt+j/alt+k)
" and set M-l and M-h to move tab one left or right
nnoremap <M-j> :tabp<CR>
nnoremap <M-k> :tabn<CR>
nnoremap <M-l> :tabm +1 <CR>
nnoremap <M-h> :tabm -1 <CR>
" press f8 to switch theme (with previously defined function)
map <F8> :call ChangeTheme()<CR>
" toggle tree on f9 or on shift+2 (which is basically ")
map " :call ToggleNetrw() <CR>
" keys for auto commenting:
" auto inline comment in command and in visual mode
nnoremap + :AutoInlineComment <CR>
vnoremap + :AutoInlineComment <CR>
" remap minus in command mode to put a newline below
noremap - mpo<esc>`p