aboutsummaryrefslogtreecommitdiff
path: root/vimrc
blob: c6a7f9f65e30554efeb5aef91e7d3322dde2ac57 (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
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
" for long lines
set wrap

" tab business
set tabstop=8
set softtabstop=4
set shiftwidth=4
set expandtab

set autoindent

" syntax highlighting
syntax on

set nohlsearch

" try to detect filetypes
filetype on

" enable loading indent file for filetype
filetype plugin indent on

" line numbers
set number

" cursor line
set cursorline

" enable mouse
set mouse=a

" set term title
set title
set titleold=

" plugin dependent conf starts

call plug#begin('~/.vim/plugged')

" git
Plug 'tpope/vim-fugitive', { 'tag': 'v3.6' }
Plug 'airblade/vim-gitgutter'

" tmux
Plug 'tmux-plugins/vim-tmux-focus-events'
Plug 'roxma/vim-tmux-clipboard'
Plug 'wincent/terminus'

" life improvements
Plug 'gruvbox-community/gruvbox'
Plug 'scrooloose/nerdtree'
Plug 'Chiel92/vim-autoformat'
Plug 'jsfaint/gen_tags.vim'
Plug 'rbong/vim-crystalline'
Plug 'godlygeek/tabular'
Plug 'vimwiki/vimwiki'

" language support
Plug 'plasticboy/vim-markdown'
Plug 'samsaga2/vim-z80'
Plug 'tomtom/tcomment_vim'
Plug 'https://tildegit.org/sloum/gemini-vim-syntax.git'
Plug 'neovimhaskell/haskell-vim'

if has('nvim-0.5')
    " general lua
    Plug 'nvim-lua/popup.nvim'
    Plug 'nvim-lua/plenary.nvim'
    " scala
    Plug 'scalameta/nvim-metals'
    if has('nvim-0.5.1')
        Plug 'nvim-telescope/telescope.nvim'
    end
    " auto complete
    Plug 'hrsh7th/nvim-cmp'
    Plug 'hrsh7th/cmp-nvim-lsp'
    Plug 'hrsh7th/cmp-vsnip'
    Plug 'hrsh7th/vim-vsnip'

    " life improvements
    Plug 'ojroques/nvim-bufdel'
end

if has('nvim-0.6.1')
    " lsp
    Plug 'neovim/nvim-lspconfig'
    Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
end

call plug#end()

if has('nvim-0.5')

" BufKil
:lua << EOF
      require('bufdel').setup {
        next = 'cycle',
        quit = false,
      }
EOF

end

" crystaline conf
"

" metals status
function! MetalsStatus() abort
    return get(g:, 'metals_status', '')
endfunction

" git-gutter status
"
function! GitStatus()
    let [a,m,r] = GitGutterGetHunkSummary()
    return printf('+%d ~%d -%d', a, m, r)
endfunction


function! StatusLine(current, width)
    let l:s = ''

    if a:current
        let l:s .= crystalline#mode() . crystalline#right_mode_sep('')
    else
        let l:s .= '%#CrystallineInactive#'
    endif
    let l:s .= ' %<%f%h%w%m%r '

    if a:current
        let l:s .= crystalline#right_sep('', 'Fill') . ' %{fugitive#statusline()}' .' %{GitStatus()}'
    endif

    let l:s .= '%='
    if a:current
        let l:s .= ' %{MetalsStatus()} '
        let l:s .= crystalline#left_sep('', 'Fill') . ' %{&paste ?"PASTE ":""}%{&spell?"SPELL ":""}'
        let l:s .= crystalline#left_mode_sep('')
    endif
    if a:width > 80
        let l:s .= ' %{&ft} [%{&fenc!=#""?&fenc:&enc}][%{&ff}] %3(%c%V%) %l/%L %P '
    else
        let l:s .= ' '
    endif

    return l:s
endfunction

let g:crystalline_enable_sep = 1
let g:crystalline_statusline_fn = 'StatusLine'
let g:crystalline_theme = 'gruvbox'

set laststatus=2

" vim-autoformat (C-F5)
"
noremap <F29> :Autoformat<CR>
au BufWrite *.py,*.c,*.h,*.cpp,*.hs :Autoformat

" enable omnicompletion
set omnifunc=syntaxcomplete#Complete

" looks nice
set termguicolors
set background=dark
let g:gruvbox_italic = 1
let g:gruvbox_contrast_dark = "soft"
let g:gruvbox_guisp_fallback = "fg"

colorscheme gruvbox

" toggle spell check
map <leader>s :set spell! spelllang=en_gb<CR>

" show tabs and EOL whitespace
:set list listchars=tab:»·,trail:·

" for tmux, screen, etc
set t_ut=

" default is too slow
set updatetime=500

" re-read the file if changed (if possible)
set autoread
au BufEnter,CursorHold,CursorHoldI * silent! checktime

" NERDTree
"
map <leader>n :NERDTreeToggle<CR>
let NERDTreeQuitOnOpen=1

" Telescope
"
nnoremap <leader>f <cmd>Telescope find_files<CR>
nnoremap <leader>B <cmd>Telescope buffers<CR>

"" gen_tags.vim (requires GNU global, aka gtags)
" disable ctags completely, use it through gtags plugin
let g:loaded_gentags#ctags = 1

" vimwiki
"
let g:vimwiki_list = [{'path': '~/textfiles/',
                      \ 'syntax': 'markdown', 'ext': '.md'}]
let g:vimwiki_global_ext = 0

" vim-markdown
"
let g:vim_markdown_folding_disabled = 1
let g:vim_markdown_frontmatter = 1
let g:vim_markdown_conceal_code_blocks = 0
autocmd FileType markdown setlocal conceallevel=2

" haskell syntax
"
let g:haskell_classic_highlighting = 1

" git gutter to play nice with others
"
let g:gitgutter_sign_allow_clobber = 0

" Required for operations modifying multiple buffers like rename.
set hidden

" better for some messages
set cmdheight=2
set shortmess+=c
" for lsc erros
set shortmess-=F

" disable preview when doing auto-complete
set completeopt-=preview

" dependent on gruvbox theme
highlight link lscDiagnosticError GruvboxRedSign
highlight link lscDiagnosticWarning GruvboxYellowSign

" Set completeopt to have a better completion experience
set completeopt=menuone,noinsert,noselect