From a5a784b2d57632a0a8f11278416433e74798a2ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Mon, 17 Jun 2024 09:59:39 +0200 Subject: [PATCH] refactor: clean up a bit --- modules/profiles/desktop.nix | 6 +- modules/programs/nvim/default.nix | 2 +- modules/programs/nvim/plugins/coding.nix | 102 ++++++++++++++--------- modules/programs/python.nix | 10 ++- 4 files changed, 69 insertions(+), 51 deletions(-) diff --git a/modules/profiles/desktop.nix b/modules/profiles/desktop.nix index 5d63b9b..c20efae 100644 --- a/modules/profiles/desktop.nix +++ b/modules/profiles/desktop.nix @@ -4,8 +4,8 @@ , ... }: -with lib; let + inherit (lib) mkEnableOption mkIf mkDefault; cfg = config.my.profiles.desktop; in { @@ -101,10 +101,6 @@ in }) ]; - nixpkgs.config.permittedInsecurePackages = [ - "electron-25.9.0" # obsidian - ]; - programs.nix-ld.enable = true; home-manager.users.moritz = { diff --git a/modules/programs/nvim/default.nix b/modules/programs/nvim/default.nix index 5619db8..92f795e 100644 --- a/modules/programs/nvim/default.nix +++ b/modules/programs/nvim/default.nix @@ -1,8 +1,8 @@ { config, lib, pkgs, inputs, ... }: -with lib; let cfg = config.my.programs.nvim; + inherit (lib) mkEnableOption mkIf readFile; in { imports = lib.my.listModulesRec ./plugins; diff --git a/modules/programs/nvim/plugins/coding.nix b/modules/programs/nvim/plugins/coding.nix index 0c2d0bf..61e6ac7 100644 --- a/modules/programs/nvim/plugins/coding.nix +++ b/modules/programs/nvim/plugins/coding.nix @@ -1,26 +1,28 @@ { pkgs, lib, inputs, ... }: -with builtins; +let + inherit (builtins) readFile; +in { - config.home-manager.users.moritz.programs.neovim.lazy.plugins = with pkgs.vimPlugins; [ + config.home-manager.users.moritz.programs.neovim.lazy.plugins = [ { - plugin = oil-nvim; + plugin = pkgs.vimPlugins.oil-nvim; lazy = false; opts = { }; - dependencies = [{ plugin = nvim-web-devicons; }]; + dependencies = [{ plugin = pkgs.vimPlugins.nvim-web-devicons; }]; } { - plugin = lualine-nvim; + plugin = pkgs.vimPlugins.lualine-nvim; opts = { }; - dependencies = [{ plugin = nvim-web-devicons; }]; + dependencies = [{ plugin = pkgs.vimPlugins.nvim-web-devicons; }]; } { - plugin = mini-nvim; + plugin = pkgs.vimPlugins.mini-nvim; lazy = false; conf = readFile ./lua/mini-nvim.lua; } { - plugin = nvim-cmp; + plugin = pkgs.vimPlugins.nvim-cmp; keys = [ { key = "tc"; cmd = "CmpToggle"; desc = "Toggle Cmp sources"; } ]; @@ -28,26 +30,43 @@ with builtins; event = [ "InsertEnter" ]; dependencies = [ { - plugin = nvim-autopairs; + plugin = pkgs.vimPlugins.nvim-autopairs; opts = { }; } - { plugin = cmp-async-path; } - { plugin = cmp-buffer; } - { plugin = cmp-cmdline; } - { plugin = cmp-nvim-lsp; } - { plugin = cmp_luasnip; } - { plugin = cmp-spell; } - { plugin = cmp-nvim-lsp-signature-help; } - { plugin = friendly-snippets; } - { plugin = lspkind-nvim; } + { plugin = pkgs.vimPlugins.cmp-async-path; } + { plugin = pkgs.vimPlugins.cmp-buffer; } + { plugin = pkgs.vimPlugins.cmp-cmdline; } + { plugin = pkgs.vimPlugins.cmp-nvim-lsp; } + { plugin = pkgs.vimPlugins.cmp_luasnip; } + { plugin = pkgs.vimPlugins.cmp-spell; } + { plugin = pkgs.vimPlugins.cmp-nvim-lsp-signature-help; } { - plugin = luasnip; + plugin = pkgs.vimPlugins.copilot-cmp; + opts = { }; + dependencies = [ + { + plugin = pkgs.vimPlugins.copilot-lua; + opts = { + suggestion = { enabled = false; }; + panel = { enabled = false; }; + }; + conf = /* lua */ '' + require("copilot").setup(opts) + vim.cmd("Copilot disable") + ''; + } + ]; + } + { plugin = pkgs.vimPlugins.friendly-snippets; } + { plugin = pkgs.vimPlugins.lspkind-nvim; } + { + plugin = pkgs.vimPlugins.luasnip; conf = readFile ./lua/luasnip.lua; } ]; } { - plugin = direnv-vim; + plugin = pkgs.vimPlugins.direnv-vim; lazy = false; } { @@ -60,25 +79,26 @@ with builtins; dependencies = [ { # TODO: add all required tools to neovim or silence warnings - plugin = pkgs.vimPlugins.null-ls-nvim.overrideAttrs (_: { - version = lib.my.mkVersionInput inputs.none-ls-nvim; - src = inputs.none-ls-nvim; - }); + plugin = pkgs.vimPlugins.none-ls-nvim; conf = readFile ./lua/null-ls-nvim.lua; dependencies = [ - { plugin = which-key-nvim; } - { plugin = plenary-nvim; } + { + plugin = pkgs.vimUtils.buildVimPlugin { + pname = "none-ls-shellcheck.nvim"; + version = lib.my.mkVersionInput inputs.none-ls-shellcheck-nvim; + src = inputs.none-ls-shellcheck-nvim; + }; + } ]; } - { plugin = which-key-nvim; } - { plugin = lsp_lines-nvim; } + { plugin = pkgs.vimPlugins.lsp_lines-nvim; } { - plugin = inc-rename-nvim; + plugin = pkgs.vimPlugins.inc-rename-nvim; opts = { input_buffer_type = "dressing"; }; dependencies = [ - { plugin = dressing-nvim; } + { plugin = pkgs.vimPlugins.dressing-nvim; } ]; } { @@ -91,7 +111,7 @@ with builtins; ]; } { - plugin = vim-fugitive; + plugin = pkgs.vimPlugins.vim-fugitive; cmd = [ "G" "Git" @@ -122,11 +142,11 @@ with builtins; ]; } { - plugin = vim-tmux-navigator; + plugin = pkgs.vimPlugins.vim-tmux-navigator; event = [ "VeryLazy" ]; } { - plugin = nvim-lastplace; + plugin = pkgs.vimPlugins.nvim-lastplace; event = [ "BufReadPost" "BufNewFile" ]; opts = { lastplace_ignore_buftype = [ "quickfix" "nofile" "help" ]; @@ -135,7 +155,7 @@ with builtins; }; } { - plugin = telescope-nvim; + plugin = pkgs.vimPlugins.telescope-nvim; cmd = [ "Telescope" ]; conf = builtins.readFile ./lua/telescope.lua; keys = [ @@ -159,31 +179,31 @@ with builtins; { key = "fr"; cmd = "Telescope oldfiles"; desc = "Recent files"; } ]; dependencies = [ - { plugin = plenary-nvim; } - { plugin = telescope-fzf-native-nvim; } + { plugin = pkgs.vimPlugins.plenary-nvim; } + { plugin = pkgs.vimPlugins.telescope-fzf-native-nvim; } ]; } { - plugin = vim-startuptime; + plugin = pkgs.vimPlugins.vim-startuptime; cmd = [ "StartupTime" ]; conf = readFile ./lua/vim-startuptime.lua; } { - plugin = typst-vim; + plugin = pkgs.vimPlugins.typst-vim; ft = [ "typst" "typ" ]; } { - plugin = comment-nvim; + plugin = pkgs.vimPlugins.comment-nvim; event = [ "BufReadPost" "BufNewFile" ]; opts = { }; } { - plugin = nvim-surround; + plugin = pkgs.vimPlugins.nvim-surround; event = [ "BufReadPost" "BufNewFile" ]; opts = { }; } { - plugin = conform-nvim; + plugin = pkgs.vimPlugins.conform-nvim; keys = [ { key = "="; cmd = "lua require('conform').format()"; desc = "format buffer"; mode = [ "n" "v" ]; } ]; diff --git a/modules/programs/python.nix b/modules/programs/python.nix index aa20e4e..7c98dcb 100644 --- a/modules/programs/python.nix +++ b/modules/programs/python.nix @@ -4,8 +4,10 @@ , ... }: -with lib; let + inherit (lib) range filterAttrs attrNames foldl' head tail mkOption mkEnableOption intersectLists genAttrs flip getAttr; + inherit (lib.types) listOf enum package; + cfg = config.my.programs.python; pythonVersions = map (version: "3${toString version}") (range 8 11); @@ -23,7 +25,7 @@ let enable = mkEnableOption (toString version); pythonPackages = mkOption { default = [ ]; - type = with types; listOf (enum (pythonPackages version)); + type = listOf (enum (pythonPackages version)); }; }; in @@ -32,11 +34,11 @@ in versions = genAttrs pythonVersions versionOpts; defaultPackages = mkOption { default = [ ]; - type = with types; listOf (enum commonPackages); + type = listOf (enum commonPackages); }; extraPackages = mkOption { default = [ ]; - type = with types; listOf package; + type = listOf package; }; };