summaryrefslogtreecommitdiffstats
path: root/.vimrc
blob: 3bda7f428b38564e0dd712adc817ac464c3a1b8e (plain) (blame)
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
call plug#begin('~/.vim/plugged')

Plug 'jremmen/vim-ripgrep'
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'stefandtw/quickfix-reflector.vim'
Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' }
Plug 'buoto/gotests-vim'
Plug 'rust-lang/rust.vim'
Plug 'w0rp/ale'
Plug 'morhetz/gruvbox'

if has('python3') 
    if has('nvim') 
      Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
      Plug 'autozimu/LanguageClient-neovim', {
        \ 'branch': 'next',
        \ 'do': 'bash install.sh',
        \ }
      let $NVIM_TUI_ENABLE_TRUE_COLOR=1
    else
      Plug 'Shougo/deoplete.nvim'
      Plug 'roxma/nvim-yarp'
      Plug 'roxma/vim-hug-neovim-rpc'
    endif
    let g:deoplete#enable_at_startup = 1
endif

call plug#end()

set autoread
set backspace=indent,eol,start
set colorcolumn=250
set expandtab
set exrc
set encoding=utf-8
set hidden
set history=1000
set incsearch
set laststatus=2
set lazyredraw
set linebreak
set nobackup
set nocompatible
set noswapfile
set nowb
set number
set pastetoggle=<F2>
set scrolloff=20
set secure
set shiftwidth=4
set shiftround
set shortmess+=I
set showcmd
set showmode
"new splits will be at the bottom or to the right side of the screen
set splitbelow
set splitright
set tabstop=4
set ttyfast
"time waited for key press(es) to complete. It makes for a faster key response
set ttimeout
set ttimeoutlen=50
set wildmenu
set wildmode=list:longest,full
set visualbell

"Code folding
set foldmethod=syntax
set foldlevel=1
set foldnestmax=1

filetype plugin on
syntax on

" Light Theme
set background=light
colorscheme peachpuff

""" Statusline bits
set statusline=
set statusline+=%7*\[%n]                                  "buffernr
set statusline+=%1*\ %<%t\                                "File+path
set statusline+=%3*\ %y\                                  "FileType
set statusline+=%4*\ %{''.(&fenc!=''?&fenc:&enc).''}      "Encoding
set statusline+=%5*\ %{(&bomb?\",BOM\":\"\")}\            "Encoding2
set statusline+=%6*\ %{&ff}\                              "FileFormat (dos/unix..)
set statusline+=%7*\ %=\ row:%l/%L\ (%03p%%)\             "Rownumber/total (%)
set statusline+=%9*\ col:%03c\                            "Colnr
set statusline+=%0*\ %m%r%w\                             "Modified? Readonly? Top/bot.
"""
" Required for operations modifying multiple buffers like rename.
set hidden

" Rust
let g:rustfmt_autosave = 1
let g:LanguageClient_serverCommands = {
    \ 'rust': ['~/.cargo/bin/rustup', 'run', 'stable', 'rls'],
    \ }
let g:ale_linters = {'rust': ['analyzer']}


""" BEGIN GOLANG

let g:go_def_mode='gopls'
let g:go_info_mode='gopls'
let g:go_gopls_gofumpt=1
let g:go_metalinter_command = 'golangci-lint'

let g:go_fmt_command="gopls"
"let g:go_fmt_command = "goimports" " Goimports is slow with modules, when module not found

" By default syntax-highlighting for Functions, Methods and Structs is disabled
let g:go_highlight_build_constraints = 1
let g:go_highlight_fields = 1
let g:go_highlight_functions = 1
let g:go_highlight_interfaces = 1
let g:go_highlight_methods = 1
let g:go_highlight_operators = 1
let g:go_highlight_structs = 1

" Auto-space Go files
autocmd BufNewFile,BufRead *.go setlocal noexpandtab tabstop=4 shiftwidth=4

" vim-go mappings
au FileType go nmap <leader>b <Plug>(go-build)
au FileType go nmap <leader>c <Plug>(go-coverage)
au FileType go nmap <leader>r <Plug>(go-run)
au FileType go nmap <leader>t <Plug>(go-test)
au FileType go nmap <leader>d <Plug>(go-def)

" Go implements (interfaces under cursor)
au FileType go nmap <Leader>s <Plug>(go-implements)
" Go show type info under cursor
au FileType go nmap <Leader>i <Plug>(go-info)
" Go rename
au FileType go nmap <Leader>e <Plug>(go-rename)
" Go vet
au FileType go nmap <Leader>v <Plug>(go-vet)
" Godoc under cursor
au FileType go nmap <Leader>k <Plug>(go-doc)

""" END GOLANG

""""" Bugfixes and oddities below
" Fix weird JSON quotation issue
let g:vim_json_syntax_conceal = 0

" Only do this part when compiled with support for autocommands
if has("autocmd")
	" Enable file type detection
	filetype on

	" Wrap text in markdown
	au BufRead,BufNewFile *.md setlocal textwidth=80

	" Syntax of these languages is fussy over tabs Vs spaces
	autocmd FileType make setlocal ts=8 sts=8 sw=8 noexpandtab
	autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab

	" Customisations based on house-style (arbitrary)
	autocmd FileType html setlocal ts=2 sts=2 sw=2 expandtab
	autocmd FileType css setlocal ts=2 sts=2 sw=2 expandtab
	autocmd FileType javascript setlocal ts=4 sts=4 sw=4 noexpandtab

	" Treat .rss files as XML
	autocmd BufNewFile,BufRead *.rss setfiletype xml
endif


" Disable mouse automatic mode
set mouse-=a

" Enable line numbers toggle
noremap <leader>n :set invnumber<CR>
"inoremap <leader>n <C-O>:set invnumber<CR>

" Enable Ripgrep formatting for vim
let g:rg_command = 'rg --vimgrep -S'

""" ToggleBackground
function! Switch_background()
    if &background == "light"
        set background=dark
    else
        set background=light
    endif
endfunction
noremap <leader>l :call Switch_background()<CR>