-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
1775 lines (1558 loc) · 64.8 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
" Vim configuration "
syntax on
filetype plugin indent on
set nocompatible
set relativenumber
set termguicolors
set t_Co=256
set cursorline
set smarttab
set tabstop=3
set expandtab
set shiftwidth=3
set softtabstop=3
set autoindent
set smartindent
set incsearch
set ignorecase
set smartcase
set magic
set nomodeline
set ttyfast
set lazyredraw
set clipboard=unnamedplus
set mouse=
set history=50
set timeout
set updatetime=150
set timeoutlen=300
set nobackup
set nowritebackup
set noswapfile
set nowrap
set noshowmatch
set conceallevel=0
set cmdheight=2
set laststatus=2
set wildmenu
set wildignore=.png,.jpg,.jpeg,.pyc
set encoding=utf-8
set fileencoding=utf-8
set scrolloff=8
set sidescrolloff=8
set foldenable
set hidden
set splitright
set splitbelow
set path=**
set background=dark
autocmd BufWinLeave *.* mkview
autocmd BufWinEnter *.* silent loadview
" Autopairs "
if exists('g:AutoPairsLoaded') || &cp
finish
end
let g:AutoPairsLoaded = 1
if !exists('g:AutoPairs')
let g:AutoPairs = {'(':')', '[':']', '{':'}',"'":"'",'"':'"', '`':'`'}
end
if !exists('g:AutoPairsParens')
let g:AutoPairsParens = {'(':')', '[':']', '{':'}'}
end
if !exists('g:AutoPairsMapBS')
let g:AutoPairsMapBS = 1
end
if !exists('g:AutoPairsMapCR')
let g:AutoPairsMapCR = 1
end
if !exists('g:AutoPairsMapSpace')
let g:AutoPairsMapSpace = 1
end
if !exists('g:AutoPairsCenterLine')
let g:AutoPairsCenterLine = 1
end
if !exists('g:AutoPairsShortcutToggle')
let g:AutoPairsShortcutToggle = '<M-p>'
end
if !exists('g:AutoPairsShortcutFastWrap')
let g:AutoPairsShortcutFastWrap = '<M-e>'
end
if !exists('g:AutoPairsShortcutJump')
let g:AutoPairsShortcutJump = '<M-n>'
endif
" Fly mode will for closed pair to jump to closed pair instead of insert.
" also support AutoPairsBackInsert to insert pairs where jumped.
if !exists('g:AutoPairsFlyMode')
let g:AutoPairsFlyMode = 0
endif
" Work with Fly Mode, insert pair where jumped
if !exists('g:AutoPairsShortcutBackInsert')
let g:AutoPairsShortcutBackInsert = '<M-b>'
endif
if !exists('g:AutoPairsSmartQuotes')
let g:AutoPairsSmartQuotes = 1
endif
" Will auto generated {']' => '[', ..., '}' => '{'}in initialize.
let g:AutoPairsClosedPairs = {}
function! AutoPairsInsert(key)
if !b:autopairs_enabled
return a:key
end
let line = getline('.')
let pos = col('.') - 1
let before = strpart(line, 0, pos)
let after = strpart(line, pos)
let next_chars = split(after, '\zs')
let current_char = get(next_chars, 0, '')
let next_char = get(next_chars, 1, '')
let prev_chars = split(before, '\zs')
let prev_char = get(prev_chars, -1, '')
let eol = 0
if col('$') - col('.') <= 1
let eol = 1
end
" Ignore auto close if prev character is \
if prev_char == '\'
return a:key
end
" The key is difference open-pair, then it means only for ) ] } by default
if !has_key(b:AutoPairs, a:key)
let b:autopairs_saved_pair = [a:key, getpos('.')]
" Skip the character if current character is the same as input
if current_char == a:key
return "\<Right>"
end
if !g:AutoPairsFlyMode
" Skip the character if next character is space
if current_char == ' ' && next_char == a:key
return "\<Right>\<Right>"
end
" Skip the character if closed pair is next character
if current_char == ''
let next_lineno = line('.')+1
let next_line = getline(nextnonblank(next_lineno))
let next_char = matchstr(next_line, '\s*\zs.')
if next_char == a:key
return "\<ESC>e^a"
endif
endif
endif
" Fly Mode, and the key is closed-pairs, search closed-pair and jump
if g:AutoPairsFlyMode && has_key(b:AutoPairsClosedPairs, a:key)
if search(a:key, 'W')
return "\<Right>"
endif
endif
" Insert directly if the key is not an open key
return a:key
end
let open = a:key
let close = b:AutoPairs[open]
if current_char == close && open == close
return "\<Right>"
end
" Ignore auto close ' if follows a word
" MUST after closed check. 'hello|'
if a:key == "'" && prev_char =~ '\v\w'
return a:key
end
" support for ''' ``` and """
if open == close
" The key must be ' " `
let pprev_char = line[col('.')-3]
if pprev_char == open && prev_char == open
" Double pair found
return repeat(a:key, 4) . repeat("\<LEFT>", 3)
end
end
let quotes_num = 0
" Ignore comment line for vim file
if &filetype == 'vim' && a:key == '"'
if before =~ '^\s*$'
return a:key
end
if before =~ '^\s*"'
let quotes_num = -1
end
end
" Keep quote number is odd.
" Because quotes should be matched in the same line in most of situation
if g:AutoPairsSmartQuotes && open == close
" Remove \\ \" \'
let cleaned_line = substitute(line, '\v(\\.)', '', 'g')
let n = quotes_num
let pos = 0
while 1
let pos = stridx(cleaned_line, open, pos)
if pos == -1
break
end
let n = n + 1
let pos = pos + 1
endwhile
if n % 2 == 1
return a:key
endif
endif
return open.close."\<Left>"
endfunction
function! AutoPairsDelete()
if !b:autopairs_enabled
return "\<BS>"
end
let line = getline('.')
let pos = col('.') - 1
let current_char = get(split(strpart(line, pos), '\zs'), 0, '')
let prev_chars = split(strpart(line, 0, pos), '\zs')
let prev_char = get(prev_chars, -1, '')
let pprev_char = get(prev_chars, -2, '')
if pprev_char == '\'
return "\<BS>"
end
" Delete last two spaces in parens, work with MapSpace
if has_key(b:AutoPairs, pprev_char) && prev_char == ' ' && current_char == ' '
return "\<BS>\<DEL>"
endif
" Delete Repeated Pair eg: '''|''' [[|]] {{|}}
if has_key(b:AutoPairs, prev_char)
let times = 0
let p = -1
while get(prev_chars, p, '') == prev_char
let p = p - 1
let times = times + 1
endwhile
let close = b:AutoPairs[prev_char]
let left = repeat(prev_char, times)
let right = repeat(close, times)
let before = strpart(line, pos-times, times)
let after = strpart(line, pos, times)
if left == before && right == after
return repeat("\<BS>\<DEL>", times)
end
end
if has_key(b:AutoPairs, prev_char)
let close = b:AutoPairs[prev_char]
if match(line,'^\s*'.close, col('.')-1) != -1
" Delete (|___)
let space = matchstr(line, '^\s*', col('.')-1)
return "\<BS>". repeat("\<DEL>", len(space)+1)
elseif match(line, '^\s*$', col('.')-1) != -1
" Delete (|__\n___)
let nline = getline(line('.')+1)
if nline =~ '^\s*'.close
if &filetype == 'vim' && prev_char == '"'
" Keep next line's comment
return "\<BS>"
end
let space = matchstr(nline, '^\s*')
return "\<BS>\<DEL>". repeat("\<DEL>", len(space)+1)
end
end
end
return "\<BS>"
endfunction
function! AutoPairsJump()
call search('["\]'')}]','W')
endfunction
" string_chunk cannot use standalone
let s:string_chunk = '\v%(\\\_.|[^\1]|[\r\n]){-}'
let s:ss_pattern = '\v''' . s:string_chunk . ''''
let s:ds_pattern = '\v"' . s:string_chunk . '"'
func! s:RegexpQuote(str)
return substitute(a:str, '\v[\[\{\(\<\>\)\}\]]', '\\&', 'g')
endf
func! s:RegexpQuoteInSquare(str)
return substitute(a:str, '\v[\[\]]', '\\&', 'g')
endf
" Search next open or close pair
func! s:FormatChunk(open, close)
let open = s:RegexpQuote(a:open)
let close = s:RegexpQuote(a:close)
let open2 = s:RegexpQuoteInSquare(a:open)
let close2 = s:RegexpQuoteInSquare(a:close)
if open == close
return '\v'.open.s:string_chunk.close
else
return '\v%(' . s:ss_pattern . '|' . s:ds_pattern . '|' . '[^'.open2.close2.']|[\r\n]' . '){-}(['.open2.close2.'])'
end
endf
" Fast wrap the word in brackets
function! AutoPairsFastWrap()
let line = getline('.')
let current_char = line[col('.')-1]
let next_char = line[col('.')]
let open_pair_pattern = '\v[({\[''"]'
let at_end = col('.') >= col('$') - 1
normal x
" Skip blank
if next_char =~ '\v\s' || at_end
call search('\v\S', 'W')
let line = getline('.')
let next_char = line[col('.')-1]
end
if has_key(b:AutoPairs, next_char)
let followed_open_pair = next_char
let inputed_close_pair = current_char
let followed_close_pair = b:AutoPairs[next_char]
if followed_close_pair != followed_open_pair
" TODO replace system searchpair to skip string and nested pair.
" eg: (|){"hello}world"} will transform to ({"hello})world"}
call searchpair('\V'.followed_open_pair, '', '\V'.followed_close_pair, 'W')
else
call search(s:FormatChunk(followed_open_pair, followed_close_pair), 'We')
end
return "\<RIGHT>".inputed_close_pair."\<LEFT>"
else
normal he
return "\<RIGHT>".current_char."\<LEFT>"
end
endfunction
function! AutoPairsMap(key)
" | is special key which separate map command from text
let key = a:key
if key == '|'
let key = '<BAR>'
end
let escaped_key = substitute(key, "'", "''", 'g')
" use expr will cause search() doesn't work
execute 'inoremap <buffer> <silent> '.key." <C-R>=AutoPairsInsert('".escaped_key."')<CR>"
endfunction
function! AutoPairsToggle()
if b:autopairs_enabled
let b:autopairs_enabled = 0
echo 'AutoPairs Disabled.'
else
let b:autopairs_enabled = 1
echo 'AutoPairs Enabled.'
end
return ''
endfunction
function! AutoPairsReturn()
if b:autopairs_enabled == 0
return ''
end
let line = getline('.')
let pline = getline(line('.')-1)
let prev_char = pline[strlen(pline)-1]
let cmd = ''
let cur_char = line[col('.')-1]
if has_key(b:AutoPairs, prev_char) && b:AutoPairs[prev_char] == cur_char
if g:AutoPairsCenterLine && winline() * 3 >= winheight(0) * 2
" Use \<BS> instead of \<ESC>cl will cause the placeholder deleted
" incorrect. because <C-O>zz won't leave Normal mode.
" Use \<DEL> is a bit wierd. the character before cursor need to be deleted.
let cmd = " \<C-O>zz\<ESC>cl"
end
" If equalprg has been set, then avoid call =
" https://github.com/jiangmiao/auto-pairs/issues/24
if &equalprg != ''
return "\<ESC>O".cmd
endif
" conflict with javascript and coffee
" javascript need indent new line
" coffeescript forbid indent new line
if &filetype == 'coffeescript' || &filetype == 'coffee'
return "\<ESC>k==o".cmd
else
return "\<ESC>=ko".cmd
endif
end
return ''
endfunction
function! AutoPairsSpace()
let line = getline('.')
let prev_char = line[col('.')-2]
let cmd = ''
let cur_char =line[col('.')-1]
if has_key(g:AutoPairsParens, prev_char) && g:AutoPairsParens[prev_char] == cur_char
let cmd = "\<SPACE>\<LEFT>"
endif
return "\<SPACE>".cmd
endfunction
function! AutoPairsBackInsert()
if exists('b:autopairs_saved_pair')
let pair = b:autopairs_saved_pair[0]
let pos = b:autopairs_saved_pair[1]
call setpos('.', pos)
return pair
endif
return ''
endfunction
function! AutoPairsInit()
let b:autopairs_loaded = 1
let b:autopairs_enabled = 1
let b:AutoPairsClosedPairs = {}
if !exists('b:AutoPairs')
let b:AutoPairs = g:AutoPairs
end
" buffer level map pairs keys
for [open, close] in items(b:AutoPairs)
call AutoPairsMap(open)
if open != close
call AutoPairsMap(close)
end
let b:AutoPairsClosedPairs[close] = open
endfor
" Still use <buffer> level mapping for <BS> <SPACE>
if g:AutoPairsMapBS
" Use <C-R> instead of <expr> for issue #14 sometimes press BS output strange words
execute 'inoremap <buffer> <silent> <BS> <C-R>=AutoPairsDelete()<CR>'
execute 'inoremap <buffer> <silent> <C-H> <C-R>=AutoPairsDelete()<CR>'
end
if g:AutoPairsMapSpace
" Try to respect abbreviations on a <SPACE>
let do_abbrev = ""
if v:version >= 703 && has("patch489")
let do_abbrev = "<C-]>"
endif
execute 'inoremap <buffer> <silent> <SPACE> '.do_abbrev.'<C-R>=AutoPairsSpace()<CR>'
end
if g:AutoPairsShortcutFastWrap != ''
execute 'inoremap <buffer> <silent> '.g:AutoPairsShortcutFastWrap.' <C-R>=AutoPairsFastWrap()<CR>'
end
if g:AutoPairsShortcutBackInsert != ''
execute 'inoremap <buffer> <silent> '.g:AutoPairsShortcutBackInsert.' <C-R>=AutoPairsBackInsert()<CR>'
end
if g:AutoPairsShortcutToggle != ''
" use <expr> to ensure showing the status when toggle
execute 'inoremap <buffer> <silent> <expr> '.g:AutoPairsShortcutToggle.' AutoPairsToggle()'
execute 'noremap <buffer> <silent> '.g:AutoPairsShortcutToggle.' :call AutoPairsToggle()<CR>'
end
if g:AutoPairsShortcutJump != ''
execute 'inoremap <buffer> <silent> ' . g:AutoPairsShortcutJump. ' <ESC>:call AutoPairsJump()<CR>a'
execute 'noremap <buffer> <silent> ' . g:AutoPairsShortcutJump. ' :call AutoPairsJump()<CR>'
end
endfunction
function! s:ExpandMap(map)
let map = a:map
let map = substitute(map, '\(<Plug>\w\+\)', '\=maparg(submatch(1), "i")', 'g')
return map
endfunction
function! AutoPairsTryInit()
if exists('b:autopairs_loaded')
return
end
" for auto-pairs starts with 'a', so the priority is higher than supertab and vim-endwise
"
" vim-endwise doesn't support <Plug>AutoPairsReturn
" when use <Plug>AutoPairsReturn will cause <Plug> isn't expanded
"
" supertab doesn't support <SID>AutoPairsReturn
" when use <SID>AutoPairsReturn will cause Duplicated <CR>
"
" and when load after vim-endwise will cause unexpected endwise inserted.
" so always load AutoPairs at last
" Buffer level keys mapping
" comptible with other plugin
if g:AutoPairsMapCR
if v:version >= 703 && has('patch32')
" VIM 7.3 supports advancer maparg which could get <expr> info
" then auto-pairs could remap <CR> in any case.
let info = maparg('<CR>', 'i', 0, 1)
if empty(info)
let old_cr = '<CR>'
let is_expr = 0
else
let old_cr = info['rhs']
let old_cr = s:ExpandMap(old_cr)
let old_cr = substitute(old_cr, '<SID>', '<SNR>' . info['sid'] . '_', 'g')
let is_expr = info['expr']
let wrapper_name = '<SID>AutoPairsOldCRWrapper73'
endif
else
" VIM version less than 7.3
" the mapping's <expr> info is lost, so guess it is expr or not, it's
" not accurate.
let old_cr = maparg('<CR>', 'i')
if old_cr == ''
let old_cr = '<CR>'
let is_expr = 0
else
let old_cr = s:ExpandMap(old_cr)
" old_cr contain (, I guess the old cr is in expr mode
let is_expr = old_cr =~ '\V(' && toupper(old_cr) !~ '\V<C-R>'
let wrapper_name = '<SID>AutoPairsOldCRWrapper'
end
end
if old_cr !~ 'AutoPairsReturn'
if is_expr
" remap <expr> to `name` to avoid mix expr and non-expr mode
execute 'inoremap <buffer> <expr> <script> '. wrapper_name . ' ' . old_cr
let old_cr = wrapper_name
end
" Always silent mapping
execute 'inoremap <script> <buffer> <silent> <CR> '.old_cr.'<SID>AutoPairsReturn'
end
endif
call AutoPairsInit()
endfunction
" Always silent the command
inoremap <silent> <SID>AutoPairsReturn <C-R>=AutoPairsReturn()<CR>
imap <script> <Plug>AutoPairsReturn <SID>AutoPairsReturn
au BufEnter * :call AutoPairsTryInit()
" Statusline "
set statusline=
set statusline+=%7*\[%n] "buffernr
set statusline+=%1*\ %<%f\ "File
set statusline+=%2*\ %y\ "FileType
set statusline+=%3*\ %{''.(&fenc!=''?&fenc:&enc).''} "Encoding
set statusline+=%3*\ %{(&bomb?\",BOM\":\"\")}\ "Encoding2
set statusline+=%4*\ %{&ff}\ "FileFormat (dos/unix..)
set statusline+=%5*\ %{&spelllang}\%{HighlightSearch()}\ "Spellanguage & Highlight on?
set statusline+=%8*\ %=\ row:%l/%L\ (%03p%%)\ "Rownumber/total (%)
set statusline+=%9*\ col:%03c\ "Colnr
set statusline+=%0*\ \ %m%r%w\ %P\ \
function! HighlightSearch()
if &hls
return 'H'
else
return ''
endif
endfunction
hi User1 guifg=#ffdad8 guibg=#880c0e
hi User2 guifg=#000000 guibg=#F4905C
hi User3 guifg=#292b00 guibg=#f4f597
hi User4 guifg=#112605 guibg=#aefe7B
hi User5 guifg=#051d00 guibg=#7dcc7d
hi User7 guifg=#ffffff guibg=#880c0e gui=bold
hi User8 guifg=#ffffff guibg=#5b7fbb
hi User9 guifg=#ffffff guibg=#810085
hi User0 guifg=#ffffff guibg=#094afe
" Keymaps "
let mapleader=' '
nmap <silent> <leader>x :wq<CR>
" Colorscheme "
if exists('g:colors_name')
highlight clear
if exists('syntax_on')
syntax reset
endif
endif
let g:colors_name='nightfly'
" Please check that Vim/Neovim is able to run this true-color only theme.
"
" If running in a terminal make sure termguicolors exists and is set.
if has('nvim')
if has('nvim-0.4') && len(nvim_list_uis()) > 0 && nvim_list_uis()[0]['ext_termcolors'] && !&termguicolors
" The nvim_list_uis test indicates terminal Neovim vs GUI Neovim.
" Note, versions prior to Neovim 0.4 did not set 'ext_termcolors'.
echomsg 'The termguicolors option must be set'
finish
endif
else " Vim
if !has('gui_running') && !exists('&termguicolors')
echomsg 'A modern version of Vim with termguicolors is required'
finish
elseif !has('gui_running') && !&termguicolors
echomsg 'The termguicolors option must be set'
echomsg 'Be aware macOS default Vim is broken, use Homebrew Vim instead'
finish
endif
endif
" By default do not color the cursor.
let g:nightflyCursorColor = get(g:, 'nightflyCursorColor', v:false)
" By default do use italics in GUI versions of Vim.
let g:nightflyItalics = get(g:, 'nightflyItalics', v:true)
" By default do not use a customized 'NormalFloat' highlight group (for Neovim
" floating windows).
let g:nightflyNormalFloat = get(g:, 'nightflyNormalFloat', v:false)
" By default use the nightly color palette in the `:terminal`
let g:nightflyTerminalColors = get(g:, 'nightflyTerminalColors', v:true)
" By default do not use a transparent background in GUI versions of Vim.
let g:nightflyTransparent = get(g:, 'nightflyTransparent', v:false)
" By default do use undercurls in GUI versions of Vim, including terminal Vim
" with termguicolors set.
let g:nightflyUndercurls = get(g:, 'nightflyUndercurls', v:true)
" By default do not underline matching parentheses.
let g:nightflyUnderlineMatchParen = get(g:, 'nightflyUnderlineMatchParen', v:false)
" By default do display vertical split columns.
let g:nightflyWinSeparator = get(g:, 'nightflyWinSeparator', 1)
" Background and foreground
let s:black = '#011627'
let s:white = '#c3ccdc'
" Variations of blue-grey
let s:black_blue = '#081e2f'
let s:dark_blue = '#092236'
let s:deep_blue = '#0e293f'
let s:slate_blue = '#2c3043'
let s:regal_blue = '#1d3b53'
let s:steel_blue = '#4b6479'
let s:grey_blue = '#7c8f8f'
let s:cadet_blue = '#a1aab8'
let s:ash_blue = '#acb4c2'
let s:white_blue = '#d6deeb'
" Core theme colors
let s:yellow = '#e3d18a'
let s:peach = '#ffcb8b'
let s:tan = '#ecc48d'
let s:orange = '#f78c6c'
let s:red = '#fc514e'
let s:watermelon = '#ff5874'
let s:violet = '#c792ea'
let s:purple = '#ae81ff'
let s:indigo = '#5e97ec'
let s:blue = '#82aaff'
let s:turquoise = '#7fdbca'
let s:emerald = '#21c7a8'
let s:green = '#a1cd5e'
" Extra colors
let s:cyan_blue = '#296596'
" Specify the colors used by the inbuilt terminal of Neovim and Vim
if g:nightflyTerminalColors
if has('nvim')
let g:terminal_color_0 = s:regal_blue
let g:terminal_color_1 = s:red
let g:terminal_color_2 = s:green
let g:terminal_color_3 = s:yellow
let g:terminal_color_4 = s:blue
let g:terminal_color_5 = s:violet
let g:terminal_color_6 = s:turquoise
let g:terminal_color_7 = s:white
let g:terminal_color_8 = s:grey_blue
let g:terminal_color_9 = s:watermelon
let g:terminal_color_10 = s:emerald
let g:terminal_color_11 = s:tan
let g:terminal_color_12 = s:blue
let g:terminal_color_13 = s:purple
let g:terminal_color_14 = s:turquoise
let g:terminal_color_15 = s:white_blue
else
let g:terminal_ansi_colors = [
\ s:regal_blue, s:red, s:green, s:yellow,
\ s:blue, s:violet, s:turquoise, s:white,
\ s:grey_blue, s:watermelon, s:emerald, s:tan,
\ s:blue, s:purple, s:turquoise, s:white_blue
\]
endif
endif
" Background and text
if g:nightflyTransparent
exec 'highlight Normal guibg=NONE' . ' guifg=' . s:white
else
exec 'highlight Normal guibg=' . s:black . ' guifg=' . s:white
endif
" Custom nightfly highlight groups
exec 'highlight NightflyReset guifg=fg'
exec 'highlight NightflyVisual guibg=' . s:regal_blue
exec 'highlight NightflyWhite guifg=' . s:white
exec 'highlight NightflyDeepBlue guifg=' . s:deep_blue
exec 'highlight NightflySlateBlue guifg=' . s:slate_blue
exec 'highlight NightflyRegalBlue guifg=' . s:regal_blue
exec 'highlight NightflySteelBlue guifg=' . s:steel_blue
exec 'highlight NightflyGreyBlue guifg=' . s:grey_blue
exec 'highlight NightflyCadetBlue guifg=' . s:cadet_blue
exec 'highlight NightflyAshBlue guifg=' . s:ash_blue
exec 'highlight NightflyWhiteBlue guifg=' . s:white_blue
exec 'highlight NightflyYellow guifg=' . s:yellow
exec 'highlight NightflyPeach guifg=' . s:peach
exec 'highlight NightflyTan guifg=' . s:tan
exec 'highlight NightflyOrange guifg=' . s:orange
exec 'highlight NightflyRed guifg=' . s:red
exec 'highlight NightflyWatermelon guifg=' . s:watermelon
exec 'highlight NightflyViolet guifg=' . s:violet
exec 'highlight NightflyPurple guifg=' . s:purple
exec 'highlight NightflyBlue guifg=' . s:blue
exec 'highlight NightflyIndigo guifg=' . s:indigo
exec 'highlight NightflyTurquoise guifg=' . s:turquoise
exec 'highlight NightflyEmerald guifg=' . s:emerald
exec 'highlight NightflyGreen guifg=' . s:green
exec 'highlight NightflyWhiteAlert guibg=bg guifg=' . s:white
exec 'highlight NightflyCadetBlueAlert guibg=bg guifg=' . s:cadet_blue
exec 'highlight NightflyYellowAlert guibg=bg guifg=' . s:yellow
exec 'highlight NightflyOrangeAlert guibg=bg guifg=' . s:orange
exec 'highlight NightflyRedAlert guibg=bg guifg=' . s:red
exec 'highlight NightflyPurpleAlert guibg=bg guifg=' . s:purple
exec 'highlight NightflyBlueAlert guibg=bg guifg=' . s:blue
exec 'highlight NightflyEmeraldAlert guibg=bg guifg=' . s:emerald
exec 'highlight NightflyUnderline gui=underline'
exec 'highlight NightflyNoCombine gui=nocombine'
" Statusline helper colors.
exec 'highlight NightflyBlueMode guibg=' . s:blue . ' guifg=' . s:dark_blue
exec 'highlight NightflyEmeraldMode guibg=' . s:emerald . ' guifg=' . s:dark_blue
exec 'highlight NightflyPurpleMode guibg=' . s:purple . ' guifg=' . s:dark_blue
exec 'highlight NightflyWatermelonMode guibg=' . s:watermelon . ' guifg=' . s:dark_blue
exec 'highlight NightflyTanMode guibg=' . s:tan . ' guifg=' . s:dark_blue
exec 'highlight NightflyTurquoiseMode guibg=' . s:turquoise . ' guifg=' . s:dark_blue
" Tabline helper colors.
exec 'highlight NightflyBlueLine guibg=' . s:slate_blue . ' guifg=' . s:blue
exec 'highlight NightflyBlueLineActive guibg=' . s:regal_blue . ' guifg=' . s:blue
exec 'highlight NightflyCadetBlueLine guibg=' . s:slate_blue . ' guifg=' . s:cadet_blue
exec 'highlight NightflyEmeraldLine guibg=' . s:slate_blue . ' guifg=' . s:emerald
exec 'highlight NightflyEmeraldLineActive guibg=' . s:regal_blue . ' guifg=' . s:emerald
exec 'highlight NightflyGreyBlueLine guibg=' . s:dark_blue . ' guifg=' . s:grey_blue
exec 'highlight NightflyTanLine guibg=' . s:dark_blue . ' guifg=' . s:tan
exec 'highlight NightflyTanLineActive guibg=' . s:regal_blue . ' guifg=' . s:tan
exec 'highlight NightflyWhiteLineActive guibg=' . s:regal_blue . ' guifg=' . s:white_blue
" Color of mode text, -- INSERT --
exec 'highlight ModeMsg guifg=' . s:cadet_blue . ' gui=none'
" Comments
if g:nightflyItalics
exec 'highlight Comment guifg=' . s:grey_blue . ' gui=italic'
else
exec 'highlight Comment guifg=' . s:grey_blue
endif
" Functions
highlight! link Function NightflyBlue
" Strings
highlight! link String NightflyTan
" Booleans
highlight! link Boolean NightflyWatermelon
" Identifiers
highlight! link Identifier NightflyTurquoise
" Color of titles
exec 'highlight Title guifg=' . s:orange . ' gui=none'
" const, static
highlight! link StorageClass NightflyOrange
" void, intptr_t
exec 'highlight Type guifg=' . s:emerald . ' gui=none'
" Numbers
highlight! link Constant NightflyOrange
" Character constants
highlight! link Character NightflyPurple
" Exceptions
highlight! link Exception NightflyWatermelon
" ifdef/endif
highlight! link PreProc NightflyWatermelon
" case in switch statement
highlight! link Label NightflyTurquoise
" end-of-line '$', end-of-file '~'
exec 'highlight NonText guifg=' . s:steel_blue . ' gui=none'
" sizeof
highlight! link Operator NightflyWatermelon
" for, while
highlight! link Repeat NightflyViolet
" Search
exec 'highlight Search guibg=bg guifg=' . s:orange . ' gui=reverse'
exec 'highlight IncSearch guibg=bg guifg=' . s:peach
" '\n' sequences
highlight! link Special NightflyWatermelon
" if, else
exec 'highlight Statement guifg=' . s:violet . ' gui=none'
" struct, union, enum, typedef
highlight! link Structure NightflyIndigo
" Statusline, splits and tab lines
exec 'highlight StatusLine cterm=none guibg=' . s:slate_blue . ' guifg=' . s:white . ' gui=none'
exec 'highlight StatusLineNC cterm=none guibg=' . s:slate_blue . ' guifg=' . s:cadet_blue . ' gui=none'
exec 'highlight Tabline cterm=none guibg=' . s:slate_blue . ' guifg=' . s:cadet_blue . ' gui=none'
exec 'highlight TablineSel cterm=none guibg=' . s:dark_blue . ' guifg=' . s:blue . ' gui=none'
exec 'highlight TablineSelSymbol cterm=none guibg=' . s:dark_blue . ' guifg=' . s:emerald . ' gui=none'
exec 'highlight TablineFill cterm=none guibg=' . s:slate_blue . ' guifg=' . s:slate_blue . ' gui=none'
exec 'highlight StatusLineTerm cterm=none guibg=' . s:slate_blue . ' guifg=' . s:white . ' gui=none'
exec 'highlight StatusLineTermNC cterm=none guibg=' . s:slate_blue . ' guifg=' . s:cadet_blue . ' gui=none'
if g:nightflyWinSeparator == 0
exec 'highlight VertSplit cterm=none guibg=' . s:black . ' guifg=' . s:black . ' gui=none'
elseif g:nightflyWinSeparator == 1
exec 'highlight VertSplit cterm=none guibg=' . s:slate_blue . ' guifg=' . s:slate_blue . ' gui=none'
else
exec 'highlight VertSplit guibg=NONE guifg=' . s:slate_blue . ' gui=none'
end
" Visual selection
highlight! link Visual NightflyVisual
exec 'highlight VisualNOS guibg=' . s:regal_blue . ' guifg=fg gui=none'
exec 'highlight VisualInDiff guibg=' . s:regal_blue . ' guifg=' . s:white
" Errors, warnings and whitespace-eol
exec 'highlight Error guibg=bg guifg=' . s:red
exec 'highlight ErrorMsg guibg=bg guifg=' . s:red
exec 'highlight WarningMsg guibg=bg guifg=' . s:orange
" Auto-text-completion menu
exec 'highlight Pmenu guibg=' . s:deep_blue . ' guifg=fg'
exec 'highlight PmenuSel guibg=' . s:cyan_blue . ' guifg=' . s:white_blue
exec 'highlight PmenuSbar guibg=' . s:deep_blue
exec 'highlight PmenuThumb guibg=' . s:steel_blue
exec 'highlight WildMenu guibg=' . s:cyan_blue . ' guifg=' . s:white_blue
" Spelling errors
if g:nightflyUndercurls
exec 'highlight SpellBad ctermbg=NONE cterm=underline guibg=NONE gui=undercurl guisp=' . s:red
exec 'highlight SpellCap ctermbg=NONE cterm=underline guibg=NONE gui=undercurl guisp=' . s:blue
exec 'highlight SpellRare ctermbg=NONE cterm=underline guibg=NONE gui=undercurl guisp=' . s:yellow
exec 'highlight SpellLocal ctermbg=NONE cterm=underline guibg=NONE gui=undercurl guisp=' . s:blue
else
exec 'highlight SpellBad ctermbg=NONE cterm=underline guibg=NONE guifg=' . s:red . ' gui=underline guisp=' . s:red
exec 'highlight SpellCap ctermbg=NONE cterm=underline guibg=NONE guifg=' . s:blue . ' gui=underline guisp=' . s:blue
exec 'highlight SpellRare ctermbg=NONE cterm=underline guibg=NONE guifg=' . s:yellow . ' gui=underline guisp=' . s:yellow
exec 'highlight SpellLocal ctermbg=NONE cterm=underline guibg=NONE guifg=' . s:blue . ' gui=underline guisp=' . s:blue
endif
" Misc
exec 'highlight Question guifg=' . s:green . ' gui=none'
exec 'highlight MoreMsg guifg=' . s:red . ' gui=none'
exec 'highlight LineNr guibg=bg guifg=' . s:steel_blue . ' gui=none'
if g:nightflyCursorColor
exec 'highlight Cursor guifg=bg guibg=' . s:blue
else
exec 'highlight Cursor guifg=bg guibg=' . s:cadet_blue
endif
exec 'highlight lCursor guifg=bg guibg=' . s:cadet_blue
exec 'highlight CursorLineNr cterm=none guibg=' . s:dark_blue . ' guifg=' . s:blue . ' gui=none'
exec 'highlight CursorColumn guibg=' . s:dark_blue
exec 'highlight CursorLine cterm=none guibg=' . s:dark_blue
exec 'highlight Folded guibg=' . s:dark_blue . ' guifg='. s:green
exec 'highlight FoldColumn guibg=' . s:slate_blue . ' guifg=' . s:green
exec 'highlight SignColumn guibg=bg guifg=' . s:green
exec 'highlight Todo guibg=' . s:yellow . ' guifg=' . s:black
exec 'highlight SpecialKey guibg=bg guifg=' . s:blue
if g:nightflyUnderlineMatchParen
exec 'highlight MatchParen guibg=bg gui=underline'
else
highlight! link MatchParen NightflyVisual
endif
exec 'highlight Ignore guifg=' . s:blue
exec 'highlight Underlined guifg=' . s:green . ' gui=none'
exec 'highlight QuickFixLine guibg=' . s:deep_blue
highlight! link Delimiter NightflyWhite
highlight! link qfFileName NightflyEmerald
" Color column (after line 80)
exec 'highlight ColorColumn guibg=' . s:black_blue
" Conceal color
exec 'highlight Conceal guibg=NONE guifg=' . s:ash_blue
" Neovim only highlight groups
if has('nvim')
exec 'highlight Whitespace guifg=' . s:regal_blue
exec 'highlight TermCursor guibg=' . s:cadet_blue . ' guifg=bg gui=none'
if g:nightflyNormalFloat
exec 'highlight NormalFloat guibg=bg guifg=' . s:cadet_blue
else
exec 'highlight NormalFloat guibg=' . s:dark_blue . ' guifg=fg'
endif
exec 'highlight FloatBorder guibg=bg guifg=' . s:slate_blue
exec 'highlight WinBar cterm=none guibg=' . s:deep_blue . ' guifg=' . s:white . ' gui=none'
exec 'highlight WinBarNC cterm=none guibg=' . s:deep_blue . ' guifg=' . s:cadet_blue . ' gui=none'
highlight! link WinSeparator VertSplit
" Neovim Treesitter
highlight! link TSAnnotation NightflyViolet
highlight! link TSAttribute NightflyBlue
highlight! link TSConstant NightflyTurquoise
highlight! link TSConstBuiltin NightflyGreen
highlight! link TSConstMacro NightflyViolet
highlight! link TSConstructor NightflyEmerald
highlight! link TSFuncBuiltin NightflyBlue
highlight! link TSFuncMacro NightflyBlue
highlight! link TSInclude NightflyWatermelon
highlight! link TSKeywordOperator NightflyViolet
highlight! link TSNamespace NightflyTurquoise
highlight! link TSParameter NightflyWhite
highlight! link TSPunctSpecial NightflyWatermelon
highlight! link TSSymbol NightflyPurple
highlight! link TSTag NightflyBlue
highlight! link TSTagDelimiter NightflyGreen
highlight! link TSVariableBuiltin NightflyGreen
highlight! link bashTSParameter NightflyTurquoise
highlight! link cssTSPunctDelimiter NightflyWatermelon
highlight! link cssTSType NightflyBlue
highlight! link scssTSPunctDelimiter NightflyWatermelon
highlight! link scssTSType NightflyBlue
highlight! link scssTSVariable NightflyTurquoise