-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathlazy.lua
2543 lines (2489 loc) · 77.4 KB
/
lazy.lua
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
--- NOTE: I keep all plugins in one file, because I often want to disable half of them when I debug what plugin broke my config.
local nvim_treesitter_dev = false
local nvim_treesitter_textobjects_dev = false
local jupynium_dev = false
local python_import_dev = false
local icons = require("kiyoon.icons")
return {
{
"folke/tokyonight.nvim",
lazy = false, -- make sure we load this during startup if it is your main colorscheme
priority = 1000, -- make sure to load this before all the other start plugins
config = function()
require("kiyoon.tokyonight")
vim.cmd.colorscheme("tokyonight")
end,
},
{
"kiyoon/tmuxsend.vim",
keys = {
{
"-",
"<Plug>(tmuxsend-smart)",
mode = { "n", "x" },
desc = "Send to tmux (smart)",
},
{
"_",
"<Plug>(tmuxsend-plain)",
mode = { "n", "x" },
desc = "Send to tmux (plain)",
},
{
"<space>-",
"<Plug>(tmuxsend-uid-smart)",
mode = { "n", "x" },
desc = "Send to tmux w/ pane uid (smart)",
},
{
"<space>_",
"<Plug>(tmuxsend-uid-plain)",
mode = { "n", "x" },
desc = "Send to tmux w/ pane uid (plain)",
},
{ "<C-_>", "<Plug>(tmuxsend-tmuxbuffer)", mode = { "n", "x" }, desc = "Yank to tmux buffer" },
},
},
--- NOTE: Python
{
-- There are four types of python highlighting.
-- 1. Default vim python (syntax highlighting)
-- 2. This plugin (syntax highlighting)
-- 3. nvim-treesitter (syntax highlighting)
-- 4. basedpyright (semantic highlighting)
--
-- I want to use 4, so I disabled 3 which is distracting. (It's good but too much color)
-- However, then it was sometimes confusing if f-strings were actually f-strings. (the values were not highlighted)
-- with this plugin (2), I can see the f-strings are actually f-strings, but it doesn't hurt the 4.
"vim-python/python-syntax",
ft = "python",
init = function()
-- I only care about string highlighting here.
-- vim.g.python_highlight_all = 1
vim.g.python_highlight_string_formatting = 1
vim.g.python_highlight_string_format = 1
vim.g.python_highlight_string_templates = 1
vim.g.python_highlight_builtin_funcs = 1
vim.g.python_highlight_builtin_objs = 1
vim.g.python_highlight_builtin_types = 1
end,
},
{
"kiyoon/python-import.nvim",
build = "uv tool install . --force --reinstall",
keys = {
{
"<M-CR>",
function()
require("python_import.api").add_import_current_word_and_notify()
end,
mode = { "i", "n" },
silent = true,
desc = "Add python import",
ft = "python",
},
{
"<M-CR>",
function()
require("python_import.api").add_import_current_selection_and_notify()
end,
mode = "x",
silent = true,
desc = "Add python import",
ft = "python",
},
{
"<space>i",
function()
require("python_import.api").add_import_current_word_and_move_cursor()
end,
mode = "n",
silent = true,
desc = "Add python import and move cursor",
ft = "python",
},
{
"<space>i",
function()
require("python_import.api").add_import_current_selection_and_move_cursor()
end,
mode = "x",
silent = true,
desc = "Add python import and move cursor",
ft = "python",
},
{
"<space>tr",
function()
require("python_import.api").add_rich_traceback()
end,
silent = true,
desc = "Add rich traceback",
ft = "python",
},
},
opts = {
extend_lookup_table = {
---@type string[]
import = {
-- "tqdm",
},
---@type table<string, string>
import_as = {
-- These are the default values. Here for demonstration.
-- np = "numpy",
-- pd = "pandas",
},
---@type table<string, string>
import_from = {
-- tqdm = nil,
-- tqdm = "tqdm",
},
---@type table<string, string[]>
statement_after_imports = {
-- logger = { "import my_custom_logger", "", "logger = my_custom_logger.get_logger()" },
},
},
---Return nil to indicate no match is found and continue with the default lookup
---Return a table to stop the lookup and use the returned table as the result
---Return an empty table to stop the lookup. This is useful when you want to add to wherever you need to.
---@type fun(winnr: integer, word: string, ts_node: TSNode?): string[]?
custom_function = function(winnr, word, ts_node)
local bufnr = vim.api.nvim_win_get_buf(winnr)
local utils = require("python_import.utils")
if utils.get_cached_first_party_modules(bufnr) ~= nil then
local first_module = utils.get_cached_first_party_modules(bufnr)[1]
-- if statement ends with _DIR, import from the first module (from project import PROJECT_DIR)
if word:match("_DIR$") then
return { "from " .. first_module .. " import " .. word }
elseif word == "setup_logging" then
return { "from " .. first_module .. " import setup_logging" }
end
end
end,
},
dev = python_import_dev,
},
-- {
-- "Vimjas/vim-python-pep8-indent",
-- ft = "python",
-- },
{
"metakirby5/codi.vim",
cmd = "Codi",
init = function()
vim.g["codi#interpreters"] = {
python = {
bin = "python3",
},
}
vim.g["codi#virtual_text_pos"] = "right_align"
end,
},
{
"kiyoon/jupynium.nvim",
build = "bash scripts/build_with_uv.sh ~/.virtualenvs/jupynium",
ft = { "python", "markdown" },
config = function()
local python_host
if jupynium_dev then
python_host = { "conda", "run", "--no-capture-output", "-n", "jupynium_dev", "python" }
else
python_host = { "~/.virtualenvs/jupynium/bin/python" }
end
require("jupynium").setup({
default_notebook_URL = "localhost:8888/nbclassic",
python_host = python_host,
jupyter_command = { "conda", "run", "--no-capture-output", "-n", "base", "jupyter" },
-- firefox_profiles_ini_path = "~/snap/firefox/common/.mozilla/firefox/profiles.ini",
-- notify = {
-- ignore = {
-- "download_ipynb",
-- },
-- },
})
end,
dev = jupynium_dev,
},
-- {
-- "SUSTech-data/neopyter",
-- dependencies = {
-- "nvim-lua/plenary.nvim",
-- "AbaoFromCUG/websocket.nvim",
-- },
-- opts = {
-- -- auto define autocmd
-- auto_attach = true,
-- -- auto connect rpc service
-- auto_connect = true,
-- mode = "direct",
-- -- same with JupyterLab settings
-- remote_address = "127.0.0.1:19001",
-- file_pattern = { "*.ju.*" },
-- on_attach = function(bufnr) end,
--
-- highlight = {
-- enable = true,
-- shortsighted = true,
-- },
-- },
-- },
--- NOTE: Coding
-- {
-- -- "jk or jj to escape insert mode"
-- "max397574/better-escape.nvim",
-- event = "InsertEnter",
-- config = function()
-- require("better_escape").setup()
-- end,
-- },
{
-- <space>siwie to substitute word from entire buffer
-- <space>siwip to substitute word from paragraph
-- <space>siwif to substitute word from function
-- <space>siwic to substitute word from class
-- <space>ssip to substitute word from paragraph
"svermeulen/vim-subversive",
keys = {
{ "<space>s", "<plug>(SubversiveSubstituteRange)", mode = { "n", "x" } },
{ "<space>ss", "<plug>(SubversiveSubstituteWordRange)", mode = { "n" } },
},
},
{
-- Similar to tpope/vim-surround
-- Plus dsf to delete surrounding function call.
"kylechui/nvim-surround",
event = "VeryLazy",
config = function()
require("nvim-surround").setup()
local right = function()
local nowCol = vim.api.nvim_eval([[virtcol('.')]])
local lastCol = vim.api.nvim_eval([[virtcol('$')]]) - 1
if nowCol == lastCol then
vim.cmd("startinsert!")
else
vim.cmd("norm! a")
end
end
-- map backtick to surround backtick (or alt ` in i mode)
-- backtick originally goes to the mark, but I don't use it. You can use ` to go to the mark.
-- 디폴트 `ys`를 선행키로 잡으면 약간의 딜레이가 생긴다.
vim.keymap.set("n", "`", function()
vim.cmd.normal("viwS`f`l")
end, { desc = "Surround backtick" })
vim.keymap.set("i", "<A-`>", function()
vim.cmd.normal("hviwS`f`l")
right()
end, { silent = false, desc = "Surround backtick" })
vim.keymap.set("x", "`", function()
vim.cmd.normal("S`f`")
right()
end, { silent = false, desc = "Surround backtick" })
-- map <F4> to surround with parenthesis for function call (keep cursor at front)
-- change iskeyword temporarily because we don't want `-` to be included in the word
vim.keymap.set("n", "<F4>", function()
local original_iskeyword = vim.opt.iskeyword
vim.opt.iskeyword = "@,48-57,_,192-255" -- alphabet, _, and European accented characters
vim.cmd.normal({ "viw", bang = true })
vim.opt.iskeyword = original_iskeyword
vim.cmd.normal("S)")
vim.cmd.startinsert()
end, { desc = "Surround parens (function call)" })
vim.keymap.set("i", "<F4>", function()
local original_iskeyword = vim.opt.iskeyword
vim.opt.iskeyword = "@,48-57,_,192-255" -- alphabet, _, and European accented characters
vim.cmd.normal({ "hviw", bang = true })
vim.opt.iskeyword = original_iskeyword
vim.cmd.normal("S)")
end, { silent = false, desc = "Surround parens (function call)" })
vim.keymap.set("x", "<F4>", function()
vim.cmd.normal("S)")
vim.cmd.startinsert()
end, { silent = false, desc = "Surround parens (function call)" })
-- map <space>tl to make hyperlink for markdown
vim.keymap.set("n", "<space>tl", function()
vim.cmd.normal("viwS]f]a()")
vim.cmd.startinsert()
end, { desc = "Make markdown hyperlink" })
vim.keymap.set("x", "<space>tl", function()
vim.cmd.normal("S]f]a()")
vim.cmd.startinsert()
end, { desc = "Make markdown hyperlink" })
end,
},
{
-- I don't use autopairs. I only need this for fast-wrap.
-- <A-e> in insert mode to add closing pair without moving cursor
-- Similar to nvim-surround, but works in insert mode
"windwp/nvim-autopairs",
keys = {
{ "<m-e>", mode = "i" },
},
config = function()
local ap = require("nvim-autopairs")
ap.setup({
-- Disable auto fast wrap
enable_afterquote = false,
-- <A-e> to manually trigger fast wrap
fast_wrap = {},
})
-- Remove all autopair rules, but keep the fast wrap
local function manual_trigger(opening, closing)
local rule
if ap.get_rule(opening)[1] == nil then
rule = ap.get_rule(opening)
else
rule = ap.get_rule(opening)[1]
end
rule:use_key("<m-p>"):replace_endpair(function()
-- repeat the number of characters in the closing pair
return closing .. string.rep("<left>", #closing)
end)
end
manual_trigger("'", "'")
manual_trigger('"', '"')
manual_trigger("`", "`")
manual_trigger("{", "}")
manual_trigger("(", ")")
manual_trigger("[", "]")
end,
},
{
"numToStr/Comment.nvim",
keys = {
{ "gc", mode = { "n", "x", "o" }, desc = "Comment / uncomment lines" },
{ "gb", mode = { "n", "x", "o" }, desc = "Comment / uncomment a block" },
},
config = function()
require("Comment").setup()
end,
},
-- {
-- "tpope/vim-sleuth", -- Detect tabstop and shiftwidth automatically
-- event = "BufReadPost",
-- -- config = function()
-- -- -- script to execute AFTER the plugin is loaded
-- -- -- vim.defer_fn(function()
-- -- -- vim.opt.tabstop = 4
-- -- -- end, 0)
-- -- end,
-- },
{
"kana/vim-textobj-entire",
keys = {
{ "ie", mode = { "o", "x" }, desc = "Select entire buffer (file)" },
{ "ae", mode = { "o", "x" }, desc = "Select entire buffer (file)" },
},
dependencies = { "kana/vim-textobj-user" },
}, -- vie, vae to select entire buffer (file)
{
"kana/vim-textobj-fold",
keys = {
{ "iz", mode = { "o", "x" }, desc = "Select fold" },
{ "az", mode = { "o", "x" }, desc = "Select fold" },
},
dependencies = { "kana/vim-textobj-user" },
}, -- viz, vaz to select fold
{
"glts/vim-textobj-comment",
keys = {
{ "ic", mode = { "o", "x" }, desc = "Select comment block" },
{ "ac", mode = { "o", "x" }, desc = "Select comment block" },
},
dependencies = { "kana/vim-textobj-user" },
}, -- vic, vac
{
"chaoren/vim-wordmotion",
event = "VeryLazy",
-- use init instead of config to set variables before loading the plugin
init = function()
vim.g.wordmotion_prefix = "<space>"
end,
},
---Yank
{
"aserowy/tmux.nvim",
keys = {
"<C-h>",
"<C-j>",
"<C-k>",
"<C-l>",
{ "<C-A-i>", [[<cmd>lua require("tmux").resize_top()<cr>]] },
{ "<C-A-u>", [[<cmd>lua require("tmux").resize_bottom()<cr>]] },
{ "<C-A-y>", [[<cmd>lua require("tmux").resize_left()<cr>]] },
{ "<C-A-o>", [[<cmd>lua require("tmux").resize_right()<cr>]] },
{ "<F16>", [[<cmd>lua require("tmux").resize_top()<cr>]], mode = { "n", "i", "x", "s", "o" } }, -- <S-F3>
{ "<F15>", [[<cmd>lua require("tmux").resize_top()<cr>]], mode = { "n", "i", "x", "s", "o" } }, -- <S-F2>
{ "<F18>", [[<cmd>lua require("tmux").resize_bottom()<cr>]], mode = { "n", "i", "x", "s", "o" } }, -- <S-F6>
{ "<F27>", [[<cmd>lua require("tmux").resize_left()<cr>]], mode = { "n", "i", "x", "s", "o" } }, -- <C-F3>
{ "<F26>", [[<cmd>lua require("tmux").resize_left()<cr>]], mode = { "n", "i", "x", "s", "o" } }, -- <C-F2>
{ "<F30>", [[<cmd>lua require("tmux").resize_right()<cr>]], mode = { "n", "i", "x", "s", "o" } }, -- <C-F6>
"<C-n>",
"<C-p>",
-- { '"', mode = { "n", "x" } },
-- { "<C-r>", mode = { "i" } },
{ "p", mode = { "n", "x", "o", "s" } },
{ "P", mode = { "n", "x", "o", "s" } },
{ "=p", mode = { "n", "x", "o", "s" } },
{ "=P", mode = { "n", "x", "o", "s" } },
{ "y", mode = { "x", "o", "s" } },
{ "d", mode = { "x", "o", "s" } },
{ "c", mode = { "x", "o", "s" } },
{ "Y", mode = { "n", "x", "o", "s" } },
{ "D", mode = { "n", "x", "o", "s" } },
{ "C", mode = { "n", "x", "o", "s" } },
},
dependencies = {
"gbprod/yanky.nvim",
"nvim-telescope/telescope.nvim",
"nvim-lua/plenary.nvim",
},
config = function()
require("kiyoon.tmux-yanky")
-- After initialising yanky, this mapping gets lost so we do this here.
vim.cmd([[nnoremap Y y$]])
end,
},
{
"github/copilot.vim",
-- event = "InsertEnter",
-- cmd = { "Copilot" },
init = function()
vim.g.copilot_no_tab_map = true
vim.cmd([[imap <silent><script><expr> <C-s> copilot#Accept("")]])
vim.cmd([[imap <silent><script><expr> <F7> copilot#Accept("")]])
-- delete word in INSERT mode
-- you can use <C-w> but this is for consistency with github copilot
-- using <A-Right> to accept a word.
vim.cmd([[inoremap <A-Left> <C-\><C-o>db]])
vim.cmd([[inoremap <A-BS> <C-\><C-o>db]]) -- consistency with zsh and bash
vim.cmd([[inoremap <F2> <C-\><C-o>db]])
vim.cmd([[inoremap <F3> <C-\><C-o>db]])
vim.cmd([[inoremap <F5> <Plug>(copilot-accept-word)]])
vim.cmd([[inoremap <F6> <Plug>(copilot-accept-word)]])
end,
},
-- Free copilot alternative
-- "Exafunction/codeium.vim",
{
"Bryley/neoai.nvim",
dependencies = {
"MunifTanjim/nui.nvim",
},
cmd = {
"NeoAI",
"NeoAIOpen",
"NeoAIClose",
"NeoAIToggle",
"NeoAIContext",
"NeoAIContextOpen",
"NeoAIContextClose",
"NeoAIInject",
"NeoAIInjectCode",
"NeoAIInjectContext",
"NeoAIInjectContextCode",
"InjectCommitMessage",
"TextifyCommitMessage",
},
keys = {
{ "<space>as", mode = { "x" }, desc = "summarize text" },
},
config = function()
require("neoai").setup({
models = {
{
name = "openai",
model = "gpt-4o",
params = nil,
},
},
shortcuts = {
{
name = "textify",
key = "<space>as",
desc = "fix text with AI",
use_context = true,
prompt = [[
Please rewrite the text to make it more readable, clear,
concise, and fix any grammatical, punctuation, or spelling
errors
]],
modes = { "x" },
strip_function = nil,
},
},
})
require("kiyoon.neoai")
end,
},
{
"robitx/gp.nvim",
init = function()
local status, wk = pcall(require, "which-key")
if status then
wk.add({
{ "<leader>c", group = "ChatGPT" },
})
end
end,
cmd = {
"GpChatNew",
"GpChatPaste",
"GpRewrite",
"GpAppend",
"GpAgent",
"GpNextAgent",
},
keys = {
{ "<leader>cg", "<cmd>GpChatNew<CR>", mode = { "n", "x" }, desc = "ChatGPT" },
{
"<leader>ce",
"<cmd>GpRewrite<CR>",
mode = { "n", "x" },
desc = "ChatGPT Edit With Instructions",
},
},
config = function()
require("gp").setup({
openai_api_key = { "pass", "API-dear/openai" },
agents = {
{
name = "ChatGPT4o",
chat = true,
command = false,
-- string with model name or table with model name and parameters
model = { model = "gpt-4o", temperature = 1.1, top_p = 1 },
-- system prompt (use this to specify the persona/role of the AI)
system_prompt = "You are a general AI assistant.\n\n"
.. "The user provided the additional info about how they would like you to respond:\n\n"
.. "- If you're unsure don't guess and say you don't know instead.\n"
.. "- Ask question if you need clarification to provide better answer.\n"
.. "- Think deeply and carefully from first principles step by step.\n"
.. "- Zoom out first to see the big picture and then zoom in to details.\n"
.. "- Use Socratic method to improve your thinking and coding skills.\n"
.. "- Don't elide any code from your output if the answer requires coding.\n"
.. "- Take a deep breath; You've got this!\n",
},
{
name = "ChatGPT3-5-Turbo",
chat = true,
command = false,
-- string with model name or table with model name and parameters
model = { model = "gpt-3.5-turbo", temperature = 1.1, top_p = 1 },
-- system prompt (use this to specify the persona/role of the AI)
system_prompt = "You are a general AI assistant.\n\n"
.. "The user provided the additional info about how they would like you to respond:\n\n"
.. "- If you're unsure don't guess and say you don't know instead.\n"
.. "- Ask question if you need clarification to provide better answer.\n"
.. "- Think deeply and carefully from first principles step by step.\n"
.. "- Zoom out first to see the big picture and then zoom in to details.\n"
.. "- Use Socratic method to improve your thinking and coding skills.\n"
.. "- Don't elide any code from your output if the answer requires coding.\n"
.. "- Take a deep breath; You've got this!\n",
},
{
name = "CodeGPT4o",
chat = false,
command = true,
-- string with model name or table with model name and parameters
model = { model = "gpt-4o", temperature = 0.8, top_p = 1 },
-- system prompt (use this to specify the persona/role of the AI)
system_prompt = "You are an AI working as a code editor.\n\n"
.. "Please AVOID COMMENTARY OUTSIDE OF THE SNIPPET RESPONSE.\n"
.. "START AND END YOUR ANSWER WITH:\n\n```",
},
{
name = "CodeGPT3-5-Turbo",
chat = false,
command = true,
-- string with model name or table with model name and parameters
model = { model = "gpt-3.5-turbo", temperature = 0.8, top_p = 1 },
-- system prompt (use this to specify the persona/role of the AI)
system_prompt = "You are an AI working as a code editor.\n\n"
.. "Please AVOID COMMENTARY OUTSIDE OF THE SNIPPET RESPONSE.\n"
.. "START AND END YOUR ANSWER WITH:\n\n```",
},
},
})
end,
},
--- NOTE: Git
{
"sindrets/diffview.nvim",
keys = {
{ "<leader>dv", ":DiffviewOpen<CR>" },
{ "<leader>dc", ":DiffviewClose<CR>" },
{ "<leader>dq", ":DiffviewClose<CR>:q<CR>" },
},
cmd = { "DiffviewOpen", "DiffviewClose" },
},
{
"lewis6991/gitsigns.nvim",
event = { "BufReadPre", "BufNewFile" },
opts = require("kiyoon.gitsigns_opts"),
-- add at least one keys so that which-key can register the leader key
keys = {
{
"<leader>hb",
},
},
init = function()
local status, wk = pcall(require, "which-key")
if status then
wk.add({
{ "<leader>h", group = "Gitsigns" },
})
end
end,
},
--- NOTE: File tree
{
"nvim-tree/nvim-tree.lua",
lazy = true,
-- init = function()
-- local function open_nvim_tree(data)
-- -- buffer is a directory
-- local directory = vim.fn.isdirectory(data.file) == 1
--
-- if not directory then
-- return
-- end
--
-- -- change to the directory
-- vim.cmd.cd(data.file)
--
-- -- open the tree
-- require("nvim-tree.api").tree.open()
-- end
--
-- vim.api.nvim_create_augroup("nvim_tree_open", {})
-- vim.api.nvim_create_autocmd({ "VimEnter" }, {
-- callback = open_nvim_tree,
-- group = "nvim_tree_open",
-- })
-- end,
dependencies = {
"nvim-tree/nvim-web-devicons",
},
keys = {
{
"<space>nt",
"<cmd>NvimTreeToggle<CR>",
desc = "Toggle NvimTree",
},
},
cmd = {
"NvimTreeToggle",
"NvimTreeOpen",
},
config = function()
require("kiyoon.nvim_tree")
end,
},
{
"nvim-neo-tree/neo-tree.nvim",
branch = "v3.x",
dependencies = {
"nvim-lua/plenary.nvim",
"nvim-tree/nvim-web-devicons", -- not strictly required, but recommended
"MunifTanjim/nui.nvim",
},
init = function()
vim.g.neo_tree_remove_legacy_commands = 1
end,
cmd = "Neotree",
keys = {
{ "<space>nn", "<cmd>Neotree toggle<CR>", mode = { "n", "x" }, desc = "[N]eotree toggle" },
},
},
{
"stevearc/oil.nvim",
-- cond = function()
-- return vim.fn.isdirectory(vim.fn.expand "%:p") == 1
-- end,
config = function()
require("oil").setup({
keymaps = {
["\\"] = { "actions.select", opts = { vertical = true }, desc = "Open the entry in a vertical split" },
["|"] = { "actions.select", opts = { horizontal = true }, desc = "Open the entry in a horizontal split" },
["<C-r>"] = "actions.refresh",
["g?"] = "actions.show_help",
["<CR>"] = "actions.select",
["<C-t>"] = { "actions.select", opts = { tab = true }, desc = "Open the entry in new tab" },
["<C-p>"] = "actions.preview",
["<C-c>"] = "actions.close",
["-"] = "actions.parent",
["_"] = "actions.open_cwd",
["`"] = "actions.cd",
["~"] = { "actions.cd", opts = { scope = "tab" }, desc = ":tcd to the current oil directory" },
["gs"] = "actions.change_sort",
["gx"] = "actions.open_external",
["g."] = "actions.toggle_hidden",
["g\\"] = "actions.toggle_trash",
},
use_default_keymaps = false,
})
end,
},
--- NOTE: Treesitter: Better syntax highlighting, text objects, refactoring, context
{
"nvim-treesitter/nvim-treesitter",
event = { "BufReadPost", "BufNewFile" },
build = ":TSUpdate",
init = function(plugin)
-- PERF: add nvim-treesitter queries to the rtp and it's custom query predicates early
-- This is needed because a bunch of plugins no longer `require("nvim-treesitter")`, which
-- no longer trigger the **nvim-treesitter** module to be loaded in time.
-- Luckily, the only things that those plugins need are the custom queries, which we make available
-- during startup.
require("lazy.core.loader").add_to_rtp(plugin)
require("nvim-treesitter.query_predicates")
end,
config = function()
require("kiyoon.treesitter")
end,
dependencies = {
{
"nvim-treesitter/nvim-treesitter-textobjects",
-- "kiyoon/nvim-treesitter-textobjects",
-- branch = "fix/builtin_find",
dev = nvim_treesitter_textobjects_dev,
},
"RRethy/nvim-treesitter-endwise",
{
"andymass/vim-matchup",
init = function()
--- Without this, lualine will flicker when matching offscreen
--- Maybe it happens when cmdheight is set to 0
vim.g.matchup_matchparen_offscreen = { method = "popup" }
end,
},
{
"HiPhish/rainbow-delimiters.nvim",
config = function()
-- https://github.com/ayamir/nvimdots/pull/868/files
---@param threshold number @Use global strategy if nr of lines exceeds this value
local function init_strategy(threshold)
return function()
local errors = 200
vim.treesitter.get_parser():for_each_tree(function(lt)
if lt:root():has_error() and errors >= 0 then
errors = errors - 1
end
end)
if errors < 0 then
return nil
end
return vim.fn.line("$") > threshold and require("rainbow-delimiters").strategy["global"]
or require("rainbow-delimiters").strategy["local"]
end
end
vim.g.rainbow_delimiters = {
strategy = {
[""] = init_strategy(500),
c = init_strategy(200),
cpp = init_strategy(200),
lua = init_strategy(500),
vimdoc = init_strategy(300),
vim = init_strategy(300),
markdown = require("rainbow-delimiters").strategy["global"], -- markdown parser is slow
},
query = {
[""] = "rainbow-delimiters",
latex = "rainbow-blocks",
javascript = "rainbow-delimiters-react",
},
highlight = {
"RainbowDelimiterRed",
"RainbowDelimiterOrange",
"RainbowDelimiterYellow",
"RainbowDelimiterGreen",
"RainbowDelimiterBlue",
"RainbowDelimiterCyan",
"RainbowDelimiterViolet",
},
}
end,
},
},
dev = nvim_treesitter_dev,
},
{
-- "nvim-treesitter/nvim-treesitter-context",
"kiyoon/nvim-treesitter-context",
event = { "BufReadPost", "BufNewFile" },
-- This commit is the parent of https://github.com/nvim-treesitter/nvim-treesitter-context/pull/316
-- which introduced showing context in multiple lines.
-- However, it becomes too long and I prefer the old behaviour.
-- commit = "e5676455c7e68069c6299facd4b5c4eb80cc4e9d",
config = function()
require("treesitter-context").setup({
max_lines = 7,
})
end,
},
{
"lukas-reineke/indent-blankline.nvim",
tag = "v2.20.8",
-- main = "ibl",
-- opts = {},
event = "BufReadPost",
config = function()
vim.opt.list = true
--vim.opt.listchars:append "space:⋅"
--vim.opt.listchars:append "eol:↴"
-- local highlight = {
-- "RainbowDelimiterRed",
-- "RainbowDelimiterOrange",
-- "RainbowDelimiterYellow",
-- "RainbowDelimiterGreen",
-- "RainbowDelimiterBlue",
-- "RainbowDelimiterCyan",
-- "RainbowDelimiterViolet",
-- }
-- local hooks = require "ibl.hooks"
-- -- create the highlight groups in the highlight setup hook, so they are reset
-- -- every time the colorscheme changes
-- hooks.register(hooks.type.HIGHLIGHT_SETUP, function()
-- vim.api.nvim_set_hl(0, "RainbowRed", { fg = "#E06C75" })
-- vim.api.nvim_set_hl(0, "RainbowYellow", { fg = "#E5C07B" })
-- vim.api.nvim_set_hl(0, "RainbowBlue", { fg = "#61AFEF" })
-- vim.api.nvim_set_hl(0, "RainbowOrange", { fg = "#D19A66" })
-- vim.api.nvim_set_hl(0, "RainbowGreen", { fg = "#98C379" })
-- vim.api.nvim_set_hl(0, "RainbowViolet", { fg = "#C678DD" })
-- vim.api.nvim_set_hl(0, "RainbowCyan", { fg = "#56B6C2" })
-- end)
--
-- require("ibl").setup { scope = { highlight = highlight } }
-- hooks.register(hooks.type.SCOPE_HIGHLIGHT, hooks.builtin.scope_highlight_from_extmark)
require("indent_blankline").setup({
space_char_blankline = " ",
show_current_context = true,
show_current_context_start = true,
})
end,
},
{
"kiyoon/treesitter-indent-object.nvim",
dependencies = {
"lukas-reineke/indent-blankline.nvim",
},
keys = {
{
"ai",
function()
require("treesitter_indent_object.textobj").select_indent_outer()
end,
mode = { "x", "o" },
desc = "Select context-aware indent (outer)",
},
{
"aI",
function()
require("treesitter_indent_object.textobj").select_indent_outer(true, "V")
require("treesitter_indent_object.refiner").include_surrounding_empty_lines()
end,
mode = { "x", "o" },
desc = "Select context-aware indent (outer, line-wise)",
},
{
"ii",
function()
require("treesitter_indent_object.textobj").select_indent_inner()
end,
mode = { "x", "o" },
desc = "Select context-aware indent (inner, partial range)",
},
{
"iI",
function()
require("treesitter_indent_object.textobj").select_indent_inner(true, "V")
end,
mode = { "x", "o" },
desc = "Select context-aware indent (inner, entire range) in line-wise visual mode",
},
},
},
-- {
-- -- Alternative to indent-blankline and treesitter-indent-object
-- "folke/snacks.nvim",
-- opts = {
-- indent = {
-- -- your indent configuration comes here
-- -- or leave it empty to use the default settings
-- -- refer to the configuration section below
-- indent = {
-- -- only_scope = true, -- only show indent guides of the scope
-- },
-- scope = {
-- enabled = true,
-- underline = true,
-- },
-- animate = {
-- enabled = false,
-- },
-- },
-- scope = {
-- enabled = true,
-- -- These keymaps will only be set if the `scope` plugin is enabled.
-- -- Alternatively, you can set them manually in your config,
-- -- using the `Snacks.scope.textobject` and `Snacks.scope.jump` functions.
-- },
-- },
-- },
{
"danymat/neogen",
dependencies = "nvim-treesitter/nvim-treesitter",
config = function()
local custom_templates = require("kiyoon.neogen")
require("neogen").setup({
snippet_engine = "luasnip",
languages = {
python = {
template = {
annotation_convention = "google_docstrings_notypes",
google_docstrings_notypes = custom_templates.google_docstrings_notypes,
},
},
},
})
end,
-- Uncomment next line if you want to follow only stable versions
-- version = "*"
keys = {
{
"<space>td",
"<cmd>lua require('neogen').generate()<CR>",
desc = "Generate [D]ocstring",
},
},
},
-- % to match up if, else, etc. Enabled in the treesitter config below
{
"Wansmer/treesj",
keys = {
{ "<space>l", "<cmd>TSJSplit<CR>", desc = "Treesitter Split" },
{ "<space>h", "<cmd>TSJJoin<CR>", desc = "Treesitter Join" },
-- { "<space>g", "<cmd>TSJToggle<CR>", desc = "Treesitter Toggle" },
},
config = function()
require("treesj").setup({ use_default_keymaps = false })
end,
},
{
"ThePrimeagen/refactoring.nvim",