From aff8a0aca32624768599543ba4bc2cd982cd3a34 Mon Sep 17 00:00:00 2001 From: catvayor Date: Thu, 28 Nov 2024 15:44:53 +0100 Subject: [PATCH] ~ --- kat/users/neovim.nix | 114 ++++++++++++++++++++++++++++--- machines/kat-probook/default.nix | 2 +- machines/kat-probook/router.nix | 4 +- 3 files changed, 108 insertions(+), 12 deletions(-) diff --git a/kat/users/neovim.nix b/kat/users/neovim.nix index 4c4690f..2bcc282 100644 --- a/kat/users/neovim.nix +++ b/kat/users/neovim.nix @@ -95,16 +95,18 @@ let which-key = { enable = true; settings.triggers = - [ - { - __unkeyed-1 = ""; + map + (key: { + __unkeyed = key; mode = "nxsot"; - } - { - __unkeyed-1 = "f"; - mode = "nxsot"; - } - ]; + }) + [ + "" + "f" + "c" + "d" + "y" + ]; }; todo-comments = { @@ -158,6 +160,96 @@ let } ]; + luasnip.enable = true; + cmp_luasnip.enable = true; + cmp-nvim-lsp.enable = true; + cmp-buffer.enable = true; + cmp-cmdline.enable = true; + cmp-path.enable = true; + cmp-latex-symbols.enable = true; + + cmp = { + enable = true; + autoEnableSources = false; + cmdline = + let + slash-qu = { + mapping.__raw = "cmp.mapping.preset.cmdline()"; + sources = [ + { name = "buffer"; } + ]; + }; + in + { + "/" = slash-qu; + "?" = slash-qu; + ":" = { + mapping.__raw = "cmp.mapping.preset.cmdline()"; + sources = [ + { name = "path"; } + { name = "cmdline"; } + ]; + matching = { + disallow_symbol_nonprefix_matching = false; + }; + }; + }; + settings = { + snippet.expand = '' + function(args) + require('luasnip').lsp_expand(args.body) + end + ''; + sources = map (name: { inherit name; }) [ + "luasnip" + "nvim_lsp" + "buffer" + ] ++ [ + { name = "latex_symbols"; option.strategy = 2; } + ]; + mapping = { + "" = "cmp.mapping.complete()"; + "" = "cmp.mapping.scroll_docs(-4)"; + "" = "cmp.mapping.close()"; + "" = "cmp.mapping.scroll_docs(4)"; + "" = "cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Insert, select = true })"; + "" = '' + cmp.mapping( + function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif require("luasnip").jumpable(-1) then + vim.fn.feedkeys( + vim.api.nvim_replace_termcodes( + "luasnip-jump-prev", + true, true, true), + "") + else + fallback() + end + end, + {'i', 's'})''; + "" = '' + cmp.mapping( + function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif require("luasnip").expand_or_jumpable() then + vim.fn.feedkeys( + vim.api.nvim_replace_termcodes( + "luasnip-expand-or-jump", + true, true, true), + "") + else + fallback() + end + end, + { 'i', 's' }) + ''; + }; + }; + }; + lsp-lines.enable = true; lsp = { @@ -201,6 +293,10 @@ let installCargo = true; installRustc = true; }; + hls = { + enable = true; + installGhc = true; + }; }; }; }; diff --git a/machines/kat-probook/default.nix b/machines/kat-probook/default.nix index 2bcb9a9..d5d1e4d 100644 --- a/machines/kat-probook/default.nix +++ b/machines/kat-probook/default.nix @@ -10,7 +10,7 @@ imports = [ ./hardware-configuration.nix users.catvayor - # ./router.nix + ./router.nix ]; fileSystems."/tmp" = { diff --git a/machines/kat-probook/router.nix b/machines/kat-probook/router.nix index c9644b6..26fba83 100644 --- a/machines/kat-probook/router.nix +++ b/machines/kat-probook/router.nix @@ -1,5 +1,5 @@ -{ - boot.kernel.sysctl."net.ipv4.ip_forward" = true; +{ lib, ... }: { + boot.kernel.sysctl."net.ipv4.ip_forward" = lib.mkForce true; systemd.network = { enable = true;