This repository has been archived by the owner on Mar 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathconfig.nix
692 lines (615 loc) · 16.7 KB
/
config.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
{
pkgs,
config,
helpers,
lib,
...
}: {
config = {
colorschemes.tokyonight = {
style = "night";
enable = true;
};
autoGroups.BigFileOptimizer = {};
autoCmd = [
{
event = "BufReadPost";
pattern = [
"*.md"
"*.rs"
"*.lua"
"*.sh"
"*.bash"
"*.zsh"
"*.js"
"*.jsx"
"*.ts"
"*.tsx"
"*.c"
".h"
"*.cc"
".hh"
"*.cpp"
".cph"
];
group = "BigFileOptimizer";
callback = helpers.mkRaw ''
function(auEvent)
local bufferCurrentLinesCount = vim.api.nvim_buf_line_count(0)
if bufferCurrentLinesCount > 2048 then
vim.notify("bigfile: disabling features", vim.log.levels.WARN)
vim.cmd("TSBufDisable refactor.highlight_definitions")
vim.g.matchup_matchparen_enabled = 0
require("nvim-treesitter.configs").setup({
matchup = {
enable = false
}
})
end
end
'';
}
];
globals = {
neo_tree_remove_legacy_commands = 1;
mapleader = " ";
};
options = {
termguicolors = true;
number = true;
tabstop = 4;
shiftwidth = 4;
scrolloff = 7;
signcolumn = "yes";
cmdheight = 2;
cot = ["menu" "menuone" "noselect"];
updatetime = 100;
colorcolumn = "100";
spell = true;
listchars = "tab:>-,lead:·,nbsp:␣,trail:•";
fsync = true;
timeout = true;
timeoutlen = 300;
};
commands = {
"SpellFr" = "setlocal spelllang=fr";
};
filetype = {
filename = {
Jenkinsfile = "groovy";
};
extension = {
lalrpop = "lalrpop";
};
};
keymaps = let
modeKeys = mode:
lib.attrsets.mapAttrsToList (key: action:
{
inherit key mode;
}
// (
if builtins.isString action
then {inherit action;}
else action
));
nm = modeKeys ["n"];
vs = modeKeys ["v"];
in
helpers.keymaps.mkKeymaps {options.silent = true;} (nm {
"ft" = "<cmd>Neotree<CR>";
"fG" = "<cmd>Neotree git_status<CR>";
"fR" = "<cmd>Neotree remote<CR>";
"fc" = "<cmd>Neotree close<CR>";
"bp" = "<cmd>Telescope buffers<CR>";
"<C-s>" = "<cmd>Telescope spell_suggest<CR>";
"mk" = "<cmd>Telescope keymaps<CR>";
"fg" = "<cmd>Telescope git_files<CR>";
"gr" = "<cmd>Telescope lsp_references<CR>";
"gI" = "<cmd>Telescope lsp_implementations<CR>";
"gW" = "<cmd>Telescope lsp_workspace_symbols<CR>";
"gF" = "<cmd>Telescope lsp_document_symbols<CR>";
"ge" = "<cmd>Telescope diagnostics bufnr=0<CR>";
"gE" = "<cmd>Telescope diagnostics<CR>";
"<leader>zn" = "<Cmd>ZkNew { title = vim.fn.input('Title: ') }<CR>";
"<leader>zo" = "<Cmd>ZkNotes { sort = { 'modified' } }<CR>";
"<leader>zt" = "<Cmd>ZkTags<CR>";
"<leader>zf" = "<Cmd>ZkNotes { sort = { 'modified' }, match = { vim.fn.input('Search: ') } }<CR>";
"yH" = {
action = "<Cmd>Telescope yank_history<CR>";
options.desc = "history";
};
})
++ (vs {
"<leader>zf" = "'<,'>ZkMatch<CR>";
})
++ [
{
key = "<leader>rn";
mode = ["n"];
action = ''
function()
return ":IncRename " .. vim.fn.expand("<cword>")
end
'';
lua = true;
options.expr = true;
}
];
plugins.nvim-osc52 = {
enable = true;
package = pkgs.vimPlugins.nvim-osc52;
keymaps.enable = true;
};
plugins.efmls-configs = {
enable = true;
toolPackages.mdformat = with pkgs.python3.pkgs;
mdformat.withPlugins [
mdformat-gfm
mdformat-frontmatter
mdformat-footnote
mdformat-tables
mdit-py-plugins
];
setup = {
sh = {
#linter = "shellcheck";
formatter = "shfmt";
};
bash = {
#linter = "shellcheck";
formatter = "shfmt";
};
c = {
linter = "cppcheck";
};
markdown = {
formatter = ["cbfmt" "mdformat"];
};
python = {
formatter = "black";
};
nix = {
linter = "statix";
};
lua = {
formatter = "stylua";
};
html = {
formatter = ["prettier" (helpers.mkRaw "djlint_fmt")];
};
htmldjango = {
formatter = [(helpers.mkRaw "djlint_fmt")];
linter = "djlint";
};
json = {
formatter = "prettier";
};
css = {
formatter = "prettier";
};
ts = {
formatter = "prettier";
};
gitcommit = {
linter = "gitlint";
};
};
};
# plugins.null-ls = {
# enable = true;
# sources = {
# diagnostics = {
# gitlint.enable = true;
# };
# code_actions = {
# shellcheck.enable = true;
# #gitsigns.enable = true;
# };
# formatting = {
# alejandra.enable = true;
# };
# };
# };
plugins.gitsigns.enable = true;
plugins.gitmessenger.enable = true;
plugins.firenvim.enable = false;
plugins.luasnip = {
enable = true;
};
extraConfigLuaPre = ''
local has_words_before = function()
unpack = unpack or table.unpack
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
end
local luasnip = require("luasnip")
local efm_fs = require('efmls-configs.fs')
local djlint_fmt = {
formatCommand = string.format('%s --reformat ''${INPUT} -', efm_fs.executable('djlint')),
formatStdin = true,
}
'';
plugins.nvim-cmp = {
enable = true;
snippet.expand = "luasnip";
mapping = {
"<CR>" = "cmp.mapping.confirm({select = true })";
"<C-d>" = "cmp.mapping.scroll_docs(-4)";
"<C-f>" = "cmp.mapping.scroll_docs(4)";
"<C-Space>" = "cmp.mapping.complete()";
"<Tab>" = ''
cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
-- You could replace the expand_or_jumpable() calls with expand_or_locally_jumpable()
-- they way you will only jump inside the snippet region
elseif luasnip.expand_or_locally_jumpable() then
luasnip.expand_or_jump()
elseif has_words_before() then
cmp.complete()
else
fallback()
end
end, { "i", "s" })
'';
"<S-Tab>" = ''
cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif luasnip.jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, { "i", "s" })
'';
"<Down>" = "cmp.mapping(cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Select }), {'i'})";
"<Up>" = "cmp.mapping(cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Select }), {'i'})";
};
sources = [
{name = "luasnip";}
{name = "nvim_lsp";}
{name = "path";}
{name = "buffer";}
{name = "calc";}
{name = "zsh";}
];
};
plugins.telescope = {
enable = true;
enabledExtensions = ["ui-select"];
extensionConfig = {
ui-select = {
__raw = ''
require("telescope.themes").get_dropdown {
-- even more opts
}
'';
};
};
extraOptions = {
defaults.layout_strategy = "vertical";
};
};
extraFiles."queries/rust/injections.scm" = ''
;; extends
(
(macro_invocation
macro: ((scoped_identifier) @_sql_def)
(token_tree (string_literal) @sql))
(#eq? @_sql_def "sqlx::query")
)
'';
plugins.treesitter = {
enable = true;
indent = true;
nixvimInjections = true;
grammarPackages = with config.plugins.treesitter.package.passthru.builtGrammars; [
arduino
bash
c
cpp
cuda
dart
devicetree
diff
dockerfile
gitattributes
gitcommit
gitignore
git_rebase
groovy
html
ini
json
lalrpop
latex
lua
make
markdown
markdown_inline
meson
ninja
nix
python
regex
rst
rust
slint
sql
tlaplus
toml
vim
vimdoc
yaml
];
};
plugins.treesitter-refactor = {
enable = true;
highlightDefinitions = {
enable = true;
clearOnCursorMove = true;
};
smartRename = {
enable = true;
};
navigation = {
enable = true;
};
};
plugins.treesitter-context = {
enable = true;
};
plugins.vim-matchup = {
treesitterIntegration = {
enable = true;
includeMatchWords = true;
};
enable = true;
};
plugins.headerguard.enable = true;
plugins.comment-nvim = {
enable = true;
};
plugins.neo-tree = {
enable = true;
};
plugins.plantuml-syntax.enable = true;
plugins.indent-blankline = {
enable = true;
scope = {
enabled = true;
showStart = true;
};
};
plugins.lsp = {
enable = true;
enabledServers = [
{
name = "lemminx";
extraOptions = {
cmd = ["${pkgs.lemminx-bin}/bin/lemminx-bin"];
};
}
# {
# name = "groovyls";
# extraOptions = {
# cmd = ["${pkgs.groovy-language-server}/bin/groovy-language-server"];
# };
# }
];
keymaps = {
silent = true;
lspBuf = {
"gd" = "definition";
"gD" = "declaration";
"ca" = "code_action";
"ff" = "format";
"K" = "hover";
};
};
servers = {
nil_ls = {
enable = true;
settings = {
formatting.command = ["${pkgs.alejandra}/bin/alejandra" "--quiet"];
};
};
bashls.enable = true;
dartls.enable = true;
clangd.enable = true;
typst-lsp.enable = true;
tsserver.enable = true;
efm.extraOptions = {
init_options = {
documentFormatting = true;
};
};
taplo.enable = true;
};
};
plugins.typst-vim.enable = true;
plugins.rust-tools = {
enable = true;
inlayHints = {
maxLenAlign = true;
};
server = {
cargo.features = "all";
checkOnSave = true;
check.command = "clippy";
rustc.source = "discover";
};
};
plugins.lspkind = {
enable = true;
cmp = {
enable = true;
};
};
plugins.nvim-lightbulb = {
enable = true;
autocmd.enabled = true;
};
plugins.lsp_signature = {
#enable = true;
};
plugins.inc-rename = {
enable = true;
};
plugins.clangd-extensions = {
enable = true;
enableOffsetEncodingWorkaround = true;
ast = {
roleIcons = {
type = "";
declaration = "";
expression = "";
specifier = "";
statement = "";
templateArgument = "";
};
kindIcons = {
compound = "";
recovery = "";
translationUnit = "";
packExpansion = "";
templateTypeParm = "";
templateTemplateParm = "";
templateParamObject = "";
};
};
};
# fidget = {
# enable = true;
#
# sources.null-ls.ignore = true;
# };
plugins.lualine = {
enable = true;
};
plugins.trouble = {
enable = true;
};
plugins.noice = {
enable = true;
messages = {
view = "mini";
viewError = "mini";
viewWarn = "mini";
};
lsp.override = {
"vim.lsp.util.convert_input_to_markdown_lines" = true;
"vim.lsp.util.stylize_markdown" = true;
"cmp.entry.get_documentation" = true;
};
presets = {
bottom_search = true;
command_palette = true;
long_message_to_split = true;
inc_rename = true;
lsp_doc_border = false;
};
};
plugins.netman = {
enable = false;
package = pkgs.vimPlugins.netman-nvim;
neoTreeIntegration = true;
};
plugins.openscad = {
enable = true;
loadSnippets = true;
keymaps.enable = true;
};
extraConfigLuaPost = ''
require("luasnip.loaders.from_snipmate").lazy_load()
-- local null_ls = require("null-ls")
-- local helpers = require("null-ls.helpers")
--
-- local sca2d = {
-- method = null_ls.methods.DIAGNOSTICS,
-- filetypes = { "openscad" },
-- generator = null_ls.generator({
-- command = "sca2d",
-- args = { "$FILENAME" },
-- from_stderr = false,
-- to_stdin = true,
-- format = "line",
-- check_exit_code = function(code)
-- return code <= 1
-- end,
-- on_output = helpers.diagnostics.from_pattern(
-- [[[^:]+:(%d+):(%d+): (%w)%d+: (.*)]], {"row", "col", "severity", "message"}, {
-- severities = {
-- F = helpers.diagnostics.severities["error"],
-- E = helpers.diagnostics.severities["error"],
-- W = helpers.diagnostics.severities["warning"],
-- D = helpers.diagnostics.severities["warning"],
-- I = helpers.diagnostics.severities["info"],
-- },
-- }),
-- }),
-- }
-- null_ls.register(sca2d)
'';
plugins.zk = {
enable = true;
picker = "telescope";
};
plugins.which-key.enable = true;
plugins.leap.enable = true;
plugins.yanky = {
enable = true;
picker.telescope = {
useDefaultMappings = true;
enable = true;
};
};
files."ftplugin/nix.lua" = {
options = {
tabstop = 2;
shiftwidth = 2;
expandtab = true;
};
};
files."ftplugin/markdown.lua" = {
extraConfigLua = ''
if require("zk.util").notebook_root(vim.fn.expand('%:p')) ~= nil then
local function map(...) vim.api.nvim_buf_set_keymap(0, ...) end
local opts = { noremap=true, silent=false }
-- Open the link under the caret.
map("n", "<CR>", "<Cmd>lua vim.lsp.buf.definition()<CR>", opts)
-- Create a new note after asking for its title.
-- This overrides the global `<leader>zn` mapping to create the note in the same directory as the current buffer.
map("n", "<leader>zn", "<Cmd>ZkNew { dir = vim.fn.expand('%:p:h'), title = vim.fn.input('Title: ') }<CR>", opts)
-- Create a new note in the same directory as the current buffer, using the current selection for title.
map("v", "<leader>znt", ":'<,'>ZkNewFromTitleSelection { dir = vim.fn.expand('%:p:h') }<CR>", opts)
-- Create a new note in the same directory as the current buffer, using the current selection for note content and asking for its title.
map("v", "<leader>znc", ":'<,'>ZkNewFromContentSelection { dir = vim.fn.expand('%:p:h'), title = vim.fn.input('Title: ') }<CR>", opts)
-- Open notes linking to the current buffer.
map("n", "<leader>zb", "<Cmd>ZkBacklinks<CR>", opts)
-- Alternative for backlinks using pure LSP and showing the source context.
--map('n', '<leader>zb', '<Cmd>lua vim.lsp.buf.references()<CR>', opts)
-- Open notes linked by the current buffer.
map("n", "<leader>zl", "<Cmd>ZkLinks<CR>", opts)
-- Preview a linked note.
map("n", "K", "<Cmd>lua vim.lsp.buf.hover()<CR>", opts)
-- Open the code actions for a visual selection.
map("v", "<leader>za", ":'<,'>lua vim.lsp.buf.range_code_action()<CR>", opts)
end
'';
};
extraPackages = with pkgs; [
/*
sca2d
*/
djlint
];
extraPlugins = with pkgs.vimPlugins; [
telescope-ui-select-nvim
vim-snippets
markdown-preview-nvim
];
};
}