From fe22704b14055989f03beab7b1fb24c17d9e8a91 Mon Sep 17 00:00:00 2001 From: Giulio De Pasquale Date: Thu, 11 Apr 2024 12:32:58 +0100 Subject: [PATCH] helix: add aichat --- roles/home/helix.nix | 87 ++++++++++++++++++++++---------------------- 1 file changed, 44 insertions(+), 43 deletions(-) diff --git a/roles/home/helix.nix b/roles/home/helix.nix index e286b41..bd64002 100644 --- a/roles/home/helix.nix +++ b/roles/home/helix.nix @@ -1,4 +1,4 @@ -{ pkgs, ... }: +{ pkgs, lib, stdenv, ... }: let actualPkgs = pkgs.unstablePkgs; @@ -17,6 +17,24 @@ let bash-language-server pyright ]; + aichatConfigDir = "$HOME/.config/aichat"; + aichatConfig = '' + model: ollama + clients: + - type: ollama + api_base: https://ollama.giugl.io + api_key: null + models: + - name: pino-fast + max_input_tokens: null + ''; + aichatRoles = '' + - name: comment + prompt: > + As a helpful assistant designed to assist in documenting code, your primary task is to review the provided code and add clear, concise comments and documentation that will help other developers understand its purpose, functionality, and implementation details. Your comments should be written using language-specific conventions, such as docstrings for Python or Javadoc for Java, to ensure compatibility and maximize their utility for users of different programming languages. + When adding comments, focus on conveying essential information about the code, including its inputs, outputs, and behavior, but avoid getting bogged down in unnecessary detail. Your goal is to provide enough context and explanation to allow a competent developer to understand how the code works and how to use it effectively, without overwhelming them with irrelevant or overly technical information. + UNDER NO CIRCUMSTANCES should you modify the code itself. Your role is purely to document and explain the code as it currently exists, not to make changes or suggest improvements. By focusing on providing high-quality documentation, you can help ensure that the code is easy to understand, use, and maintain, even as it evolves over time. + ''; in { home = { @@ -39,56 +57,39 @@ in sessionVariables = { EDITOR = "hx"; VISUAL = "hx"; + AICHAT_CONFIG_DIR = aichatConfigDir; }; - file.".config/helix/config.toml".text = '' - theme = "monokai_pro_spectrum" + file = { + ".config/helix/config.toml".text = '' + theme = "monokai_pro_spectrum" - [editor] - cursorline = true - true-color = true - gutters = ["diff", "diagnostics", "line-numbers", "spacer"] + [editor] + cursorline = true + true-color = true + gutters = ["diff", "diagnostics", "line-numbers", "spacer"] - [editor.cursor-shape] - insert = "bar" - normal = "block" - select = "underline" + [editor.cursor-shape] + insert = "bar" + normal = "block" + select = "underline" - [editor.lsp] - display-messages = true + [editor.lsp] + display-messages = true - [editor.indent-guides] - render = true + [editor.indent-guides] + render = true - [editor.statusline] - left = ["mode", "spinner"] - center = ["file-name"] - ''; + [editor.statusline] + left = ["mode", "spinner"] + center = ["file-name"] - file.".config/helix/languages.toml".text = '' - [[language]] - name = "nix" - formatter = { command = "nixpkgs-fmt" } + [keys.select.l] + c = ":pipe ${pkgs.unstablePkgs.aichat}/bin/aichat -c -r comment" + ''; - [[language]] - name = "python" - formatter = { command = "black", args = [ "-" ] } - language-servers = [ {name = "pyright"}, {name = "ruff-lsp"}, ] - - [language-server.pyright] - command = "pyright-langserver" - args = ["--stdio"] - config = {} - - [language-server.ruff-lsp] - command = "ruff-lsp" - args = [] - config = {} - - [[language]] - name = "bash" - indent = { tab-width = 2, unit = " " } - formatter = { command = 'shfmt', args = ["-i", "2"] } - ''; + "${aichatConfigDir}/roles.yaml".text = aichatRoles; + "${aichatConfigDir}/config.yaml".text = aichatConfig; + }; }; }