-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
8317 lines (7247 loc) · 219 KB
/
.vimrc
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
function ShuntCallsToBottom()
let regex = '^(\(|console.log|print)|^const .{-} require'
let base = line('$')
let threefourth = base * 0.95
let start = float2nr(round(threefourth))
ec start
let lines = getline(start, '$')
for i in Ranger(lines)
if Test(lines[i], regex)
call setline(i + start, '')
call append('$', lines[i])
endif
endfor
endfunction
function FixTheLineViaTemplate(indexes, arg)
call GetSetLines(a:indexes, {s -> Replace(a:arg, '\$1', trim(s))}, 0)
endfunction
function GoHtmlBackward()
let lineindex = line('.')
let line = CurrentLine()
let index = match(line, '""')
"ec line[28]
"ec line[29]
"ec index
call cursor(lineindex, index + 2)
endfunction
function GoHtmlForward()
let lineindex = line('.')
let line = CurrentLine()
let index = match(line, '>')
call cursor(lineindex, index + 2)
endfunction
function AddErrorDebugForTheThing(indexes)
let lines = ['try {',
\'catch(e) {',
\ 'console.log(e)',
\ 'console.log(s)',
\ 'throw "error"',
\ '}'
]
let [a,b] = a:indexes
let spaces = CurrentSpaces()
call IndentAll([a,b])
call append(a - 1, spaces . lines[0])
call append(b + 1, IndentAll(lines[1:], spaces))
call cursor(b + 3, 100)
endfunction
function AddFileToFileDict(s)
let [a,b] = SplitOnce(a:s)
let index = search('\v^ *"\\ *''file-dict-start''', '')
let p = DictEntry(a, Quotify(b))
call SmartAppend(index, p)
endfunction
" We are in the beta right now. Something that you've never seen before.
function SmartNav()
ec 'hi'
endfunction
function SaveToIndex()
call WriteFile('index.html', readfile(
endfunction
function PrintToScreen(indexes)
ec join(GetLines(a:indexes), "\n") . "\n\n"
endfunction
function ArchiveContents(indexes)
let lang = expand('%:t')
let name = 'archive' . lang
call AppendFile(name, GetLines(a:indexes))
call DeleteLines(a:indexes)
ec ReadFile(name)
endfunction
function SaveFunctionToList()
let lang = FileLang()
let fn = GetFunctionName()
call ThrowGetter(lang, fn)
let s = lang . ' ' . fn
call AppendFile('myfunctions.txt', s)
ec ReadFile('myfunctions.txt')
endfunction
function SaveFileToList()
call AppendFile('myfiles.txt', FileTail())
ec ReadFile('myfiles.txt')
endfunction
function FileLang()
return expand('%:e')
endfunction
function FileTail()
return expand('%:t')
endfunction
function IsIndexes(lines)
return len(a:lines) == 2 && IsNumber(a:lines[0]) && IsNumber(a:lines[1])
endfunction
function ReadFile(file)
ec join(readfile(a:file), "\n")
endfunction
function SmartTextFix()
let line = CurrentLine()
let items = [
\[ '\{\w+,? \w+.{-}\}', {t -> Sub(t[0], '\w+', {x -> Quotify(x[0]) . ': ' . x[0] . (Test(t[0], ',') ? '' : ', ') })}],
\]
"store.append({'id': id, 'question': question, 'choices': choices, 'answer': answer})
if 1 || GetLang() == 'py'
for [regex, Replacement] in items
ec regex
if Test(line, regex)
ec 'hi'
let product = Replace(line, regex, Replacement)
ec product
return setline('.', product)
endif
endfor
endif
endfunction
nnoremap 5 /^\.
function Pugify()
let match = Match(GetFunctionLine(), '\w+\ze \=')
ec match
call setline('.', 'pug(' . match . ')')
endfunction
function LookForFiles(s)
if Test(a:s, '^\w+$')
if Test(a:s, 'mp3|jpg|svg|png|js|py|txt|html|pdf|css')
ec globpath('.', '*' . a:s)
else
ec globpath('.', a:s . '*')
endif
return
endif
let [dir, query] = SplitOnce(a:s)
ec [dir, query]
ec globpath(dir, query)
endfunction
function Latest(s)
ec globpath('.', '*' . a:s)
endfunction
"06-09-2021 05:53:39 /
iab gd '/mnt/chromeos/GoogleDrive/MyDrive/CWF/'
iab mgd '/mnt/chromeos/GoogleDrive/MyDrive/CWF/'
nnoremap zv /^Vue.prototype.
let g:jspydict = {
\ 'bash': {
\ 'function': '',
\ 'p1': '',
\ 'p2': ' {',
\ 'suffix': ' }',
\ },
\ 'js': {
\ 'clbr': 'console.log("*******************************************")',
\ 'lbr': '/****************************************************/',
\ 'expand': 'javascript',
\ 'libfile': 'javascript.lib',
\ 'sdelimiter': '`',
\ 'else': 'else {',
\ 'stry': 'try {',
\ 'scatch': ['}', 'catch(e) {', ' ', '}'],
\ 'try': ['try {', ' ', '}', 'catch(e) {', ' ', '}'],
\ 'ift': ['if (', ') {'],
\ 'eft': ['else if (', ') {'],
\ 'if': ['if (', ') {'],
\ 'ef': ['else if (', ') {'],
\ 'o': 'isObject',
\ 'classparam': '',
\ 'classp1': '',
\ 'a': 'isArray',
\ 'n': 'isNumber',
\ 's': 'isString',
\ 'testfunc': 'test',
\ 'commentPrefix': '//',
\ 'commentSuffix': '',
\ 'comment': '//',
"\ 'commentfn': CommentJS,
\ 'consolefn': {s -> 'console.log(' . s . ')'},
\ 'function': 'function',
\ 'p1': 'function',
\ 'p2': ' {',
\ 'suffix': '}',
\ 'capitalize': 0,
\ 'runtime': 'node',
\ 'prettier': 'prettier --write ',
\ 'variablePrefix': 'const ',
\ 'consoleStart': 'console.log(',
\ 'consoleEnd': ')',
\ 'logicsuffix': '}',
\ },
\ 'vim': {
\ 'lbr': '"""""""""""""""""""""""""""""""""""""""""""""""""""""""',
\ 'else': 'else',
\ 'stry': 'try',
\ 'scatch': ['catch', ' ', 'endtry'],
\ 'try': ['try', ' ', 'catch', ' ', 'endtry'],
\ 'o': 'IsObject',
\ 'a': 'IsArray',
\ 'classparam': 'self',
\ 'classp1': '',
\ 'n': 'IsNumber',
\ 'logicsuffix': '',
\ 's': 'IsString',
\ 'if': ['if ', ''],
\ 'ef': ['elseif ', ''],
\ 'ift': ['if ', ''],
\ 'eft': ['elseif ', ''],
\ 'testfunc': 'Test',
\ 'commentPrefix': '"',
\ 'commentSuffix': '',
\ 'comment': '"',
\ 'function': 'function',
\ 'p1': 'function',
\ 'p2': '',
\ 'suffix': 'endfunction',
\ 'capitalize': 1,
\ 'variablePrefix': 'let ',
\ 'consoleStart': 'echom ',
\ 'consoleEnd': '',
\ 'consolefn': {s -> 'echo ' . s},
\ },
\ 'html': {
\ 'commentPrefix': '<!--',
\ 'commentSuffix': ' -->',
\ },
\ 'css': {
\ 'lbr': '/*********************************************************/',
\ 'commentPrefix': '/*',
\ 'commentSuffix': ' */',
\ },
\ 'py': {
\ 'lbr': '#######################################################',
\ 'expand': 'python',
\ 'libfile': 'combine.py.lib',
\ 'sdelimiter': '''''''',
\ 'else': 'else:',
\ 'stry': 'try:',
\ 'scatch': ['except Exception as e:', ' '],
\ 'classp1': 'def ',
\ 'classparam': 'self',
\ 'try': ['try:', ' ', 'except Exception as e:', ' '],
\ 'o': 'isObject',
\ 'logicsuffix': '',
\ 'a': 'isArray',
\ 'n': 'isNumber',
\ 's': 'isString',
\ 'prettier': 'black ',
\ 'if': ['if ', ':'],
\ 'ef': ['elif ', ':'],
\ 'ift': ['if ', ':'],
\ 'eft': ['elif ', ':'],
\ 'testfunc': 'test',
\ 'commentPrefix': '#',
\ 'commentSuffix': '',
\ 'function': 'def',
\ 'comment': '#',
\ 'p1': 'def',
\ 'p2': ':',
\ 'suffix': '',
\ 'capitalize': 0,
\ 'run': 'python3',
\ 'runtime': 'python3',
\ 'variablePrefix': '',
\ 'consoleStart': 'print(',
\ 'consoleEnd': ')',
\ 'consolefn': {s -> 'print(' . s . ')'},
\ }
\}
let g:filedict = {
"\ 'file-dict-start': 'foo',
\ 'ss': 'scrapescript.py',
\ 'i': 'index.html',
\ 'mk': 'makescript.js',
\ 'g': 'githubscript.py',
\ 'th': 'thursday.html',
\ 'm': 'main.js',
\ 'st': 'styles.css',
\ 'c': 's.css',
"\ 'q': 'questions.txt',
\ 'n': 'notes.txt',
\ 'red': 'redditscript.py',
\ 'em': 'emailscript.py',
\ 'r': 'r.py',
\ 'ft': 'filetracker.txt',
\ 't': 't.html',
\ 'd': 'derived.py',
\ 's': 'storage.py',
\ 'sh': 'shortcuts.py',
\ 'h': 'helpers.js',
\ 'vh': 'vuehelpers.js',
\ 'u': 'utils.py',
\ 'uj': 'utils.js',
\ 'isss': 'vuecm3.html',
\ 'ii': 'vuecm5.html',
\ 'ex': 'ex1.html',
\ 'vim': '~/.vimrc',
\ 'vimrc': '~/.vimrc',
\ 'bash': '~/.bash_aliases',
\ }
let g:cabmap = {
\ 'center': "display: flex; align-items: center; justify-content: center;",
\ 'b': "border: 0.5px solid blue;",
\ }
"05-31-2021 06:44:56
"05-29-2021 17:06:08 tossed bananas because they were completely soft. toss corn because it was slimey. i had only bought it for a few days. toss crutons because i dont like crutons. tossed the black highlighter sharpie bc it went out of ink really fast.
function OpenCurrentFiles()
let files = ['vuecm5.html', 'vuehelpers.js']
for file in files
call OpenBuffer(file)
endfor
endfunction
function WriteDebugMessage()
let message = '/* ' . toupper(g:debug) . ' */ '
call ReplaceLine(line('.'), '^ *\zs', message)
endfunction
let g:prepfiledict = {
\'py': [
\ "from storage import *",
"\ "import regex as re",
\ "",
\ "",
\],
\}
" a superpack of 9 fotl underwears is $15.98, while a 6 pack of hanes underwear is 9.98. wts the better deal
let g:snippetdict = {
\ 'bar': 'baz',
\ 'eater': "<left><Left><C-R>=Eatchar('\s')<CR>",
\}
func Eatchar(pat)
let c = nr2char(getchar(0))
return (c =~ a:pat) ? '' : c
endfunc
fun CopyGetter(regex)
let @/ = a:regex
ec
let repl = expand("<cword>")
//s//\=repl
endfun
iab cmsetup this.codemirror = CodeMirror.fromTextArea(this.$refs.codemirror, options)
iabbrev <silent> tcm this.codemirror<C-R>=Eatchar('\s')<CR>
iabbrev <silent> gv getValue<C-R>=Eatchar('\s')<CR>
iabbrev <silent> sv setValue<C-R>=Eatchar('\s')<CR>
inoremap 90 ()<left>
"iabbrev <silent> <~/.vimrc> if if ()<Left><C-R>=Eatchar('\s')<CR>
"iabbrev <silent> 90 ()<left><C-R>=Eatchar('\s')<CR>
"iabbrev <silent> sw startsWith('')<Left><left><C-R>=Eatchar('\s')<CR>
"iabbrev <silent> ift if (test())<left><Left><C-R>=Eatchar('\s')<CR>
"iabbrev <silent> l90 () =>
"iab ls (s) =>
"iab lkv (k,v) =>
"iab l console.log()<Left><C-R>=Eatchar('\s')<CR>
"iab asdf daf
"iab vimeat \<left>\<Left>\<C-R>=Eatchar('\s')\<CR>
"iab efe else if (exists())<Left><Left><C-R>=Eatchar('\s')<CR>
"iab efs else if (isString())<Left><Left><C-R>=Eatchar('\s')<CR>
"iab efo else if (isObject())<Left><Left><C-R>=Eatchar('\s')<CR>
"iab efn else if (!)<Left><C-R>=Eatchar('\s')<CR>
"iab efa else if (isArray())<Left><Left><C-R>=Eatchar('\s')<CR>
"iab ife if (exists())<Left><Left><C-R>=Eatchar('\s')<CR>
"iab ifs if (isString())<Left><Left><C-R>=Eatchar('\s')<CR>
"iab ifo if (isObject())<Left><Left><C-R>=Eatchar('\s')<CR>
"iab ifn if (!)<Left><C-R>=Eatchar('\s')<CR>
"iab ifa if (isArray())<Left><Left><C-R>=Eatchar('\s')<CR>
inoremap w. <esc>A {<esc>o}<esc><s-o>
inoremap <expr> w, EnterBlockExpression()
let g:pyactualpydict = {
\ 'ifn': "if not $0:\n $c",
\ 'ift': "if test($2, $1):\n $c",
\ 'ifo': "if isObject($1):\n $c",
\ 'ifs': "if isString($1):\n $c",
\ 'ifa': "if isArray($1):\n $c",
\ 'iff': "if isFunction($1):\n $c",
\
\
\ 'class': "class ${Capitalize($1)}:\n def __init__(self${AddParams($2)}$c):",
\ 'enter': "def __enter__(self):\n return self\ndef __exit__(self, error, *args):\n $c",
\ }
"//pdicfs
function UseHelper(s)
let s = a:s
if Test(s, 'fetch')
return "const fetch = require('node-fetch')"
elseif Test(s, 'fs')
return "const fs = require('fs')"
elseif Test(s, 'css$')
return '<link rel="stylesheet" type="text/css" href="./' . s . '" />'
elseif Test(s, 'style')
return '<link rel="stylesheet" type="text/css" href="./styles.css" />'
else
return '<script src="' . s . '"></script>'
endif
endfunction
let g:pydict = {
\ 'script': "<script>$c</script>",
\ 'jshint': "const JSHINT = require('./jshint.js')",
\ 'prom': "return new Promise((resolve) => {\n $c\n})",
\ 'u': "${UseHelper($1)}",
\ 'use': "${UseHelper($1)}",
\ 'vuediv': "<div id=\"app\">\n $c\n</div>",
\ 'katex': '<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.css" integrity="sha384-Um5gpz1odJg5Z4HAmzPtgZKdTBHZdw8S29IecapCSB31ligYPhHQZMIlWLYQGVoc" crossorigin="anonymous"><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.js" integrity="sha384-YNHdsYkH6gMx9y3mRkmcJ2mFUjTd0qNQQvY9VYZgQd7DcN7env35GzlmFaZ23JGp" crossorigin="anonymous"></script>',
\ 'kf': "${KeyFramer($0)}",
\ 'computed': "computed: {\n computed${Capitalize($1)}() {\n $c\n },\n},",
\ 'writer': "from storage import write\nwrite('temp.txt', $1)",
"\ 'vmo': "mounted() {\n $c\n}",
\ 'vuen': "const ${Capitalize($1)}Component = {\n props: ['value'],\n template: `$c`,\n \n data() {\n return {\n message: 'hi',\n }\n },\n\n}",
\'fetch': "const fetch = require('node-fetch')",
\ 'vueno': "Vue.component('${Capitalize($1)}Component', {\n props: ['value'],\n template: `$c`,\n \n data() {\n return {\n message: 'hi',\n }\n },\n})",
\ 'vuer': "const ${Capitalize($1)}Component = {\n props: ['value'],\n render(h) {\n $c\n },\n\n}",
\ 'vueco': "const ${tolower($1)}template = `\n\ndiv {\n $c\n}\n\n`\n\nconst ${Capitalize($1)} = {\n template: simplepug(${tolower($1)}template),\n props: ['abcdefg'],\n\n\n}",
\ 'vuec': "const $1template = `\n\n$c\\nn`\n\nVue.component('$1', {\n template: $1template,\n props: ['abcdefg'],\n\n\n})",
\ 'rpw': "def parser(data):\n $c\n\nrpwo('$1', parser)",
\ 'cs': "class: '$c',",
\ 'dir': "directives: [\n {\n name: $c\n value: \n },\n],",
\ 'center': "display: flex; align-items: center; justify-content: center;$c",
\ 'b': "border: 0.5px solid blue;$c",
\ 'wh100': "width: 100%; height: 100%;$c",
\
\
\
\ 'a' : "const $1 = [\n $c\n]",
\ 'd' : "const $1 = {\n $c\n}",
\ 'vp' : "Vue.prototype.$$1 = function($2) {\n $c\n}",
\ 'rpwo': "rpwo('$1', (s) => {\n $c\n})",
\ 'switch': "switch ($1) {\n $c\n}",
\ 'vprop': "props: ${ArrayExpand($0)},",
\ 'wae': "window.addEventListener('keydown', $1)",
\ 'vmo': "mounted() {\n $c\n},",
\ 'vm': "methods: {\n $c\n},",
\ 'st': "setTimeout(() => {\n $c\n}, $0)",
\ 'vt': "template: `\n $c\n`,",
\ 'vd': "data() {\n return {\n $c\n }\n},",
\ 'data': "function data() {\n return {\n $c\n }\n}",
\ 'rc': "Vue.component('$1', {\n render(h) {,\n $c\n }\n})",
\ 'cc': "Vue.component('$1', {\n render(h) {\n $c\n }\n})",
\ 'cidfgdc': "Vue.component('$1', {\n data() {\n return {\n $c\n }\n },\n methods: {\n\n },\n computed: {\n\n },\n watch: {\n\n },\n mounted() {\n\n },\n render(h) {\n\n }\n}",
\ 'vc': "const $1 = {\n template: ${tolower($1)}template,\n data() {\n return {\n $c\n }\n },\n methods: {\n\n },\n computed: {\n\n },\n mounted() {\n\n },\n}",
\ 'fori': "for (let i = 0; i < $1; i++) {\n $c\n}",
\ 'for2': "for (let i = 0; i + 1 < $1; i += 2) {\n $c\n}",
\ 'forkv': "for (let [k, v] of Object.entries($1)) {\n $c\n}",
\ 'for': "for (let ${ZoopBar($1)} of $1) {\n $c\n}",
\ 'if': "if ($0) {\n $c\n}",
\ 'ef': "if ($0) {\n $c\n}",
\ 'ife': "if (exists($0) {\n $c\n}",
\ 'ifn': "if (!$0) {\n $c\n}",
\ 'ift': "if (test($2, $1)) {\n $c\n}",
\ 'iff': "if (isFunction($1)) {\n $c\n}",
\ 'ifa': "if (isArray($1)) {\n $c\n}",
\ 'ifo': "if (isObject($1)) {\n $c\n}",
\ 'ifs': "if (isString($1)) {\n $c\n}",
\ 'ifnum': "if (isNumber($1)) {\n $c\n}",
\ 'efn': "else if (!($0) {\n $c\n}",
\ 'eft': "else if (test($2, $1)) {\n $c\n}",
\ 'eff': "else if (isFunction($1)) {\n $c\n}",
\ 'efa': "else if (isArray($1)) {\n $c\n}",
\ 'efo': "else if (isObject($1)) {\n $c\n}",
\ 'efs': "else if (isString($1)) {\n $c\n}",
\ 'efnum': "else if (isNumber($1)) {\n $c\n}",
\ 'class': "class ${Capitalize($1)} {\n constructor($c) {\n }\n\n}",
\ }
function PySnippetTemplater(match, parts, line)
"let match = IsArray(a:match) ? a:match[1] : a:match
let match = a:match[1]
let parts = a:parts
let line = a:line
if match == 'c'
return ''
elseif Test(match, '^\d+')
if match == '0'
return line
elseif match - 1 < len(parts)
return parts[match - 1]
else
return ''
endif
ec match
elseif match =~ '^{'
let match = match[1:-2]
"let match = Sub(match, '\$(\d+)', {s -> function('P99')(s, parts, line)})
ec 'howdyddd'
let match = Sub(match, '\$(\d+)', {s -> function('Quotify')(function('PySnippetTemplater')(s, parts, line))})
return eval(match)
map
endif
endfunction
function PySnippet()
let [spaces, tag, line, parts] = GetSpacesTagLineAndParts()
if !has_key(g:pydict, tag)
if !Test(line, ':$')
let line .= ':'
endif
call setline('.', spaces . tag . ' ' . line)
call append('.', spaces . ' ')
call cursor(line('.') + 1, 100)
return
endif
let snippet = get(g:pydict, tag)
let regex = '\$(\{.{-}\}|\d+)'
let Parser89 = {x -> function('PySnippetTemplater')(x, parts, line)}
let snippet = Sub(snippet, regex, Parser89)
let cursorpos = GetCursorFromStringSnippet(snippet)
let snippet = Replace(snippet, '\$c', '')
call TextPlacement(SplitLines(snippet), spaces)
call SetCursor(cursorpos, spaces)
endfunction
function GetCursorFromStringSnippet(snippet)
let lines = split(a:snippet, "\n")
for [i, line] in Enumerate(lines)
if line =~ '\$c'
let ch = match(line, '\$c')
return [Relative(i), ch]
endif
endfor
endfunction
let jsdict = {
\ "div": {'template': "<div>$c</div>" , 'cursor': 'smart', 'suffix': ''},
\ "vt": {'template': "template: `\n \n`," , 'suffix': ''},
\ "vd": {'template': "data() {\n return {\n %c\n }\n}," , 'suffix': ''},
\ "vm": {'template': "methods: {\n \n}," , 'suffix': ''},
\ "vc": {'template': "computed: {\n \n}," , 'suffix': ''},
\ "props": {'snippet': "props: $0,", 'functions': 'ArrayExpand', 'noappend': 1},
\ "else": "else {",
\ "m": "method $0($1) {",
\ "border": "border: 0.5px solid red;",
\ "mo": "mounted() {",
\ "st": {'snippet': "setTimeout(() => {\n %c\n}, $0)"},
\ "vp": "Vue.prototype.$$0 = function($1) {",
\ "lbr": "$$JSPY('comment')$$ --------------------------",
\ "len": "print('length of $0:', len($0))",
\ "forkjiii": "",
\ "forkijiii": "",
\ "fork": "for (let key of Object.keys($0) {",
\ "forv": "for (let value of Object.values($0) {",
\ "forkv": "for (let [k, v] of Object.entries($0)) {",
\ "fori": "for (let i = 0; i < $0; i++) {",
\ "for": [1, "for (let $a of $0) {", {s -> s[:-2]}],
\ "ef": "else if ($0) {",
\ "efs": "else if (isString($0)) {",
\ "efo": "else if (isObject($0)) {",
\ "efa": "else if (isArray($0)) {",
\ "efn": "else if (!$0) {",
\ "class": {
\ 'snippet': "class $0 {\n constructor($1) {\n }",
\ 'functions': ['Capitalize', 'Identity'],
\},
\ "if": "if ($0) {",
\ "ifs": "if (isString($0)) {",
\ "ifo": "if (isObject($0)) {",
\ "ifa": "if (isArray($0)) {",
\ "ifn": "if (!$0) {",
\ "ift": "if (test($0)) {",
\ "eft": "else if (test($0)) {",
\ "while": "while {\n}",
\ "try": "try {\n}\ncatch(e) {",
\ "dict": "const dict = {",
\ "obj": "const obj = {",
\ "arr": "const arr = [",
\ "items": "const items = [",
\ }
let g:logicdict = {'js': jsdict, 'vim': jsdict, 'py': jsdict}
let g:htmldict = {
\ 'div': 'div',
\ 'section': 'section',
\}
"05-17-2021 08:07:30 extreme hunger pain. happened after waking up. i felt fine, then i did a lot of kitchen actions, then, i was swamped by hunger. hunger like i have never really felt. it lasted for quite some time. even now, some 2 hours later, the hunger is persisting. eating some mentos helped a little bit. is it from seaweed parasite. is it from low blood sugar. why did it happen. i have no idea. maybe bc ive been on a protein deficit for awhile. maybe i shud eat 2 breakfasts. threw away hoison sauce. tossed all the green beans. they were all dirty. shud i be writing notes here...
"05-16-2021 09:17:10 appendbelow's final argument is usespaces which is active by default. to deactivate, press 1.
iab ifmain if __name__ != '__main__': return
function WriteVimIab(s)
let cmd = 'iab ' . a:s
AppendFile('~/.vimrc', cmd, 0)
endfunction
iab ssp s.split('\n')
nnoremap sh :call ShuntBlock('/home/kdog3682/CWF/helpers.js')<cr>
nnoremap sb :call ShuntBlock()<cr>
function JsonGetter(file, key)
data = ReadJson(FuzzyFileFinder(a:file))
if IsNumber(key)
kjhkjkj
endif
endfunction
hi Error ctermfg=Red guifg=Red
"05-12-2021 11:18:52 all of these sentences should be aggregated away. the resultant file should be parsed.
"05-12-2021 10:07:53 the comparisons are necessary. give them constant reinforcement for how the student is doing. You have to consider the history of 1000s of years.
"05-12-2021 09:34:51 when mom talks to me, she often references me as a young child. 'you're a good kid.' 'you're a good boy.' she talks to me as if i am a child. she rarely seems to hear what im saying. she likes to make assumptions and judgments. 'you are like this, or you are like that.' I don't enjoy the conversation. I find myself saying rediculous things. 'I love lists. I have thousands of lists.'
"05-12-2021 07:16:28 how do you install the :py command for reference, I am running vim 8.1 on linux via chromebook. When checking :version, I see that both :python and python3 have are not installed with the build. I have been googling, 'add python3 support to vim' but thus far, haven't been able to find an answer. Any ideas on what I might try? thx.
"05-11-2021 10:13:54 istaw to have the cursor always start at the bttom of a file instead of the start of a file i noticed the first thing that i do in almost every file is to type G to get to the bttom of the file. i feel like there is probably a way to automatically bring the cursor down?
"05-11-2021 09:43:14 is there a way to auto capitalize text in command mode For instance, my vimrc has a command 'Tick' which activates call Ticker(). But in order for me to access this function, I have to type a capitalized 'T' for Tick. Hence, I'm wondering if there is a way to autocapitalize, so that I can write 'tick' instead of having to write 'Tick.'
"05-10-2021 16:27:12 why does vim have a lot of 'gotchas' when it comes to single and double quotes so many times i will be bashing my head over a regex or an execute command and the final debugging solution comes down to i shudve used single quotes or i shudve used double quotes. as a beginner, im really starting to enjoy scripting with vim, but these gotchas have been really aggrevating to say the least. Are there any cut and cold guidelines for when u shud basically always use sq vs dq and vice versa?
"05-10-2021 07:06:47 is there a way to have multiple vimrcs for example, when i am using the js vimrc, ec should expand into console.log. when using the python vimrc, ec should expand into print
"05-09-2021 09:09:07 leaderf can be used 2 ways. the first is when a;s has '/'. this will activate normal find and replace global. the second way is to use it without a space. this will search for the function if it exists, otherwise, the fn will be settled to the bottom of the file.
"05-09-2021 09:03:59 til you have to double the quotes if you want to escape them
"05-09-2021 08:46:21 how do you incorporate regex into split function fex, id lk 2 split on period, on space, or on slash.
"05-09-2021 07:27:35 hi
set hidden
nnoremap ze :call FileOpener()<cr>
set scrolloff=3 " Keep 3 lines below and above the cursor
"05-08-2021 15:51:34 what is the purpose of setting a mapleader or localmapleader i recently discovered that commands can be multiple characters. for example, someething like this
nnoremap < :call SmartIndent()<cr>
function QuestionShifter()
let lang = GetLang()
call OpenBuffer('questions.txt', 1)
call append('.', lang)
return
if GetFile() == 'questions.txt'
execute "edit #"
else
call OpenBuffer('questions.txt', 1)
call append('.', lang)
endif
endfunction
nnoremap zs :call ShuntManager('')<left><left>
nnoremap za :call QuestionShifter('')<left><left>
nnoremap zn :call WriteNote('')<left><left>
nnoremap za :call QuestionShifter()<cr>
"nnoremap zd :call delete(expand('%')) | bdelete!
nnoremap zi :call AddImportStatement('')<cr>
nnoremap zg :call ShuntAndGoTo('')<left><left>
nnoremap zr :call Replacer("")<left><left>
nnoremap z0 :! python3 foo.py<cr>
nnoremap zm :! python3 foo.py<cr>
"inoremap zb <esc>:call SayHi()<cr>
"in this case, the 'z' is kind of acting like my mapleader. I'm curious, what benefit is derived by expliciting saying 'let mapleader = z' versus, doing it the way that im currently doing itqm
"
"how do you programmatically delete a line currently, i use cs call setline('.', '') ce but this doesnt actually dellte the line. ur left with a blank line. istaw a to have this blank also not be there i have tried using cs normal D ce but the problem with this is that i cant control the line index the way that you can with setline.
"
"hdu run a script a single time id like to run script.py when vim is loaded / sourced, but it should only be run, if it is the first time. otherwise, nothing should happen.
function ShuntToReddit()
let store = []
let start = 0
let end = line('.')
for i in range(start, end)
call add(store, getline(i)
call DeleteLine(i)
endfor
endfunction
iab rf findall
function SetLines(lines)
let spaces = CurrentSpaces()
let lines = map(lines, {i, line -> spaces . line})
call append('.', lines)
endfunction
function GetVariable()
return 's'
endfunction
function Finder(r)
let index = search(a:r, 'bn')
return Match(getline(index), a:r)
endfunction
function Prf()
let r = '^ *\zs\w+\ze ='
let r = Finder(r)
let s = GetVariable()
call SetLines('matches = findall(' . r . ', ' . s . ')', Logger('matches'))
endfunction
function Logger(s, ...)
let lang = a:0 == 1 ? a:1 : GetLang()
if lang == 'js'
return 'console.log' . Parens(a:s)
elseif lang == 'py'
return 'print' . Parens(a:s)
elseif lang == 'vim'
return 'echo ' . a:s
endif
endfunction
"ask: how do you rename a file for example, the buffer that i have opened is a.txt. i have a file in my directory called b.txt. i would like to rename b.txt to c.txt. i came up with kind of a convoluted soln, and im wondering if there might be a better way.
"05-07-2021 18:31:26: When using subsitution on a line, is there a way to remove the trailing newline as well?
function Foo(...)
echom a:000
endfunction
function FunctionManager(x)
if Getlang() == 'vimrc'
call VimrcFunctionManager(a:x)
return
endif
let items = split(a:x)
let key = items[0]
let args = items[1:]
call call(function(Capitalize(key)), args)
endfunction
function CharPos(n)
let [a,b,c,d] = getpos('.')
return [a,b, c + a:n, d]
endfunction
function ReplaceWordUnderCursor(replacement)
let word = WordUnderCursor()
execute '%s/\v<' . word . '>/' . a:replacement . '/g'
endfunction
function CurrentWord()
return expand('<cword>')
endfunction
function Boundary(s)
return '<' . a:s . '>'
endfunction
function FunctionRange()
let r = GetCodeIndexes()
return range(r[0], r[1], 1)
endfunction
function GetSetLines(indexes, fn, ...)
let spaces = a:0 >= 1 ? '' : GetSpaces(getline(a:indexes[0]))
if IsNumber(a:indexes) || (IsString(a:indexes) && a:indexes == '.')
let index = a:indexes
let line = getline(index)
let spaces = GetSpaces(line)
let product = FunctionGetter(a:fn)(Strip(line))
if empty(product)
let product = line
else
let product = spaces . product
endif
call setline(index, product)
return
endif
for index in range(a:indexes[0], a:indexes[1])
let line = Strip(getline(index))
let product = a:fn(line)
if empty(product)
let product = line
else
let product = spaces . product
endif
call setline(index, product)
endfor
endfunction
function GetSet(index, fn)
if IsNumber(a:index) || Test(a:index, '[.$^]')
let line = a:fn(getline(a:index))
call setline(a:index, line)
else
call setline('.', a:fn(a:index))
endif
endfunction
function FasdfileGetter(file)
let dict = {
\ 'q': 'questions.txt',
\ 'n': 'notes.txt',
\ 'r': 'r.py',
\ 't': 'today.py',
\ 'd': 'derived.py',
\ 's': 'storage.py',
\ 'sh': 'shortcuts.py',
\ 'h': 'helpers.py',
\ 'u': 'utils.py',
\ 'vim': '~/.vimrc',
\ 'vimrc': '~/.vimrc',
\ 'bash': '~/.bash_aliases',
\ }
let match = get(dict, a:file)
return match
let file = a:file
if Not(file)
if Not('b:buffer')
let b:buffer = 'today.py'
endif
let file = b:buffer
endif
let dict = {
\ "sc": 'shortcuts',
\ "s": 'storage',
\ "h": 'helpers',
\ }
let file = get(dict, file, file)
if Not(HasExtension(file))
let file += '.' . CurrentExtension()
endif
return PathFix(file)
endfunction
function HasExtension(file)
return Test(a:file, '\.\w+$')
endfunction
nnoremap zq :call ShuntFunction()<left><left>
function ShuntAndGoTo(s)
call ShuntManager(a:s)
call ChooseBuffer(a:s)
endfunction
let b:deleterange = 1
function ShuntManager(s)
let [file, options] = ForceSplit(a:s, '/')
let options = split(options, '\zs')
let gotobuffer = 0
let keeprange = 0
for option in options
if option == 'd'
let b:deleterange = 1
elseif option == 'k'
let keeprange = 1
elseif option == 'g'
let gotobuffer = 1
endif
endfor
let file = FileGetter(file)
let insertion = 0
if Not(file)
let insertion = GetLine()
if IsConstant(insertion)
let file = 'r.py'
endif
else
let range = GetCodeIndexes()
let insertion = GetLines(range)
let lang = GetLang(file)
let regex = '\v^ *(const|let) '
if lang == 'py' && insertion[0] =~ regex
let insertion[0] = Replace(insertion[0], regex, '')
endif
endif
ec 'Shunting to file: ' . file
call AppendLines(insertion, file)
if Not(keeprange)
call DeleteRange(range)
endif
if gotobuffer
call OpenBuffer(file)
endif
endfunction
function ShuntFunction(...)
let file = a:0 == 1 ? a:1 : ''
let file = FileGetter(file)
let lines = GetFunction()
if file =~ '.'
call DeleteRange(range)
endif
call AppendLines(lines, file)
endfunction
function DeleteLine(i)
call deletebufline('%', a:i)
"call setline(a:i, '')
endfunction
function DeleteRange(indexes)
let [a,b] = a:indexes
call deletebufline('%', a, b)
endfunction
function AppendLines(lines, destination)
call add(a:lines, '')
call writefile(a:lines, a:destination, 'a')
endfunction
nnoremap cf :call CreateFunctionFromLine()<cr>A
nnoremap cu :call Cleanup()<cr>
iab cr9 <cr>()
let g:dotu = '.{-}'
function Count(s, el)
let matches = matchlist(a:s, Regexed('\ze' . a:el))
ec matches
endfunction
function CreateFunctionFromLine()
let line = CurrentLine()
let currentword = CurrentWord()
let wordindex = match(line, currentword . '(')
if wordindex > -1
let line = line[wordindex:]
endif
let line = Replace(line, 'a:', '', 'g')
let match = Strip(Match(line, '\w+\([a-zA-Z, ]+\)'))
if empty(match)
let match = Strip(matchstr(line, '\v\w*\ze\('))
else
let match = Replace(match, '''''', 's')
endif
call CreateFunctionBlock('bottom', match)
endfunction
"05-07-2021 12:08:17: i learned that it is mch mr conv 2 uz \v mode. u can directly use exprs lk '%subsitute'. u can rit lambda fncs. it is ezier to create anew than 2 edit. keeping function params to a bare minimum is extremely imp. folo th etiquit of th romans. u can append 2 othr buffers. it will be an endless hole to continue down.
function IsHtml()
return GetLang() == 'html'
endfunction
function ToggleKeyBindings()
execute ''
endfunction
"inoremap w[ <esc> IsHtml() ? ":call EnterBlock() <cr>a" : ":call HtmlHandler()) <cr>a"
function TextPlacement(lines, ...)
let spaces = a:0 == 2 ? a:1 : CurrentSpaces()
let lines = map(a:lines, {pos, line -> spaces . line})
call setline('.', lines[0])
call append('.', lines[1:])
endfunction
function Quotify(s, ...)
let dq = a:0 >= 1 ? a:1 : 0
if Exists(dq)
return '"' . a:s . '"'
endif
return '''' . a:s . ''''
endfunction
function OptionGetter(args, flags)
let store = []
let flags = split(a:flags, '\zs')
for i in range(0, len(flags) - 1)
"if i < len(a:args) && a:args[i] == flags[i]
if i < len(a:args)
call add(store, a:args[i])
else
call add(store, 0)