From f6174bc0ba8555172408c61506e7c3edaaa15c54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Mon, 27 May 2024 15:09:37 +0200 Subject: [PATCH] feat: add jetbrains module --- modules/profiles/webis.nix | 14 +++-- modules/programs/hyprland/_config.nix | 2 +- modules/programs/jetbrains/default.nix | 37 ++++++++++++ modules/programs/jetbrains/ideavimrc | 84 ++++++++++++++++++++++++++ 4 files changed, 131 insertions(+), 6 deletions(-) create mode 100644 modules/programs/jetbrains/default.nix create mode 100644 modules/programs/jetbrains/ideavimrc diff --git a/modules/profiles/webis.nix b/modules/profiles/webis.nix index 6a506a2..a11cc71 100644 --- a/modules/profiles/webis.nix +++ b/modules/profiles/webis.nix @@ -4,16 +4,23 @@ , ... }: -with lib; let cfg = config.my.profiles.webis; + inherit (lib) mkEnableOption mkIf; in { options.my.profiles.webis.enable = mkEnableOption "webis profile"; config = mkIf cfg.enable { - my.programs.ssh.includeSecrets = [ ../../secrets/webis-ssh.age ]; + my.programs = { + ssh.includeSecrets = [ ../../secrets/webis-ssh.age ]; + jetbrains = { + pycharm.enable = true; + pycharm.package = pkgs.jetbrains.pycharm-professional; + }; + }; + age.secrets.webis = { file = ../../secrets/webis.age; name = "webis.ovpn"; @@ -25,9 +32,6 @@ in updateResolvConf = true; }; }; - environment.systemPackages = with pkgs; [ - jetbrains.pycharm-professional - ]; programs.dconf.enable = true; }; } diff --git a/modules/programs/hyprland/_config.nix b/modules/programs/hyprland/_config.nix index 651a896..c2182cd 100644 --- a/modules/programs/hyprland/_config.nix +++ b/modules/programs/hyprland/_config.nix @@ -133,7 +133,7 @@ in windowrulev2 = rounding 0, xwayland:1, floating:1 windowrulev2 = center, class:^(.*jetbrains.*)$, title:^(Confirm Exit|Open Project|win424|win201|splash)$ windowrulev2 = size 640 400, class:^(.*jetbrains.*)$, title:^(splash)$ - ${mkRules ["opaque" "noshadow" "noblur" "noanim" "move cursor 5 5"] ["class:^(.*jetbrains-.*)$"]} + windowrulev2 = nofocus, class:^jetbrains-(?!toolbox), floating:1, title:^win\d+$ # See https://wiki.hyprland.org/Configuring/Keywords/ for more $mainMod = SUPER diff --git a/modules/programs/jetbrains/default.nix b/modules/programs/jetbrains/default.nix new file mode 100644 index 0000000..a625c28 --- /dev/null +++ b/modules/programs/jetbrains/default.nix @@ -0,0 +1,37 @@ +{ config, lib, pkgs, ... }: + +let + inherit (lib) mkEnableOption mkIf mkOption any filterAttrs mapAttrsToList; + cfg = config.my.programs.jetbrains; + isEnabled = _: value: value.enable; + anyEnabled = any (x: x) (mapAttrsToList isEnabled cfg); +in +{ + options.my.programs.jetbrains = { + pycharm = { + enable = mkEnableOption "pycharm"; + package = mkOption { + default = pkgs.jetbrains.pycharm-community; + }; + }; + idea = { + enable = mkEnableOption "idea"; + package = mkOption { + default = pkgs.jetbrains.pycharm-community; + }; + }; + }; + + config = mkIf anyEnabled { + home-manager.users.moritz = { + xdg.configFile."ideavim/ideavimrc" = { + source = ./ideavimrc; + }; + home.packages = + let + enabledPackages = filterAttrs isEnabled cfg; + in + mapAttrsToList (_: value: value.package) enabledPackages; + }; + }; +} diff --git a/modules/programs/jetbrains/ideavimrc b/modules/programs/jetbrains/ideavimrc new file mode 100644 index 0000000..0a79200 --- /dev/null +++ b/modules/programs/jetbrains/ideavimrc @@ -0,0 +1,84 @@ +""" Map leader to space --------------------- +let mapleader=" " + +""" Plugins -------------------------------- +set surround +set commentary + +""" Common settings ------------------------- +set showmode +set so=5 +set incsearch +set nu + +""" Which-Key +set which-key +set timeoutlen=5000 + +""" Idea specific settings ------------------ +set ideajoin + +""" Mappings -------------------------------- +"" Quick action +let g:WhichKeyDesc_quick_action = 'q Quick action' +map q (ShowIntentionActions) + +"" Refactor binds +let g:WhichKeyDesc_inline = 'i Inline' +map i (Inline) + +let g:WhichKeyDesc_extract = 'e Extract' +let g:WhichKeyDesc_extract_variable = 'ev Extract variable' +map ev (IntroduceVariable) +let g:WhichKeyDesc_extract_constant = 'ec Extract constant' +map ec (IntroduceConstant) +let g:WhichKeyDesc_extract_field = 'ef Extract field' +map ef (IntroduceField) +let g:WhichKeyDesc_extract_parameter = 'ep Extract parameter' +map ep (IntroduceParameter) + +let g:WhichKeyDesc_rename = 'r Rename' +map r (RenameElement) + +"" Navigation +let g:WhichKeyDesc_prev_buffer = ']b Previous buffer' +map [b (PreviousTab) +let g:WhichKeyDesc_next_buffer = ']b Next buffer' +map ]b (NextTab) + +let g:WhichKeyDesc_prev_error = 'gI Goto Implementation' +map gI (GotoImplementation) + +"" Other +let g:WhichKeyDesc_terminal = 't Terminal' +map t (ActivateTerminalToolWindow) +map (HideActiveWindow) +map = (ReformatCode) + +"" Folding +let g:WhichKeyDesc_folding = 'z Folding' +let g:WhichKeyDesc_folding_toggle = 'za Toggle fold' +map za (ExpandCollapseToggleAction) + +let g:WhichKeyDesc_folding_expand = 'zr Fold less' +map zr (ExpandRegion) +let g:WhichKeyDesc_folding_collapse = 'zR Open all folds' +map zR (ExpandAllRegions) +let g:WhichKeyDesc_folding_collapse = 'zm Fold more' +map zm (CollapseRegion) +let g:WhichKeyDesc_folding_collapse = 'zM Close all folds' +map zM (CollapseAllRegions) + +let g:WhichKeyDesc_folding_collapse_doc = 'zc Collapse doc comments' +map zc (CollapseDocComments) +let g:WhichKeyDesc_folding_expand_doc = 'zC Expand doc comments' +map zC (ExpandDocComments) + +let g:WhichKeyDesc_folding_expand_level_one = 'z1 Expand all to level 1' +map z1 (ExpandAllToLevel1) +let g:WhichKeyDesc_folding_expand_level_two = 'z2 Expand all to level 2' +map z2 (ExpandAllToLevel2) +let g:WhichKeyDesc_folding_expand_level_three = 'z3 Expand all to level 3' +map z3 (ExpandAllToLevel3) +let g:WhichKeyDesc_folding_expand_level_four = 'z4 Expand all to level 4' +map z4 (ExpandAllToLevel4)