summaryrefslogtreecommitdiff
path: root/lib/vimrc
blob: 4b8b35954aa99e1251494bf04ac501e86f8caae8 (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
""" General settings
set autoindent
set backspace=indent,eol,start
set complete-=i      " Set the matches for insert mode completion
set encoding=utf-8   " Set encoding
set expandtab        " Use spaces instead of tabs
set formatoptions+=j " Delete comment character when joining commented lines
set hlsearch         " Highlight all search results
set laststatus=2     " Always status line
set ignorecase       " Ignore cases when searching
set incsearch        " Incremental search
set linebreak        " Break lines at word (requires Wrap lines)
set nowrap           " Don't add an actual linebreak when wrapping
set ruler            " Show line & col number of cursor position
set shiftwidth=4     " Number of auto-indent spaces
set showmatch        " Highlight matching brace
set smartcase        " Better searching btw cases
set smartindent      " Autoindent when starting a new line
set smarttab         " Tab insertion & deletion
set tabstop=4        " One tab = 4 spaces
set textwidth=80     " Line wrap (number of cols)
set visualbell       " Use visual bell (no beeping)
set wildmenu         " Helpful completion menu

" Strings to use in 'list' mode and for the :list command
set listchars=tab:>\ ,trail:-,extends:>,precedes:<,nbsp:+

""" Enable syntax
"if has('syntax') && !exists('g:syntax_on')
"    syntax enable
"endif

""" Make , the leader key
let mapleader = ","

" easy escape
imap fd <Esc>

" send to ix.io
noremap <silent> <leader>i :w !ix<CR>

" edit files and buffers, relative to local
nmap ,e  :edit
nmap ;e  :edit <C-R>=expand("%:h") . "/" <CR>
nmap ,o  :buffer
nmap ;o  :buffer <C-R>=expand("%:h") . "/" <CR>

" list buffers
nmap ,l  :ls<cr>

" kill buffer
nmap ,k  :bdelete<cr>

" insert current date
nmap <silent> ,d  :r !date +\%Y.\%m.\%d<cr>
nmap <silent> ,D  :r !date +\%Y.\%m.\%d..\%H.\%M.\%S<cr>

" grep (ripgrep)
nmap ,g  :Rg

" format haskell code
nmap ,f  :!ormolu -m inplace %<cr>

" clear out trailing whitespace and lines ending in whitespace
nmap <silent> ,w   :%s/[\t ]\+$//e<cr>

" Use <C-L> to clear the highlighting of :set hlsearch.
if maparg('<C-L>', 'n') ==# ''
    nnoremap <silent> <C-L> :nohlsearch<C-R>=has('diff')?'<Bar>diffupdate':''<CR><CR><C-L>
endif

" trailing spaces are always bad
syntax match Warning   display "\s\+$"
" mixed tabs and spaces
syntax match Warning   display " \+\t"
syntax match Warning   display "\t\+ "

""" Easily find cursor with crosshair (,c)
":hi CursorLine   cterm=NONE term=reverse ctermbg=7 guibg=Grey90
":hi CursorColumn cterm=NONE term=reverse ctermbg=7 guibg=Grey90
:nnoremap <Leader>c :set cursorline! cursorcolumn!<CR>

""" File browser
let g:netrw_banner=0       " Disable file browser banner
let g:netrw_liststyle=3    " Tree view

""" CTAGS shortcuts
" open definition in a new tab:
map <C-\> :tab split<CR>:exec("tag ".expand("<cword>"))<CR>
" open definition in a vertical split:
map <A-]> :vsp <CR>:exec("tag ".expand("<cword>"))<CR>

""" Colors!
set termguicolors
let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"

""" Show highlighting groups for current word
nmap <C-S-P> :call <SID>SynStack()<CR>
function! <SID>SynStack()
    if !exists("*synstack")
        return
    endif
    echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")')
endfunc

" A function for setting colors, if I want it...
function! s:hi(...)
    let group = a:1
    let fg    = get(a:, 2, s:default_fg)
    let bg    = get(a:, 3, s:default_bg)
    let attr  = get(a:, 4, s:default_str)

    let cmd = ['hi', group]

    if fg != s:default_lst
        call add(cmd, 'guifg='.fg[0])
        call add(cmd, 'ctermfg='.fg[1])
    endif

    if bg != s:default_lst && bg != s:default_bg
        call add(cmd, 'guibg='.bg[0])
        call add(cmd, 'ctermbg='.bg[1])
    endif

    if attr != s:default_str
        call add(cmd, 'gui='.attr)
        call add(cmd, 'cterm='.attr)
    endif

    exec join(cmd, ' ')
endfunction

call plug#begin('~/.vim/plugged')
Plug 'wfxr/minimap.vim'
call plug#end()

let g:minimap_auto_start=1