aboutsummaryrefslogtreecommitdiffstats
path: root/.vimrc
blob: 77d64b8e1136ca41150c30109393896078213439 (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
syntax on
filetype plugin indent on
"set omnifunc=syntaxcomplete#Complete
set autoindent

"colours!
colorscheme anotherdark
set background=dark

"enable status-line
set laststatus=2

"hide mode in cmd
set noshowmode

"allow edited background buffers
set hidden

"gvim-specific settings
set guifont=Tamsyn\ 11
set guioptions=aegimt

"buffer / tab controls
nnoremap <C-j> :bn<CR>
nnoremap <C-k> :bp<CR>
nnoremap <C-g> :buffers<CR>:b<Space>
nnoremap <C-n> :tabn<CR>
nnoremap <C-p> :tabp<CR>
nnoremap <C-t> <C-w>s<C-w>T
nnoremap <C-w><C-n> :tabm +1<CR>
nnoremap <C-w><C-p> :tabm -1<CR>

"insert lines below
nnoremap ++ ==
nnoremap = Oa<C-u><Esc>j

"folds!
nnoremap fo zO
nnoremap fc zC
nnoremap fm zM
nnoremap fr zR

"copy words from above and below the cursor
inoremap <expr> <C-y> pumvisible() ? "\<C-y>" : matchstr(getline(line('.')-1), '\%' . virtcol('.') . 'v\%(\k\+\\|.\)')
inoremap <expr> <C-e> pumvisible() ? "\<C-e>" : matchstr(getline(line('.')+1), '\%' . virtcol('.') . 'v\%(\k\+\\|.\)')

"use the X clipboard for things when running in a virtual terminal, because yes
if &term != "linux"
	nnoremap <expr> y (v:register ==# '"' ? '"+' : '') . 'y'
	nnoremap <expr> Y (v:register ==# '"' ? '"+' : '') . 'Y'
	xnoremap <expr> y (v:register ==# '"' ? '"+' : '') . 'y'
	xnoremap <expr> Y (v:register ==# '"' ? '"+' : '') . 'Y'
	
	nnoremap <expr> d (v:register ==# '"' ? '"+' : '') . 'd'
	nnoremap <expr> D (v:register ==# '"' ? '"+' : '') . 'D'
	xnoremap <expr> d (v:register ==# '"' ? '"+' : '') . 'd'
	xnoremap <expr> D (v:register ==# '"' ? '"+' : '') . 'D'
	
	nnoremap <expr> p (v:register ==# '"' ? '"+' : '') . 'p'
	nnoremap <expr> P (v:register ==# '"' ? '"+' : '') . 'P'
	xnoremap <expr> p (v:register ==# '"' ? '"+' : '') . 'p'
	xnoremap <expr> P (v:register ==# '"' ? '"+' : '') . 'P'
end

"annoying syntax-related values that need to be set before files are
"opened
let g:c_no_comment_fold = 1
let g:c_no_if0_fold = 1

"other filetype-specific settings. i can't figure out how to stick all
"the FileTypes in one list (mostly because i have no idea what i'm
"doing with viml), so separate lines it is.
autocmd FileType asm     call Settings_asm()
autocmd FileType c       call Settings_c()
autocmd FileType cpp     call Settings_cpp()
autocmd FileType tex     call Settings_tex()
autocmd FileType haskell call Settings_haskell()
autocmd FileType make    call Settings_script()
autocmd FileType matlab  call Settings_matlab()
autocmd FileType perl    call Settings_script()
autocmd FileType python  call Settings_script()
autocmd FileType sh      call Settings_script()
autocmd FileType vim     call Settings_vim()
autocmd FileType zsh     call Settings_script()

function! Settings_asm()
	"settings
	setlocal foldmethod=syntax
	"mappings
	nnoremap -- A<Tab>;<Space>
endfunction

function! Settings_c()
	"settings
	setlocal foldmethod=syntax
	"mappings
	nnoremap <Leader>c :!make<CR>
	nnoremap -- O<Space>*/<Esc>hhi/*<Space>
endfunction

function! Settings_cpp()
	"settings
	setlocal foldmethod=syntax
	setlocal shiftwidth=4
	setlocal tabstop=4
	"mappings
	nnoremap <Leader>c :!make<CR>
	nnoremap -- O<Space>*/<Esc>hhi/*<Space>
endfunction

function! Settings_haskell()
	"settings
	"mappings
	nnoremap -- O--<Space>
endfunction

function! Settings_matlab()
	"settings
	"mappings
	nnoremap -- O%<Space>
endfunction

function! Settings_script()
	"settings
	setlocal shiftwidth=4
	setlocal tabstop=4
	"mappings
	nnoremap -- O#<Space>
endfunction

function! Settings_tex()
	"settings
	setlocal shiftwidth=4
	setlocal tabstop=4
	"mappings
	nnoremap -- O%<Space>
	nnoremap <Leader>c :!latex -output-format=pdf %<CR><CR>
	nnoremap <Leader>C :!latex -output-format=pdf %<CR>
endfunction

function! Settings_vim()
	"settings
	"mappings
	nnoremap -- O"
endfunction