forked from nvim-lua/kickstart.nvim
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.lua
More file actions
2118 lines (1901 loc) · 89.2 KB
/
init.lua
File metadata and controls
2118 lines (1901 loc) · 89.2 KB
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
--[[
{{{
=====================================================================
==================== READ THIS BEFORE CONTINUING ====================
=====================================================================
======== .-----. ========
======== .----------------------. | === | ========
======== |.-""""""""""""""""""-.| |-----| ========
======== || || | === | ========
======== || KICKSTART.NVIM || |-----| ========
======== || || | === | ========
======== || || |-----| ========
======== ||:Tutor || |:::::| ========
======== |'-..................-'| |____o| ========
======== `"")----------------(""` ___________ ========
======== /::::::::::| |::::::::::\ \ no mouse \ ========
======== /:::========| |==hjkl==:::\ \ required \ ========
======== '""""""""""""' '""""""""""""' '""""""""""' ========
======== ========
=====================================================================
=====================================================================
What is Kickstart?
Kickstart.nvim is *not* a distribution.
Kickstart.nvim is a starting point for your own configuration.
The goal is that you can read every line of code, top-to-bottom, understand
what your configuration is doing, and modify it to suit your needs.
Once you've done that, you can start exploring, configuring and tinkering to
make Neovim your own! That might mean leaving Kickstart just the way it is for a while
or immediately breaking it into modular pieces. It's up to you!
If you don't know anything about Lua, I recommend taking some time to read through
a guide. One possible example which will only take 10-15 minutes:
- https://learnxinyminutes.com/docs/lua/
After understanding a bit more about Lua, you can use `:help lua-guide` as a
reference for how Neovim integrates Lua.
- :help lua-guide
- (or HTML version): https://neovim.io/doc/user/lua-guide.html
Kickstart Guide:
TODO: The very first thing you should do is to run the command `:Tutor` in Neovim.
If you don't know what this means, type the following:
- <escape key>
- :
- Tutor
- <enter key>
(If you already know the Neovim basics, you can skip this step.)
Once you've completed that, you can continue working through **AND READING** the rest
of the kickstart init.lua.
Next, run AND READ `:help`.
This will open up a help window with some basic information
about reading, navigating and searching the builtin help documentation.
This should be the first place you go to look when you're stuck or confused
with something. It's one of my favorite Neovim features.
MOST IMPORTANTLY, we provide a keymap "<space>sh" to [s]earch the [h]elp documentation,
which is very useful when you're not exactly sure of what you're looking for.
I have left several `:help X` comments throughout the init.lua
These are hints about where to find more information about the relevant settings,
plugins or Neovim features used in Kickstart.
NOTE: Look for lines like this
Throughout the file. These are for you, the reader, to help you understand what is happening.
Feel free to delete them once you know what you're doing, but they should serve as a guide
for when you are first encountering a few different constructs in your Neovim config.
If you experience any errors while trying to install kickstart, run `:checkhealth` for more info.
I hope you enjoy your Neovim journey,
- TJ
P.S. You can delete this when you're done too. It's your config now! :)
}}}
--]]
-- Set <space> as the leader key
-- See `:help mapleader`
-- NOTE: Must happen before plugins are loaded (otherwise wrong leader will be used)
vim.g.mapleader = ' '
vim.g.maplocalleader = ' '
-- Set to true if you have a Nerd Font installed and selected in the terminal
vim.g.have_nerd_font = true
-- [[ Setting options ]] {{{
-- See `:help vim.o`
-- NOTE: You can change these options as you wish!
-- For more options, you can see `:help option-list`
-- Make line numbers default
vim.o.number = true
-- You can also add relative line numbers, to help with jumping.
-- Experiment for yourself to see if you like it!
-- vim.o.relativenumber = true
-- Enable mouse mode, can be useful for resizing splits for example!
vim.o.mouse = 'a'
-- Don't show the mode, since it's already in the status line
vim.o.showmode = false
-- Sync clipboard between OS and Neovim.
-- Schedule the setting after `UiEnter` because it can increase startup-time.
-- Remove this option if you want your OS clipboard to remain independent.
-- See `:help 'clipboard'`
vim.schedule(function()
vim.o.clipboard = 'unnamedplus'
end)
-- Enable break indent
vim.o.breakindent = true
-- Save undo history
vim.o.undofile = true
-- Case-insensitive searching UNLESS \C or one or more capital letters in the search term
vim.o.ignorecase = true
vim.o.smartcase = true
-- Keep signcolumn on by default
vim.o.signcolumn = 'yes'
-- Decrease update time
vim.o.updatetime = 250
-- Decrease mapped sequence wait time
-- Displays which-key popup sooner
vim.o.timeoutlen = 300
-- Configure how new splits should be opened
vim.o.splitright = true
vim.o.splitbelow = true
-- Sets how neovim will display certain whitespace characters in the editor.
-- See `:help 'list'`
-- and `:help 'listchars'`
--
-- Notice listchars is set using `vim.opt` instead of `vim.o`.
-- It is very similar to `vim.o` but offers an interface for conveniently interacting with tables.
-- See `:help lua-options`
-- and `:help lua-options-guide`
vim.o.list = true
vim.opt.listchars = { tab = '» ', trail = '·', nbsp = '␣' }
-- Preview substitutions live, as you type!
vim.o.inccommand = 'split'
-- Show which line your cursor is on
vim.o.cursorline = true
-- Minimal number of screen lines to keep above and below the cursor.
vim.o.scrolloff = 10
-- if performing an operation that would fail due to unsaved changes in the buffer (like `:q`),
-- instead raise a dialog asking if you wish to save the current file(s)
-- See `:help 'confirm'`
vim.o.confirm = true
-- }}} [[ Setting options ]]
-- [[ Setting more options ]] {{{
-- Set highlight on search
vim.o.hlsearch = false
vim.o.autoindent = true -- Copy indent from current line when starting a new line.
vim.o.belloff = 'all' -- Turn off bell for everything.
vim.o.colorcolumn = '+1' -- Highlight column at textwidth.
vim.o.complete = '.,w,b,u,t' -- Better Completion
-- Set completeopt to have a better completion experience
-- vim.o.completeopt = 'menuone,noselect'
vim.o.completeopt = 'longest,menuone,preview'
vim.opt.cpoptions:append 'J' -- Two spaces after a sentence.
vim.o.encoding = 'utf-8'
vim.o.expandtab = true -- Insert spaces instead of real <tab> characters.
vim.o.fillchars = 'diff:⣿,vert:┃,stl:='
vim.o.formatoptions = 'qrn1j'
vim.o.hidden = true -- Allow modified buffers to be hidden.
vim.o.history = 1000 -- History of ":" commands.
vim.o.ignorecase = true -- Ignore case when searching.
vim.o.laststatus = 2 -- Always show status line.
vim.o.lazyredraw = true -- Don't redraw while executing macros, registers, commands.
vim.o.linebreak = true -- Wrap long lines at a character in 'breakat' rather
-- than last char that fits on the screen.
vim.o.list = true -- Show tabs, end-of-line.
-- Show tabs, end-of-line, line continuation.
vim.o.listchars = 'tab:▸\\ ,eol:¬,extends:❯,precedes:❮'
-- Add < and > to matchpairs for html editing.
vim.o.matchpairs = '(:),{:},[:],<:>'
vim.o.modeline = true -- Enable vim modeline by default.
vim.o.mouse = 'a' -- Allow mouse use even in a xterm, in tmux.
vim.o.equalalways = false -- Do not keep windows the same height when splitting.
vim.o.number = true -- Show line numbers.
vim.o.relativenumber = true -- Show relative line numbers around current line.
vim.o.ruler = true -- Show line, column numbers, cursor position.
vim.o.scrolloff = 0 -- Show NO context above/below cursorline.
vim.o.shiftround = true -- Round indent to multiple of 'shiftwidth'.
vim.o.shiftwidth = 4 -- Number of spaces shifted with >> and <<.
vim.o.showbreak = '↪' -- String to put at the start of wrapped lines.
vim.o.showcmd = true -- Show number of selected lines in visual mode.
vim.o.sidescroll = 1 -- Scroll horizontally 1 column at a time.
vim.o.sidescrolloff = 0 -- Scroll horizontally all the way to the edge.
vim.o.smartcase = true -- Override ignorecase when capitals used in search.
vim.o.splitbelow = true -- Put new window below current one when splitting.
vim.o.splitright = true -- Put new window right of the current one when splitting.
vim.o.synmaxcol = 800 -- Don't try to highlight lines longer than 800 characters.
vim.o.tabstop = 4 -- Number of spaces for a tab.
vim.o.termguicolors = true -- Use highlight-guifg and highlight-guibg attributes
-- in the terminal (thus using 24-bit color).
-- NOTE: You should make sure your terminal supports this
--vim.o.termwinscroll = 50000 -- keep 50k lines in a terminal (default is 10k)
-- Time out on key codes but not mappings.
-- Basically this makes terminal Vim work sanely.
--vim.o.timeout = false -- Must use timeout=true for 'folke/which-key.nvim' plugin to work.
vim.o.ttimeout = true
vim.o.ttimeoutlen = 10
-- Set title to 'titlestring' if terminal supports it.
-- Note that this doesn't work within tmux.
vim.o.title = true
-- Indicates a fast terminal connection.
-- Enables extra chars at end of line that wrap, and helps copy/paste with mouse.
vim.o.ttyfast = true
vim.o.visualbell = true -- Use a visual bell instead of beeping.
vim.o.wmh = 0 -- Set the minimum window height to 0.
vim.o.wmw = 0 -- Set the minimum window width to 0.
vim.o.ignorecase = true -- Ignore case when searching.
vim.o.smartcase = true -- Override ignorecase when capitals used in search.
vim.o.incsearch = true -- Show where the pattern matches as it is typed.
vim.o.showmatch = true -- Briefly jump to matching bracket when insert one.
vim.o.hlsearch = true -- Hilight matching search pattern.
--vim.o.gdefault = false -- when true the :substitute flag 'g' is on by default, :s///g.
vim.o.scrolloff = 0 -- Show NO context above/below cursorline.
vim.o.sidescroll = 1 -- Scroll horizontally 1 column at a time.
--vim.o.sidescrolloff = 10 -- Keep 10 chars of context when side scrolling.
vim.o.sidescrolloff = 0 -- Scroll horizontally all the way to the edge.
-- Allow virtual editing in Visual block mode (e.g. allow to go pass end of line).
vim.opt.virtualedit:append 'block'
-- Cursorline {{{
-- Only show cursorline in the current window and in normal mode.
vim.o.cursorline = true
vim.cmd [[
augroup cline
au!
au WinLeave,InsertEnter * set nocursorline
au WinEnter,InsertLeave * set cursorline
augroup END
]]
-- }}}
-- Trailing whitespace {{{
-- Only shown when not in insert mode so I don't go insane.
vim.cmd [[
augroup trailing
au!
au InsertEnter * :set listchars-=trail:⌴
au InsertLeave * :set listchars+=trail:⌴
augroup END
]]
-- }}}
-- Line Return {{{
-- Make sure Vim returns to the same line when you reopen a file.
-- Thanks, Amit
vim.cmd [[
augroup line_return
au!
au BufReadPost *
\\ if line(--'\"") > 0 && line("'\\"") <= line("$") |
\\ execute 'normal! g`--zvzz' |
\\ endif
augroup END
]]
-- }}}
-- Backups {{{
vim.cmd [[
set backup " enable backups
"set noswapfile " it's 2013, Vim.
set undodir=~/.vim/tmp/undo// " undo files
set backupdir=~/.vim/tmp/backup// " backups
set directory=~/.vim/tmp/swap// " swap files
" Make those folders automatically if they don't already exist.
if !isdirectory(expand(&undodir))
call mkdir(expand(&undodir), --p--)
endif
if !isdirectory(expand(&backupdir))
call mkdir(expand(&backupdir), --p--)
endif
if !isdirectory(expand(&directory))
call mkdir(expand(&directory), --p--)
endif
]]
-- }}}
-- Code folding with treesitter.
vim.o.foldmethod = 'expr'
vim.o.foldexpr = 'nvim_treesitter#foldexpr()'
-- }}} [[ Setting more options ]]
-- [[ Basic Keymaps ]] {{{
-- See `:help vim.keymap.set()`
-- Clear highlights on search when pressing <Esc> in normal mode
-- See `:help hlsearch`
vim.keymap.set('n', '<Esc>', '<cmd>nohlsearch<CR>')
-- Diagnostic keymaps
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' })
-- Exit terminal mode in the builtin terminal with a shortcut that is a bit easier
-- for people to discover. Otherwise, you normally need to press <C-\><C-n>, which
-- is not what someone will guess without a bit more experience.
--
-- NOTE: This won't work in all terminal emulators/tmux/etc. Try your own mapping
-- or just use <C-\><C-n> to exit terminal mode
vim.keymap.set('t', '<Esc><Esc>', '<C-\\><C-n>', { desc = 'Exit terminal mode' })
-- TIP: Disable arrow keys in normal mode
-- vim.keymap.set('n', '<left>', '<cmd>echo "Use h to move!!"<CR>')
-- vim.keymap.set('n', '<right>', '<cmd>echo "Use l to move!!"<CR>')
-- vim.keymap.set('n', '<up>', '<cmd>echo "Use k to move!!"<CR>')
-- vim.keymap.set('n', '<down>', '<cmd>echo "Use j to move!!"<CR>')
-- Keybinds to make split navigation easier.
-- Use CTRL+<hjkl> to switch between windows
--
-- See `:help wincmd` for a list of all window commands
vim.keymap.set('n', '<C-h>', '<C-w><C-h>', { desc = 'Move focus to the left window' })
vim.keymap.set('n', '<C-l>', '<C-w><C-l>', { desc = 'Move focus to the right window' })
vim.keymap.set('n', '<C-j>', '<C-w><C-j>', { desc = 'Move focus to the lower window' })
vim.keymap.set('n', '<C-k>', '<C-w><C-k>', { desc = 'Move focus to the upper window' })
-- }}} [[ Basic Keymaps ]]
-- [[ Other Mappings ]] {{{
--vim.keymap.set({ 'n', 'v' }, '<Space>', '<Nop>', { silent = true })
-- Remap for dealing with word wrap
--vim.keymap.set('n', 'k', "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true })
--vim.keymap.set('n', 'j', "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true })
-- Diagnostic keymaps
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous diagnostic message' })
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next diagnostic message' })
vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, { desc = 'Open floating diagnostic message' })
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostics list' })
-- Reuse F5 to update any doc changes.
vim.keymap.set('n', '<F5>', ':checktime<cr>')
vim.keymap.set('i', '<F5>', '<esc>:checktime<cr>')
-- Wrap
vim.keymap.set('n', '<leader>W', ':set wrap!<cr>')
-- List
vim.keymap.set('n', '<leader>l', ':set list!<cr>')
-- Remove trailing whitespaces (and clear search pattern).
vim.keymap.set('n', '<leader>ww', "mz:%s/\\s\\+$//<cr>:let @/=''<cr>`z")
-- "Uppercase word" mapping.
--
-- This mapping allows you to press <c-u> in insert mode to convert the current
-- word to uppercase. It's handy when you're writing names of constants and
-- don't want to use Capslock.
--
-- To use it you type the name of the constant in lowercase. While your
-- cursor is at the end of the word, press <c-u> to uppercase it, and then
-- continue happily on your way:
--
-- cursor
-- v
-- max_connections_allowed|
-- <c-u>
-- MAX_CONNECTIONS_ALLOWED|
-- ^
-- cursor
--
-- It works by exiting out of insert mode, recording the current cursor
-- location in the z mark, using gUiw to uppercase inside the current word,
-- moving back to the u mark, and entering insert mode again. Note that this
-- will overwrite the contents of the u mark.
vim.keymap.set('i', '<C-u>', '<esc>mugUiw`ua')
-- Panic Button
vim.keymap.set('n', '<f9>', 'mzggg?G`z')
-- zt is okay for putting something at the top of the screen, but when I'm
-- writing prose I often want to put something at not-quite-the-top of the
-- screen. zh is "zoom to head level"
vim.keymap.set('n', 'zh', 'muzt10<c-u>`u')
-- Diffoff
vim.keymap.set('n', '<leader>D', ':diffoff!<cr>')
vim.keymap.set('n', '<leader>dd', ':diffthis<cr>')
vim.keymap.set('n', '<leader>do', ':diffoff<cr>')
-- Formatting, TextMate-style
--nnoremap Q gqip
vim.keymap.set('n', 'Q', 'gq')
vim.keymap.set('v', 'Q', 'gq')
-- Easier linewise reselection of what you just pasted.
vim.keymap.set('n', '<leader>V', 'V`]')
-- Indent/dedent/autoindent what you just pasted.
vim.keymap.set('n', '<lt>>', 'V`]<')
vim.keymap.set('n', '><lt>', 'V`]>')
vim.keymap.set('n', '=-', 'V`]=')
-- Keep the cursor in place while joining lines
--nnoremap J mzJ`z
-- XML
vim.keymap.set('v', '<Leader>x', '!xmllint --format -<CR>')
vim.keymap.set('n', '<Leader>xl', '!!xmllint --format -<CR>')
vim.keymap.set('n', '<Leader>xa', ':%!xmllint --format -<CR>')
-- command line maps to edit line just like in a shell command line.
vim.keymap.set('c', '<C-A>', '<Home>')
vim.keymap.set('c', '<C-F>', '<Right>')
vim.keymap.set('c', '<C-B>', '<Left>')
--cnoremap <Esc>b <S-Left>
--cnoremap <Esc>f <S-Right>
vim.keymap.set('c', '<C-k>', '<C-\\>estrpart(getcmdline(),0,getcmdpos()-1)<CR>')
vim.keymap.set('c', '<C-D>', '<DEL>')
-- Make timestamps readable in SWItrc logs
--vim.keymap.set('n', '<leader>d', ':g/^20/s/\\(....\\)\\(..\\)\\(..\\)\\(..\\)\\(..\\)\\(..\\)\\(...\\)/\\1\\/\\2\\/\\3 \\4:\\5:\\6.\\7<cr>')
-- do not wrap text
vim.keymap.set('n', '=t0', ':set textwidth=0<cr>')
-- make text wrap around after <num> chars
vim.keymap.set('n', '=t5', ':set textwidth=50<cr>')
vim.keymap.set('n', '=t6', ':set textwidth=60<cr>')
vim.keymap.set('n', '=t7', ':set textwidth=70<cr>')
vim.keymap.set('n', '=t8', ':set textwidth=80<cr>')
-- pop back to the last tag (doesn't work with /usr/bin/vi)
vim.keymap.set('n', '=p', ':pop<cr>')
-- underline current line. The underlining starts from the first
-- non-blank character to the last non-blank character of the line.
vim.keymap.set('n', '=ul', '"myy0I <esc>0"nd/[^ ]<cr>:s/./-/g<cr>0"nP0x"mP')
-- double underline current line. The underlining starts from the first
-- non-blank character to the last non-blank character of the line.
vim.keymap.set('n', '=uL', '"myy0I <esc>0"nd/[^ ]<cr>:s/./=/g<cr>0"nP0x"mP')
-- ,da = "date insert"
-- ,dt = "date and time insert" 070127^I11:22:33
-- ,X = add extra short date, 070127
-- ,dd = date of the form: 2007/01/27
vim.keymap.set('n', '<leader>ida', ':r!date<cr>')
vim.keymap.set('n', '<leader>idt', ':r!date +\\%Y\\%m\\%d\\%t\\%T<cr>')
vim.keymap.set('n', '<leader>idd', ':r!date +\\%Y\\%m\\%d<cr>')
vim.keymap.set('n', '<leader>id/', ':r!date +\\%Y/\\%m/\\%d<cr>')
-- set wrap/nowrap
vim.keymap.set('n', '<F11>', ':set wrap!<cr>')
vim.keymap.set('n', '=w', ' :set wrap!<cr>')
-- Toggle le highlight du search pattern
vim.keymap.set('n', 'XX', ':set hlsearch!<cr>:set hlsearch?<cr>')
-- horizontal scroll
vim.keymap.set('n', '<c-Left>', 'zh')
vim.keymap.set('n', '<c-Right>', 'zl')
vim.cmd [[
" command to remove duplicate lines in a selection
:command! -range=% Uniq <line1>,<line2>s/\v^(.*)(%<<line2>l\n\1)+$/\1/e
" command to replace duplicate lines in a selection by blank lines
:command! -range=% Uniqb <line1>,<line2>s/\v^(.*)(%<<line2>l\n\1)+$/\1\n/e
]]
-- hold down Ctrl and move between windows with the standard Vim movement keys.
--map <c-j> <c-w>j<c-w>_
--map <c-k> <c-w>k<c-w>_
--map <c-h> <c-w>h<c-w><bar>
--map <c-l> <c-w>l<c-w><bar>
vim.keymap.set('n', '<c-j>', '<c-w>j')
vim.keymap.set('n', '<c-k>', '<c-w>k')
vim.keymap.set('n', '<c-h>', '<c-w>h')
vim.keymap.set('n', '<c-l>', '<c-w>l')
-- Also use Alt with the arrows to move around windows
vim.keymap.set('n', '<silent>', '<A-Up> :wincmd k<CR>')
vim.keymap.set('n', '<silent>', '<A-Down> :wincmd j<CR>')
vim.keymap.set('n', '<silent>', '<A-Left> :wincmd h<CR>')
vim.keymap.set('n', '<silent>', '<A-Right> :wincmd l<CR>')
-- to quickly resize windows with a vertical split
vim.keymap.set('n', '-', '<C-W>-')
vim.keymap.set('n', '+', '<C-W>+')
-- to resize vertical windows quickly with ALT-SHIFT-[<>]
vim.keymap.set('n', '<', '<')
vim.keymap.set('n', '>', '>')
-- Draw arrows in between vertical bars in replace mode,
-- useful to make call flow diagrams.
-- e.g.
-- |protocol message'ctrl-'> |
-- will result in
-- |-protocol message--------------------->|
--inoremap <c-->> <esc>ldwF\|pT\|r-ldwf\|Pr>bf vt>r-F\|jlR
--inoremap <c-->< <esc>ldwF\|pwhvT\|r-r<lxf\|PF<jR
--inoremap <c-->> <esc>lxvt\|r-t\|r>F\|a-<esc>jR
--inoremap <c-->< <esc>ldt\|F\|pxhvT\|r-r<f\|i-<esc>T\|jR
--inoremap <c-->> <Esc>ldwF\|pT\|r-ldwf\|Pr>bf vt>r-
--inoremap <c-->< <Esc>ldwF\|pwhvT\|r-r<lxf\|P
-- Windows Terminal uses ctrl- and ctrl+ to control the font size.
-- So use ctrl_ instead for the call-flow maps.
--vim.keymap.set('i', '<c-_>>', '<Esc>ldwF|pT|r-ldwf|Pr>bf vt>r-')
--vim.keymap.set('i', '<c-_><', '<Esc>ldwF|pwhvT|r-r<lxf|P')
--vim.keymap.set('i', '<right>', '<Esc>ldwF|pT|r-ldwf|Pr>bf vt>r-')
--vim.keymap.set('i', '<left>', '<Esc>ldwF|pwhvT|r-r<lxf|P')
-- This doesn't work:
--vim.keymap.set('i', '<c->>>', '<Esc>ldwF|pT|r-ldwf|Pr>bf vt>r-')
--vim.keymap.set('i', '<c-<><', '<Esc>ldwF|pwhvT|r-r<lxf|P')
vim.keymap.set('i', '<c-l><c-l>', '<Esc>ldwF|pT|r-ldwf|Pr>bf vt>r-T|jR')
vim.keymap.set('i', '<c-h><c-h>', '<Esc>ldwF|pwhvT|r-r<lxf|PT|jR')
-- |protocol message'ctrl-') |
-- will result in
-- | protocol message |
-- |-------------------------------------->|
--inoremap <c-->) <esc>F\|maldt\|O<esc>P:s/\(.*\S\)\(\s*\)$/\2\1<cr>:s/\(\s*\)\(\1\)/\1;\2<cr>:s/;\(\s*\)\(.*\)/\2\1<cr>0d$`apT\|jvt\|r-t\|r>kkdd`ajjlR
--inoremap <c-->( <esc>F\|maldt\|O<esc>P:s/\(.*\S\)\(\s*\)$/\2\1<cr>:s/\(\s*\)\(\1\)/\1;\2<cr>:s/;\(\s*\)\(.*\)/\2\1<cr>0d$`apT\|jvt\|r-r<kkdd`ajjlR
-- Windows Terminal uses ctrl- and ctrl+ to control the font size.
-- So use ctrl_ instead for the call-flow maps.
--vim.keymap.set('i', '<c-_>)', '<esc>F|maldt|O<esc>P:s/\\(.*\\S\\)\\(\\s*\\)$/\\2\\1<cr>:s/\\(\\s*\\)\\(\\1\\)/\\1;\\2<cr>:s/;\\(\\s*\\)\\(.*\\)/\\2\\1<cr>0d$`apT|jvt|r-t|r>kkdd`ajjlR')
--vim.keymap.set('i', '<c-_>(', '<esc>F|maldt|O<esc>P:s/\\(.*\\S\\)\\(\\s*\\)$/\\2\\1<cr>:s/\\(\\s*\\)\\(\\1\\)/\\1;\\2<cr>:s/;\\(\\s*\\)\\(.*\\)/\\2\\1<cr>0d$`apT|jvt|r-r<kkdd`ajjlR')
vim.keymap.set('i', '<c-L>l', '<esc>F|maldt|O<esc>P:s/\\(.*\\S\\)\\(\\s*\\)$/\\2\\1<cr>:s/\\(\\s*\\)\\(\\1\\)/\\1;\\2<cr>:s/;\\(\\s*\\)\\(.*\\)/\\2\\1<cr>0d$`apT|jvt|r-t|r>kkdd`ajjlR')
vim.keymap.set('i', '<c-H>h', '<esc>F|maldt|O<esc>P:s/\\(.*\\S\\)\\(\\s*\\)$/\\2\\1<cr>:s/\\(\\s*\\)\\(\\1\\)/\\1;\\2<cr>:s/;\\(\\s*\\)\\(.*\\)/\\2\\1<cr>0d$`apT|jvt|r-r<kkdd`ajjlR')
-- Navigate betweenn protocol sections.
-- |█<right> | |
-- will result in cursor moving to next section.
-- | |█ |
--vim.keymap.set('i', '<c-right>', '<esc>f|lR')
--vim.keymap.set('i', '<c-left>', ' <esc>F|lR')
--vim.keymap.set('i', '<c-right>', '<esc>f|lR')
--vim.keymap.set('i', '<c-left>', ' <esc>F|hT|R')
vim.keymap.set('i', '<c-right>', '<c-o>f|<c-o>l')
vim.keymap.set('i', '<c-left>', '<c-o>F|<c-o>T|')
-- Go to the next error or match
vim.keymap.set('n', '<c-n>', ':cn<cr>')
-- Go to the previous error or match
vim.keymap.set('n', '<c-p>', ':cp<cr>')
-- format into human-readable json
vim.keymap.set('v', '<Leader>j', '!python3 -mjson.tool<cr>')
vim.keymap.set('n', '<Leader>jl', '!!python3 -mjson.tool<cr>')
vim.keymap.set('n', '<Leader>ja', ':%!python3 -mjson.tool<cr>')
-- change local directory to where current file is located.
vim.keymap.set('n', '<leader>.', ":if expand('%:p') !~ '://' | :lchdir %:p:h | endif<cr>")
-- While in a terminal (Terminal-Job mode), press <Esc> to switch to Terminal-Normal mode
vim.keymap.set('t', '<Esc>', '<C-W>N')
-- Toggle showing line numbers
vim.keymap.set('n', '<leader>#', ':set number! relativenumber!<cr>')
-- Heresy
vim.keymap.set('i', '<c-a>', '<esc>I')
vim.keymap.set('i', '<c-e>', '<esc>A')
vim.keymap.set('c', '<c-a>', '<home>')
vim.keymap.set('c', '<c-e>', '<end>')
-- NOTE: Some terminals have colliding keymaps or are not able to send distinct keycodes
-- vim.keymap.set("n", "<C-S-h>", "<C-w>H", { desc = "Move window to the left" })
-- vim.keymap.set("n", "<C-S-l>", "<C-w>L", { desc = "Move window to the right" })
-- vim.keymap.set("n", "<C-S-j>", "<C-w>J", { desc = "Move window to the lower" })
-- vim.keymap.set("n", "<C-S-k>", "<C-w>K", { desc = "Move window to the upper" })
-- }}} [[ Other Mappings ]]
-- [[ Basic Autocommands ]] {{{
-- See `:help lua-guide-autocommands`
-- Highlight when yanking (copying) text
-- Try it with `yap` in normal mode
-- See `:help vim.hl.on_yank()`
vim.api.nvim_create_autocmd('TextYankPost', {
desc = 'Highlight when yanking (copying) text',
group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }),
callback = function()
vim.hl.on_yank()
end,
})
-- }}} [[ Basic Autocommands ]]
-- vim-mark {{{
vim.g.mwDefaultHighlightingPalette = {
--[[
{ ctermbg = '226', ctermfg = 'black', guibg = '#ffff00', guifg = 'black' },
{ ctermbg = '196', ctermfg = 'black', guibg = '#ff0000', guifg = 'black' },
{ ctermbg = '21', ctermfg = 'white', guibg = '#0030ff', guifg = 'white' },
{ ctermbg = '46', ctermfg = 'black', guibg = '#00ff00', guifg = 'black' },
{ ctermbg = '201', ctermfg = 'black', guibg = '#ff00ff', guifg = 'black' },
{ ctermbg = '51', ctermfg = 'black', guibg = '#00ffff', guifg = 'black' },
{ ctermbg = '88', ctermfg = 'white', guibg = '#870000', guifg = 'white' },
{ ctermbg = '208', ctermfg = 'black', guibg = '#ff8700', guifg = 'black' },
{ ctermbg = '18', ctermfg = 'white', guibg = '#003087', guifg = 'white' },
{ ctermbg = '22', ctermfg = 'white', guibg = '#005f00', guifg = 'white' },
{ ctermbg = '90', ctermfg = 'white', guibg = '#870087', guifg = 'white' },
{ ctermbg = '36', ctermfg = 'black', guibg = '#00af87', guifg = 'black' },
{ ctermbg = '239', ctermfg = 'white', guibg = '#4e4e4e', guifg = 'white' },
{ ctermbg = '202', ctermfg = 'black', guibg = '#ff5f00', guifg = 'black' },
{ ctermbg = '131', ctermfg = 'black', guibg = '#af5f5f', guifg = 'black' },
{ ctermbg = '113', ctermfg = 'black', guibg = '#87d75f', guifg = 'black' },
{ ctermbg = '71', ctermfg = 'white', guibg = '#5faf5f', guifg = 'white' },
{ ctermbg = '192', ctermfg = 'black', guibg = '#d7ff87', guifg = 'black' },
{ ctermbg = '99', ctermfg = 'white', guibg = '#875fff', guifg = 'white' },
{ ctermbg = '168', ctermfg = 'white', guibg = '#d75f87', guifg = 'white' },
{ ctermbg = '231', ctermfg = 'black', guibg = '#ffffff', guifg = 'black' },
{ ctermbg = '227', ctermfg = 'black', guibg = '#ffff5f', guifg = 'black' },
{ ctermbg = '49', ctermfg = 'black', guibg = '#00ffaf', guifg = 'black' },
{ ctermbg = '154', ctermfg = 'black', guibg = '#afff00', guifg = 'black' },
--]]
--[[
{ ctermbg = '196', ctermfg = 'black', guibg = '#FF0000', guifg = 'black' },
{ ctermbg = ' 0', ctermfg = 'black', guibg = '#00FF00', guifg = 'black' },
{ ctermbg = ' 0', ctermfg = 'black', guibg = '#0000FF', guifg = 'white' },
{ ctermbg = ' 0', ctermfg = 'black', guibg = '#FFFF00', guifg = 'black' },
{ ctermbg = ' 0', ctermfg = 'black', guibg = '#00FFFF', guifg = 'black' },
{ ctermbg = ' 0', ctermfg = 'black', guibg = '#FF00FF', guifg = 'black' },
{ ctermbg = ' 0', ctermfg = 'black', guibg = '#FFFFFF', guifg = 'black' },
{ ctermbg = ' 0', ctermfg = 'black', guibg = '#000000', guifg = 'white' },
{ ctermbg = ' 0', ctermfg = 'black', guibg = '#008000', guifg = 'white' },
{ ctermbg = ' 0', ctermfg = 'black', guibg = '#FFA500', guifg = 'black' },
{ ctermbg = ' 0', ctermfg = 'black', guibg = '#800080', guifg = 'white' },
{ ctermbg = ' 0', ctermfg = 'black', guibg = '#008080', guifg = 'white' },
{ ctermbg = ' 0', ctermfg = 'black', guibg = '#FFC0CB', guifg = 'black' },
{ ctermbg = ' 0', ctermfg = 'black', guibg = '#A52A2A', guifg = 'white' },
{ ctermbg = ' 0', ctermfg = 'black', guibg = '#000080', guifg = 'white' },
{ ctermbg = ' 0', ctermfg = 'black', guibg = '#FFDAB9', guifg = 'black' },
{ ctermbg = ' 0', ctermfg = 'black', guibg = '#7FFF00', guifg = 'black' },
{ ctermbg = ' 0', ctermfg = 'black', guibg = '#87CEEB', guifg = 'black' },
{ ctermbg = ' 0', ctermfg = 'black', guibg = '#808000', guifg = 'white' },
{ ctermbg = ' 0', ctermfg = 'black', guibg = '#DA70D6', guifg = 'black' },
{ ctermbg = ' 0', ctermfg = 'black', guibg = '#40E0D0', guifg = 'black' },
{ ctermbg = ' 0', ctermfg = 'black', guibg = '#A0522D', guifg = 'white' },
{ ctermbg = ' 0', ctermfg = 'black', guibg = '#FFD700', guifg = 'black' },
{ ctermbg = ' 0', ctermfg = 'black', guibg = '#800000', guifg = 'white' },
--]]
--[[
{ ctermbg = '196', ctermfg = 'black', guibg = '#FF0000', guifg = 'black' }, -- Red
{ ctermbg = '46', ctermfg = 'black', guibg = '#00FF00', guifg = 'black' }, -- Lime
{ ctermbg = '21', ctermfg = 'white', guibg = '#0000FF', guifg = 'white' }, -- Blue
{ ctermbg = '226', ctermfg = 'black', guibg = '#FFFF00', guifg = 'black' }, -- Yellow
{ ctermbg = '51', ctermfg = 'black', guibg = '#00FFFF', guifg = 'black' }, -- Cyan
{ ctermbg = '201', ctermfg = 'black', guibg = '#FF00FF', guifg = 'black' }, -- Magenta
{ ctermbg = '15', ctermfg = 'black', guibg = '#FFFFFF', guifg = 'black' }, -- White
{ ctermbg = '16', ctermfg = 'white', guibg = '#000000', guifg = 'white' }, -- Black
{ ctermbg = '34', ctermfg = 'white', guibg = '#008000', guifg = 'white' }, -- Green
{ ctermbg = '208', ctermfg = 'black', guibg = '#FFA500', guifg = 'black' }, -- Orange
{ ctermbg = '93', ctermfg = 'white', guibg = '#800080', guifg = 'white' }, -- Purple
{ ctermbg = '30', ctermfg = 'white', guibg = '#008080', guifg = 'white' }, -- Teal
{ ctermbg = '218', ctermfg = 'black', guibg = '#FFC0CB', guifg = 'black' }, -- Pink
{ ctermbg = '124', ctermfg = 'white', guibg = '#A52A2A', guifg = 'white' }, -- Brown
{ ctermbg = '19', ctermfg = 'white', guibg = '#000080', guifg = 'white' }, -- Navy
{ ctermbg = '225', ctermfg = 'black', guibg = '#E6E6FA', guifg = 'black' }, -- Lavender
{ ctermbg = '45', ctermfg = 'black', guibg = '#40E0D0', guifg = 'black' }, -- Turquoise
{ ctermbg = '88', ctermfg = 'white', guibg = '#800000', guifg = 'white' }, -- Maroon
{ ctermbg = '220', ctermfg = 'black', guibg = '#FFD700', guifg = 'black' }, -- Gold
{ ctermbg = '100', ctermfg = 'white', guibg = '#808000', guifg = 'white' }, -- Olive
{ ctermbg = '210', ctermfg = 'black', guibg = '#FA8072', guifg = 'black' }, -- Salmon
{ ctermbg = '117', ctermfg = 'black', guibg = '#87CEEB', guifg = 'black' }, -- Sky Blue
{ ctermbg = '54', ctermfg = 'white', guibg = '#4B0082', guifg = 'white' }, -- Indigo
{ ctermbg = '28', ctermfg = 'white', guibg = '#228B22', guifg = 'white' }, -- Forest Green
--]]
{ ctermbg = '196', ctermfg = 'black', guibg = '#FF0000', guifg = 'black' }, -- Red
{ ctermbg = '46', ctermfg = 'black', guibg = '#00FF00', guifg = 'black' }, -- Lime
{ ctermbg = '21', ctermfg = 'white', guibg = '#0000FF', guifg = 'white' }, -- Blue
{ ctermbg = '226', ctermfg = 'black', guibg = '#FFFF00', guifg = 'black' }, -- Yellow
{ ctermbg = '51', ctermfg = 'black', guibg = '#00FFFF', guifg = 'black' }, -- Cyan
{ ctermbg = '201', ctermfg = 'black', guibg = '#FF00FF', guifg = 'black' }, -- Magenta
{ ctermbg = '208', ctermfg = 'black', guibg = '#FFA500', guifg = 'black' }, -- Orange
{ ctermbg = '118', ctermfg = 'black', guibg = '#7FFF00', guifg = 'black' }, -- Chartreuse
{ ctermbg = '45', ctermfg = 'black', guibg = '#40E0D0', guifg = 'black' }, -- Turquoise
{ ctermbg = '93', ctermfg = 'white', guibg = '#800080', guifg = 'white' }, -- Purple
{ ctermbg = '220', ctermfg = 'black', guibg = '#FFD700', guifg = 'black' }, -- Gold
{ ctermbg = '210', ctermfg = 'black', guibg = '#FA8072', guifg = 'black' }, -- Salmon
{ ctermbg = '117', ctermfg = 'black', guibg = '#87CEEB', guifg = 'black' }, -- Sky Blue
{ ctermbg = '54', ctermfg = 'white', guibg = '#4B0082', guifg = 'white' }, -- Indigo
{ ctermbg = '28', ctermfg = 'white', guibg = '#228B22', guifg = 'white' }, -- Forest Green
{ ctermbg = '214', ctermfg = 'black', guibg = '#FF7F00', guifg = 'black' }, -- Vivid Orange
{ ctermbg = '33', ctermfg = 'white', guibg = '#0066CC', guifg = 'white' }, -- Royal Blue
{ ctermbg = '82', ctermfg = 'black', guibg = '#66FF33', guifg = 'black' }, -- Neon Green
{ ctermbg = '177', ctermfg = 'black', guibg = '#FF66FF', guifg = 'black' }, -- Hot Pink
{ ctermbg = '47', ctermfg = 'black', guibg = '#33FFCC', guifg = 'black' }, -- Aqua Green
{ ctermbg = '172', ctermfg = 'black', guibg = '#FF6600', guifg = 'black' }, -- Bright Orange
{ ctermbg = '141', ctermfg = 'black', guibg = '#CC66FF', guifg = 'black' }, -- Violet
{ ctermbg = '75', ctermfg = 'black', guibg = '#3399FF', guifg = 'black' }, -- Bright Azure
{ ctermbg = '190', ctermfg = 'black', guibg = '#CCFF00', guifg = 'black' }, -- Acid Green
{ ctermbg = '203', ctermfg = 'black', guibg = '#FF3333', guifg = 'black' }, -- Bright Red
{ ctermbg = '99', ctermfg = 'white', guibg = '#6666CC', guifg = 'white' }, -- Muted Purple
{ ctermbg = '48', ctermfg = 'black', guibg = '#33FF99', guifg = 'black' }, -- Mint Green
{ ctermbg = '227', ctermfg = 'black', guibg = '#FFFF66', guifg = 'black' }, -- Light Yellow
{ ctermbg = '129', ctermfg = 'white', guibg = '#9933CC', guifg = 'white' }, -- Deep Violet
{ ctermbg = '38', ctermfg = 'black', guibg = '#339999', guifg = 'black' }, -- Teal Blue
{ ctermbg = '219', ctermfg = 'black', guibg = '#FF99CC', guifg = 'black' }, -- Light Pink
{ ctermbg = '202', ctermfg = 'black', guibg = '#FF4500', guifg = 'black' }, -- Orange Red
{ ctermbg = '79', ctermfg = 'black', guibg = '#66FFCC', guifg = 'black' }, -- Aqua Mint
{ ctermbg = '153', ctermfg = 'black', guibg = '#9999FF', guifg = 'black' }, -- Soft Blue
{ ctermbg = '112', ctermfg = 'black', guibg = '#66CC66', guifg = 'black' }, -- Medium Green
{ ctermbg = '229', ctermfg = 'black', guibg = '#FFFF99', guifg = 'black' }, -- Pastel Yellow
{ ctermbg = '183', ctermfg = 'black', guibg = '#FF99FF', guifg = 'black' }, -- Candy Pink
{ ctermbg = '159', ctermfg = 'black', guibg = '#99FFFF', guifg = 'black' }, -- Pastel Cyan
{ ctermbg = '171', ctermfg = 'black', guibg = '#FF66CC', guifg = 'black' }, -- Neon Pink
{ ctermbg = '121', ctermfg = 'black', guibg = '#66FF66', guifg = 'black' }, -- Bright Green
{ ctermbg = '105', ctermfg = 'white', guibg = '#6666FF', guifg = 'white' }, -- Strong Blue
{ ctermbg = '215', ctermfg = 'black', guibg = '#FF9966', guifg = 'black' }, -- Peach Orange
{ ctermbg = '84', ctermfg = 'black', guibg = '#66FF99', guifg = 'black' }, -- Soft Mint
{ ctermbg = '225', ctermfg = 'black', guibg = '#E6E6FA', guifg = 'black' }, -- Lavender
{ ctermbg = '195', ctermfg = 'black', guibg = '#CCFFFF', guifg = 'black' }, -- Baby Blue
{ ctermbg = '140', ctermfg = 'black', guibg = '#CC66CC', guifg = 'black' }, -- Purple Rose
{ ctermbg = '186', ctermfg = 'black', guibg = '#FFFFCC', guifg = 'black' }, -- Cream Yellow
{ ctermbg = '81', ctermfg = 'black', guibg = '#66CCFF', guifg = 'black' }, -- Clear Sky
}
-- turn off the creation of the default mappings.
vim.g.mw_no_mappings = 1
-- }}} vim-mark
-- [[ Install `lazy.nvim` plugin manager ]] {{{
-- See `:help lazy.nvim.txt` or https://github.com/folke/lazy.nvim for more info
local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim'
if not (vim.uv or vim.loop).fs_stat(lazypath) then
local lazyrepo = 'https://github.com/folke/lazy.nvim.git'
local out = vim.fn.system { 'git', 'clone', '--filter=blob:none', '--branch=stable', lazyrepo, lazypath }
if vim.v.shell_error ~= 0 then
error('Error cloning lazy.nvim:\n' .. out)
end
end
---@type vim.Option
local rtp = vim.opt.rtp
rtp:prepend(lazypath)
-- }}}
-- [[ Configure and install plugins ]] {{{
--
-- To check the current status of your plugins, run
-- :Lazy
--
-- You can press `?` in this menu for help. Use `:q` to close the window
--
-- To update plugins you can run
-- :Lazy update
--
-- NOTE: Here is where you install your plugins.
require('lazy').setup({
-- NOTE: Plugins can be added with a link (or for a github repo: 'owner/repo' link).
'NMAC427/guess-indent.nvim', -- Detect tabstop and shiftwidth automatically
-- NOTE: Plugins can also be added by using a table,
-- with the first argument being the link and the following
-- keys can be used to configure plugin behavior/loading/etc.
--
-- Use `opts = {}` to automatically pass options to a plugin's `setup()` function, forcing the plugin to be loaded.
--
-- Alternatively, use `config = function() ... end` for full control over the configuration.
-- If you prefer to call `setup` explicitly, use:
-- {
-- 'lewis6991/gitsigns.nvim',
-- config = function()
-- require('gitsigns').setup({
-- -- Your gitsigns configuration here
-- })
-- end,
-- }
--
-- Here is a more advanced example where we pass configuration
-- options to `gitsigns.nvim`.
--
-- See `:help gitsigns` to understand what the configuration keys do
--[[
{ -- Adds git related signs to the gutter, as well as utilities for managing changes
'lewis6991/gitsigns.nvim',
opts = {
signs = {
add = { text = '+' },
change = { text = '~' },
delete = { text = '_' },
topdelete = { text = '‾' },
changedelete = { text = '~' },
},
--]]
--[[
on_attach = function(bufnr)
local gs = package.loaded.gitsigns
local function map(mode, l, r, opts)
opts = opts or {}
opts.buffer = bufnr
vim.keymap.set(mode, l, r, opts)
end
-- Navigation
map({ 'n', 'v' }, ']c', function()
if vim.wo.diff then
return ']c'
end
vim.schedule(function()
gs.next_hunk()
end)
return '<Ignore>'
end, { expr = true, desc = 'Jump to next hunk' })
map({ 'n', 'v' }, '[c', function()
if vim.wo.diff then
return '[c'
end
vim.schedule(function()
gs.prev_hunk()
end)
return '<Ignore>'
end, { expr = true, desc = 'Jump to previous hunk' })
-- Actions
-- visual mode
map('v', '<leader>hs', function()
gs.stage_hunk { vim.fn.line '.', vim.fn.line 'v' }
end, { desc = 'stage git hunk' })
map('v', '<leader>hr', function()
gs.reset_hunk { vim.fn.line '.', vim.fn.line 'v' }
end, { desc = 'reset git hunk' })
-- normal mode
map('n', '<leader>hs', gs.stage_hunk, { desc = 'git stage hunk' })
map('n', '<leader>hr', gs.reset_hunk, { desc = 'git reset hunk' })
map('n', '<leader>hS', gs.stage_buffer, { desc = 'git Stage buffer' })
map('n', '<leader>hu', gs.undo_stage_hunk, { desc = 'undo stage hunk' })
map('n', '<leader>hR', gs.reset_buffer, { desc = 'git Reset buffer' })
map('n', '<leader>hp', gs.preview_hunk, { desc = 'preview git hunk' })
map('n', '<leader>hb', function()
gs.blame_line { full = false }
end, { desc = 'git blame line' })
map('n', '<leader>hd', gs.diffthis, { desc = 'git diff against index' })
map('n', '<leader>hD', function()
gs.diffthis '~'
end, { desc = 'git diff against last commit' })
-- Toggles
map('n', '<leader>tb', gs.toggle_current_line_blame, { desc = 'toggle git blame line' })
map('n', '<leader>td', gs.toggle_deleted, { desc = 'toggle git show deleted' })
-- Text object
map({ 'o', 'x' }, 'ih', ':<C-U>Gitsigns select_hunk<CR>', { desc = 'select git hunk' })
end,
--]]
--[[
},
},
--]]
-- Other gitsigns configuration examples
--[[
-- {{{
{
-- Adds git releated signs to the gutter, as well as utilities for managing changes
'lewis6991/gitsigns.nvim',
opts = {
-- See `:help gitsigns.txt`
signs = {
add = { text = '+' },
change = { text = '~' },
delete = { text = '_' },
topdelete = { text = '‾' },
changedelete = { text = '~' },
},
on_attach = function(bufnr)
vim.keymap.set('n', '<leader>gp', require('gitsigns').prev_hunk, { buffer = bufnr, desc = '[G]o to [P]revious Hunk' })
vim.keymap.set('n', '<leader>gn', require('gitsigns').next_hunk, { buffer = bufnr, desc = '[G]o to [N]ext Hunk' })
vim.keymap.set('n', '<leader>ph', require('gitsigns').preview_hunk, { buffer = bufnr, desc = '[P]review [H]unk' })
end,
-- {{{
-- on_attach = function(bufnr)
-- if vim.api.nvim_buf_get_name(bufnr):match('<PATTERN>') then
-- -- Don't attach to specific buffers whose name matches a pattern
-- return false
-- end
--
-- -- Setup keymaps
-- --vim.api.nvim_buf_set_keymap(bufnr, 'n', 'hs', '<cmd>lua require"gitsigns".stage_hunk()<CR>', {})
-- vim.api.nvim_buf_set_keymap(bufnr, 'n', 'hs', require('gitsigns').stage_hunk, { desc = '[H]unk [S]tage' })
-- end,
-- }}}
-- From: https://github.com/omerxx/dotfiles/blob/master/nvim/init.lua {{{
-- https://www.youtube.com/watch?v=IyBAuDPzdFY
-- on_attach = function(bufnr)
-- local gs = package.loaded.gitsigns
-- local function map(mode, l, r, opts)
-- opts = opts or {}
-- opts.buffer = bufnr
-- vim.keymap.set(mode, l, r, opts)
-- end
-- -- Navigation
-- map('n', ']c', function()
-- if vim.wo.diff then return ']c' end
-- vim.schedule(function() gs.next_hunk() end)
-- return '<Ignore>'
-- end, {expr=true, desc='next hunk'})
-- map('n', '[c', function()
-- if vim.wo.diff then return '[c' end
-- vim.schedule(function() gs.prev_hunk() end)
-- return '<Ignore>'
-- end, {expr=true, desc='previous hunk'})
-- -- Actions
-- map({'n', 'v'}, '<leader>hs', ':Gitsigns stage_hunk<CR>')
-- map({'n', 'v'}, '<leader>hr', ':Gitsigns reset_hunk<CR>')
-- map('n', '<leader>hS', gs.stage_buffer, {desc='stage buffer'})
-- map('n', '<leader>ha', gs.stage_hunk, {desc='stage hunk'})
-- map('n', '<leader>hu', gs.undo_stage_hunk, {desc='undo_stage_hunk'})
-- map('n', '<leader>hR', gs.reset_buffer, {desc='reset_buffer'})
-- map('n', '<leader>hp', gs.preview_hunk, {desc='preview_hunk'})
-- map('n', '<leader>hb', function() gs.blame_line{full=true} end, {desc='blame_line'})
-- map('n', '<leader>tb', gs.toggle_current_line_blame, {desc='toggle_current_line_blame'})
-- map('n', '<leader>hd', gs.diffthis, {desc='diffthis'})
-- map('n', '<leader>hD', function() gs.diffthis('~') end, {desc='diffthis ~'})
-- map('n', '<leader>td', gs.toggle_deleted, {desc='toggle_deleted'})
-- -- Text object
-- map({'o', 'x'}, 'ih', ':<C-U>Gitsigns select_hunk<CR>')
-- end,
--}}}
},
},
-- }}}
--]]
-- NOTE: Plugins can also be configured to run Lua code when they are loaded.
--
-- This is often very useful to both group configuration, as well as handle
-- lazy loading plugins that don't need to be loaded immediately at startup.
--
-- For example, in the following configuration, we use:
-- event = 'VimEnter'
--
-- which loads which-key before all the UI elements are loaded. Events can be
-- normal autocommands events (`:help autocmd-events`).
--
-- Then, because we use the `opts` key (recommended), the configuration runs
-- after the plugin has been loaded as `require(MODULE).setup(opts)`.
{ -- Useful plugin to show you pending keybinds.
'folke/which-key.nvim',
event = 'VimEnter', -- Sets the loading event to 'VimEnter'
opts = {
-- delay between pressing a key and opening which-key (milliseconds)
-- this setting is independent of vim.o.timeoutlen
delay = 0,
icons = {
-- set icon mappings to true if you have a Nerd Font
mappings = vim.g.have_nerd_font,
-- If you are using a Nerd Font: set icons.keys to an empty table which will use the
-- default which-key.nvim defined Nerd Font icons, otherwise define a string table
keys = vim.g.have_nerd_font and {} or {
Up = '<Up> ',
Down = '<Down> ',
Left = '<Left> ',
Right = '<Right> ',
C = '<C-…> ',
M = '<M-…> ',
D = '<D-…> ',
S = '<S-…> ',
CR = '<CR> ',
Esc = '<Esc> ',