diff --git a/home/desktop.nix b/home/desktop.nix index 350d523..704de96 100644 --- a/home/desktop.nix +++ b/home/desktop.nix @@ -15,7 +15,7 @@ ./core.nix ../modules/home/vscode ../modules/home/zsh - ../modules/home/xdg.nix + ../modules/home/xdg ../modules/home/theme.nix ../modules/home/fcitx.nix ../modules/home/wechat.nix diff --git a/modules/home/vscode/keybindings.json b/modules/home/vscode/conf/keybindings.json similarity index 100% rename from modules/home/vscode/keybindings.json rename to modules/home/vscode/conf/keybindings.json diff --git a/modules/home/vscode/settings.json b/modules/home/vscode/conf/settings.json similarity index 88% rename from modules/home/vscode/settings.json rename to modules/home/vscode/conf/settings.json index e52f253..b839c36 100644 --- a/modules/home/vscode/settings.json +++ b/modules/home/vscode/conf/settings.json @@ -49,11 +49,9 @@ "augment.chat.userGuidelines": "Always response in 中文", "augment.completions.enableAutomaticCompletions": true, "editor.fontFamily": "'Source Code Pro', 'JetBrainsMono Nerd Font'", - "github.copilot.enable": { - "*": true, - "plaintext": false, - "markdown": false, - "scminput": false, - "nix": true - } + "github.copilot.nextEditSuggestions.enabled": true, + "update.mode": "none", + "github.copilot.chat.localeOverride": "zh-CN", + "github.copilot.selectedCompletionModel": "GPT-4.1", + "diffEditor.ignoreTrimWhitespace": false } diff --git a/modules/home/vscode/default.nix b/modules/home/vscode/default.nix index d2f590d..d29f64a 100644 --- a/modules/home/vscode/default.nix +++ b/modules/home/vscode/default.nix @@ -25,12 +25,15 @@ in }); }; - xdg.configFile = { - "Code/User/keybindings.json" = { - source = config.home-libs.mkOutOfStoreSymlink "modules/home/vscode/keybindings.json"; - }; - "Code/User/settings.json" = { - source = config.home-libs.mkOutOfStoreSymlink "modules/home/vscode/settings.json"; - }; - }; + # 使用map函数循环 conf 变量,动态的生成 home.file..config.${i} + xdg.configFile = builtins.listToAttrs + (builtins.map + (name: { + name = "Code/User/${name}"; + value = { + source = config.home-libs.mkOutOfStoreSymlink "modules/home/vscode/conf/${name}"; + }; + }) + (builtins.attrNames (builtins.readDir ./conf)) + ); } diff --git a/modules/home/xdg.nix b/modules/home/xdg.nix deleted file mode 100644 index f330232..0000000 --- a/modules/home/xdg.nix +++ /dev/null @@ -1,92 +0,0 @@ -# XDG stands for "Cross-Desktop Group", with X used to mean "cross". -# It's a bunch of specifications from freedesktop.org intended to standardize desktops and -# other GUI applications on various systems (primarily Unix-like) to be interoperable: -# https://www.freedesktop.org/wiki/Specifications/ -{ config, pkgs, ... }: { - home.packages = with pkgs; [ - xdg-utils # provides cli tools such as `xdg-mime` `xdg-open` - xdg-user-dirs - ]; - - xdg = { - enable = true; - cacheHome = config.home.homeDirectory + "/.cache"; - - # manage $XDG_CONFIG_HOME/mimeapps.list - # xdg search all desktop entries from $XDG_DATA_DIRS, check it by command: - # echo $XDG_DATA_DIRS - # the system-level desktop entries can be list by command: - # ls -l /run/current-system/sw/share/applications/ - # the user-level desktop entries can be list by command(user ryan): - # ls /etc/profiles/per-user/ryan/share/applications/ - mimeApps = { - enable = true; - defaultApplications = - let - browser = [ "microsoft-edge.desktop" ]; - in - { - "application/json" = browser; - "application/pdf" = browser; # TODO: pdf viewer - - "text/html" = browser; - "text/xml" = browser; - "application/xml" = browser; - "application/xhtml+xml" = browser; - "application/xhtml_xml" = browser; - "application/rdf+xml" = browser; - "application/rss+xml" = browser; - "application/x-extension-htm" = browser; - "application/x-extension-html" = browser; - "application/x-extension-shtml" = browser; - "application/x-extension-xht" = browser; - "application/x-extension-xhtml" = browser; - - "x-scheme-handler/about" = browser; - "x-scheme-handler/ftp" = browser; - "x-scheme-handler/http" = browser; - "x-scheme-handler/https" = browser; - "x-scheme-handler/unknown" = browser; - - "x-scheme-handler/discord" = [ "discord.desktop" ]; - "x-scheme-handler/tg" = [ "telegramdesktop.desktop" ]; - - "audio/*" = [ "vlc.desktop" ]; - "video/*" = [ "vlc.dekstop" ]; - "image/*" = [ "imv.desktop" ]; - "image/gif" = [ "imv.desktop" ]; - "image/jpeg" = [ "imv.desktop" ]; - "image/png" = [ "imv.desktop" ]; - "image/webp" = [ "imv.desktop" ]; - - "inode/directory" = [ ] - ++ (if config.xdg.enable then [ "nemo.desktop" ] else [ ]) - ++ (if config.xdg.enable then [ "xdg-open.desktop" ] else [ ]) - ++ (if config.xdg.enable then [ "nemo.desktop" ] else [ ]) - ++ (if config.xdg.enable then [ "thunar.desktop" ] else [ ]) - ++ (if config.xdg.enable then [ "org.gnome.Nautilus.desktop" ] else [ ]); - }; - - associations.removed = - { - # ...... - }; - }; - - userDirs = { - enable = true; - createDirectories = false; - documents = config.home.homeDirectory + "/doc"; - music = config.home.homeDirectory + "/doc/music"; - desktop = config.home.homeDirectory + "/tmp"; - download = config.home.homeDirectory + "/tmp"; - videos = config.home.homeDirectory + "/tmp"; - pictures = config.home.homeDirectory + "/tmp"; - # templates = config.home.homeDirectory + "/tmp"; - # publicShare = config.home.homeDirectory + "/tmp"; - extraConfig = { - XDG_SCREENSHOTS_DIR = config.home.homeDirectory + "/tmp/Screenshots"; - }; - }; - }; -} diff --git a/modules/home/xdg/conf/mimeapps.list b/modules/home/xdg/conf/mimeapps.list new file mode 100644 index 0000000..31ed962 --- /dev/null +++ b/modules/home/xdg/conf/mimeapps.list @@ -0,0 +1,31 @@ +[Default Applications] +application/json=microsoft-edge.desktop +application/pdf=microsoft-edge.desktop +application/rdf+xml=microsoft-edge.desktop +application/rss+xml=microsoft-edge.desktop +application/x-extension-htm=microsoft-edge.desktop +application/x-extension-html=microsoft-edge.desktop +application/x-extension-shtml=microsoft-edge.desktop +application/x-extension-xht=microsoft-edge.desktop +application/x-extension-xhtml=microsoft-edge.desktop +application/xhtml+xml=microsoft-edge.desktop +application/xhtml_xml=microsoft-edge.desktop +application/xml=microsoft-edge.desktop +audio/*=vlc.desktop +image/*=imv.desktop +image/gif=imv.desktop +image/jpeg=imv.desktop +image/png=imv.desktop +image/webp=imv.desktop +inode/directory=nemo.desktop;xdg-open.desktop;nemo.desktop;thunar.desktop;org.gnome.Nautilus.desktop +text/html=microsoft-edge.desktop +text/xml=microsoft-edge.desktop +video/*=vlc.dekstop +x-scheme-handler/about=microsoft-edge.desktop +x-scheme-handler/discord=discord.desktop +x-scheme-handler/ftp=microsoft-edge.desktop +x-scheme-handler/http=microsoft-edge.desktop +x-scheme-handler/https=microsoft-edge.desktop +x-scheme-handler/tg=telegramdesktop.desktop +x-scheme-handler/unknown=microsoft-edge.desktop +text/plain=code.desktop diff --git a/modules/home/xdg/default.nix b/modules/home/xdg/default.nix new file mode 100644 index 0000000..76b93e9 --- /dev/null +++ b/modules/home/xdg/default.nix @@ -0,0 +1,51 @@ +# XDG stands for "Cross-Desktop Group", with X used to mean "cross". +# It's a bunch of specifications from freedesktop.org intended to standardize desktops and +# other GUI applications on various systems (primarily Unix-like) to be interoperable: +# https://www.freedesktop.org/wiki/Specifications/ +{ config, pkgs, ... }: { + home.packages = with pkgs; [ + xdg-utils # provides cli tools such as `xdg-mime` `xdg-open` + xdg-user-dirs + ]; + + xdg = { + enable = true; + cacheHome = config.home.homeDirectory + "/.cache"; + + # manage $XDG_CONFIG_HOME/mimeapps.list + # xdg search all desktop entries from $XDG_DATA_DIRS, check it by command: + # echo $XDG_DATA_DIRS + # the system-level desktop entries can be list by command: + # ls -l /run/current-system/sw/share/applications/ + # the user-level desktop entries can be list by command(user ryan): + # ls /etc/profiles/per-user/ryan/share/applications/ + + userDirs = { + enable = true; + createDirectories = false; + documents = config.home.homeDirectory + "/doc"; + music = config.home.homeDirectory + "/doc/music"; + desktop = config.home.homeDirectory + "/tmp"; + download = config.home.homeDirectory + "/tmp"; + videos = config.home.homeDirectory + "/tmp"; + pictures = config.home.homeDirectory + "/tmp"; + # templates = config.home.homeDirectory + "/tmp"; + # publicShare = config.home.homeDirectory + "/tmp"; + extraConfig = { + XDG_SCREENSHOTS_DIR = config.home.homeDirectory + "/tmp/Screenshots"; + }; + }; + }; + + # 使用map函数循环 conf 变量,动态的生成 home.file..config.${i} + xdg.configFile = builtins.listToAttrs + (builtins.map + (name: { + inherit name; + value = { + source = config.home-libs.mkOutOfStoreSymlink "modules/home/xdg/conf/${name}"; + }; + }) + (builtins.attrNames (builtins.readDir ./conf)) + ); +}