summaryrefslogtreecommitdiff
path: root/vim/vimrc
blob: a39ae9eb23ed627fd829d51bd14eecdc0de680f4 (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
" ============== KEY MAPPINGS

let mapleader=","

" Tab modes.
map <leader>m <Esc>:set expandtab ts=2 sw=2 sts=2<CR>
map <leader>t <Esc>:set noexpandtab ts=4 sw=4 sts=4<CR>
map <leader>T <Esc>:set expandtab ts=4 sw=4 sts=4<CR>

" Folds:
" map <leader>f <Esc>:set fen fdn=3 fdm=indent fml=1 fdc=3<CR>

" ; -> FZF (see :help fzf-vim-commands)
map ; <ESC>:GFiles<CR>

" H-L for next-prev buffer
nnoremap <leader>l :bnext<CR>
nnoremap <leader>k :bprev<CR>

" S-D for prev/next Coc error diagnostic
" X-C for prev/next Coc diagnostic
nnoremap <leader>d <Plug>(coc-diagnostic-next-error)
nnoremap <leader>s <Plug>(coc-diagnostic-prev-error)
nnoremap <leader>x <Plug>(coc-diagnostic-next)
nnoremap <leader>c <Plug>(coc-diagnostic-prev)

" F for Coc show documentation
nnoremap <leader>f :call ShowDocumentation()<CR>
function! ShowDocumentation()
  if CocAction('hasProvider', 'hover')
    call CocActionAsync('doHover')
  else
    call feedkeys('K', 'in')
  endif
endfunction

" Symbol renaming
nmap <leader>rn <Plug>(coc-rename)

" Append modeline after last line in buffer.
" Use substitute() instead of printf() to handle '%%s' modeline in LaTeX
" files.
function! AppendModeline()
  let l:modeline = printf(" vim: set sts=%d ts=%d sw=%d tw=%d %set :",
        \ &softtabstop, &tabstop, &shiftwidth, &textwidth, &expandtab ? '' : 'no')
  let l:modeline = substitute(&commentstring, "%s", l:modeline, "")
  call append(line("$"), l:modeline)
endfunction
nnoremap <silent> <Leader>ml :call AppendModeline()<CR>


" =================== OPTIONS

" colorscheme slate

filetype plugin indent on
set autoindent
set ts=4 sw=4

" Controls
set mouse=a
set nostartofline
set wildmode=list:longest

" Display
highlight SpellBad ctermfg=red ctermbg=none
set bg=dark
set hlsearch
set incsearch
syntax on
set lazyredraw
set number
set relativenumber
set showcmd
set shortmess=a
set display+=lastline

" indentation for long line wraps
set wrap
set linebreak
set breakindent
let &showbreak = '>   '

" set cursorline
" hi CursorLine cterm=bold ctermbg=0
" hi Folded ctermfg=2 ctermbg=0
" hi FoldColumn ctermfg=2 ctermbg=0

let g:sclangTerm = "urxvt -e"

let NERDTreeIgnore=['\.o$', '\.cmo$', '\.cmx$', '\.cmi$', '\.lib$', '\.pyc$', '^__pycache__$']

" set completeopt=menuone,menu,longest,preview

set directory=~/.vim/swp,/tmp

" =========== FILE TYPE SPECIFIC

au BufRead,BufNewFile *.make set filetype=make
au BufRead,BufNewFile *.md set filetype=markdown
au BufRead,BufNewFile *.lus set filetype=lustre
au BufRead,BufNewFile *.scade set filetype=scade

au FileType make setl noexpandtab
au FileType python setl sw=4 sts=4 et
au FileType html setl sw=2 sts=2 et
au FileType htmldjango setl sw=2 sts=2 et
au FileType json setl sw=2 sts=2 et
au FileType javascript setl sw=2 sts=2 et
au FileType yaml setl sw=2 sts=2 et
au FileType css setl sw=4 sts=4 et
au FileType lua setl ts=4 sw=4 noet
au FileType elixir setl sw=2 sts=2 et
au FileType nix setl sw=2 sts=2 et

autocmd FileType tex setlocal spell spelllang=en

" Packs

" packloadall
" silent! helptags ALL