home-manager: refactor vscode module, seperate language settings

This commit is contained in:
xinyangli 2024-04-16 15:53:02 +08:00
parent dd077d98e2
commit af11897dda
Signed by: xin
SSH key fingerprint: SHA256:qZ/tzd8lYRtUFSrfBDBMcUqV4GHKxqeqRA3huItgvbk

View file

@ -3,62 +3,139 @@ with lib;
let let
cfg = config.custom-hm.vscode; cfg = config.custom-hm.vscode;
packages = {
nixPackages = {
systemPackages = with pkgs; [ nixd nixpkgs-fmt ];
extension = with inputs.nix-vscode-extensions.extensions.${pkgs.system}.vscode-marketplace; [
jnoortheen.nix-ide
];
settings = {
"nix.enableLanguageServer" = true;
"nix.formatterPath" = "nixpkgs-fmt";
"nix.serverPath" = "nixd";
};
};
cxxPackages = {
systemPackages = with pkgs; [ clang-tools ];
extension = with inputs.nix-vscode-extensions.extensions.${pkgs.system}.vscode-marketplace; [
llvm-vs-code-extensions.vscode-clangd
(ms-vscode.cmake-tools.overrideAttrs (_: { sourceRoot = "extension"; }))
twxs.cmake
];
settings = {
"cmake.configureOnEdit" = false;
"cmake.showOptionsMovedNotification" = false;
"cmake.showNotAllDocumentsSavedQuestion" = false;
};
};
pythonPackages = {
systemPackages = with pkgs; [ ];
extension = with inputs.nix-vscode-extensions.extensions.${pkgs.system}.vscode-marketplace; [
ms-python.python
];
settings = { };
};
scalaPackages = {
systemPackages = with pkgs; [ ];
extension = with inputs.nix-vscode-extensions.extensions.${pkgs.system}.vscode-marketplace; [
scala-lang.scala
scalameta.metals
];
settings = { };
};
latexPackages = {
systemPackages = with pkgs; [ texliveSmall ];
extension = with inputs.nix-vscode-extensions.extensions.${pkgs.system}.vscode-marketplace; [
james-yu.latex-workshop
];
settings = {
"latex-workshop.latex.autoBuild.run" = "never";
"latex-workshop.latex.tools" = [
{ "name" = "xelatex";
"command" = "xelatex";
"args" = [ "-synctex=1" "-interaction=nonstopmode" "-file-line-error" "-pdf" "%DOCFILE%" ];
}
{ "name" = "pdflatex";
"command" = "pdflatex";
"args" = [ "-synctex=1" "-interaction=nonstopmode" "-file-line-error" "%DOCFILE%" ];
}
{ "name" = "bibtex"; "command" = "bibtex"; "args" = [ "%DOCFILE%" ]; }
];
"latex-workshop.latex.recipes" = [
{ "name" = "xelatex"; "tools" = [ "xelatex" ]; }
{ "name" = "pdflatex"; "tools" = [ "pdflatex" ]; }
{ "name" = "xe->bib->xe->xe"; "tools" = [ "xelatex" "bibtex" "xelatex" "xelatex" ]; }
{ "name" = "pdf->bib->pdf->pdf"; "tools" = [ "pdflatex" "bibtex" "pdflatex" "pdflatex" ]; }
];
"[latex]" = {
"editor.formatOnPaste" = false;
"editor.suggestSelection" = "recentlyusedbyprefix";
"editor.wordWrap" = "bounded";
"editor.wordWrapColumn" = 80;
"editor.unicodeHighlight.ambiguousCharacters" = false;
};
};
};
};
languages = [ "nix" "cxx" "python" "scala" "latex" ];
zipAttrsWithLanguageOption = (attr:
(map (l: (lib.mkIf cfg.languages.${l} packages."${l}Packages".${attr})) languages)
);
in in
{ {
options.custom-hm.vscode = { options.custom-hm.vscode = {
enable = mkEnableOption "Vscode config"; enable = mkEnableOption "Vscode config";
languages = {
nix = mkOption {
type = lib.types.bool;
default = true;
};
cxx = mkEnableOption "C++";
python = mkEnableOption "Python";
scala = mkEnableOption "Scala";
latex = mkEnableOption "Latex";
};
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
home.packages = with pkgs; [ home.packages = lib.mkMerge ([
pkgs.wl-clipboard-x11 [ pkgs.clang-tools ]
]; ] ++ zipAttrsWithLanguageOption "systemPackages");
programs.vscode = { programs.vscode = {
enable = true; enable = true;
enableUpdateCheck = false; enableUpdateCheck = false;
enableExtensionUpdateCheck = false; enableExtensionUpdateCheck = false;
mutableExtensionsDir = false; mutableExtensionsDir = false;
extensions = (with inputs.nix-vscode-extensions.extensions.${pkgs.system}.vscode-marketplace; [ extensions = lib.mkMerge ([
mkhl.direnv (with inputs.nix-vscode-extensions.extensions.${pkgs.system}.vscode-marketplace; [
mkhl.direnv
bbenoist.nix ms-azuretools.vscode-docker
ms-azuretools.vscode-docker ms-vscode-remote.remote-ssh
ms-vscode-remote.remote-ssh vscodevim.vim
vscodevim.vim github.vscode-pull-request-github
github.vscode-pull-request-github gruntfuggly.todo-tree # todo highlight
gruntfuggly.todo-tree # todo highlight
# Language support # Markdown
# Python davidanson.vscode-markdownlint
ms-python.python # Latex
# Markdown # Scale / chisel
davidanson.vscode-markdownlint sterben.fpga-support
# C/C++
llvm-vs-code-extensions.vscode-clangd
# Nix
jnoortheen.nix-ide
# Latex
james-yu.latex-workshop
# Vue
vue.volar
# Scale / chisel
scala-lang.scala
scalameta.metals
(ms-vscode.cmake-tools.overrideAttrs (_: { sourceRoot = "extension"; })) ms-vscode-remote.remote-ssh-edit
twxs.cmake mushan.vscode-paste-image
])
sterben.fpga-support (with pkgs.vscode-extensions; [
waderyan.gitblame
ms-vscode-remote.remote-ssh-edit catppuccin.catppuccin-vsc
mushan.vscode-paste-image # Rust
]) ++ (with pkgs.vscode-extensions; [ rust-lang.rust-analyzer
waderyan.gitblame # ]) ++ ;
catppuccin.catppuccin-vsc ])
# Rust ] ++ zipAttrsWithLanguageOption "extension");
rust-lang.rust-analyzer userSettings = lib.mkMerge ([
]); {"workbench.colorTheme" = "Catppuccin Macchiato";
userSettings = {
"workbench.colorTheme" = "Catppuccin Macchiato";
"terminal.integrated.sendKeybindingsToShell" = true; "terminal.integrated.sendKeybindingsToShell" = true;
"extensions.ignoreRecommendations" = true; "extensions.ignoreRecommendations" = true;
"files.autoSave" = "afterDelay"; "files.autoSave" = "afterDelay";
@ -70,80 +147,10 @@ in
"git.autofetch" = false; "git.autofetch" = false;
"window.zoomLevel" = -1; "window.zoomLevel" = -1;
"nix.enableLanguageServer" = true; "extensions.experimental.affinity" = {
"vscodevim.vim" = 1;
"latex-workshop.latex.autoBuild.run" = "never";
"latex-workshop.latex.tools" = [
{
"name" = "xelatex";
"command" = "xelatex";
"args" = [
"-synctex=1"
"-interaction=nonstopmode"
"-file-line-error"
"-pdf"
"%DOCFILE%"
];
}
{
"name" = "pdflatex";
"command" = "pdflatex";
"args" = [
"-synctex=1"
"-interaction=nonstopmode"
"-file-line-error"
"%DOCFILE%"
];
}
{
"name" = "bibtex";
"command" = "bibtex";
"args" = [
"%DOCFILE%"
];
}
];
"latex-workshop.latex.recipes" = [
{
"name" = "xelatex";
"tools" = [
"xelatex"
];
}
{
"name" = "pdflatex";
"tools" = [
"pdflatex"
];
}
{
"name" = "xe->bib->xe->xe";
"tools" = [
"xelatex"
"bibtex"
"xelatex"
"xelatex"
];
}
{
"name" = "pdf->bib->pdf->pdf";
"tools" = [
"pdflatex"
"bibtex"
"pdflatex"
"pdflatex"
];
}
];
"[latex]" = {
"editor.formatOnPaste" = false;
"editor.suggestSelection" = "recentlyusedbyprefix";
"editor.wordWrap" = "bounded";
"editor.wordWrapColumn" = 80;
"editor.unicodeHighlight.ambiguousCharacters" = false;
}; };
"cmake.configureOnEdit" = false; }] ++ zipAttrsWithLanguageOption "settings");
};
}; };
}; };
} }