From ed19829fe4bdb5060a4484901549b5c6b9b5bec1 Mon Sep 17 00:00:00 2001 From: xinyangli Date: Tue, 20 Aug 2024 21:07:34 +0800 Subject: [PATCH] modules/vscode: llm support --- home/xin/calcite.nix | 17 ++++++++- modules/home-manager/vscode.nix | 64 +++++++++++++++++++++++---------- 2 files changed, 61 insertions(+), 20 deletions(-) diff --git a/home/xin/calcite.nix b/home/xin/calcite.nix index b26d5d8..130bd00 100644 --- a/home/xin/calcite.nix +++ b/home/xin/calcite.nix @@ -51,7 +51,7 @@ fish = { enable = true; }; git = { enable = true; signing.enable = true; }; neovim = { enable = true; }; - vscode = { enable = true; languages = { cxx = true; python = true; scala = true; latex = true; }; }; + vscode = { enable = true; languages = { cxx = true; python = true; scala = true; latex = true; }; llm = true; }; zellij = { enable = true; }; }; @@ -59,4 +59,19 @@ enable = true; flags = [ "--disable-up-arrow" ]; }; + + programs.firefox.enable = true; + + programs.firefox.policies = { + DefaultDownloadDirectory = "/media/data/Downloads"; + }; + + programs.firefox.profiles.default = { + isDefault = true; + userChrome = builtins.readFile "${pkgs.fetchgit { + url = "https://gist.github.com/0ded98af9fe3da35f3688f81364d8c14.git"; + rev = "11bb4f428382052bcbbceb6cc3fef97f3c939481"; + hash = "sha256-J11indzEGdUA0HSW8eFe5AjesOxCL/G05KwkJk9GZSY="; + }}/userChrome.css"; + }; } diff --git a/modules/home-manager/vscode.nix b/modules/home-manager/vscode.nix index 6042b6a..9017f4c 100644 --- a/modules/home-manager/vscode.nix +++ b/modules/home-manager/vscode.nix @@ -31,7 +31,7 @@ let "cmake.pinnedCommands" = [ "workbench.action.tasks.configureTaskRunner" "workbench.action.tasks.runTask" - ]; + ]; "C_Cpp.intelliSenseEngine" = "Disabled"; }; }; @@ -43,7 +43,7 @@ let settings = { }; }; scalaPackages = { - systemPackages = with pkgs; [ coursier ]; + systemPackages = with pkgs; [ coursier metals ]; extension = with inputs.nix-vscode-extensions.extensions.${pkgs.system}.vscode-marketplace; [ scala-lang.scala scalameta.metals @@ -58,11 +58,13 @@ let settings = { "latex-workshop.latex.autoBuild.run" = "never"; "latex-workshop.latex.tools" = [ - { "name" = "xelatex"; + { + "name" = "xelatex"; "command" = "xelatex"; "args" = [ "-synctex=1" "-interaction=nonstopmode" "-file-line-error" "%DOCFILE%" ]; } - { "name" = "pdflatex"; + { + "name" = "pdflatex"; "command" = "pdflatex"; "args" = [ "-synctex=1" "-interaction=nonstopmode" "-file-line-error" "%DOCFILE%" ]; } @@ -84,6 +86,7 @@ let }; }; }; + llmExtensions = [ pkgs.vscode-extensions.continue.continue ]; languages = [ "nix" "cxx" "python" "scala" "latex" ]; zipAttrsWithLanguageOption = (attr: @@ -103,12 +106,14 @@ in scala = mkEnableOption "Scala"; latex = mkEnableOption "Latex"; }; + llm = mkEnableOption "tab completion with Continue and ollama"; }; config = mkIf cfg.enable { nixpkgs.config.allowUnfree = true; home.packages = lib.mkMerge ([ [ pkgs.clang-tools ] + (mkIf cfg.llm [ pkgs.ollama ]) ] ++ zipAttrsWithLanguageOption "systemPackages"); programs.vscode = { enable = true; @@ -135,30 +140,51 @@ in ms-vscode-remote.remote-ssh-edit mushan.vscode-paste-image ]) + (with pkgs.vscode-extensions; [ waderyan.gitblame catppuccin.catppuccin-vsc # Rust rust-lang.rust-analyzer ]) + + (mkIf cfg.llm llmExtensions) ] ++ zipAttrsWithLanguageOption "extension"); userSettings = lib.mkMerge ([ - {"workbench.colorTheme" = "Catppuccin Macchiato"; - "terminal.integrated.sendKeybindingsToShell" = true; - "extensions.ignoreRecommendations" = true; - "files.autoSave" = "afterDelay"; - "editor.inlineSuggest.enabled" = true; - "editor.rulers" = [ - 80 - ]; - "editor.mouseWheelZoom" = true; - "git.autofetch" = false; - "window.zoomLevel" = -1; + { + "workbench.colorTheme" = "Catppuccin Macchiato"; + "terminal.integrated.sendKeybindingsToShell" = true; + "extensions.ignoreRecommendations" = true; + "files.autoSave" = "afterDelay"; + "editor.inlineSuggest.enabled" = true; + "editor.rulers" = [ + 80 + ]; + "editor.mouseWheelZoom" = true; + "git.autofetch" = false; + "window.zoomLevel" = -1; - "extensions.experimental.affinity" = { - "vscodevim.vim" = 1; - }; - }] ++ zipAttrsWithLanguageOption "settings"); + "extensions.experimental.affinity" = { + "vscodevim.vim" = 1; + }; + } + ] ++ zipAttrsWithLanguageOption "settings"); + }; + + home.file.".continue/config.json".text = lib.generators.toJSON { } { + models = [ + { + model = "AUTODETECT"; + provider = "ollama"; + title = "Ollama"; + } + ]; + tabAutocompleteModel = { + model ="deepseek-coder:6.7b-base"; + provider = "ollama"; + title = "codegemma"; + }; }; }; + }