-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc
286 lines (263 loc) · 7.84 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
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
" File: .vimrc
" Author: Øystein Walle???
" Description: Tradsj diverse settings?
set nocompatible
filetype off
if has("win32")
set encoding=utf-8
set runtimepath^=~/.vim
set runtimepath+=~/.vim/after
endif
if empty($MSYSTEM)
let fuzzy = 'fzf'
let use_coc = 1
else
let fuzzy = 'fzy'
let use_coc = 0
endif
" Start Plug {{{
let g:plug_shallow = 0
silent! call plug#begin()
if exists(":Plug")
Plug 'tpope/vim-surround'
Plug 'tomtom/tcomment_vim'
Plug 'godlygeek/tabular'
Plug 'SirVer/ultisnips'
Plug 'honza/vim-snippets'
if fuzzy == 'fzf'
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
elseif fuzzy == 'fzy'
Plug 'srstevenson/vim-picker'
endif
Plug 'tpope/vim-repeat'
Plug 'tpope/vim-fugitive'
Plug 'Osse/double-tap'
Plug 'nanotech/jellybeans.vim'
Plug 'mhinz/vim-startify'
Plug 'richq/vim-cmake-completion'
Plug 'PotatoesMaster/i3-vim-syntax'
if use_coc == 1
Plug 'neoclide/coc.nvim', {'branch': 'release'}
endif
Plug 'PProvost/vim-ps1'
Plug 'rust-lang/rust.vim'
Plug 'cespare/vim-toml', { 'branch': 'main' }
endif
silent! call plug#end()
" }}}
filetype plugin indent on
syntax enable
runtime macros/matchit.vim
if findfile('colors/jellybeans.vim', &rtp) != ""
let g:jellybeans_overrides = {
\ 'StatusLine': { 'attr': 'bold' },
\ 'StatusLineNC': { 'attr': 'bold' },
\ }
colorscheme jellybeans
endif
" Options {{{
if has("win32")
set guifont=Lucida_Console:h10:cANSI
cd $HOME " To avoid starting it the location of the binary
else
set guifont=Ubuntu\ Mono\ 12
endif
set ruler
set suffixes=.bak,~,.swp,.o,.info,.aux,.log,.dvi,.bbl,.blg,.brf,.cb,.ind,.idx,.ilg,.inx,.out,.toc
set backspace=indent,eol,start
set history=50
set sessionoptions-=options,blank,winsize
set sessionoptions+=winpos
set autoindent
" set mouse=a
set linebreak " Velg fornuftig sted å bryte linjer
set softtabstop=4 " Alltid tabs
set shiftwidth=4 " Bare tabs
set expandtab " Extand tabs to spaces
set foldmethod=syntax " fold based on syntax by default
set foldlevelstart=99 " Folds aldri lukket som standard
set hlsearch " Lyser opp skit
set incsearch " Søker etter hvert
set showcmd " Viser delkommandoer nede til høyre
set showmatch " showmatch
set wildmode=list:longest " Bash-like auto-completion
set hidden " Gjør det levelig med ulagrede buffers
set nojoinspaces " Lager ikke 70-talls mellomrom mellom setninger
set completeopt-=preview
set cinoptions+=(0,u0,g0,N-s
set pastetoggle=<F4>
set showbreak=>\
set laststatus=2
set ttimeout ttimeoutlen=100
set splitright
set splitbelow
set nowrap
set scrolloff=5
set undofile
set directory=~/.vim/swap//,.
if ! isdirectory(expand("~/.vim/swap"))
call mkdir(expand("~/.vim/swap"),"p",0700)
endif
set undodir=~/.vim/undo
if ! isdirectory(expand("~/.vim/undo"))
call mkdir(expand("~/.vim/undo"),"p",0700)
endif
set switchbuf=useopen
set cmdheight=2
" }}}
" Diverse mappings {{{
let mapleader="ø"
nnoremap ! ?
nnoremap S /
nnoremap <Space> <C-W><C-W>
map Y y$
noremap ZA :qa!<CR>
noremap ¤ $
noremap æ ^
noremap <Leader>p p=']
vnoremap > >gv
vnoremap < <gv
nnoremap c) v)?[.!?]\+?s-1<CR>c
nnoremap g) )gE
nnoremap g( (gE
nnoremap <C-Left> <C-W><Left>
nnoremap <C-Right> <C-W><Right>
nnoremap <C-Down> <C-W><Down>
nnoremap <C-Up> <C-W><Up>
nnoremap <Esc>O5D <C-W><Left>
nnoremap <Esc>O5C <C-W><Right>
nnoremap <Esc>O5B <C-W><Down>
nnoremap <Esc>O5A <C-W><Up>
" Toggles and other stuff {{{
nnoremap <F1> :he
nnoremap <F2> :set invnumber number?<CR>
nnoremap <F3> :set invrelativenumber relativenumber?<CR>
nnoremap <F5> :set invlist list?<CR>
nnoremap <F6> :set invspell spell?<CR>
nnoremap <F7> :set invwrap wrap?<CR>
nnoremap <silent> <F9> :wall <Bar> make<CR><CR><CR>:botright cwindow<CR>
" }}}
nnoremap <C-W>] :vsplit<CR>:tag<CR>
nnoremap <silent> <C-l> :noh<CR><C-l>
nnoremap ' `
nnoremap ` '
nnoremap <leader>q gqap
"}}}
" Settings for UltiSnips {{{
let g:UltiSnipsDontReverseSearchPath = "1"
let g:UltiSnipsExpandTrigger = "<Tab>"
let g:UltiSnipsJumpForwardTrigger = "<Tab>"
let g:UltiSnipsJumpBackwardTrigger = "<S-tab>"
let g:UltiSnipsSnippetDirectories = [ "osse_snippets", "UltiSnips"]
" }}}
" Fuzzy-finder specific mappings {{{
if fuzzy == 'fzf'
function! MyFiles(...)
call system('git rev-parse --show-toplevel')
if (v:shell_error)
call call('fzf#vim#files', a:000) " Use :Files instead?
else
call call('fzf#vim#gitfiles', a:000) " Use :GFiles instead?
endif
endfunction
command! -bang -nargs=? MyFiles call MyFiles(<q-args>, <bang>0)
nnoremap <C-P> :<C-U>MyFiles<CR>
nmap <unique> Q :Buffers<CR>
elseif fuzzy == 'fzy'
nmap <unique> <C-P> <Plug>(PickerEdit)
nmap <unique> Q <Plug>(PickerBuffer)
endif
" }}}
" Noe LaTeX-reier {{{
let g:tex_fold_enabled = 1
let g:tex_flavor = "latex"
let g:tex_conceal = 'sgdm'
let g:tex_comment_nospell = 1
" }}}
" Startify {{{
let g:startify_relative_path = 1
let g:startify_skiplist = [ 'COMMIT_EDITMSG$', '\('.escape($VIMRUNTIME, '\').'\|bundle/.*\)/doc/.*\.txt$' ]
let g:startify_bookmarks = [
\ { 'm': '~/.vim/vimrc' },
\ { 'i': '~/.i3/config' },
\ { 'z': '~/.zshrc' },
\ { 'b': '~/.bashrc' },
\ { 'g': '~/.gitconfig' },
\ { 'p': '/u/Docs/WindowsPowerShell/Microsoft.PowerShell_profile.ps1' },
\ ]
let g:startify_change_to_dir = 0
let g:startify_change_to_vcs_root = 1
" }}}
" PHP stuff from ftplugin/php.vim {{{
let g:php_folding=2
let php_htmlInString=1
let php_sql_query=1
" }}}
" Rust stuff {{{
let g:cargo_makeprg_params = 'build'
" }}}
" Oppretter/bruker en autcmd-gruppe som heter minvimrc {{{
augroup minvimrc
autocmd! minvimrc
autocmd CmdwinEnter * nnoremap <buffer> q :q<CR>
autocmd Filetype asciidoc setlocal makeprg=asciidoc\ %
autocmd QuickFixCmdPost * cwindow
autocmd Filetype qf nnoremap <buffer> q :q<CR>
autocmd BufRead /tmp/bash-* let b:is_bash = 1 | set filetype=sh
augroup end
" }}}
" Funksjon som skriver highlight group(s) til det under cursor {{{
func! SynStack()
if !exists("*synstack")
return
endif
echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")')
endfunc
" }}}
if $TERM == 'xterm-kitty'
" vim hardcodes background color erase even if the terminfo file does
" not contain bce (not to mention that libvte based terminals
" incorrectly contain bce in their terminfo files). This causes
" incorrect background rendering when using a color theme with a
" background color.
let &t_ut=''
endif
let gitlvimrc = findfile('.git/lvimrc', ';')
for rc in findfile('.lvimrc', ';', -1) + (gitlvimrc != "" ? [fnamemodify(gitlvimrc, ':p')] : [])
let path = substitute(rc, '/\(.git/lvimrc\|.lvimrc\)$', '', '')
execute 'source' rc
unlet path
endfor
" OsseCursorBlind {{{
" grabbed from https://gist.github.com/dahu/5003452
" inspired by Blind Osse de Hashvim
" Barry Arthur, February 2013
function! OsseCursorBlindOn()
" extra heinous colour jizz here if desired
" Oh indeed
hi CursorLine ctermbg=2
hi CursorColumn ctermbg=2
set cursorcolumn
set cursorline
augroup OsseCursorBlind
au!
au CursorHold * call OsseCursorBlindOff()
au CursorMoved * call OsseCursorBlindOff()
augroup END
endfunction
function! OsseCursorBlindOff()
set nocursorline
set nocursorcolumn
" hack to force reloading of the colorscheme
let &bg = &bg
augroup OsseCursorBlind
au!
augroup END
endfunction
augroup OsseCursorBlind
au!
augroup END
nnoremap <F8> :call OsseCursorBlindOn()<cr>
" }}}
" vim: foldmethod=marker foldlevel=0