-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.vim
164 lines (164 loc) · 5.25 KB
/
init.vim
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
" plugins
" install plugin manager!
let data_dir = has('nvim') ? stdpath('data') . '/site' : '~/.vim'
if empty(glob(data_dir . '/autoload/plug.vim'))
silent execute '!curl -fLo '.data_dir.'/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
"
" install plugins!
call plug#begin()
" COC
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'neoclide/vim-jsx-improve'
Plug 'clangd/coc-clangd'
Plug 'fannheyward/coc-marketplace'
"
" slime
Plug 'jpalardy/vim-slime'
Plug 'klafyvel/vim-slime-cells'
"
call plug#end()
"
"
" basic preferences
:set tabstop=4
:set shiftwidth=4
:set expandtab
:set wrap
:set number
:set foldmethod=marker
:set list
"
" fold stuff! "
" foldmarkers!
:set foldmarker=// ,
autocmd filetype python setlocal foldmarker =# ,#
autocmd filetype r setlocal foldmarker =# ,#
autocmd filetype vim setlocal foldmarker =\" ,\"
autocmd filetype sql setlocal foldmarker =--\ f,--\ d
autocmd BufEnter *.s setlocal foldmarker =; ,;
"
" hotkeys!
vnoremap <Leader>' :<c-u>call SurroundWithNamedFold()<CR>
vnoremap <Leader>; :<c-u>call SurroundWithUnnamedFold()<CR>
"
" pretty fold text
let fold_text_discriminator="@@@@"
:set foldtext=CustomFoldText()
autocmd BufEnter *.py let fold_text_discriminator="\\(^\\W*@\\)\\|\\(^\\W*\"\"\"\\)"
autocmd BufEnter *.txt let fold_text_discriminator="@@@@"
"
" functions!
function SurroundWithNamedFold() "
" aquire needed strings!
let first_line_whitespace = matchstr(getline("'<"),"^\\s*")
let foldDescription = input("Fold description! ")
let [left_foldmarker, right_foldmarker] = split(&foldmarker, ',')
"
" add foldmarkers!
call append(line("'<")-1, first_line_whitespace.left_foldmarker."".foldDescription)
call append(line("'>"), first_line_whitespace.right_foldmarker)
"
" refresh folds!
execute "normal! zMzvzc"
"
endfunction "
function SurroundWithUnnamedFold() "
" make sure we have <2 lines!
"if getline("'<")==getline("'>")
" echo "Select at least two lines"
" return 0
"endif
"
" aquire needed strings!
let first_line = getline("'<")
let first_line_whitespace = matchstr(getline("'<"),"^\\s*")
let [left_foldmarker, right_foldmarker] = split(&foldmarker, ',')
"
" add foldmarkers!
call setline(line("'<"), first_line." ".left_foldmarker)
call append(line("'>"), first_line_whitespace.right_foldmarker)
"
" refresh folds
execute "normal! zMzvzc"
"
endfunction "
function CustomFoldText() "
let display_line_number=v:foldstart
let display_line=getline(display_line_number)
let ick_found=(-1!=match(display_line, g:fold_text_discriminator))
while ick_found
let display_line_number=display_line_number + 1
let display_line=getline(display_line_number)
let ick_found=(-1!=match(display_line, g:fold_text_discriminator))
endwhile
return matchstr(foldtext(), "^.\\{-}:")." ".matchstr(display_line,"\\w.*")
"if ick_found
" let return_value="ick: ".display_line
"else
" let return_value="good: ".display_line
"endif
"return return_value
endfunction
"
"
"
" slime!
" hotkeys!
" <Leader>c send a cell!
"This needs the execute to work on some platforms?
nnoremap <Leader>c :execute "normal \<Plug>SlimeCellsSend"<enter><enter>
"
" <Leader>v send a cell and jump to the next one!
"This needs the execute to work on some platforms?
nnoremap <Leader>v :execute "normal \<Plug>SlimeCellsSendAndGoToNext"<enter><enter>
"
" <Leader>a send the current line
nnoremap <Leader>a :SlimeSend<enter>
"
" <Leader>l launch repl!
nnoremap <Leader>l :execute ":SlimeSend1 " . repl_launch_command<enter>
"
" <Leader>q send exit command!
nnoremap <Leader>q :execute ":SlimeSend1 " . repl_exit_command<enter><enter>
"
" <Leader>p send utility command!
nnoremap <Leader>p :execute ":SlimeSend1 " . repl_utility_command<enter><enter>
"
" <Leader>s send user specified command!
nnoremap <Leader>s :SlimeSend1
"
" <Leader>: make cell boundary!
nnoremap <Leader>: :execute "normal O" . g:slime_cell_delimiter . " "<enter>j0
"
"
" general settings
let g:slime_target = 'tmux'
let g:slime_no_mappings = 1
"
" language utilities!
" python
autocmd filetype python let repl_launch_command="ipython --matplotlib --no-autoindent"
autocmd filetype python let repl_exit_command="exit()"
autocmd filetype python let repl_utility_command="plt.close(\"all\")"
autocmd filetype python let g:slime_cell_delimiter="###"
"
" r
autocmd filetype r let repl_launch_command="R"
autocmd filetype r let repl_exit_command="q(\"no\")"
autocmd filetype r let repl_utility_command="# Utility command not configured"
autocmd filetype r let g:slime_cell_delimiter="###"
"
" unrecognized files
let repl_launch_command="no launch command set for this filetype"
let repl_exit_command="no exit command set for this filetype"
let repl_utility_command="no utility command set for this filetype"
let g:slime_cell_delimiter="cell delimiter not set"
"
"
"
" make space a leader!
nmap <Space> <Leader>
vmap <Space> <Leader>
"