summaryrefslogtreecommitdiff
path: root/vimrc
blob: 64ee7e2b05a2989e97ea7504853735686c63ebd0 (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
packadd snippets

" General
set ignorecase

" Indentation
set tabstop=8
set shiftround
set nobackup 
set autoindent
set smartindent
set cindent
set nu

" Search
set incsearch
set matchpairs+=<:>

" Theme
syntax on
set background=light
set termguicolors
colorscheme quiet
hi Normal guifg=black  guibg=#FFFFEA
""hi Keyword ctermfg=black cterm=bold
hi SpellBad term=reverse term=underline guibg=#FFFFEA  
hi SpellCap term=reverse term=underline guibg=#FFFFEA  
hi SpellRare term=reverse term=underline guibg=#FFFFEA  
hi SpellLocal term=reverse term=underline guibg=#FFFFEA  

"" Cursor - switch between line and full when going to insert mode
let &t_SI = "\<Esc>[6 q"
let &t_SR = "\<Esc>[4 q"
let &t_EI = "\<Esc>[2 q"

" Pesky swap
set backupdir=~/.vim/backup//
set directory=~/.vim/swap//
set undodir=~/.vim/undo//

" Netrw
let g:netrw_keepdir = 0
let g:netrw_banner = 0
let g:netrw_localcopydircmd = 'cp -r'
hi! link netrwMarkFile Search
nnoremap - :Explore<CR>

" LSP
packadd lsp

if exists('g:loaded_lsp')
	call LspOptionsSet(#{
		\   aleSupport: v:false,
		\   autoComplete: v:true,
		\   autoHighlight: v:false,
		\   autoHighlightDiags: v:true,
		\   autoPopulateDiags: v:true,
		\   completionMatcher: 'case',
		\   completionMatcherValue: 1,
		\   diagSignErrorText: 'E',
		\   diagSignHintText: 'H',
		\   diagSignInfoText: 'I',
		\   diagSignWarningText: 'W',
		\   echoSignature: v:false,
		\   hideDisabledCodeActions: v:false,
		\   highlightDiagInline: v:true,
		\   hoverInPreview: v:false,
		\   ignoreMissingServer: v:true,
		\   keepFocusInDiags: v:true,
		\   keepFocusInReferences: v:true,
		\   completionTextEdit: v:true,
		\   diagVirtualTextAlign: 'above',
		\   diagVirtualTextWrap: 'default',
		\   noNewlineInCompletion: v:false,
		\   omniComplete: v:null,
		\   outlineOnRight: v:true,
		\   outlineWinSize: 20,
		\   semanticHighlight: v:false,
		\   showDiagInBalloon: v:true,
		\   showDiagInPopup: v:true,
		\   showDiagOnStatusLine: v:false,
		\   showDiagWithSign: v:false,
		\   showDiagWithVirtualText: v:false,
		\   showInlayHints: v:false,
		\   showSignature: v:true,
		\   snippetSupport: v:false,
		\   ultisnipsSupport: v:false,
		\   useBufferCompletion: v:false,
		\   usePopupInCodeAction: v:false,
		\   useQuickfixForLocations: v:false,
		\   vsnipSupport: v:false,
		\   bufferCompletionTimeout: 100,
		\   customCompletionKinds: v:false,
		\   completionKinds: {},
		\   filterCompletionDuplicates: v:false,
		\ })
end

" Ocaml 
if exists('g:loaded_lsp')
	call LspAddServer([#{
		\    name: 'caml',
		\    filetype: ['ocaml'],
		\    path: 'ocamllsp',
		\    args: [],
		\    syncInit: v:true
		\  }])
end
"autocmd Filetype ocaml autocmd BufWritePre <buffer> :LspFormat
autocmd Filetype ocaml setlocal tabstop=2
autocmd Filetype ocaml setlocal shiftwidth=2

" Go
if exists('g:loaded_lsp')
	call LspAddServer([#{
		\    name: 'golang',
		\    filetype: ['go', 'gomod', 'gowork', 'gohtml'],
		\    path: '/usr/bin/gopls',
		\    args: ['serve'],
		\    syncInit: v:true
		\  }])
end

filetype plugin on
autocmd Filetype go set makeprg=go\ build
"autocmd Filetype go autocmd BufWritePre <buffer> :LspFormat
" Auto test directory with <leader>t
autocmd Filetype go nnoremap <buffer> <leader>t :!go test %:h/*.go<Enter>

au BufRead,BufNewFile *.tmpl 	set filetype=gohtml
autocmd Filetype gohtml setlocal tabstop=2


" Nix
if exists('g:loaded_lsp')
	call LspAddServer([#{
		\    name: 'nix',
		\    filetype: ['nix'],
		\    path: 'nixd',
		\    args: [],
		\    syncInit: v:true
		\  }])
end
autocmd Filetype nix autocmd BufWritePre <buffer> :LspFormat

" Markdown
if exists('g:loaded_lsp')
  call LspAddServer([#{ 
	\     name: 'marksman', 
	\     filetype: ['markdown'], 
	\     path: 'marksman', 
	\     args: ['server'], 
	\     syncInit: v:true }])
end


autocmd Filetype markdown setlocal spell



" Keybindings
let mapleader=" "
noremap , :
noremap <leader>e :e! **/*
noremap <silent> gd mB:LspGotoDefinition<Enter>
noremap <silent> ]d :LspDiagNext<Enter>
noremap <silent> [d :LspDiagPrev<Enter>
noremap <silent> ]c :cnext<Enter>
noremap <silent> [c :cprev<Enter>
noremap <silent> gs mB:LspDocumentSymbol<Enter>
noremap <silent> gr mB:LspGotoImpl<Enter>
noremap <leader>ca :LspCodeAction<Enter>
noremap <leader>cr :LspRename<Enter>
noremap <leader>m :make<Enter>
noremap <silent> <leader>k :LspDiagCurrent<Enter>
noremap <silent> K :LspHover<Enter>
nnoremap <leader>l :ls<CR>:b<space>
nnoremap <silent> <leader>= :LspFormat<Enter>
"" Tab completion
inoremap <expr> <TAB> pumvisible() ? "\<C-n>" : "\<TAB>"
inoremap <expr> <S-TAB> pumvisible() ? "\<C-p>" : "\<TAB>"


" Spell
au BufEnter *.org set spell

" Wildmenu
set wildmenu
set wildignore=_build/**,release/**,node_modules/**
set wildoptions=fuzzy

" Grep
set grepprg=git\ grep\ -nH 


" Auto add marks
augroup VIMRC
	autocmd!
	autocmd BufLeave *.css,*.scss 		normal! mC
	autocmd BufLeave *.html       		normal! mH
	autocmd BufLeave *.js,*.ts    		normal! mJ
	autocmd BufLeave *.md         		normal! mM
	autocmd BufLeave *.yml,*.yaml 		normal! mY
	autocmd BufLeave *_test.go		normal! mT
	autocmd BufLeave *{_test}\@<!.go	normal! mA
augroup END