1"DOTFILES
2syntax on
3" set leader key to spacebar
4nnoremap <SPACE> <Nop>
5let mapleader=" "
6if (has('win 64') || has('win32'))
7 " Windows specific
8 set guifont=MesloLGS\ NF:h10
9 if !has('nvim')
10 " Vim with all enhancements
11 source $VIMRUNTIME/vimrc_example.vim
12 " set shell to powershell in vim, breaks in neovim
13 " set shell=\"C:\Program\ Files\PowerShell\7\pwsh.exe\"
14 endif
15elseif has('linux')
16 if empty(glob('~/.vim/autoload/plug.vim'))
17 silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
18 \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
19 autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
20 endif
21endif
22
23if has('gui_running')
24 autocmd GUIEnter * set vb t_vb=
25endif
26
27call plug#begin('~/.vim/plugged')
28 Plug 'tpope/vim-sensible'
29 Plug 'vim-airline/vim-airline'
30 Plug 'vim-airline/vim-airline-themes'
31 Plug 'kaicataldo/material.vim', { 'branch': 'main' }
32 Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
33 Plug 'junegunn/fzf.vim'
34 Plug 'joshdick/onedark.vim'
35 Plug 'tpope/vim-commentary'
36 Plug 'kana/vim-textobj-user' " requirement for vim-textobj-comment
37 Plug 'glts/vim-textobj-comment'
38 Plug 'cespare/vim-toml'
39 Plug 'tpope/vim-fugitive'
40 Plug 'neoclide/coc.nvim', {'branch': 'release'}
41call plug#end()
42
43set nu rnu
44" save swap and ~ files in dedicated `vimtmp` directory
45" requires the existence of `vimtmp` directory in the home directory
46set backupdir=~/vimtmp,.
47set directory=~/vimtmp,.
48set noundofile
49set guioptions-=m "menu bar
50set guioptions-=T "toolbar
51set guioptions-=L "left scrollbar
52set guioptions-=r "scrollbar
53let g:airline_theme='minimalist'
54colorscheme onedark
55set t_ut=
56set encoding=utf-8
57set splitbelow
58set splitright
59
60" sensible window movement controls
61nnoremap <C-J> <C-W><C-J>
62nnoremap <C-K> <C-W><C-K>
63nnoremap <C-L> <C-W><C-L>
64nnoremap <C-H> <C-W><C-H>
65
66nnoremap <Leader>H :vertical res -5 <CR>
67nnoremap <Leader>J :res -5 <CR>
68nnoremap <Leader>K :res +5 <CR>
69nnoremap <Leader>L :vertical res +5 <CR>
70
71" sensible remaps
72" make Y behave like other captial letters
73nnoremap Y y$
74
75" keep cursor centered
76nnoremap n nzzzv
77nnoremap N Nzzzv
78nnoremap J mzJ`z
79nnoremap <C-u> <C-u>zzzv
80nnoremap <C-d> <C-d>zzzv
81
82" undo break poins
83" inoremap , ,<c-g>u
84" inoremap . .<c-g>u
85" inoremap ! !<c-g>u
86" inoremap ? ?<c-g>u
87" inoremap { {<c-g>u
88" inoremap ( (<c-g>u
89
90" moving text
91nnoremap <leader>j :m .+1<CR>==
92nnoremap <leader>k :m .-2<CR>==
93inoremap <C-j> <esc>:m .+1<CR>==
94inoremap <C-k> <esc>:m .-2<CR>==
95vnoremap J :m '>+1<CR>gv=gv
96vnoremap K :m '<-2<CR>gv=gv
97
98vnoremap > >gv
99vnoremap < <gv
100
101" Redo
102nnoremap U <C-r>
103
104" fzf
105nnoremap <C-p> :Files <CR>
106
107set shiftwidth=2
108set tabstop=4 softtabstop=0 expandtab shiftwidth=2 smarttab
109set clipboard=unnamed
110" set vim to chdir for each file
111if exists('+autochdir')
112 set autochdir
113else
114 autocmd BufEnter * silent! lcd %:p:h:gs/ /\\ /
115endif
116
117" vim-commentary ocaml comment string
118" autocmd FileType ocaml setlocal commentstring=(*\ %s\ *)
119
120if has('linux')
121 " ## added by OPAM user-setup for vim / base ## 93ee63e278bdfc07d1139a748ed3fff2 ## you can edit, but keep this line
122 let s:opam_share_dir = system("opam config var share")
123 let s:opam_share_dir = substitute(s:opam_share_dir, '[\r\n]*$', '', '')
124
125 let s:opam_configuration = {}
126
127 function! OpamConfOcpIndent()
128 execute "set rtp^=" . s:opam_share_dir . "/ocp-indent/vim"
129 endfunction
130 let s:opam_configuration['ocp-indent'] = function('OpamConfOcpIndent')
131
132 function! OpamConfOcpIndex()
133 execute "set rtp+=" . s:opam_share_dir . "/ocp-index/vim"
134 endfunction
135 let s:opam_configuration['ocp-index'] = function('OpamConfOcpIndex')
136
137 function! OpamConfMerlin()
138 let l:dir = s:opam_share_dir . "/merlin/vim"
139 execute "set rtp+=" . l:dir
140 endfunction
141 let s:opam_configuration['merlin'] = function('OpamConfMerlin')
142
143 let s:opam_packages = ["ocp-indent", "ocp-index", "merlin"]
144 let s:opam_check_cmdline = ["opam list --installed --short --safe --color=never"] + s:opam_packages
145 let s:opam_available_tools = split(system(join(s:opam_check_cmdline)))
146 for tool in s:opam_packages
147 " Respect package order (merlin should be after ocp-index)
148 if count(s:opam_available_tools, tool) > 0
149 call s:opam_configuration[tool]()
150 endif
151 endfor
152 " ## end of OPAM user-setup addition for vim / base ## keep this line
153endif