From f30afe506b4da8e9ad8e6b3d7a8d86409fdf2d69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jalil=20David=20Salam=C3=A9=20Messina?= Date: Sat, 5 Oct 2024 22:37:58 +0200 Subject: [PATCH] feat(nvim): setup for ipynb dev work Setup: - molten (run python code) - otter (lsp in markdown codeblocks) - jupytext (convert .ipynb files to .md files transparently) - image (display images inside neovim (e.g. matplotlib graphs)) --- flake-modules/nvim.nix | 20 +++++++++----------- nvim/plugins.nix | 22 +++++++++++++++++++++- nvim/standalone.nix | 1 + system/default.nix | 20 +++++++++++--------- 4 files changed, 42 insertions(+), 21 deletions(-) diff --git a/flake-modules/nvim.nix b/flake-modules/nvim.nix index 95280ef..a143ff1 100644 --- a/flake-modules/nvim.nix +++ b/flake-modules/nvim.nix @@ -1,24 +1,22 @@ { inputs, ... }: -let - standalone = ../nvim/standalone.nix; -in { flake.overlays.nixvim = inputs.nixvim.overlays.default; perSystem = { pkgs, system, ... }: - { - # Check standalone nvim build - checks.nvim = inputs.nixvim.lib.${system}.check.mkTestDerivationFromNixvimModule { + let + nixvimLib = inputs.nixvim.lib.${system}; + nixvim = inputs.nixvim.legacyPackages.${system}; + module = { inherit pkgs; module = ../nvim/standalone.nix; }; + in + { + # Check standalone nvim build + checks.nvim = nixvimLib.check.mkTestDerivationFromNixvimModule module; # Nvim standalone module - packages.nvim = inputs.nixvim.legacyPackages.${system}.makeNixvimWithModule { - inherit pkgs; - module = standalone; - }; - + packages.nvim = nixvim.makeNixvimWithModule module; }; } diff --git a/nvim/plugins.nix b/nvim/plugins.nix index 4a85f8e..3c2f67d 100644 --- a/nvim/plugins.nix +++ b/nvim/plugins.nix @@ -5,7 +5,7 @@ ... }: let - inherit (helpers) mkRaw; + inherit (helpers) mkRaw enableExceptInTests; in { config.plugins = { @@ -160,6 +160,15 @@ in }; }; gitsigns.enable = true; + image.enable = enableExceptInTests; + jupytext = { + enable = true; + settings.custom_language_formatting.python = { + extension = "md"; + style = "markdown"; + force_ft = "markdown"; + }; + }; lint = { enable = true; lintersByFt = { @@ -210,6 +219,15 @@ in enable = true; settings.update_events = "TextChanged,TextChangedI"; }; + molten = { + enable = true; + settings = { + image_provider = "image.nvim"; + virt_text_output = true; + molten_auto_open_output = false; + molten_virt_lines_off_by_1 = true; + }; + }; noice = { enable = true; lsp.override = { @@ -241,6 +259,7 @@ in mode = "virtualtext"; }; }; + otter.enable = true; rustaceanvim = { enable = true; # Install through rustup @@ -256,6 +275,7 @@ in treesitter = { enable = true; settings = { + highlight.enable = true; indent.enable = true; incremental_election.enable = true; }; diff --git a/nvim/standalone.nix b/nvim/standalone.nix index 155d91b..b5f13e8 100644 --- a/nvim/standalone.nix +++ b/nvim/standalone.nix @@ -61,6 +61,7 @@ pkgs.unstable.taplo pkgs.unstable.typos pkgs.unstable.yamlfmt + (pkgs.unstable.python3.withPackages (p: [ p.jupytext ])) ]; extraConfigLuaPre = # lua diff --git a/system/default.nix b/system/default.nix index 9d168a1..a3c2347 100644 --- a/system/default.nix +++ b/system/default.nix @@ -74,15 +74,17 @@ in }; environment.etc = keysFromGithub; - services.openssh.authorizedKeysFiles = builtins.map (path: "/etc/${path}") ( - builtins.attrNames keysFromGithub - ); - - # Enable printer autodiscovery if printing is enabled - services.avahi = { - inherit (config.services.printing) enable; - nssmdns4 = true; - openFirewall = true; + services = { + # Enable printer autodiscovery if printing is enabled + avahi = { + inherit (config.services.printing) enable; + nssmdns4 = true; + openFirewall = true; + }; + openssh.authorizedKeysFiles = builtins.map (path: "/etc/${path}") ( + builtins.attrNames keysFromGithub + ); + jupyter.enable = cfg.dev.enable; }; users.defaultUserShell = pkgs.zsh; # Open ports for spotifyd