summaryrefslogtreecommitdiff
path: root/vim/.vimrc
blob: 1c9e5e24bd09f498a546cf302abffdd94f896cf6 (plain)
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
set nocompatible              " be iMproved, required
filetype plugin on
set shellslash

" Plugins
    " set the runtime path to include Vundle and initialize
    set rtp+=~/.vim/bundle/Vundle.vim
    call vundle#begin()
    " alternatively, pass a path where Vundle should install plugins
    "call vundle#begin('~/some/path/here')

    " let Vundle manage Vundle, required
    Plugin 'VundleVim/Vundle.vim'

    " Completion
    Plugin 'prabirshrestha/async.vim'
    Plugin 'prabirshrestha/vim-lsp'
    Plugin 'fatih/vim-go'
    Plugin 'ajh17/VimCompletesMe'
    Plugin 'Shougo/echodoc.vim'

    Plugin 'tpope/vim-surround'
    Plugin 'tpope/vim-repeat'
    Plugin 'tpope/vim-unimpaired'
    Plugin 'tpope/vim-commentary'

    Plugin 'godlygeek/tabular'

    " Editor config
    " Plugin 'editorconfig/editorconfig-vim'

    " Color theme
    " Plugin 'agude/vim-eldar'
    " Plugin 'ntk148v/vim-horizon'
    " Plugin 'rakr/vim-colors-rakr'
    " Plugin 'rakr/vim-one'
    Plugin 'morhetz/gruvbox'
    " Plugin 'ntk148v/vim-horizon'

    " Git
    Plugin 'tpope/vim-fugitive'
    
    " File support
    " Plugin 'cespare/vim-toml'
    Plugin 'lervag/vimtex'
    
    " Plugin 'vimwiki/vimwiki'
    

    " Snippets are separated from the engine. Add this if you want them:
    " Plugin 'honza/vim-snippets'

    call vundle#end()            " required
    filetype plugin indent on    " required

" Completion
    set completeopt=menuone
    " let g:go_def_mode='gopls'
    " let g:go_info_mode='gopls'

    if has('nvim')
        let g:echodoc#enable_at_startup = 1
        let g:echodoc#type = 'virtual'
    endif

    autocmd FileType c let b:vcm_tab_complete = 'omni'
    autocmd FileType py let b:vcm_tab_complete = 'omni'
    autocmd FileType go let b:vcm_tab_complete = 'omni'
    autocmd FileType vim let b:vcm_tab_complete = 'vim'

    " Lsp options
    let g:lsp_diagnostics_echo_cursor = 0
    let g:lsp_signature_help_enabled = 0
    let g:lsp_insert_text_enabled = 0

    " Setup lsp servers
    if executable('pyls')
        au User lsp_setup call lsp#register_server({
        			\ 'name': 'python',
        			\ 'cmd': {server_info->['pyls']},
        			\ 'whitelist': ['python'],
        			\ })
    endif
    if executable('clangd')
        au User lsp_setup call lsp#register_server({
        			\ 'name': 'clangd',
        			\ 'cmd': {server_info->['clangd']},
        			\ 'whitelist': ['c', 'cpp'],
        			\ })
    endif
    if executable('gopls')
        au User lsp_setup call lsp#register_server({
        			\ 'name': 'golang',
        			\ 'cmd': {server_info->['gopls']},
        			\ 'whitelist': ['go'],
        			\ })
    endif

    " Enable csp if available, stolen from lsp github
    function! s:on_lsp_buffer_enabled() abort
        echo "Enabling lsp"
        set omnifunc=lsp#complete
        set signcolumn=yes
        nmap <buffer> gd <plug>(lsp-definition)
        nmap <buffer> <f2> <plug>(lsp-rename)
        " refer to doc to add more commands
    endfunction

    augroup lsp_install
        au!
        " call s:on_lsp_buffer_enabled only for languages that has the server registered.
        autocmd User lsp_buffer_enabled call s:on_lsp_buffer_enabled()
    augroup END

" General vim settings
    syntax enable
    set number 
    set relativenumber

    " More sensible splitting
    set splitbelow splitright

    set tabstop=4
    set softtabstop=4
    set shiftwidth=4
    set expandtab
    set colorcolumn=79

    " Show 5 lines above and below cursor
    set scrolloff=5
    set list

    " Remove statusline
    set laststatus=1

    if has('nvim')
        set inccommand=split
    endif

    set hidden

    " Case insensitive search if all letters are small
    set smartcase
    set ignorecase

    " Persistent undo
    set undofile

    set autoread

    " Exit insert mode on inactivity
    " au CursorHoldI * stopinsert

" Vimwiki stuff
    let g:vimwiki_list = [{'path': '~/Documents/vimwiki', 'path_html': '~/Documents/vimwiki/export'}]

" Latex stuff
    let g:tex_flavor='latex'

    let g:vimtex_quickfix_blgparser = {'disable': 1}
    let g:vimtex_quickfix_open_on_warning = 0
    let g:vimtex_compiler_latexmk = {
        \ 'backend' : 'nvim',
        \ 'background' : 0,
        \ 'build_dir' : '',
        \ 'callback' : 1,
        \ 'continuous' : 0,
        \ 'executable' : 'latexmk',
        \ 'hooks' : [],
        \ 'options' : [
        \   '-file-line-error',
        \   '-synctex=1',
        \ ],
        \}

" File management
    " Fuzzy like menu
    set path+=**
    set wildmenu

    let g:netrw_liststyle=2
    let g:netrw_banner = 0

" Keymapping
    " When moving more lines make it a jump. If couns i 2 it will run m'2j,
    " thus storing it on the jumplist and then jumping
    nnoremap <expr> j (v:count > 1 ? "m'" . v:count : '' ) . 'j'
    nnoremap <expr> k (v:count > 1 ? "m'" . v:count : '' ) . 'k'

    " Leader stuff
        let mapleader=" "

        map <leader>mm :make V=1<CR>
        map <leader>mf :make flash V=1<CR>

" Enforcing filetypes
    autocmd BufRead,BufNewFile *.ino set filetype=c
    autocmd BufRead,BufNewFile *.asc set filetype=asciidoc

" Highlightning And colors
    set termguicolors
    " let g:one_allow_italics = 1
    let g:gruvbox_italic = 1
    colorscheme gruvbox


" Spell check
    set spelllang=en
    autocmd FileType tex,markdown,rst set spell