-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdefault.nix
1691 lines (1568 loc) · 49.6 KB
/
default.nix
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
{
upkgs,
pkgs,
lib,
config,
inputs,
...
}:
let
# Toggles for including tooling related to a given language
packedTargets = {
elm = false;
latex = true;
lua = true;
nix = true;
purescript = false;
python = false;
rust = false;
typst = true;
web = true;
csharp = false;
};
korora = inputs.korora.lib;
nlib = import ../../../modules/common/korora-neovim.nix { inherit lib korora; } {
tempestModule = "my.tempest";
};
mirosSnippetCache = "${config.xdg.cacheHome}/miros";
obsidianVault = "${config.xdg.userDirs.extraConfig.XDG_PROJECTS_DIR}/stellar-sanctum";
generated =
with nlib;
generateConfig {
# {{{ Pre-plugin config
pre = {
# {{{ General options
"0:general-options" = {
vim.g = {
# Disable filetype.vim
do_filetype_lua = true;
did_load_filetypes = false;
# Set leader
mapleader = " ";
};
vim.opt = {
# Basic options
joinspaces = false; # No double spaces with join (mapped to qj in my config)
list = false; # I don't want to show things like tabs
cmdheight = 0; # Hide command line when it's not getting used
spell = true; # Spell checker
signcolumn = "yes"; # Keeps the sign column of a consistent width
# tcqj are there by default, and "r" automatically continues comments on enter
formatoptions = "tcqjr";
scrolloff = 4; # Starts scrolling 4 lines from the edge of the screen
termguicolors = true; # True color support
wrap = false; # Disable line wrap (by default)
wildmode = [
"list"
"longest"
]; # Command-line completion mode
completeopt = [
"menu"
"menuone"
"noselect"
];
undofile = true; # persist undos!!
# {{{ Line numbers
number = true; # Show line numbers
relativenumber = true; # Relative line numbers
# }}}
# {{{ Indents
expandtab = true; # Use spaces for the tab char
shiftwidth = 2; # Size of an indent
tabstop = 2; # Size of tab character
shiftround = true; # When using < or >, rounds to closest multiple of shiftwidth
smartindent = true; # Insert indents automatically
# }}}
# {{{ Casing
ignorecase = true; # Ignore case
smartcase = true; # Do not ignore case with capitals
# }}}
# {{{ Splits
splitbelow = true; # Put new windows below current
splitright = true; # Put new windows right of current
# }}}
# {{{ Folding
foldmethod = "marker"; # use {{{ }}} for folding
foldcolumn = "0"; # show no column with folds on the left
# }}}
};
# {{{Disable pseudo-transparency;
autocmds = {
event = "FileType";
group = "WinblendSettings";
action.vim.opt.winblend = 0;
};
# }}}
# {{{ Starter page
callback =
# lua
thunk ''
local cwd = vim.loop.cwd()
local header
if cwd == ${encode obsidianVault} then
header = ${encode (builtins.readFile ./headers/obsidian.txt)}
else
header = ${encode (builtins.readFile ./headers/main.txt)}
end
require("my.starter").setup({ header = header })
'';
# }}}
};
# }}}
# {{{ Misc keybinds
"1:misc-keybinds" = {
# {{{ Global keybinds
keys =
# {{{ Keybind helpers
let
dmap = mapping: action: desc: {
inherit mapping desc;
action = vim /diagnostic/${action};
};
in
# }}}
[
# {{{ Free up q and Q
(nmap "<c-q>" "q" "Record macro")
(nmap "<c-s-q>" "Q" "Repeat last recorded macro")
(unmap "q")
(unmap "Q")
# }}}
# {{{ Chords
# Different chords get remapped to f-keys by my [my kaanta config](../../../hosts/nixos/common/optional/services/kanata.nix).
#
# Exit insert mode using *jk*
(keymap "iv" "<f10>" "<esc>" "Exit insert mode")
# Use global clipboard using *cp*
(keymap "nv" "<f11>" ''"+'' "Use global clipboard")
# Save using *ji*
(nmap "<f12>" (thunk ''
-- If we don't do this, the statusbar will flash for a second...
vim.cmd([[silent! write]])
vim.opt.stl = vim.opt.stl
'') "Save current file")
# }}}
# {{{ Newline without comments
{
mode = "i";
mapping = "<c-cr>";
action =
_:
vim /paste (args [
[
""
""
]
(-1)
]);
desc = "Insert newline without continuing the current comment";
}
{
mode = "i";
mapping = "<c-s-cr>";
# This is a bit scuffed and might not work for all languages
action = "<cmd>norm O<bs><bs><bs><cr>";
desc = "Insert newline above without continuing the current comment";
}
# }}}
# {{{ Diagnostics
(dmap "J" "open_float" "Open current diagnostic")
(dmap "<leader>D" "setloclist" "[D]iagnostic loclist")
(nmap "qj" "J" "join lines")
# }}}
# {{{ Other misc keybinds
(nmap "<Leader>a" "<C-^>" "[A]lternate file")
(unmap "<C-^>")
(nmap "Q" ":wqa<cr>" "Save all files and [q]uit")
(nmap "<leader>rw" ":%s/<C-r><C-w>/" "[R]eplace [w]ord in file")
(nmap "<leader>sw" (require "my.helpers.wrap" /toggle) "toggle word [w]rap")
(nmap "<leader>ss" (
# lua
thunk "vim.opt.spell = not vim.o.spell"
) "toggle [s]pell checker")
(nmap "<leader>yp" "<cmd>!curl --data-binary @% https://paste.rs | wl-copy<cr>"
"[y]ank [p]aste.rs link to clipboard"
)
# }}}
];
# }}}
# {{{ Autocmds
autocmds = [
# {{{ Exit certain buffers with qq
{
event = "FileType";
pattern = [ "help" ];
group = "BasicBufferQuitting";
action.keys = nmap "qq" "<cmd>close<cr>" "[q]uit current buffer";
}
# }}}
# {{{ Enable wrap movemenets by default in certain filetypes
{
event = "FileType";
pattern = [
"markdown"
"typst"
"tex"
];
group = "EnableWrapMovement";
action = require "my.helpers.wrap" /enable;
}
# }}}
];
# }}}
};
# }}}
# {{{ Manage cmdheight
"2:manage-cmdheight".autocmds = [
{
event = "CmdlineEnter";
group = "SetCmdheightCmdlineEnter";
action.vim.opt.cmdheight = 1;
}
{
event = "CmdlineLeave";
group = "SetCmdheightCmdlineLeave";
action.vim.opt.cmdheight = 0;
}
];
# }}}
# {{{ Lsp settings
"3:lsp-settings" = {
# {{{ Change lsp on-hover borders
vim.lsp.handlers."textDocument/hover" = vim /lsp/with (args [
(vim /lsp/handlers/hover)
{ border = "single"; }
]);
vim.lsp.handlers."textDocument/signatureHelp" = vim /lsp/with (args [
(vim /lsp/handlers/signature_help)
{ border = "single"; }
]);
# }}}
# {{{ Create on-attach keybinds
autocmds = {
event = "LspAttach";
group = "UserLspConfig";
action = {
mkContext = event: {
bufnr = lua event /buf;
client = vim /lsp/get_client_by_id (lua event /data/client_id);
};
keys = [ ];
};
};
# }}}
};
# }}}
# {{{ Neovide config
"4:configure-neovide" = {
cond = whitelist "neovide";
vim.g = {
neovide_transparency = tempest /theme/transparency/applications/value;
neovide_cursor_animation_length = 4.0e-2;
neovide_cursor_animate_in_insert_mode = false;
};
};
# }}}
# {{{ Language specific overrides
"5:language-specific-settings" = {
autocmds = [
# {{{ Nix
{
event = "FileType";
group = "UserNixSettings";
pattern = "nix";
action = {
vim.opt.commentstring = "# %s";
keys = {
mapping = "<leader>lg";
action =
_:
let
cmd = _: vim /cmd ":%!${lib.getExe pkgs.update-nix-fetchgit}";
in
tempest /withSavedCursor cmd;
desc = "Update all fetchgit calls";
};
};
}
# }}}
# {{{ Purescript
{
event = "FileType";
group = "UserPurescriptSettings";
pattern = "purs";
action.vim.opt = {
expandtab = true; # Use spaces for the tab char
commentstring = "-- %s";
};
}
# }}}
];
};
# }}}
};
# }}}
# {{{ Plugins
lazy = {
# {{{ libraries
# {{{ plenary
plenary = {
package = "nvim-lua/plenary.nvim";
# Autoload when running tests
cmd = [
"PlenaryBustedDirectory"
"PlenaryBustedFile"
];
};
# }}}
# {{{ nui
nui.package = "MunifTanjim/nui.nvim";
# }}}
# {{{ web-devicons
web-devicons.package = "nvim-tree/nvim-web-devicons";
# }}}
# {{{ scrap
scrap = {
package = "prescientmoon/scrap.nvim";
event = "InsertEnter";
};
# }}}
# }}}
# {{{ ui
# {{{ mini.statusline
mini-statusline = {
package = "echasnovski/mini.statusline";
name = "mini.statusline";
dependencies.lua = [ "web-devicons" ];
lazy = false;
opts.content.inactive =
_:
require "mini.statusline" /combine_groups [
{
hl = "MiniStatuslineFilename";
strings = [ (vim /fn/expand "%:t") ];
}
];
opts.content.active =
# lua
thunk ''
local st = require("mini.statusline");
local mode, mode_hl = st.section_mode({ trunc_width = 120 })
local git = st.section_git({ trunc_width = 75 })
local diagnostics = st.section_diagnostics({ trunc_width = 75 })
return st.combine_groups({
{ hl = mode_hl, strings = { mode } },
{ hl = "MiniStatuslineDevinfo", strings = { git } },
{ hl = "MiniStatuslineFilename", strings = {
vim.fn.fnamemodify(vim.fn.expand("%:p"), ":~:.")
} },
"%=", -- End left alignment
{ hl = "MiniStatuslineFilename", strings = { diagnostics } },
{ hl = "MiniStatuslineDevinfo", strings = { vim.bo.filetype } },
})
'';
};
# }}}
# {{{ mini.files
mini-files = {
package = "echasnovski/mini.files";
name = "mini.files";
dependencies.lua = [ "web-devicons" ];
keys = {
mapping = "<c-s-f>";
desc = "[S]earch [F]iles";
action =
# lua
thunk ''
local files = require("mini.files")
if not files.close() then
files.open(vim.api.nvim_buf_get_name(0))
files.reveal_cwd()
end
'';
};
opts.windows.preview = false;
opts.mappings.go_in_plus = "l";
};
# }}}
# {{{ quicker.nvim
quicker-nvim = {
package = "stevearc/quicker.nvim";
name = "quicker.nvim";
dependencies.lua = [ "web-devicons" ];
event = "FileType qf";
opts = { };
};
# }}}
# {{{ harpoon
harpoon = {
package = "ThePrimeagen/harpoon";
event = "VeryLazy";
keys =
let
goto = key: index: {
desc = "Goto harpoon file ${toString index}";
mapping = "<c-s>${key}";
action = _: require "harpoon.ui" /nav_file (toString index);
};
in
[
{
desc = "Add file to [h]arpoon";
mapping = "<leader>H";
action = _: require "harpoon.mark" /add_file none;
}
{
desc = "Toggle harpoon quickmenu";
mapping = "<c-a>";
action = _: require "harpoon.ui" /toggle_quick_menu none;
}
(goto "q" 1)
(goto "w" 2)
(goto "e" 3)
(goto "r" 4)
(goto "a" 5)
(goto "s" 6)
(goto "d" 7)
(goto "f" 8)
(goto "z" 9)
];
};
# }}}
# {{{ telescope
telescope = {
package = "nvim-telescope/telescope.nvim";
version = "0.1.x";
event = "VeryLazy";
# {{{ Dependencies
dependencies = {
nix = [ pkgs.ripgrep ];
lua = [
"plenary"
{
# We want a prebuilt version of this plugin
dir = pkgs.vimPlugins.telescope-fzf-native-nvim;
name = "telescope-fzf-native";
}
];
};
# }}}
# {{{ Keymaps
keys =
let
nmap = mapping: action: desc: {
inherit mapping desc;
action = "<cmd>Telescope ${action} theme=ivy<cr>";
};
findFilesByExtension =
mapping: extension: tag:
nmap "<leader>f${mapping}" "find_files find_command=rg,--files,--glob=**/*.${extension}"
"Find ${tag} files";
in
[
(nmap "<c-p>" "find_files" "File finder [p]alette")
(nmap "<leader>d" "diagnostics root_dir=true" "[D]iagnostics")
(nmap "<c-f>" "live_grep" "[F]ind in project")
(nmap "<c-t>" "builtin" "[T]elescope pickers")
# {{{ Files by extension
(findFilesByExtension "tx" "tex" "[t]ex")
(findFilesByExtension "ts" "ts" "[t]ypescript")
(findFilesByExtension "ty" "typ" "[t]ypst")
(findFilesByExtension "l" "lua" "[l]ua")
(findFilesByExtension "n" "nix" "[n]ua")
(findFilesByExtension "p" "purs" "[p]urescript")
(findFilesByExtension "h" "hs" "[h]askell")
(findFilesByExtension "e" "elm" "[e]lm")
(findFilesByExtension "r" "rs" "[r]ust")
# }}}
];
# }}}
# {{{ Disable folds in telescope windows
config.autocmds = {
event = "FileType";
pattern = "TelescopeResults";
group = "TelescopeResultsDisableFolds";
action.vim.opt.foldenable = false;
};
# }}}
# {{{ Load fzf extension
config.callback = _: require "telescope" /load_extension "fzf";
# }}}
# {{{ Options
opts.defaults.mappings.i."<C-h>" = "which_key";
opts.extensions.fzf = {
fuzzy = true;
override_generic_sorter = true;
override_file_sorter = true;
};
# }}}
};
# }}}
# {{{ dressing
dressing = {
package = "stevearc/dressing.nvim";
event = "VeryLazy";
opts = {
select.backend = [
"nui"
"builtin"
"telescope"
];
input.insert_only = false;
};
};
# }}}
# }}}
# {{{ visual
# The line between `ui` and `visual` is a bit rought. I currenlty mostly judge
# it by vibe.
# {{{ indent-blankline
indent-blankline = {
package = "lukas-reineke/indent-blankline.nvim";
main = "ibl";
event = "VeryLazy";
config = true;
# {{{ Keybinds
keys =
let
# {{{ List of fold-related keybinds
foldKeybinds = [
"zo"
"zO"
"zc"
"zC"
"za"
"zA"
"zv"
"zx"
"zX"
"zm"
"zM"
"zr"
"zR"
];
in
# }}}
[ (nmap "<leader>si" "<cmd>IBLToggle<cr>" "Toggle blankline indentation") ]
++ (lib.forEach foldKeybinds (
from:
nmap from "${from}<cmd>IBLToggle<cr><cmd>IBLToggle<cr>" "Overriden ${from} (fold-related thing)"
));
# }}}}
};
# }}}
# {{{ live-command
# Live command preview for commands like :norm
live-command = {
package = "smjonas/live-command.nvim";
version = "remote"; # https://github.com/smjonas/live-command.nvim/pull/29
main = "live-command";
event = "CmdlineEnter";
opts.commands.Norm.cmd = "norm";
opts.commands.G.cmd = "g";
keys = keymap "v" "N" ":Norm " "Map lines in [n]ormal mode";
};
# }}}
# {{{ fidget
fidget = {
package = "j-hui/fidget.nvim";
tag = "legacy";
event = "BufReadPre";
config = true;
};
# }}}
# {{{ treesitter
treesitter = {
# REASON: more grammars
dir = pkgs.symlinkJoin {
name = "treesitter-with-parsers";
paths = [
upkgs.vimPlugins.nvim-treesitter.withAllGrammars
upkgs.vimPlugins.nvim-treesitter.withAllGrammars.dependencies
];
};
# package = "nvim-treesitter/nvim-treesitter";
main = "nvim-treesitter.configs";
dependencies.nix = [ pkgs.tree-sitter ];
event = "VeryLazy";
#{{{ Highlighting
opts.highlight = {
enable = true;
disable = [ "kotlin" ]; # This one seemed a bit broken
additional_vim_regex_highlighting = false;
};
#}}}
opts.indent.enable = true;
};
# }}}
# }}}
# {{{ editing
# {{{ text navigation
# {{{ flash
flash = {
package = "folke/flash.nvim";
keys =
let
nmap = mode: mapping: action: desc: {
inherit mapping desc mode;
action = _: require "flash" /${action} none;
};
in
[
(nmap "nxo" "s" "jump" "Flash")
(nmap "nxo" "S" "treesitter" "Flash Treesitter")
(nmap "o" "r" "remote" "Remote Flash")
(nmap "ox" "R" "treesitter_search" "Treesitter Search")
(nmap "c" "<C-S>" "toggle" "Toggle Flash Search")
];
# Disable stuff like f/t/F/T
opts.modes.char.enabled = false;
};
# }}}
# {{{ ftft (quickscope but written in lua)
ftft = {
package = "gukz/ftFT.nvim";
keys = [
"f"
"F"
"t"
"T"
];
config = true;
};
# }}}
# }}}
# {{{ clipboard-image
clipboard-image = {
package = "postfen/clipboard-image.nvim";
cmd = "PasteImg";
keys = {
mapping = "<leader>p";
action = "<cmd>PasteImg<cr>";
desc = "[P]aste image from clipboard";
};
opts.default.img_name = importFrom ./plugins/clipboard-image.lua "img_name";
opts.tex = {
img_dir = [
"%:p:h"
"img"
];
affix = "\\includegraphics[width=\\textwidth]{%s}";
};
opts.typst = {
img_dir = [
"%:p:h"
"img"
];
affix = ''#image("%s", width: 100)'';
};
};
# }}}
# {{{ lastplace
lastplace = {
package = "ethanholz/nvim-lastplace";
event = "BufReadPre";
opts.lastplace_ignore_buftype = [
"quickfix"
"nofile"
"help"
];
};
# }}}
# {{{ undotree
undotree = {
package = "mbbill/undotree";
cmd = "UndotreeToggle";
keys = nmap "<leader>u" "<cmd>UndoTreeToggle<cr>" "[U]ndo tree";
};
# }}}
# {{{ mini.ai
mini-ai = {
package = "echasnovski/mini.ai";
name = "mini.ai";
event = "VeryLazy";
opts =
_: # lazy, as we import mini.ai inside
let
balanced = from: [
"%b${from}"
"^.().*().$"
];
in
{
custom_textobjects = {
b = balanced "()";
B = balanced "{}";
r = balanced "[]";
v = [
"⟨.-⟩"
"^⟨().*()⟩$"
];
q = balanced "\"\"";
Q = balanced "``";
a = balanced "''";
A = require "mini.ai" /gen_spec/argument none;
};
};
};
# }}}
# {{{ mini.comment
mini-comment = {
package = "echasnovski/mini.comment";
name = "mini.comment";
config = true;
keys = [
{
mapping = "gc";
mode = "nxv";
}
"gcc"
];
};
# }}}
# {{{ mini.surround
mini-surround = {
package = "echasnovski/mini.surround";
name = "mini.surround";
keys = lib.flatten [
# ^ doing the whole `flatten` thing to lie to my formatter
{
mapping = "<tab>s";
mode = "nv";
}
[
"<tab>d"
"<tab>f"
"<tab>F"
"<tab>h"
"<tab>r"
]
];
# {{{ Keybinds
opts.mappings = {
add = "<tab>s"; # Add surrounding in Normal and Visul modes
delete = "<tab>d"; # Delete surrounding
find = "<tab>f"; # Find surrounding (to the right)
find_left = "<tab>F"; # Find surrounding (to the left)
highlight = "<tab>h"; # Highlight surrounding
replace = "<tab>r"; # Replace surrounding
update_n_lines = ""; # Update `n_lines`
};
# }}}
# {{{ Custom surroundings
opts.custom_surroundings =
let
mk = balanced: input: left: right: {
input = [
input
(if balanced then "^.%s*().-()%s*.$" else "^.().*().$")
];
output = {
inherit left right;
};
};
in
{
b = mk true "%b()" "(" ")";
B = mk true "%b{}" "{" "}";
r = mk true "%b[]" "[" "]";
v = mk true "%b⟨⟩" "⟨" "⟩";
q = mk false "\".-\"" "\"" "\"";
Q = mk false "`.-`" "`" "`";
a = mk false "'.-'" "'" "'";
};
# }}}
};
# }}}
# {{{ mini.operators
mini-operators = {
package = "echasnovski/mini.operators";
name = "mini.operators";
config = true;
keys =
let
operator = key: [
{
mapping = "g${key}";
mode = "nv";
}
"g${key}${key}"
];
in
lib.flatten [
(operator "=")
(operator "m")
(operator "x")
(operator "r")
(operator "s")
];
};
# }}}
# {{{ mini.pairs
mini-pairs = {
package = "echasnovski/mini.pairs";
name = "mini.pairs";
# We could specify all the generated bindings, but I don't think it's worth it
event = [
"InsertEnter"
"CmdlineEnter"
];
};
# }}}
# {{{ luasnip
# snippeting engine
luasnip = {
package = "L3MON4D3/LuaSnip";
version = "v2";
config =
_:
do [
(require "luasnip" /config/setup {
enable_autosnippets = true;
update_events = [
"TextChanged"
"TextChangedI"
];
})
(require "luasnip.loaders.from_lua" /lazy_load { fs_event_providers.libuv = true; })
];
# {{{ Keybinds
keys = [
{
mode = "i";
expr = true;
mapping = "<tab>";
action =
# lua
thunk ''
local luasnip = require("luasnip")
if not luasnip.jumpable(1) then
return "<tab>"
end
vim.schedule(function()
luasnip.jump(1)
end)
return "<ignore>"
'';
desc = "Jump to next snippet tabstop";
}
{
mode = "i";
mapping = "<s-tab>";
action = _: require "luasnip" /jump (-1);
desc = "Jump to previous snippet tabstop";
}
{
mode = "is";
mapping = "<c-a>";
action = "<Plug>luasnip-prev-choice";
desc = "Previous snippet node choice";
}
{
mode = "is";
mapping = "<c-f>";
action = "<Plug>luasnip-next-choice";
desc = "Next snippet node choice";
}
];
# }}}
};
# }}}
# {{{ miros
# snippeting generation language
miros = with inputs.miros.packages.${pkgs.system}; {
dir = miros-nvim;
dependencies.nix = [ miros ];
ft = "miros";
keys = {
mapping = "<leader>rm";
action =
"<cmd>!miros generate"
+ " -i ${config.satellite.dev.path "home/features/neovim/snippets"}"
+ " -o ${mirosSnippetCache}/luasnippets"
+ " luasnip -r my.luasnip <cr>";
desc = "[R]erun [m]iros";
};
};
# }}}
# }}}
# {{{ ide
# {{{ lspconfig
lspconfig = {
# {{{ Nix dependencies
dependencies.nix =
with lib.lists;
with packedTargets;
(
optionals web [
pkgs.nodePackages.typescript
pkgs.nodePackages_latest.vscode-langservers-extracted
pkgs.nodePackages.typescript-language-server
]
++ optionals lua [
pkgs.lua-language-server
pkgs.lua
]
++ optionals nix [ upkgs.nixd ]
++ optionals latex [
pkgs.texlab
pkgs.texlive.combined.scheme-full
]
++ optionals elm [
pkgs.elmPackages.elm
pkgs.elmPackages.elm-format
pkgs.elmPackages.elm-language-server
]
++ optionals purescript [
pkgs.purescript-language-server
pkgs.nodePackages.purs-tidy
]
++ optionals csharp [ pkgs.csharp-ls ]
);
# }}}
dependencies.lua = [
"neoconf"
"neodev"
];
package = "neovim/nvim-lspconfig";
event = "VeryLazy";
keys = nmap "<leader>li" "<cmd>LspInfo<cr>" "[L]sp [i]nfo";
config =
_:
importFrom ./plugins/lspconfig.lua "config" {
# We handle formatting using null-ls and prettierd
ts_ls.on_attach = client: ''
${client}.server_capabilities.documentFormattingProvider = false
'';
purescriptls.settings.purescript = {