-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc
111 lines (98 loc) · 2.88 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
" Plugins {{{
packadd vim-fugitive
packadd vim-commentary
packadd ale
" }}}
" Settings {{{
filetype plugin indent on
syntax on
" Let's save undo info!
if !isdirectory($HOME."/.vim")
call mkdir($HOME."/.vim", "", 0770)
endif
if !isdirectory($HOME."/.vim/undo-dir")
call mkdir($HOME."/.vim/undo-dir", "", 0700)
endif
set undodir=~/.vim/undo-dir
set undofile
set colorcolumn=121 "mark theoretical line limit of 120 chars"
set number "activate line numbers
set cursorline "activate underline of cursor
set foldmethod=indent
set expandtab shiftwidth=4 softtabstop=4 tabstop=4 autoindent
set backspace=2 " Allows the removal of newlines and indents in insertmode via backspace button
set wildmenu
set wildmode=list:longest
set wildignore=*.docx,*.jpg,*.png,*.gif,*.pdf,*.pyc,*.exe,*.flv,*.img,*.xlsx
set hlsearch " Enable search highlighting
set incsearch " Incremental search highlighting as you type
set omnifunc=ale#completion#OmniFunc
let g:ale_completion_enabled = 1 " activate Ale's own completion mechanism
let g:ale_linters = {
\ 'rust': ['analyzer'],
\ 'python': ['jedils'],
\ }
" }}}
" Functions {{{
function! Auto_complete_string()
if pumvisible()
return "\<C-n>"
else
return "\<C-x>\<C-o>\<C-r>=Auto_complete_opened()\<CR>"
end
endfunction
function! Auto_complete_opened()
if pumvisible()
return "\<Down>"
end
return ""
endfunction
function! Toggle_docs()
let l:preview_window_id = bufwinnr("ALEPreviewWindow")
if l:preview_window_id != -1
execute l:preview_window_id . "close"
else
ALEHover
endif
endfunction
function! Switch_to_docs()
let l:preview_window_id = bufwinnr("ALEPreviewWindow")
if l:preview_window_id != -1
if bufname('%') == 'ALEPreviewWindow'
wincmd p
else
execute l:preview_window_id . "wincmd w"
endif
else
echo "ABCPreviewWindow not found."
endif
endfunction
" }}}
" Mappings {{{
nnoremap gb :Git blame<CR>
nnoremap <C-k> :Commentary<CR>j
vnoremap <C-k> :Commentary<CR>
nunmap gcc
vunmap gc
nnoremap <C-w>m :rightbelow vertical terminal<CR>
" Solution taken from https://stackoverflow.com/questions/510503/ctrlspace-for-omni-and-keyword-completion-in-vim
inoremap <expr> <Nul> Auto_complete_string()
inoremap <expr> <C-Space> Auto_complete_string()
nnoremap Fg :ALEGoToDefinition -tab<CR>
nnoremap Ko :call Toggle_docs()<CR>
nnoremap KK :call Switch_to_docs()<CR>
nnoremap Ff :ALEFindReferences<CR>
nnoremap Fr :ALERename<CR>
" }}}
" File Type specific Settings {{{
" Settings specifically for vim files
augroup filetype_vim
autocmd!
autocmd FileType vim setlocal foldmethod=marker "set for vim files marker as foldmethod
augroup END
" Settings specifically for python files
augroup filetype_python
autocmd!
autocmd FileType python let g:python_recommended_style = 0
augroup END
" }}}