From 02ea7e95b7509ff3c31990362b38c9c5e76fe03f Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Thu, 17 Oct 2024 11:36:39 +0200 Subject: [PATCH 01/32] Update osu --- home/osu.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/home/osu.nix b/home/osu.nix index 5551e33..1af458d 100644 --- a/home/osu.nix +++ b/home/osu.nix @@ -5,10 +5,10 @@ let osu-pkg = with pkgs; with lib; appimageTools.wrapType2 rec { pname = "osu-lazer-bin"; - version = "2024.906.2"; + version = "2024.1009.1"; src = fetchurl { url = "https://github.com/ppy/osu/releases/download/${version}/osu.AppImage"; - sha256 = "1ddnac72xk9zsi9pmxg72xd3piq6s5hgh7vzb09mh4r5mkfd22fd"; + sha256 = "sha256-2H2SPcUm/H/0D9BqBiTFvaCwd0c14/r+oWhyeZdNpoU="; }; extraPkgs = pkgs: with pkgs; [ icu ]; From 8702656b2440b1b599aab7b23fc2d827609bc6bb Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Sat, 19 Oct 2024 20:06:00 +0200 Subject: [PATCH 02/32] Update gotosocial to 0.17.0 --- overlay.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/overlay.nix b/overlay.nix index def8c33..8ea7abf 100644 --- a/overlay.nix +++ b/overlay.nix @@ -25,7 +25,7 @@ let overlay-versioning = final: prev: { gotosocial = prev.gotosocial.overrideAttrs (attrs: rec { - version = "0.17.0-rc3"; + version = "0.17.0"; ldflags = [ "-s" "-w" @@ -35,13 +35,13 @@ let web-assets = final.fetchurl { url = "https://github.com/superseriousbusiness/gotosocial/releases/download/v${version}/gotosocial_${version}_web-assets.tar.gz"; - hash = "sha256-Uwltr5syOnDZOgMc2L/iedxiMMKXmULzm0SAs3W0SXQ="; + hash = "sha256-ASqPIf98qdnkh3j72ifQN3mWnzNCTRcUegmrStvQ08Q="; }; src = final.fetchFromGitHub { owner = "superseriousbusiness"; repo = "gotosocial"; rev = "v${version}"; - hash = "sha256-c7CJFQWTMCBZuzI/Mf5PJuCWY1NKW4LLMAJem3TTJvM="; + hash = "sha256-uyqP3zhjcXKejGFAwZoTn2kY8IpX0QAAXNzb1VG6ve8="; }; postInstall = '' tar xf ${web-assets} From c36f5f66b12be9cf44d017c6c22a1b2a197be518 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Thu, 31 Oct 2024 13:04:58 +0000 Subject: [PATCH 03/32] Move stuff to various S3 stores instead of local minio (#5) Move most things to Cloudflare R2, whilst gotosocial goes to local. Reviewed-on: https://git.dtth.ch/nki/nix-home/pulls/5 Co-authored-by: Natsu Kagami Co-committed-by: Natsu Kagami --- modules/cloud/authentik/default.nix | 9 +- modules/cloud/conduit/heisenbridge.nix | 2 +- modules/cloud/gotosocial/default.nix | 20 ++- modules/cloud/outline/r2.patch | 183 +++++++++++++++++++++ nki-personal-do/configuration.nix | 66 +------- nki-personal-do/gitea.nix | 44 +++-- nki-personal-do/hardware-configuration.nix | 6 +- nki-personal-do/nextcloud.nix | 67 -------- nki-personal-do/outline.nix | 56 +++++++ nki-personal-do/secrets/secrets.yaml | 12 +- overlay.nix | 6 +- 11 files changed, 315 insertions(+), 156 deletions(-) create mode 100644 modules/cloud/outline/r2.patch delete mode 100644 nki-personal-do/nextcloud.nix create mode 100644 nki-personal-do/outline.nix diff --git a/modules/cloud/authentik/default.nix b/modules/cloud/authentik/default.nix index a5a8851..e0d6459 100644 --- a/modules/cloud/authentik/default.nix +++ b/modules/cloud/authentik/default.nix @@ -48,7 +48,14 @@ in }; config = mkIf cfg.enable { - systemd.services.arion-authentik.serviceConfig.EnvironmentFile = cfg.envFile; + systemd.services.arion-authentik = { + serviceConfig.EnvironmentFile = cfg.envFile; + serviceConfig.Type = "notify"; + serviceConfig.NotifyAccess = "all"; + script = lib.mkBefore '' + ${lib.getExe pkgs.wait4x} http http://127.0.0.1:${toString cfg.port} --expect-status-code 200 -t 0 -q -- systemd-notify --ready & + ''; + }; virtualisation.arion.projects.authentik.settings = { services.postgresql.service = { image = images.postgresql; diff --git a/modules/cloud/conduit/heisenbridge.nix b/modules/cloud/conduit/heisenbridge.nix index 1db1040..c220423 100644 --- a/modules/cloud/conduit/heisenbridge.nix +++ b/modules/cloud/conduit/heisenbridge.nix @@ -33,7 +33,7 @@ with lib; { { systemd.services.heisenbridge = { description = "Matrix<->IRC bridge"; - requires = [ "matrix-synapse.service" ]; # So the registration file can be used by Synapse + requires = [ "matrix-conduit-nkagami.service" "matrix-synapse.service" ]; # So the registration file can be used by Synapse wantedBy = [ "multi-user.target" ]; serviceConfig = rec { diff --git a/modules/cloud/gotosocial/default.nix b/modules/cloud/gotosocial/default.nix index 9b7bc32..745dc62 100644 --- a/modules/cloud/gotosocial/default.nix +++ b/modules/cloud/gotosocial/default.nix @@ -4,6 +4,7 @@ let cfg = config.cloud.gotosocial; dbUser = "gotosocial"; + storageLocation = "/mnt/data/gotosocial"; in { options.cloud.gotosocial = { @@ -74,6 +75,9 @@ in # Media media-emoji-remote-max-size = 256 * 1024 /* bytes */; media-emoji-local-max-size = 256 * 1024 /* bytes */; + media-remote-cache-days = 7; + media-cleanup-from = "00:00"; + media-cleanup-every = "24h"; # OIDC oidc-enabled = true; oidc-idp-name = "DTTH"; @@ -82,10 +86,22 @@ in http-client.block-ips = [ "11.0.0.0/24" ]; # Advanced advanced-rate-limit-requests = 0; + # Storage + storage-backend = "local"; + storage-local-base-path = "${storageLocation}/storage"; # instance-inject-mastodon-version = true; }; }; - systemd.services.gotosocial.requires = mkAfter [ "minio.service" "postgresql.service" ]; - systemd.services.gotosocial.after = mkAfter [ "minio.service" "postgresql.service" ]; + systemd.services.gotosocial.requires = mkAfter [ "postgresql.service" "arion-authentik.service" ]; + systemd.services.gotosocial.after = mkAfter [ "postgresql.service" "arion-authentik.service" ]; + systemd.services.gotosocial.unitConfig = { + RequiresMountsFor = [ storageLocation ]; + ReadWritePaths = [ storageLocation ]; + }; + systemd.tmpfiles.settings."10-gotosocial".${storageLocation}.d = { + user = dbUser; + group = dbUser; + mode = "0700"; + }; }; } diff --git a/modules/cloud/outline/r2.patch b/modules/cloud/outline/r2.patch new file mode 100644 index 0000000..e62abb5 --- /dev/null +++ b/modules/cloud/outline/r2.patch @@ -0,0 +1,183 @@ +commit 8c7f8c28fabc174a71499a4737579b24b5c4b244 +Author: Natsu Kagami +Date: Mon Oct 21 02:17:36 2024 +0200 + + Support R2 + +diff --git a/.env.sample b/.env.sample +index eb57ad85c..94ffcee07 100644 +--- a/.env.sample ++++ b/.env.sample +@@ -66,6 +66,8 @@ AWS_S3_UPLOAD_BUCKET_URL=http://s3:4569 + AWS_S3_UPLOAD_BUCKET_NAME=bucket_name_here + AWS_S3_FORCE_PATH_STYLE=true + AWS_S3_ACL=private ++AWS_S3_R2=true ++AWS_S3_R2_PUBLIC_URL=http://s3:4569 + + # –––––––––––––– AUTHENTICATION –––––––––––––– + +diff --git a/app/utils/files.ts b/app/utils/files.ts +index 6607a6b12..5138f68ad 100644 +--- a/app/utils/files.ts ++++ b/app/utils/files.ts +@@ -63,8 +63,13 @@ export const uploadFile = async ( + xhr.addEventListener("loadend", () => { + resolve(xhr.readyState === 4 && xhr.status >= 200 && xhr.status < 400); + }); +- xhr.open("POST", data.uploadUrl, true); +- xhr.send(formData); ++ xhr.open(data.method, data.uploadUrl, true); ++ xhr.setRequestHeader("Content-Type", file.type); ++ if (data.method === "POST") { ++ xhr.send(formData); ++ } else { ++ xhr.send(file); ++ } + }); + + if (!success) { +diff --git a/server/env.ts b/server/env.ts +index 5b420f2e1..4ea1e8d3c 100644 +--- a/server/env.ts ++++ b/server/env.ts +@@ -519,6 +519,14 @@ export class Environment { + environment.AWS_S3_UPLOAD_BUCKET_NAME + ); + ++ @IsOptional() ++ public AWS_S3_R2 = this.toBoolean(environment.AWS_S3_R2 ?? "false"); ++ ++ @IsOptional() ++ public AWS_S3_R2_PUBLIC_URL = this.toOptionalString( ++ environment.AWS_S3_R2_PUBLIC_URL ++ ); ++ + /** + * Whether to force path style URLs for S3 objects, this is required for some + * S3-compatible storage providers. +diff --git a/server/routes/api/attachments/attachments.ts b/server/routes/api/attachments/attachments.ts +index 5e6c27594..b7620f440 100644 +--- a/server/routes/api/attachments/attachments.ts ++++ b/server/routes/api/attachments/attachments.ts +@@ -3,6 +3,7 @@ import { v4 as uuidv4 } from "uuid"; + import { AttachmentPreset } from "@shared/types"; + import { bytesToHumanReadable } from "@shared/utils/files"; + import { AttachmentValidation } from "@shared/validations"; ++import env from "@server/env"; + import { AuthorizationError, ValidationError } from "@server/errors"; + import auth from "@server/middlewares/authentication"; + import { rateLimiter } from "@server/middlewares/rateLimiter"; +@@ -90,16 +91,30 @@ router.post( + { transaction } + ); + +- const presignedPost = await FileStorage.getPresignedPost( +- key, +- acl, +- maxUploadSize, +- contentType +- ); ++ let uploadUrl; ++ let method; ++ let presignedPost = { ++ fields: {}, ++ }; ++ if (env.AWS_S3_R2) { ++ uploadUrl = await FileStorage.getPresignedPut(key); ++ method = "PUT"; ++ } else { ++ uploadUrl = FileStorage.getUploadUrl(); ++ method = "POST"; ++ ++ presignedPost = await FileStorage.getPresignedPost( ++ key, ++ acl, ++ maxUploadSize, ++ contentType ++ ); ++ } + + ctx.body = { + data: { +- uploadUrl: FileStorage.getUploadUrl(), ++ uploadUrl, ++ method, + form: { + "Cache-Control": "max-age=31557600", + "Content-Type": contentType, +diff --git a/server/storage/files/BaseStorage.ts b/server/storage/files/BaseStorage.ts +index ce0287ebc..a1931c83d 100644 +--- a/server/storage/files/BaseStorage.ts ++++ b/server/storage/files/BaseStorage.ts +@@ -26,6 +26,8 @@ export default abstract class BaseStorage { + contentType: string + ): Promise>; + ++ public abstract getPresignedPut(key: string): Promise; ++ + /** + * Returns a promise that resolves with a stream for reading a file from the storage provider. + * +diff --git a/server/storage/files/LocalStorage.ts b/server/storage/files/LocalStorage.ts +index 83cf98c50..324e60dd9 100644 +--- a/server/storage/files/LocalStorage.ts ++++ b/server/storage/files/LocalStorage.ts +@@ -30,6 +30,10 @@ export default class LocalStorage extends BaseStorage { + }); + } + ++ public async getPresignedPut(key: string) { ++ return this.getUrlForKey(key); ++ } ++ + public getUploadUrl() { + return "/api/files.create"; + } +diff --git a/server/storage/files/S3Storage.ts b/server/storage/files/S3Storage.ts +index a42442e0c..d55ef5472 100644 +--- a/server/storage/files/S3Storage.ts ++++ b/server/storage/files/S3Storage.ts +@@ -4,6 +4,7 @@ import { + S3Client, + DeleteObjectCommand, + GetObjectCommand, ++ PutObjectCommand, + ObjectCannedACL, + } from "@aws-sdk/client-s3"; + import { Upload } from "@aws-sdk/lib-storage"; +@@ -58,6 +59,16 @@ export default class S3Storage extends BaseStorage { + return createPresignedPost(this.client, params); + } + ++ public async getPresignedPut(key: string) { ++ const params = { ++ Bucket: env.AWS_S3_UPLOAD_BUCKET_NAME, ++ Key: key, ++ }; ++ ++ const command = new PutObjectCommand(params); ++ return await getSignedUrl(this.client, command, { expiresIn: 3600 }); ++ } ++ + private getPublicEndpoint(isServerUpload?: boolean) { + if (env.AWS_S3_ACCELERATE_URL) { + return env.AWS_S3_ACCELERATE_URL; +@@ -137,10 +148,17 @@ export default class S3Storage extends BaseStorage { + ); + } + ++ public getR2ObjectUrl = async (key: string) => ++ env.AWS_S3_R2_PUBLIC_URL + "/" + key; ++ + public getSignedUrl = async ( + key: string, + expiresIn = S3Storage.defaultSignedUrlExpires + ) => { ++ if (env.AWS_S3_R2) { ++ return this.getR2ObjectUrl(key); ++ } ++ + const isDocker = env.AWS_S3_UPLOAD_BUCKET_URL.match(/http:\/\/s3:/); + const params = { + Bucket: this.getBucket(), diff --git a/nki-personal-do/configuration.nix b/nki-personal-do/configuration.nix index 8d65ae4..447da89 100644 --- a/nki-personal-do/configuration.nix +++ b/nki-personal-do/configuration.nix @@ -24,8 +24,11 @@ ./invidious.nix ./owncast.nix ./peertube.nix + ./outline.nix ]; + system.stateVersion = "21.11"; + common.linux.enable = false; # Don't enable the "common linux" module, this is a special machine. # Personal user @@ -189,74 +192,13 @@ protocol = "udp"; }; - - # Outline - sops.secrets.minio-secret-key = { owner = "root"; mode = "0444"; }; - sops.secrets.authentik-oidc-client-secret = { owner = "outline"; }; - sops.secrets."outline/smtp-password" = { owner = "outline"; }; - services.outline = { - enable = true; - package = pkgs.outline.overrideAttrs (attrs: { - patches = if builtins.hasAttr "patches" attrs then attrs.patches else [ ] ++ [ ../modules/cloud/outline/dtth-wiki.patch ]; - }); - databaseUrl = "postgres://outline:outline@localhost/outline?sslmode=disable"; - redisUrl = "local"; - publicUrl = "https://wiki.dtth.ch"; - port = 18729; - storage = { - accessKey = "minio"; - secretKeyFile = config.sops.secrets.minio-secret-key.path; - region = config.services.minio.region; - uploadBucketUrl = "https://s3.dtth.ch"; - uploadBucketName = "dtth-outline"; - uploadMaxSize = 50 * 1024 * 1000; - }; - maximumImportSize = 50 * 1024 * 1000; - - oidcAuthentication = { - clientId = "3a0c10e00cdcb4a1194315577fa208a747c1a5f7"; - clientSecretFile = config.sops.secrets.authentik-oidc-client-secret.path; - authUrl = "https://auth.dtth.ch/application/o/authorize/"; - tokenUrl = "https://auth.dtth.ch/application/o/token/"; - userinfoUrl = "https://auth.dtth.ch/application/o/userinfo/"; - displayName = "DTTH Account"; - }; - - smtp = { - fromEmail = "DTTH Wiki "; - replyEmail = ""; - host = "mx1.nkagami.me"; - username = "dtth.wiki@nkagami.me"; - passwordFile = config.sops.secrets."outline/smtp-password".path; - port = 465; - secure = true; - }; - - forceHttps = false; - }; - cloud.postgresql.databases = [ "outline" ]; - systemd.services.outline.requires = [ "postgresql.service" ]; - cloud.traefik.hosts.outline = { host = "wiki.dtth.ch"; port = 18729; }; - # GoToSocial - sops.secrets.gts-env = { }; + sops.secrets.gts-env = { restartUnits = [ "gotosocial.service" ]; }; cloud.gotosocial = { enable = true; envFile = config.sops.secrets.gts-env.path; }; - # Minio - sops.secrets.minio-credentials = { }; - services.minio = { - enable = true; - listenAddress = ":61929"; - consoleAddress = ":62929"; - rootCredentialsFile = config.sops.secrets.minio-credentials.path; - dataDir = lib.mkForce [ "/mnt/data/minio" ]; - }; - cloud.traefik.hosts.minio = { host = "s3.dtth.ch"; port = 61929; }; - system.stateVersion = "21.11"; - # ntfy cloud.traefik.hosts.ntfy-sh = { host = "ntfy.nkagami.me"; port = 11161; noCloudflare = true; }; services.ntfy-sh = { diff --git a/nki-personal-do/gitea.nix b/nki-personal-do/gitea.nix index 2e1612f..237d6d5 100644 --- a/nki-personal-do/gitea.nix +++ b/nki-personal-do/gitea.nix @@ -98,6 +98,7 @@ in }; users.groups.${user} = { }; sops.secrets."gitea/signing-key".owner = user; + sops.secrets."gitea/minio-secret-key".owner = user; sops.secrets."gitea/mailer-password".owner = user; # database cloud.postgresql.databases = [ user ]; @@ -174,6 +175,17 @@ in PATH = "${pkgs.git}/bin/git"; }; + storage = { + STORAGE_TYPE = "minio"; + MINIO_USE_SSL = "true"; + MINIO_ENDPOINT = "60c0807121eb35ef52cdcd4a33735fa6.r2.cloudflarestorage.com"; + MINIO_ACCESS_KEY_ID = "704c29ade7a8b438b77ab520da2799ca"; + MINIO_SECRET_ACCESS_KEY = "#miniosecretkey#"; + MINIO_BUCKET = "dtth-gitea"; + MINIO_LOCATION = "auto"; + MINIO_CHECKSUM_ALGORITHM = "md5"; # R2 moment + }; + federation.ENABLED = true; DEFAULT.APP_NAME = "DTTHGit"; }; @@ -203,17 +215,25 @@ in environment.GNUPGHOME = "${config.services.gitea.stateDir}/.gnupg"; # https://github.com/NixOS/nixpkgs/commit/93c1d370db28ad4573fb9890c90164ba55391ce7 serviceConfig.SystemCallFilter = mkForce "~@clock @cpu-emulation @debug @keyring @module @mount @obsolete @raw-io @reboot @setuid @swap"; - preStart = '' - # Import the signing subkey - if cat ${config.services.gitea.stateDir}/.gnupg/gpg.conf | grep -q ${signingKey}; then - echo "Keys already imported" - # imported - else - echo "Import your keys!" - ${pkgs.gnupg}/bin/gpg --quiet --import ${secrets."gitea/signing-key".path} - echo "trusted-key ${signingKey}" >> ${config.services.gitea.stateDir}/.gnupg/gpg.conf - exit 1 - fi - ''; + preStart = + let + configFile = "${config.services.forgejo.customDir}/conf/app.ini"; + in + '' + # Update minio secret key + chmod u+w ${configFile} && \ + ${lib.getExe pkgs.replace-secret} '#miniosecretkey#' '${config.sops.secrets."gitea/minio-secret-key".path}' '${configFile}' && \ + chmod u-w ${configFile} + # Import the signing subkey + if cat ${config.services.forgejo.stateDir}/.gnupg/gpg.conf | grep -q ${signingKey}; then + echo "Keys already imported" + # imported + else + echo "Import your keys!" + ${pkgs.gnupg}/bin/gpg --quiet --import ${secrets."gitea/signing-key".path} + echo "trusted-key ${signingKey}" >> ${config.services.forgejo.stateDir}/.gnupg/gpg.conf + exit 1 + fi + ''; }; } diff --git a/nki-personal-do/hardware-configuration.nix b/nki-personal-do/hardware-configuration.nix index f2a2b10..33d4e0f 100644 --- a/nki-personal-do/hardware-configuration.nix +++ b/nki-personal-do/hardware-configuration.nix @@ -9,9 +9,11 @@ swapDevices = [{ device = "/var/swapfile"; size = 4 * 1024; priority = 1024; }]; zramSwap.enable = true; # volumes + services.btrfs.autoScrub.enable = true; fileSystems.data = { - device = "/dev/disk/by-id/scsi-0HC_Volume_31812942"; - fsType = "ext4"; + device = "/dev/disk/by-id/scsi-0HC_Volume_101470796"; + fsType = "btrfs"; mountPoint = "/mnt/data"; + options = [ "compress=zstd" ]; }; } diff --git a/nki-personal-do/nextcloud.nix b/nki-personal-do/nextcloud.nix deleted file mode 100644 index 2bb15f2..0000000 --- a/nki-personal-do/nextcloud.nix +++ /dev/null @@ -1,67 +0,0 @@ -{ lib, pkgs, config, ... }: -with lib; -let - user = "nextcloud"; - host = "cloud.dtth.ch"; - port = 61155; - - secrets = config.sops.secrets; -in -{ - sops.secrets."nextcloud/admin-password" = { owner = user; }; - sops.secrets."nextcloud/minio-secret-key" = { owner = user; key = "minio-secret-key"; }; - # database - cloud.postgresql.databases = [ user ]; - # traefik - cloud.traefik.hosts.nextcloud = { - inherit port host; - }; - systemd.services.nextcloud.requires = [ "postgresql.service" ]; - services.nextcloud = { - enable = true; - hostName = host; - package = pkgs.nextcloud26; - enableBrokenCiphersForSSE = false; - - home = "/mnt/data/nextcloud"; - https = true; - database.createLocally = false; - - extraApps = with pkgs.nextcloud26Packages.apps; { - inherit calendar contacts deck forms groupfolders news tasks; - sociallogin = pkgs.fetchNextcloudApp rec { - url = "https://github.com/zorn-v/nextcloud-social-login/releases/download/v5.4.3/release.tar.gz"; - sha256 = "sha256-ZKwtF9j9WFIk3MZgng9DmN00A73S2Rb4qbehL9adaZo="; - }; - }; - - config = { - # Database - dbtype = "pgsql"; - dbname = user; - dbuser = user; - dbhost = "/run/postgresql"; - # User - adminuser = "nki"; - adminpassFile = secrets."nextcloud/admin-password".path; - # General - overwriteProtocol = "https"; - defaultPhoneRegion = "VN"; - - objectstore.s3 = { - enable = true; - bucket = "nextcloud-dtth"; - autocreate = true; - key = "minio"; - secretFile = config.sops.secrets."nextcloud/minio-secret-key".path; - hostname = "s3.dtth.ch"; - port = 443; - useSsl = true; - usePathStyle = true; - region = "us-east-1"; - }; - }; - }; - services.nginx.virtualHosts.${host}.listen = [{ inherit port; addr = "127.0.0.1"; }]; -} - diff --git a/nki-personal-do/outline.nix b/nki-personal-do/outline.nix new file mode 100644 index 0000000..de5e64c --- /dev/null +++ b/nki-personal-do/outline.nix @@ -0,0 +1,56 @@ +{ config, pkgs, ... }: { + sops.secrets.authentik-oidc-client-secret = { owner = "outline"; }; + sops.secrets."outline/smtp-password" = { owner = "outline"; }; + sops.secrets."outline/s3-secret-key" = { owner = "outline"; }; + + services.outline = { + enable = true; + package = pkgs.outline.overrideAttrs (attrs: { + patches = attrs.patches or [ ] ++ [ + ../modules/cloud/outline/dtth-wiki.patch + ../modules/cloud/outline/r2.patch + ]; + }); + databaseUrl = "postgres://outline:outline@localhost/outline?sslmode=disable"; + redisUrl = "local"; + publicUrl = "https://wiki.dtth.ch"; + port = 18729; + storage = { + accessKey = "6ef730e13f172d2ed6ed77f0b5b9bad9"; + secretKeyFile = config.sops.secrets."outline/s3-secret-key".path; + region = "auto"; + uploadBucketUrl = "https://60c0807121eb35ef52cdcd4a33735fa6.r2.cloudflarestorage.com"; + uploadBucketName = "dtth-outline"; + uploadMaxSize = 50 * 1024 * 1000; + }; + maximumImportSize = 50 * 1024 * 1000; + + oidcAuthentication = { + clientId = "3a0c10e00cdcb4a1194315577fa208a747c1a5f7"; + clientSecretFile = config.sops.secrets.authentik-oidc-client-secret.path; + authUrl = "https://auth.dtth.ch/application/o/authorize/"; + tokenUrl = "https://auth.dtth.ch/application/o/token/"; + userinfoUrl = "https://auth.dtth.ch/application/o/userinfo/"; + displayName = "DTTH Account"; + }; + + smtp = { + fromEmail = "DTTH Wiki "; + replyEmail = ""; + host = "mx1.nkagami.me"; + username = "dtth.wiki@nkagami.me"; + passwordFile = config.sops.secrets."outline/smtp-password".path; + port = 465; + secure = true; + }; + + forceHttps = false; + }; + cloud.postgresql.databases = [ "outline" ]; + systemd.services.outline.requires = [ "postgresql.service" ]; + systemd.services.outline.environment = { + AWS_S3_R2 = "true"; + AWS_S3_R2_PUBLIC_URL = "https://s3.wiki.dtth.ch"; + }; + cloud.traefik.hosts.outline = { host = "wiki.dtth.ch"; port = 18729; }; +} diff --git a/nki-personal-do/secrets/secrets.yaml b/nki-personal-do/secrets/secrets.yaml index 43e4aa3..c02ed8e 100644 --- a/nki-personal-do/secrets/secrets.yaml +++ b/nki-personal-do/secrets/secrets.yaml @@ -2,8 +2,6 @@ tinc: ed25519-private-key: ENC[AES256_GCM,data:HE5xtTb9BVn+5icNDivyvo4gXMXyd0dYjXyKsLfpf/6CDgYZzpBeCTEriedBnyFDqHHCuarS6Y6Tqc2DdeZ3dN1WeaLXFKYxpCGWKHu7Zjp/aZavpdYcqYJvr8GVy+bsImzg9P1lR2h8V+KdQAaT+RgnoiIQPY0f95JO9RmcJSog9h8j1UBixWdNK3n9sDAE+cstI3MUFr93u1vy1wRV/Nt9Aktcz+TAagM55YD/bep00rG3HIYr1y8+g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w2tAGuxLrryL6pb12FkCzFdplXaKiq/IP0gGcs=,tag:rEeKIvhfFksNGCRo+BE4ug==,type:str] authentik-oidc-client-secret: ENC[AES256_GCM,data:lD/xyU87nik68JX+T2H3Gw5ZqsSGzXWX1RjqWskiNu68b5uCFjhRRQ+C3A9P59Xp1pVGamEYx8J4P+hs35Xf0Y9yG/ATiOwkV5k4o7n1d3gkvNwVY/9NaQuNr3KdvjZf8Z5WmGCQkKHvYyq0e89Z9IPe7ML44zQ8qV7Jcn/q3eM=,iv:M3RHdROf+Juxnvd8SiTrjXP8ZirtkcKye8tBpIZphvc=,tag:0BFwX0e0DIj0I3xAU6PbpQ==,type:str] -minio-credentials: ENC[AES256_GCM,data:J4msUueIfNf/ExBe9c85Tf/VEDBQiICWga6swbCuE6e8polpjlRZxTa65k47g4IjEvLJ94jp1LrtH248QdB2QFqQtaOo+IjQ1Yu6,iv:7rjGHctLC1bxNjI8yF1Fuiw6xPXsmyGoANIxanF7H4I=,tag:2+tWwlO8HdAOwLgz7XFf3w==,type:str] -minio-secret-key: ENC[AES256_GCM,data:FkF4hFiW7s5gYbMbdemsmhduYDtb/aqMoUgP+CWI3rw=,iv:6syOMYtryL1Yw4UqIyuLcp2FM/dWLaVNA3UlPdeSZTQ=,tag:GPkHq0d7rvzKbg2BKrmB5w==,type:str] cloudflare-dns-api-token: ENC[AES256_GCM,data:2ny3JehpK30fTUDKrbzHv1QOczriChRyMQn6kNPULpUJ+eVwdptLvg==,iv:8wNAn3oawzLez7sO4ZvhFXcaZIpFVKgKCvTBlszFHn8=,tag:fRaO+u/5MtAWnTiy2Zwh0Q==,type:str] #ENC[AES256_GCM,data:KWrVRQg+cLm5MUdfsYrh7hkI4CWkl4Z0sDj0769eebeXDy+veixrQrxh1ZW+ro3WLwoIdU/IH5DPM4TWYn2qoM5aDHjGX764pr1x,iv:uZHBsGvSHv9vd/Wragl1dYNJ+8vCcMit2K3SrMFlz7s=,tag:7z4LyADfQvXsM2vvtWru8w==,type:comment] traefik-dashboard-users: ENC[AES256_GCM,data:kviapOq+xzxhjryse+5DaZbXRS/LEYyjqqFbHymXAZVEkWlu0T5pZ2bxSNCbXN+tXnb0u+6YPgGCaRNPLW74AF1hO8W8QqlLDA==,iv:41bwPyFQcuOLILTjLWUu5Kcnct/MaIIJsMbllc+n7Y0=,tag:17HyUjfRUcLGb0FrUm1O2A==,type:str] @@ -11,11 +9,12 @@ mail-users: ENC[AES256_GCM,data:qKLi42k8LT6ojxbPXQgbi6FlI2I6ge6qJn0aNj/Lp9iRjjnn youmubot-env: ENC[AES256_GCM,data:EQ9e6lmCrjofHiHyN5Qe4b2oplP9/3JKl0vuFp54Hw9aYIS7j3nqzWLCvV54ZK7j1PcQ+CQorjeCVMV0TUy1f1Pf3qjrLkdOdV7ICq540gdfXOeXuhAx2EILpGkwIYOdKmTMSO3l2QkOlM02RNOn1lq/DogAydkEq7gJ7qSWnUEr45oNCa1+LamH8vcbDmIyzUWWXyA5EQ==,iv:fnNGZ6OaZ4D71SvWPRynsMpO1IsvxjQ3XtrswNSY+Wo=,tag:cN/ZnKrjSfD6AbU9pYNl+Q==,type:str] outline: smtp-password: ENC[AES256_GCM,data:zpIi6jVB2Y7ksBOR8SGFgjOD1x3aS6dKa6taLKB8v2l9p92iWDti75qgB1puglmmq8mCzz8KXLrM0Bv7W8GWRg==,iv:6tKINzQcApmNuIbNn0kSzFJtwn3rky/uFG2Ff3lazUk=,tag:kjB6qB87tRQVpy32Pt3D5A==,type:str] + s3-secret-key: ENC[AES256_GCM,data:dH1Uh3G3RNqITOvsecOW0my3xM3H6xhKYONcwORNPBZmlvSWYvhZUxkOghlH9sYHLIU4yb31QO7npi01Sn3kww==,iv:cV4xqzS5/3HseODY3hS/ycjI6HccsrSGz5Dh9exqNIA=,tag:FMGR9NiTn5S2fTxNSQYBDw==,type:str] heisenbridge: ENC[AES256_GCM,data:rJY7gpcOY8nODR3KlYW1rEs54mKxr+AjNBeg1/2vTG0Gzpuvjgbnn5UVJS+P8uej/P4HfeFtlQSFZCEy8cXcwvwq97ppVliCGL4GMLRWaFmop35feC8t2ovh79cy/vKC7drASeGvWYNUmGRjboPuKA8W5LARa0HVDPGDLIEMVgJfYry/YKR3gsGmLzU7Mx1yLO6M/EFOJQJc84bSuu+CPSZcyUVF4SSNBiaDU5/NazlqaA9KWL6Xzu1MD2LEYdEFkRfitNgYj2m2gLd9voyGV4cfaCqJvYjJPwuZeZUoqCpDnom2JoV29q/Yq/gmyumPgOvriGxLsYBqV14MaCcE6KXE2uLicD+I/5or1AxepVDVjG9NoSgho1HpLvpRhMSCeXLk9+U+ykH3QA+0M+VVu9pswMMVQifnTtXZRM6pWxOnRVAzGf2tGDo4jy36S7pHaRn7SJcrljjWLfwHuNiu7E2uZhMrkcCjnjcBA9Xrb3drDQYVHya7XcoD4wOBHBDvVZwhYkNdkS3oYkom8A==,iv:fO1onfon3EdSNC/LjN1aWxpHBYq5aa0F/h0V6gl88ac=,tag:NL9p2nhIlEqgOdvUDM19Dg==,type:str] matrix-discord-bridge: ENC[AES256_GCM,data:/rlSjD6inKfak7HKKghH5ays5RjKmb9czGsoIOYHyTZC4A5EMucCbfn8DL1gkYXgvRHJ+QglGX/BGo5ebaxSj6nF60+aW87UG31KggOt5kkMuWsPsjvrufoc5IlNfWnXIWmqf8cdC01hmHEp7biUpI8CcfEZiD9OkOxbZcRfYqW+ttnzplFniRBjGPVZfL5g4DBbuJen5MuOrrMDo5CT+78n,iv:r9VBbDCAAElisCaDehrB6PhJHsaaHjdrk3103lmBT7o=,tag:WoNMMfyMifsL56yWq3MUOg==,type:str] authentik-env: ENC[AES256_GCM,data:CjxTaqIcpBX7ea9L3tgJDELr8HBPJdxXsrOfhsiH4cXwCEzktsNKHjF7l95ZFgI5O08q4Vlbln5Dg4xPEx33nwUesEbQrT5d+n+2YaAxmm/WInrYzF+jB7HYTXASb3rY9PWgd2C3v+YPBkJetHlTUc/k19Q7lOQRNw==,iv:cG8Bi2eCsS+v94tSJBsqp+bjVLzXZ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l+FTiQOGScVLag==,type:str] gitea: mailer-password: ENC[AES256_GCM,data:LDW0bpbfanBa2QjqdgtKu6F+zG84xaGuLg1cs6eTJbg=,iv:Kle+czR9Xqi45qWjYJIjRhq87rG2PNoNF6YQ7tQ+HJA=,tag:WUuPgwdnz8F2WtFsgcrw/Q==,type:str] + minio-secret-key: ENC[AES256_GCM,data:IRuaRgOgR+7LMSLwg9NxxSqUCbze8qu9cPWJllsA6GTNmllEHrlKA6ywZrlTlVmS16fkmQWCCi5wjZmltw6UCg==,iv:zCtqGkS195f7/ikwnjhYPTxqmUV2y+kI4OMT1OjMtCw=,tag:wMLfU8+zau7VTxRArfm1sg==,type:str] signing-key: ENC[AES256_GCM,data:64tLU6rVcCq6CSfVGtFfSc8m89gHFHwGQ4JSHw8p7GqlB7ioHrJVu8o+6u6UPERMfkcHsTG2gTwh7wpblF//bk1+TRyYWSuDnIGl1G7+6FVmJbvLyGJBck0NauW4s5Keiqr2qg38i3y9qy7kPaJGz/2J6cYYSQxB9xy8mtdoxwypGf+zxu1teiUnKmWa89i941s2FZZ+FoQvQCZs/7En3YnxNiDM+lXR4wqbPZPROlYHaVDOgeACBgq8GwNdgAFF7qRLdjxMGgjS3jjlD4QCJlEO6UbqVEBEK7pf4Or4kx/RM2A0rgGNUPpwKu/b5xGTUkA0X7TcZNIcLJ2zred0JIEj0bM7MNrkBIQovHEYLT3m33W1zKTTBC2lgPh90I/tPauIOb1hWHzgjM+LpV8bPkGXIk3BmoxW8eCiFmSjfvxdyS6WVJ6lGOIhaFNl59LyKsljyUmYcauig7/T+ylGyWiPViXuYB4fWxWr1t7Tb6DgY2fJdl5KQHLkDoAylHQ6pOb0l2YUGw1+vvHocMA9KTJeTnhTWAPZLOIFbfZL8sxrWRlpuZvvKdXlOjzKwVgCzWudYJ4jUoPSCmvxpnuCpiPbqaoZyA3Vyx7UCTN7UhKRb99jxEqdTrDPwRL0VlVZUQgLDTMPXHjdoOan06wXmDJEDRDBFsrrpna9wY1uvyPGB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256_GCM,data:wDL8xCv8/mFQniIRQOR+zl1kArSUXc2KAfCP1jmnidLOYwC4X0d8V60s0hAXCO1gUxNTETjbjBkGlENpvQm8dL94DIshCMyMxFc5gUmrF9qc+omOPT5HF82FgaHnN9N6sH3r19SfoXkMtBROj1V6xlU/lVqx+CiJCSCBfbllYkY=,iv:DGFlXNRXey0dIQVzsg0qkPGxDG+36tcg0BXUQzHfANk=,tag:HdpNO+ikmXo7wtahYwtkDg==,type:str] @@ -75,8 +75,8 @@ sops: by9kZFlTRVdCZFkxYTVVb0RIRk8zUlkKCqMw9oL9RaYBV5Hhy3o8Nm5xmGrPH8Sd hv36sxRFFNZT/DCKaHaSRbT3mfpBZSTXJt1dgl4nZe6whH54t/1KmA== -----END AGE ENCRYPTED FILE----- - lastmodified: "2024-08-17T15:08:31Z" - mac: ENC[AES256_GCM,data:ejelcIHDYd7zbIJVw62fj4EcgR8ln/jm32QlaE7shYHwt9nJEsV0aWy9rqEjAm8Z0z3ruT4hR9M7aFkNICR9W20r54V0aRfJsp0txe9LeisAE4gXmVo3/+6pBGOUQNtFO+WaLqDwAGNvfr7IlQFXJyrkuOGe+HGVkhlx+UHxRDI=,iv:pI2xAfhajEWt4RjL2Cu3QPX8bgJn1/ew8ldz8E5Jej8=,tag:KJoia8X/FpaSbuXSDOjQAQ==,type:str] + lastmodified: "2024-10-26T12:06:05Z" + mac: ENC[AES256_GCM,data:nici08Luubj2xDfsi1s16VCyG5oizIC6DRfvypmjWRpn0DSpcoWW1j32ya2poEwzpBJoVksFp7ijyjaJv8obExKx94ZYc790eOp/kp1f8lBaHDF8qrYYPL5penkt+UTKeb8xb7BPCJ7O89IVkIjAt7EoQOliMYrLpbiZGkMdHE0=,iv:qY5+MjU5VaXAesuFGt4SgmEdcJ6+vb/mk+NdOPLjCik=,tag:poRJZW3sAMv6EMi64SEQyA==,type:str] pgp: [] unencrypted_suffix: _unencrypted - version: 3.9.0 + version: 3.9.1 diff --git a/overlay.nix b/overlay.nix index 8ea7abf..63eed4c 100644 --- a/overlay.nix +++ b/overlay.nix @@ -25,7 +25,7 @@ let overlay-versioning = final: prev: { gotosocial = prev.gotosocial.overrideAttrs (attrs: rec { - version = "0.17.0"; + version = "0.17.1"; ldflags = [ "-s" "-w" @@ -35,13 +35,13 @@ let web-assets = final.fetchurl { url = "https://github.com/superseriousbusiness/gotosocial/releases/download/v${version}/gotosocial_${version}_web-assets.tar.gz"; - hash = "sha256-ASqPIf98qdnkh3j72ifQN3mWnzNCTRcUegmrStvQ08Q="; + hash = "sha256-rGntLlIbgfCtdqpD7tnvAY8qwF+BpYbQWfAGMhdOTgY="; }; src = final.fetchFromGitHub { owner = "superseriousbusiness"; repo = "gotosocial"; rev = "v${version}"; - hash = "sha256-uyqP3zhjcXKejGFAwZoTn2kY8IpX0QAAXNzb1VG6ve8="; + hash = "sha256-oWWsCs9jgd244yzWhgLkuHp7kY0BQ8+Ay6KpuBVG+U8="; }; postInstall = '' tar xf ${web-assets} From dc49540f8dc3a29fddc8ee2f85eeae4e7960dbae Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Thu, 31 Oct 2024 14:10:47 +0100 Subject: [PATCH 04/32] Update youmubot --- flake.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/flake.lock b/flake.lock index 3a7a51a..606eecf 100644 --- a/flake.lock +++ b/flake.lock @@ -1549,11 +1549,11 @@ "rust-overlay": "rust-overlay_4" }, "locked": { - "lastModified": 1728746553, - "narHash": "sha256-BlZpmTt6wyMIpJvd5nEWGgqJQbtjVTzBlYYQVShZ7Io=", + "lastModified": 1730379848, + "narHash": "sha256-mYea9yishYACulXY7HybIsOgMOEadyzOf84/vRfF3Zg=", "owner": "natsukagami", "repo": "youmubot", - "rev": "c5354e30ad40f67938deed1deb5ea92bb168a586", + "rev": "7d490774e0fda4deb1dcc0a4d8cf10a4b95d6271", "type": "github" }, "original": { From fc57e7734088823396014272c4c42e409c186c24 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Wed, 30 Oct 2024 12:10:36 +0100 Subject: [PATCH 05/32] Update zotero and add zoom --- home/modules/linux/graphical/default.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/home/modules/linux/graphical/default.nix b/home/modules/linux/graphical/default.nix index b1cbe56..554d138 100644 --- a/home/modules/linux/graphical/default.nix +++ b/home/modules/linux/graphical/default.nix @@ -66,7 +66,7 @@ in # Audio qpwgraph # Pipewire graph - zotero_7 + unstable.zotero libreoffice mpv # for anki @@ -76,6 +76,7 @@ in tdesktop whatsapp-for-linux slack + zoom-us librewolf From f98b48a5e361c01c2d6e0dfdbf7dd3c8e51a509c Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Wed, 30 Oct 2024 13:31:39 +0100 Subject: [PATCH 06/32] Update nixpkgs --- flake.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/flake.lock b/flake.lock index 606eecf..0c97613 100644 --- a/flake.lock +++ b/flake.lock @@ -1166,11 +1166,11 @@ }, "nixpkgs_9": { "locked": { - "lastModified": 1726838390, - "narHash": "sha256-NmcVhGElxDbmEWzgXsyAjlRhUus/nEqPC5So7BOJLUM=", + "lastModified": 1730137625, + "narHash": "sha256-9z8oOgFZiaguj+bbi3k4QhAD6JabWrnv7fscC/mt0KE=", "owner": "nixos", "repo": "nixpkgs", - "rev": "944b2aea7f0a2d7c79f72468106bc5510cbf5101", + "rev": "64b80bfb316b57cdb8919a9110ef63393d74382a", "type": "github" }, "original": { From cd4a9807cb629d6bc428581192194b54ef372a89 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Mon, 4 Nov 2024 18:23:43 +0100 Subject: [PATCH 07/32] Update nixpkgs --- flake.lock | 26 +++++++++++++------------- flake.nix | 2 +- modules/personal/fonts/default.nix | 2 +- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/flake.lock b/flake.lock index 0c97613..155dc3e 100644 --- a/flake.lock +++ b/flake.lock @@ -817,15 +817,15 @@ "lix": { "flake": false, "locked": { - "lastModified": 1723503926, - "narHash": "sha256-Rosl9iA9MybF5Bud4BTAQ9adbY81aGmPfV8dDBGl34s=", - "rev": "bcaeb6388b8916ac6d1736e3aa2b13313e6a6bd2", + "lastModified": 1729298361, + "narHash": "sha256-hiGtfzxFkDc9TSYsb96Whg0vnqBVV7CUxyscZNhed0U=", + "rev": "ad9d06f7838a25beec425ff406fe68721fef73be", "type": "tarball", - "url": "https://git.lix.systems/api/v1/repos/lix-project/lix/archive/bcaeb6388b8916ac6d1736e3aa2b13313e6a6bd2.tar.gz" + "url": "https://git.lix.systems/api/v1/repos/lix-project/lix/archive/ad9d06f7838a25beec425ff406fe68721fef73be.tar.gz?rev=ad9d06f7838a25beec425ff406fe68721fef73be" }, "original": { "type": "tarball", - "url": "https://git.lix.systems/lix-project/lix/archive/2.91.0.tar.gz" + "url": "https://git.lix.systems/lix-project/lix/archive/2.91.1.tar.gz" } }, "lix-module": { @@ -838,15 +838,15 @@ ] }, "locked": { - "lastModified": 1723510904, - "narHash": "sha256-zNW/rqNJwhq2lYmQf19wJerRuNimjhxHKmzrWWFJYts=", - "rev": "622a2253a071a1fb97a4d3c8103a91114acc1140", + "lastModified": 1729360442, + "narHash": "sha256-6U0CyPycIBc04hbYy2hBINnVso58n/ZyywY2BD3hu+s=", + "rev": "9098ac95768f7006d7e070b88bae76939f6034e6", "type": "tarball", - "url": "https://git.lix.systems/api/v1/repos/lix-project/nixos-module/archive/622a2253a071a1fb97a4d3c8103a91114acc1140.tar.gz" + "url": "https://git.lix.systems/api/v1/repos/lix-project/nixos-module/archive/9098ac95768f7006d7e070b88bae76939f6034e6.tar.gz?rev=9098ac95768f7006d7e070b88bae76939f6034e6" }, "original": { "type": "tarball", - "url": "https://git.lix.systems/lix-project/nixos-module/archive/2.91.0.tar.gz" + "url": "https://git.lix.systems/lix-project/nixos-module/archive/2.91.1-1.tar.gz" } }, "mpd-mpris": { @@ -1022,11 +1022,11 @@ }, "nixpkgs-unstable": { "locked": { - "lastModified": 1728409405, - "narHash": "sha256-kk530XBUGDpt0DQbyUb3yDpSddPqF9PA5KTo/nsmmg0=", + "lastModified": 1730272153, + "narHash": "sha256-B5WRZYsRlJgwVHIV6DvidFN7VX7Fg9uuwkRW9Ha8z+w=", "owner": "nixos", "repo": "nixpkgs", - "rev": "1366d1af8f58325602280e43ed6233849fb92216", + "rev": "2d2a9ddbe3f2c00747398f3dc9b05f7f2ebb0f53", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index e68e428..0b873f3 100644 --- a/flake.nix +++ b/flake.nix @@ -31,7 +31,7 @@ }; arion.url = github:hercules-ci/arion; lix-module = { - url = "https://git.lix.systems/lix-project/nixos-module/archive/2.91.0.tar.gz"; + url = "https://git.lix.systems/lix-project/nixos-module/archive/2.91.1-1.tar.gz"; inputs.nixpkgs.follows = "nixpkgs"; }; diff --git a/modules/personal/fonts/default.nix b/modules/personal/fonts/default.nix index 95978ec..5a02835 100644 --- a/modules/personal/fonts/default.nix +++ b/modules/personal/fonts/default.nix @@ -10,7 +10,7 @@ with lib; ibm-plex (nerdfonts.override { fonts = [ "NerdFontsSymbolsOnly" ]; }) noto-fonts - noto-fonts-cjk + (pkgs.noto-fonts-cjk-sans or pkgs.noto-fonts-cjk) merriweather corefonts font-awesome From baa3d1cd0da1100fcdd1c237dbd46e2a510f8af8 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Sun, 10 Nov 2024 23:13:35 +0100 Subject: [PATCH 08/32] Update youmubot --- flake.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/flake.lock b/flake.lock index 155dc3e..21d7c8d 100644 --- a/flake.lock +++ b/flake.lock @@ -1549,11 +1549,11 @@ "rust-overlay": "rust-overlay_4" }, "locked": { - "lastModified": 1730379848, - "narHash": "sha256-mYea9yishYACulXY7HybIsOgMOEadyzOf84/vRfF3Zg=", + "lastModified": 1730740980, + "narHash": "sha256-Z/RLbhlBxdNPZt/DeROPBV7bLQgpmamjcB0rdQrQoNw=", "owner": "natsukagami", "repo": "youmubot", - "rev": "7d490774e0fda4deb1dcc0a4d8cf10a4b95d6271", + "rev": "803d718c7ad34d3780ae6c2911ca0682b2417cc4", "type": "github" }, "original": { From 2cb0cb736c2e19b1d123f262af1b3f66118eba60 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Tue, 12 Nov 2024 22:04:22 +0100 Subject: [PATCH 09/32] Disable easyeffects --- home/common-linux.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/home/common-linux.nix b/home/common-linux.nix index 947d612..61302be 100644 --- a/home/common-linux.nix +++ b/home/common-linux.nix @@ -39,7 +39,7 @@ in systemd.user.startServices = "sd-switch"; # Audio stuff! - services.easyeffects.enable = true; + # services.easyeffects.enable = true; # Bluetooth controls # services.mpris-proxy.enable = true; From 82cefd68e056378cd58098e27216327495de1405 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Wed, 13 Nov 2024 11:41:20 +0100 Subject: [PATCH 10/32] Move rofi-rbw to common wayland --- home/modules/linux/graphical/wayland.nix | 17 +++++++++++++++++ home/modules/programs/my-sway/default.nix | 17 +++-------------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/home/modules/linux/graphical/wayland.nix b/home/modules/linux/graphical/wayland.nix index a403195..3c6cbd9 100644 --- a/home/modules/linux/graphical/wayland.nix +++ b/home/modules/linux/graphical/wayland.nix @@ -61,6 +61,12 @@ let ''; xdg.dataFile."dbus-1/services/org.freedesktop.Notifications.service".source = "${pkgs.kdePackages.plasma-workspace}/share/dbus-1/services/org.kde.plasma.Notifications.service"; }; + + rofi-rbw-script = pkgs.writeShellApplication { + name = "rofi-rbw-script"; + runtimeInputs = with pkgs; [ rofi wtype rofi-rbw ]; + text = "rofi-rbw"; + }; in with lib; { @@ -69,6 +75,7 @@ with lib; # Additional packages home.packages = with pkgs; [ wl-clipboard # Clipboard management + rofi-rbw-script # Mimic the clipboard stuff in MacOS (pkgs.writeShellScriptBin "pbcopy" '' @@ -79,6 +86,16 @@ with lib; '') ]; + programs.rofi = { + enable = true; + package = pkgs.rofi-wayland; + cycle = true; + font = "monospace"; + terminal = "${lib.getExe config.programs.kitty.package}"; + theme = "Paper"; + plugins = with pkgs; [ rofi-bluetooth rofi-calc rofi-rbw rofi-power-menu ]; + }; + home.sessionVariables = { ANKI_WAYLAND = "1"; }; diff --git a/home/modules/programs/my-sway/default.nix b/home/modules/programs/my-sway/default.nix index d4536f9..a01b4c0 100644 --- a/home/modules/programs/my-sway/default.nix +++ b/home/modules/programs/my-sway/default.nix @@ -45,12 +45,6 @@ let ${pkgs.grim}/bin/grim -g (${pkgs.slurp}/bin/slurp) - | ${pkgs.swappy}/bin/swappy -f - ''; - rofi-rbw-script = pkgs.writeShellApplication { - name = "rofi-rbw-script"; - runtimeInputs = with pkgs; [ rofi wtype rofi-rbw ]; - text = "rofi-rbw"; - }; - ignored-devices = [ "Surface_Headphones" ]; playerctl = "${pkgs.playerctl}/bin/playerctl --ignore-player=${strings.concatStringsSep "," ignored-devices}"; @@ -223,7 +217,7 @@ in # Launcher "${mod}+space" = "exec rofi -show drun"; "${mod}+tab" = "exec ${./rofi-window.py}"; - "${mod}+shift+p" = "exec ${lib.getExe rofi-rbw-script}"; + "${mod}+shift+p" = "exec rofi-rbw-script"; } // { ## Splits "${mod}+v" = "split v"; @@ -781,14 +775,9 @@ in # For waybar font-awesome ]); + config.programs.rofi = mkIf cfg.enable { - enable = true; - package = pkgs.rofi-wayland; - cycle = true; - font = "monospace ${toString cfg.fontSize}"; - terminal = cfg.terminal; - theme = "Paper"; - plugins = with pkgs; [ rofi-bluetooth rofi-calc rofi-rbw rofi-power-menu ]; + font = lib.mkForce "monospace ${toString cfg.fontSize}"; }; } From 32b4df7c28527bb70814b4d7b32fd55aff47a962 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Wed, 13 Nov 2024 12:00:44 +0100 Subject: [PATCH 11/32] Update phanpy and nixpkgs --- flake.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/flake.lock b/flake.lock index 21d7c8d..7b7dada 100644 --- a/flake.lock +++ b/flake.lock @@ -1166,11 +1166,11 @@ }, "nixpkgs_9": { "locked": { - "lastModified": 1730137625, - "narHash": "sha256-9z8oOgFZiaguj+bbi3k4QhAD6JabWrnv7fscC/mt0KE=", + "lastModified": 1731239293, + "narHash": "sha256-q2yjIWFFcTzp5REWQUOU9L6kHdCDmFDpqeix86SOvDc=", "owner": "nixos", "repo": "nixpkgs", - "rev": "64b80bfb316b57cdb8919a9110ef63393d74382a", + "rev": "9256f7c71a195ebe7a218043d9f93390d49e6884", "type": "github" }, "original": { From 4afc60bd6a3a3cd3b7c3ed7d54c0376a03519da6 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Wed, 13 Nov 2024 16:08:00 +0100 Subject: [PATCH 12/32] Enable appimage support --- modules/common/linux/default.nix | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/common/linux/default.nix b/modules/common/linux/default.nix index 39b69a0..2fae826 100644 --- a/modules/common/linux/default.nix +++ b/modules/common/linux/default.nix @@ -315,6 +315,11 @@ in programs.kdeconnect.enable = true; # Flatpaks are useful... sometimes... services.flatpak.enable = true; + # AppImages should run + programs.appimage = { + enable = true; + binfmt = true; + }; # DConf for GNOME configurations programs.dconf.enable = true; # Gaming! (not for ARM64) From ec187e65c0298645c8ce139e79f648500abbd5f0 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Wed, 13 Nov 2024 16:08:15 +0100 Subject: [PATCH 13/32] Add zen-browser-bin package --- overlay.nix | 4 +++ packages/x86_64-linux/zen-browser-bin.nix | 32 +++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 packages/x86_64-linux/zen-browser-bin.nix diff --git a/overlay.nix b/overlay.nix index 63eed4c..88159df 100644 --- a/overlay.nix +++ b/overlay.nix @@ -114,6 +114,10 @@ let lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [ Security SystemConfiguration CoreServices ]) ) ++ (with final; [ libiconv ]); }; + + zen-browser-bin = final.callPackage ./packages/x86_64-linux/zen-browser-bin.nix { + nativeMessagingHosts = with final; [ kdePackages.plasma-browser-integration ]; + }; }; overlay-rust-is-dumb = final: prev: { diff --git a/packages/x86_64-linux/zen-browser-bin.nix b/packages/x86_64-linux/zen-browser-bin.nix new file mode 100644 index 0000000..33c7633 --- /dev/null +++ b/packages/x86_64-linux/zen-browser-bin.nix @@ -0,0 +1,32 @@ +{ appimageTools, fetchurl, nativeMessagingHosts, ... }: +let + pname = "zen-browser-bin"; + version = "1.0.1-a.19"; + src = fetchurl { + url = "https://github.com/zen-browser/desktop/releases/download/${version}/zen-specific.AppImage"; + hash = "sha256-qAPZ4VyVmeZLRfL0kPHF75zyrSUFHKQUSUcpYKs3jk8="; + }; + + appimageContents = appimageTools.extract { + inherit pname version src; + }; + +in +appimageTools.wrapType2 { + inherit pname version src; + + extraInstallCommands = '' + mv $out/bin/${pname} $out/bin/zen + install -m 444 -D ${appimageContents}/zen.desktop $out/share/applications/zen.desktop + install -m 444 -D ${appimageContents}/usr/share/icons/hicolor/128x128/apps/zen.png \ + $out/share/icons/hicolor/128x128/apps/zen.png + + mkdir -p $out/lib/mozilla/native-messaging-hosts + for ext in ${toString nativeMessagingHosts}; do + ln -sLt $out/lib/mozilla/native-messaging-hosts $ext/lib/mozilla/native-messaging-hosts/* + done + ''; + + meta.mainProgram = "zen"; +} + From 43a33c23137553bb67dd2889e483a9b8ed10304c Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Wed, 13 Nov 2024 16:42:34 +0100 Subject: [PATCH 14/32] Use zen as browser on yoga --- home/modules/linux/graphical/default.nix | 5 +--- home/modules/programs/my-sway/default.nix | 5 +++- home/nki-x1c1.nix | 30 ++++++++++++++++------- packages/x86_64-linux/zen-browser-bin.nix | 2 +- 4 files changed, 27 insertions(+), 15 deletions(-) diff --git a/home/modules/linux/graphical/default.nix b/home/modules/linux/graphical/default.nix index 554d138..35a29eb 100644 --- a/home/modules/linux/graphical/default.nix +++ b/home/modules/linux/graphical/default.nix @@ -38,7 +38,6 @@ in librewolf thunderbird vesktop - premid ]; }; defaults.webBrowser = mkOption { @@ -58,7 +57,6 @@ in feh # For images? deluge # Torrent client pavucontrol # PulseAudio control panel - thunderbird # Email sublime-music # For navidrome # cinny-desktop gajim @@ -78,14 +76,13 @@ in slack zoom-us - librewolf ## CLI stuff dex # .desktop file management, startup # sct # Display color temperature xdg-utils # Open stuff wifi-indicator - ]); + ] ++ cfg.startup); nki.programs.discord.enable = pkgs.stdenv.isx86_64; nki.programs.discord.package = pkgs.vesktop; diff --git a/home/modules/programs/my-sway/default.nix b/home/modules/programs/my-sway/default.nix index a01b4c0..428c56e 100644 --- a/home/modules/programs/my-sway/default.nix +++ b/home/modules/programs/my-sway/default.nix @@ -291,7 +291,8 @@ in # Assigning windows to workspaces assigns = { "${builtins.elemAt workspaces 0}" = [ - { class = "^firefox$"; } + { app_id = "^firefox$"; } + { app_id = "^librewolf$"; } ]; "${builtins.elemAt workspaces 1}" = [ { class = "^((d|D)iscord|((A|a)rm(c|C)ord))$"; } @@ -299,6 +300,8 @@ in { app_id = "VencordDesktop"; } { class = "vesktop"; } { app_id = "vesktop"; } + + { class = "Slack"; } ]; ${extraWorkspaces.mail} = [ { app_id = "thunderbird"; } diff --git a/home/nki-x1c1.nix b/home/nki-x1c1.nix index 49f0ed0..dbad824 100644 --- a/home/nki-x1c1.nix +++ b/home/nki-x1c1.nix @@ -29,7 +29,8 @@ # Graphical set up linux.graphical.type = "wayland"; linux.graphical.wallpaper = ./images/wallpaper_0.png; - linux.graphical.defaults.webBrowser = "librewolf.desktop"; + linux.graphical.startup = with pkgs; [ zen-browser-bin thunderbird vesktop slack ]; + linux.graphical.defaults.webBrowser = "zen.desktop"; # Enable sway programs.my-sway.enable = true; programs.my-sway.fontSize = 14.0; @@ -96,14 +97,25 @@ # Multiple screen setup services.kanshi = with config.common.monitors; { enable = true; - profiles.undocked.outputs = [{ criteria = "LVDS-1"; }]; - profiles.work-both.outputs = [ - { criteria = "eDP-1"; position = "0,${toString (builtins.floor ((2160 / work.scale - 1200) + 1200 / 3))}"; status = "enable"; } - { criteria = work.name; position = "1920,0"; } - ]; - profiles.work-one.outputs = [ - { criteria = "eDP-1"; status = "disable"; } - { criteria = config.common.monitors.work.name; } + settings = [ + { + profile.name = "undocked"; + profile.outputs = [{ criteria = "LVDS-1"; }]; + } + { + profile.name = "work-both"; + profile.outputs = [ + { criteria = "eDP-1"; position = "0,${toString (builtins.floor ((2160 / work.scale - 1200) + 1200 / 3))}"; status = "enable"; } + { criteria = work.name; position = "1920,0"; } + ]; + } + { + profile.name = "work-one"; + profile.outputs = [ + { criteria = "eDP-1"; status = "disable"; } + { criteria = work.name; } + ]; + } ]; }; diff --git a/packages/x86_64-linux/zen-browser-bin.nix b/packages/x86_64-linux/zen-browser-bin.nix index 33c7633..18d3d67 100644 --- a/packages/x86_64-linux/zen-browser-bin.nix +++ b/packages/x86_64-linux/zen-browser-bin.nix @@ -1,4 +1,4 @@ -{ appimageTools, fetchurl, nativeMessagingHosts, ... }: +{ appimageTools, fetchurl, nativeMessagingHosts ? [ ], ... }: let pname = "zen-browser-bin"; version = "1.0.1-a.19"; From 689a6b061e6263f3537d90b120a3fe79a4466013 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Fri, 15 Nov 2024 21:46:26 +0100 Subject: [PATCH 15/32] Change phanpy repo and update --- flake.lock | 12 ++++++------ flake.nix | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/flake.lock b/flake.lock index 7b7dada..5958573 100644 --- a/flake.lock +++ b/flake.lock @@ -232,18 +232,18 @@ "nixpkgs": "nixpkgs_7" }, "locked": { - "lastModified": 1728598146, - "narHash": "sha256-8zAvVSR3chBSJ7YKW+MYC1mrDxtZDFBPVobfO4KPXzg=", + "lastModified": 1731494335, + "narHash": "sha256-G1G2WRGgIOFNmlJglfqEupSg0VWHgODbBJzp5xo+cYY=", "ref": "dtth-fork", - "rev": "fc6bd96aef92d7796d9c7663ac23e3fa837f8ddb", - "revCount": 3218, + "rev": "c414bb78f27b20df4463c36a5851c94cfe9c79b0", + "revCount": 3367, "type": "git", - "url": "ssh://gitea@git.dtth.ch/nki/phanpy" + "url": "ssh://gitea@git.dtth.ch/nki-dtth/phanpy" }, "original": { "ref": "dtth-fork", "type": "git", - "url": "ssh://gitea@git.dtth.ch/nki/phanpy" + "url": "ssh://gitea@git.dtth.ch/nki-dtth/phanpy" } }, "fenix": { diff --git a/flake.nix b/flake.nix index 0b873f3..6699c7d 100644 --- a/flake.nix +++ b/flake.nix @@ -46,7 +46,7 @@ url = github:natsukagami/mpd-mpris; inputs.nixpkgs.follows = "nixpkgs"; }; - dtth-phanpy.url = "git+ssh://gitea@git.dtth.ch/nki/phanpy?ref=dtth-fork"; + dtth-phanpy.url = "git+ssh://gitea@git.dtth.ch/nki-dtth/phanpy?ref=dtth-fork"; conduit.url = "gitlab:famedly/conduit/v0.9.0"; nix-gaming.url = github:fufexan/nix-gaming; From d80b12e7a9950e23bfb036673df3dbaf53a127fb Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Fri, 15 Nov 2024 21:54:41 +0100 Subject: [PATCH 16/32] Move home to use zen-browser --- home/kagami-pc-home.nix | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/home/kagami-pc-home.nix b/home/kagami-pc-home.nix index 0218c17..baaa060 100644 --- a/home/kagami-pc-home.nix +++ b/home/kagami-pc-home.nix @@ -37,7 +37,12 @@ # Enable X11 configuration linux.graphical.type = "wayland"; linux.graphical.wallpaper = ./images/pixiv_18776904.png; - linux.graphical.defaults.webBrowser = "librewolf.desktop"; + linux.graphical.defaults.startup = with pkgs; [ + zen-browser-bin + thunderbird + vesktop + ]; + linux.graphical.defaults.webBrowser = "zen.desktop"; programs.my-sway.enable = true; programs.my-sway.fontSize = 15.0; programs.my-sway.enableLaptopBars = false; From 54a41c52739ef650db5532a8b6266fb0f45da736 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Fri, 15 Nov 2024 21:57:43 +0100 Subject: [PATCH 17/32] Typo on home settings --- home/kagami-pc-home.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/home/kagami-pc-home.nix b/home/kagami-pc-home.nix index baaa060..2d0d7ab 100644 --- a/home/kagami-pc-home.nix +++ b/home/kagami-pc-home.nix @@ -37,7 +37,7 @@ # Enable X11 configuration linux.graphical.type = "wayland"; linux.graphical.wallpaper = ./images/pixiv_18776904.png; - linux.graphical.defaults.startup = with pkgs; [ + linux.graphical.startup = with pkgs; [ zen-browser-bin thunderbird vesktop From fe98578843449e50870009cb9d996ca2f6f98d2b Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Mon, 18 Nov 2024 13:53:42 +0100 Subject: [PATCH 18/32] Update osu lazer --- home/osu.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/home/osu.nix b/home/osu.nix index 1af458d..40844af 100644 --- a/home/osu.nix +++ b/home/osu.nix @@ -5,10 +5,10 @@ let osu-pkg = with pkgs; with lib; appimageTools.wrapType2 rec { pname = "osu-lazer-bin"; - version = "2024.1009.1"; + version = "2024.1115.3"; src = fetchurl { url = "https://github.com/ppy/osu/releases/download/${version}/osu.AppImage"; - sha256 = "sha256-2H2SPcUm/H/0D9BqBiTFvaCwd0c14/r+oWhyeZdNpoU="; + sha256 = "sha256-kwZHy0FfOUFIWvyOj0ghlQz05U+Lnzl5TgC4T6bhm7o="; }; extraPkgs = pkgs: with pkgs; [ icu ]; From eb16655d2ac9df2f939a02f1f505eb51fafea150 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Mon, 18 Nov 2024 13:57:35 +0100 Subject: [PATCH 19/32] Update youmubot --- flake.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/flake.lock b/flake.lock index 5958573..e452a63 100644 --- a/flake.lock +++ b/flake.lock @@ -1549,11 +1549,11 @@ "rust-overlay": "rust-overlay_4" }, "locked": { - "lastModified": 1730740980, - "narHash": "sha256-Z/RLbhlBxdNPZt/DeROPBV7bLQgpmamjcB0rdQrQoNw=", + "lastModified": 1731934405, + "narHash": "sha256-5lRtAsJjjc9BkTbpuhjgMgDpXKYkYcGDydh+xJzDVyU=", "owner": "natsukagami", "repo": "youmubot", - "rev": "803d718c7ad34d3780ae6c2911ca0682b2417cc4", + "rev": "a4fab5438bebd9c399f628151958789c7f2454a6", "type": "github" }, "original": { From 23e731a2ac5c20bb66f5a5fee349a17b67da50ed Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Mon, 18 Nov 2024 15:32:38 +0100 Subject: [PATCH 20/32] Update nixpkgs and home-manager --- flake.lock | 12 ++++++------ home/common.nix | 5 +++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/flake.lock b/flake.lock index e452a63..d9e1d78 100644 --- a/flake.lock +++ b/flake.lock @@ -742,11 +742,11 @@ ] }, "locked": { - "lastModified": 1728337164, - "narHash": "sha256-VdRTjJFyq4Q9U7Z/UoC2Q5jK8vSo6E86lHc2OanXtvc=", + "lastModified": 1731887066, + "narHash": "sha256-uw7K/RsYioJicV79Nl39yjtfhdfTDU2aRxnBgvFhkZ8=", "owner": "nix-community", "repo": "home-manager", - "rev": "038630363e7de57c36c417fd2f5d7c14773403e4", + "rev": "f3a2ff69586f3a54b461526e5702b1a2f81e740a", "type": "github" }, "original": { @@ -1022,11 +1022,11 @@ }, "nixpkgs-unstable": { "locked": { - "lastModified": 1730272153, - "narHash": "sha256-B5WRZYsRlJgwVHIV6DvidFN7VX7Fg9uuwkRW9Ha8z+w=", + "lastModified": 1731890469, + "narHash": "sha256-D1FNZ70NmQEwNxpSSdTXCSklBH1z2isPR84J6DQrJGs=", "owner": "nixos", "repo": "nixpkgs", - "rev": "2d2a9ddbe3f2c00747398f3dc9b05f7f2ebb0f53", + "rev": "5083ec887760adfe12af64830a66807423a859a7", "type": "github" }, "original": { diff --git a/home/common.nix b/home/common.nix index a78b648..253c8b1 100644 --- a/home/common.nix +++ b/home/common.nix @@ -14,8 +14,9 @@ # Let Home Manager install and manage itself. programs.home-manager.enable = true; - # Enable the manual so we don't have to load it - manual.html.enable = true; + # Temporarily disable the manuals + manual.html.enable = false; + # manual.manpage.enable = false; # Packages that are not in programs section home.packages = with pkgs; [ From 599434e43d4d92e1df6c7f1504b454e44f753400 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Sat, 28 Sep 2024 16:18:16 +0200 Subject: [PATCH 21/32] kakoune: set up package with plugins --- packages/common/default.nix | 1 + .../common/nki-kakoune/autoload/latex.kak | 133 +++++++++++ .../common/nki-kakoune/autoload/markdown.kak | 29 +++ packages/common/nki-kakoune/default.nix | 3 + packages/common/nki-kakoune/plugins.nix | 209 ++++++++++++++++++ 5 files changed, 375 insertions(+) create mode 100644 packages/common/nki-kakoune/autoload/latex.kak create mode 100644 packages/common/nki-kakoune/autoload/markdown.kak create mode 100644 packages/common/nki-kakoune/default.nix create mode 100644 packages/common/nki-kakoune/plugins.nix diff --git a/packages/common/default.nix b/packages/common/default.nix index be4ba2a..fadb679 100644 --- a/packages/common/default.nix +++ b/packages/common/default.nix @@ -2,4 +2,5 @@ final: prev: { epfl-cups-drivers = final.callPackage ./epfl-cups-drivers { }; ttaenc = final.callPackage ./ttaenc.nix { }; suwako-cursors = final.callPackage ./suwako-cursors { }; + nki-kakoune = final.callPackage ./nki-kakoune { }; } diff --git a/packages/common/nki-kakoune/autoload/latex.kak b/packages/common/nki-kakoune/autoload/latex.kak new file mode 100644 index 0000000..4bb9c9d --- /dev/null +++ b/packages/common/nki-kakoune/autoload/latex.kak @@ -0,0 +1,133 @@ +## Author: @natsukagami (https://github.com/natsukagami) +## +## To activate, source the file into kakrc and add: +### require-module latex-kak +## +## NOTE: This overrides , so if you don't like it, remove it. + +# Create a simple begin block, put the cursors in and remove multi-cursor on exit. +define-command -hidden create-begin-block %{ + execute-keys "i\begin{b0}\end{b0}" + execute-keys "b0" + execute-keys -with-hooks -with-maps "c" + hook -once buffer ModeChange .*:normal %{ + execute-keys -with-maps ",gl" + } +} +# Create a begin block with the given parameter as block name. +define-command -params 1 create-begin-block-with %{ + execute-keys "i\begin{b0}\end{b0}" + execute-keys "b0c%arg{1}," + execute-keys "ok" + execute-keys -with-maps "gl" +} +# Create a \param{} block and put the cursor in the middle. +define-command -params 2 -hidden create-delims %{ + execute-keys "i%arg{1}hZa%arg{2}zl" + execute-keys -with-hooks -with-maps "i" +} +define-command -params 1 create-block-with %{ + create-delims "\%arg{1}{" "}" +} + +# The font-menu +declare-user-mode latex-font +## Semantics +map -docstring "Text" global latex-font t ": create-block-with text" +map -docstring "Emphasize (emph)" global latex-font e ": create-block-with emph" +## Shape +map -docstring "Italics (textit)" global latex-font i ": create-block-with textit" +map -docstring "Upright (textup)" global latex-font u ": create-block-with textup" +# map -docstring "Slanted (textsl)" global latex-font S ": create-block-with textsl" +# map -docstring "Swash font (textsw)" global latex-font W ": create-block-with textsw" +# map -docstring "Small caps (textsc)" global latex-font C ": create-block-with textsc" +# Weight +map -docstring "Bold text (textbf)" global latex-font b ": create-block-with textbf" +# map -docstring "Medium bold (textmd)" global latex-font M ": create-block-with textmd" +# map -docstring "Normal (textnormal)" global latex-font N ": create-block-with textnormal" +## Family +# map -docstring "Serif font (textsf)" global latex-font s ": create-block-with textsf" +# map -docstring "Roman text (textrm)" global latex-font r ": create-block-with textrm" +map -docstring "Monospace (texttt)" global latex-font m ": create-block-with texttt" +## Math styles +map -docstring "Math Calligraphic (mathcal)" global latex-font ": create-block-with mathcal" +map -docstring "Math Blackboard (mathbb)" global latex-font ": create-block-with mathbb" +# map -docstring "Math Fraktur (mathfr)" global latex-font ": create-block-with mathfr" +# map -docstring "Math Roman (mathrm)" global latex-font ": create-block-with mathrm" +# map -docstring "Math Italics (mathit)" global latex-font ": create-block-with mathit" +# map -docstring "Math Bold (mathbf)" global latex-font ": create-block-with mathbf" +# map -docstring "Serif font (mathsf)" global latex-font ": create-block-with mathsf" +map -docstring "Math Monospace (mathtt)" global latex-font ": create-block-with mathtt" +map -docstring "Math Fraktur (mathfrak)" global latex-font f ": create-block-with mathfrak" + +# "Insert block" menu +declare-user-mode latex-insert-block +## Common normal text blocks +map -docstring "Unordered list" global latex-insert-block u ": create-begin-block-with itemize" +map -docstring "Ordered list" global latex-insert-block o ": create-begin-block-with enumerate" +## Common math blocks +map -docstring "Theorem" global latex-insert-block t ": create-begin-block-with theorem" +map -docstring "Definition" global latex-insert-block d ": create-begin-block-with definition" +map -docstring "Lemma" global latex-insert-block l ": create-begin-block-with lemma" +map -docstring "Example" global latex-insert-block e ": create-begin-block-with example" +map -docstring "Proof" global latex-insert-block p ": create-begin-block-with proof" +map -docstring "Remark" global latex-insert-block r ": create-begin-block-with remark" +map -docstring "Proposition" global latex-insert-block ": create-begin-block-with proposition" +map -docstring "Corollary" global latex-insert-block C ": create-begin-block-with corollary" +## Common environments +map -docstring "align*" global latex-insert-block a ": create-begin-block-with align*" +map -docstring "align" global latex-insert-block ": create-begin-block-with align" +map -docstring "equation" global latex-insert-block E ": create-begin-block-with equation" +map -docstring "equation*" global latex-insert-block ": create-begin-block-with equation*" +map -docstring "Matrix" global latex-insert-block m ": create-begin-block-with bmatrix" +map -docstring "Cases" global latex-insert-block C ": create-begin-block-with cases" +map -docstring "Table" global latex-insert-block T ": create-begin-block-with tabular" +## Custom +map -docstring "Custom" global latex-insert-block c ": create-begin-block" + +# Pairs of delimiters +declare-user-mode latex-insert-delims +map -docstring "Grouping" global latex-insert-delims g ": create-delims { }" +map -docstring "Parentheses" global latex-insert-delims p ": create-delims ( )" +map -docstring "Large Parentheses" global latex-insert-delims P ": create-delims \left( \right)" +map -docstring "Brackets" global latex-insert-delims b ": create-delims \left[ \right]" +map -docstring "Sets" global latex-insert-delims s ": create-delims \{ \}" +map -docstring "Large Sets" global latex-insert-delims S ": create-delims \left\{ \right\}" + + +hook global WinSetOption filetype=(tex|latex) %{ + ## Create delims (shortcuts) + map buffer normal ": enter-user-mode latex-insert-delimsp" + map buffer insert ": enter-user-mode latex-insert-delimsp" + map buffer normal ": enter-user-mode latex-insert-delimsg" + map buffer insert ": enter-user-mode latex-insert-delimsg" + map buffer normal "i\(\)Zhhi" + map buffer insert "\(\)Z2h" + map buffer normal "i\[\]Zhhi" + map buffer insert "\[\]Z2h" + map buffer normal ": enter-user-mode latex-insert-delims" + map buffer insert ": enter-user-mode latex-insert-delims" + + ## Quickly create begin/end blocks + map buffer normal ": create-begin-block" + map buffer insert ": create-begin-block" + + ## Font menu + map buffer normal ": enter-user-mode latex-font" + map buffer insert ": enter-user-mode latex-font" + + ## Insert menu + map buffer normal ": enter-user-mode latex-insert-block" + map buffer insert ": enter-user-mode latex-insert-block" + + ## Select math equations and environment blocks + map buffer object e -docstring "Inline Math equation \( \)" "c\\\\\\(,\\\\\\)" + map buffer object E -docstring "Display Math equation \[ \]" "c\\\\\\[,\\\\\\]" + map buffer object v -docstring "Simple environment \env{}" "c\\\\\\w+\\{,\\}" + map buffer object V -docstring "Full environment \begin{env}\end{env}" "c\\\\begin\\{\\w+\\}(?:\\{[\\w\\s]*\\})*(?:\\[[\\w\\s]*\\])*,\\\\end\\{\\w+\\}" + + ## Quickly get a new item + map buffer normal "o\item " + map buffer insert "o\item " +} + diff --git a/packages/common/nki-kakoune/autoload/markdown.kak b/packages/common/nki-kakoune/autoload/markdown.kak new file mode 100644 index 0000000..fb10581 --- /dev/null +++ b/packages/common/nki-kakoune/autoload/markdown.kak @@ -0,0 +1,29 @@ +hook global WinSetOption filetype=(markdown) %{ + map buffer normal ": enter-user-mode markdown-menu" +} + +# A menu for common markdown actions +declare-user-mode markdown-menu + +map -docstring "Toggle the checkboxes on the same line" global markdown-menu t ": markdown-toggle-checkbox" + +define-command -hidden markdown-toggle-checkbox %{ + try %{ + execute-keys -draft "xs^\s*- \[( |x)\]h: markdown-toggle-checkbox-selections" + } +} + +define-command -hidden markdown-toggle-checkbox-selections %{ + try %{ + execute-keys -draft -itersel ": markdown-toggle-checkbox-one" + } +} + +define-command -hidden markdown-toggle-checkbox-one %{ + try %{ + execute-keys -draft "sxr " + } catch %{ + execute-keys -draft "s rx" + } +} + diff --git a/packages/common/nki-kakoune/default.nix b/packages/common/nki-kakoune/default.nix new file mode 100644 index 0000000..6e181ce --- /dev/null +++ b/packages/common/nki-kakoune/default.nix @@ -0,0 +1,3 @@ +{ callPackage, kakoune, ... }: kakoune.override { + plugins = (callPackage ./plugins.nix { }).plugins; +} diff --git a/packages/common/nki-kakoune/plugins.nix b/packages/common/nki-kakoune/plugins.nix new file mode 100644 index 0000000..a16c898 --- /dev/null +++ b/packages/common/nki-kakoune/plugins.nix @@ -0,0 +1,209 @@ +{ pkgs, symlinkJoin, writeTextDir, kakouneUtils, ... }: +with { + inherit (kakouneUtils) buildKakounePluginFrom2Nix; +}; +let + toDir = name: file: writeTextDir name (builtins.readFile file); + + writeActivationScript = script: writeTextDir "on-load.kak" '' + hook global KakBegin .* %{ + ${script} + } + ''; + + writeModuleWrapper = name: script: writeTextDir "module.kak" '' + provide-module ${name} %◍ + ${script} + ◍ + ''; + + kakounePlugin = { name, src, wrapAsModule ? false, activationScript ? null, ... }@attrs: + let + module = if wrapAsModule then writeModuleWrapper name (builtins.readFile src) else src; + in + buildKakounePluginFrom2Nix { + pname = name; + version = attrs.version or "latest"; + src = if activationScript == null then module else + symlinkJoin { + name = "${name}-src"; + paths = [ + module + (writeActivationScript activationScript) + ]; + }; + }; +in +{ + plugins = builtins.map kakounePlugin + [ + # My own scripts + { + name = "latex.kak"; + src = toDir "latex.kak" ./autoload/latex.kak; + } + { + name = "markdown.kak"; + src = toDir "markdown.kak" ./autoload/markdown.kak; + } + + # Plugins + { + name = "luar"; + src = pkgs.fetchFromGitHub { + owner = "gustavo-hms"; + repo = "luar"; + rev = "2f430316f8fc4d35db6c93165e2e77dc9f3d0450"; + sha256 = "sha256-vHn/V3sfzaxaxF8OpA5jPEuPstOVwOiQrogdSGtT6X4="; + }; + activationScript = '' + # Enable luar + require-module luar + # Use luajit + set-option global luar_interpreter ${pkgs.luajit}/bin/luajit + ''; + } + { + name = "peneira"; + src = pkgs.fetchFromGitHub { + owner = "natsukagami"; + repo = "peneira"; + rev = "743b9971472853a752475e7c070ce99089c6840c"; + sha256 = "sha256-E4ndbF9YC1p0KrvSuGgwmG1Y2IGTuGKJo/AuMixhzlM="; + }; + activationScript = '' + require-module peneira + + # Change selection color + set-face global PeneiraSelected @PrimarySelection + + # Buffers list + define-command -hidden peneira-buffers %{ + peneira 'buffers: ' %{ printf '%s\n' $kak_quoted_buflist } %{ + buffer %arg{1} + } + } + + # Grep in the current location + define-command peneira-grep %{ + peneira 'line: ' "rg -n ." %{ + lua %arg{1} %{ + local file, line = arg[1]:match("([^:]+):(%d+):") + kak.edit(file, line) + } + } + } + + # A peneira menu + declare-user-mode fuzzy-match-menu + + map -docstring "Switch to buffer" global fuzzy-match-menu b ": peneira-buffers" + map -docstring "Symbols" global fuzzy-match-menu s ": peneira-symbols" + map -docstring "Lines" global fuzzy-match-menu l ": peneira-lines" + map -docstring "Lines in the current directory" global fuzzy-match-menu g ": peneira-grep" + map -docstring "Files in project" global fuzzy-match-menu f ": peneira-files" + map -docstring "Files in currently opening file's directory" global fuzzy-match-menu F ": peneira-local-files" + + # Bind menu to user mode + map -docstring "Fuzzy matching" global user f ": enter-user-mode fuzzy-match-menu" + ''; + } + { + name = "kakoune-focus"; + src = pkgs.fetchFromGitHub { + owner = "caksoylar"; + repo = "kakoune-focus"; + rev = "949c0557cd4c476822acfa026ca3c50f3d38a3c0"; + sha256 = "sha256-ZV7jlLJQyL420YG++iC9rq1SMjo3WO5hR9KVvJNUiCs="; + }; + activationScript = '' + map global user ': focus-toggle' -docstring "toggle selections focus" + ''; + } + { + name = "kakoune-inc-dec"; + src = pkgs.fetchFromGitLab { + owner = "Screwtapello"; + repo = "kakoune-inc-dec"; + rev = "7bfe9c51"; + sha256 = "0f33wqxqbfygxypf348jf1fiscac161wf2xvnh8zwdd3rq5yybl0"; + }; + } + { + name = "racket.kak"; + src = (builtins.fetchTree { + type = "git"; + url = "https://bitbucket.org/KJ_Duncan/kakoune-racket.kak.git"; + rev = "e397042009b46916ff089d79166ec0e8ca813a18"; + narHash = "sha256-IcxFmvG0jqpMCG/dT9crVRgPgMGKkic6xwrnW5z4+bc="; + }) + "/rc"; + } + # { + # name = "kakoune-discord"; + # src = (builtins.getFlake "github:natsukagami/kakoune-discord/03f95e40d6efd8fd3de7bca31653d43de2dcfc5f").packages.${pkgs.system}.kakoune-discord-rc + "/rc"; + # } + rec { + name = "kakoune-mirror"; + src = pkgs.fetchFromGitHub + { + owner = "Delapouite"; + repo = "kakoune-mirror"; + rev = "5710635f440bcca914d55ff2ec1bfcba9efe0f15"; + sha256 = "sha256-uslx4zZhvjUylrPWvTOugsKYKKpF0EEz1drc1Ckrpjk="; + } + "/mirror.kak"; + wrapAsModule = true; + activationScript = '' + require-module ${name} + + # Bind to ${name} + map global normal ': enter-user-mode -lock mirror' + ''; + } + { + name = "unicode-math"; + src = pkgs.fetchFromGitHub { + owner = "natsukagami"; + repo = "kakoune-unicode-math"; + rev = "08dff25da2b86ee0b0777091992bc7fb28c3cb1d"; + # sha256 = lib.fakeSha256; + sha256 = "sha256-j0L1ARex1i2ma8sGLYwgkfAbh0jWKh/6QGHFaxPXIKc="; + fetchSubmodules = true; + }; + activationScript = '' + require-module unicode-math + + # Bind to the menu + map global insert ': insert-unicode ' + ''; + } + { + name = "kakoune-buffers"; + src = pkgs.fetchFromGitHub { + owner = "Delapouite"; + repo = "kakoune-buffers"; + rev = "6b2081f5b7d58c72de319a5cba7bf628b6802881"; + sha256 = "sha256-jOSrzGcLJjLK1GiTSsl2jLmQMPbPxjycR0pwF5t/eV0="; + }; + activationScript = '' + # Suggested hook + + hook global WinDisplay .* info-buffers + + # Suggested mappings + + map global user b ':enter-buffers-mode' -docstring 'buffers…' + map global normal ^ ':enter-buffers-mode' -docstring 'buffers…' + map global user B ':enter-user-mode -lock buffers' -docstring 'buffers (lock)…' + + # Suggested aliases + + alias global bd delete-buffer + alias global bf buffer-first + alias global bl buffer-last + alias global bo buffer-only + alias global bo! buffer-only-force + ''; + } + ]; +} + From d160c48ba20cdbb5509095e865421664d11bf2b7 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Sat, 28 Sep 2024 16:34:57 +0200 Subject: [PATCH 22/32] kakoune: add back kaktex --- packages/common/nki-kakoune/default.nix | 4 +- .../common/nki-kakoune/kaktex/default.nix | 22 ++ .../common/nki-kakoune/kaktex/kaktex.fish | 26 ++ packages/common/nki-kakoune/plugins.nix | 312 +++++++++--------- 4 files changed, 205 insertions(+), 159 deletions(-) create mode 100644 packages/common/nki-kakoune/kaktex/default.nix create mode 100755 packages/common/nki-kakoune/kaktex/kaktex.fish diff --git a/packages/common/nki-kakoune/default.nix b/packages/common/nki-kakoune/default.nix index 6e181ce..53622ec 100644 --- a/packages/common/nki-kakoune/default.nix +++ b/packages/common/nki-kakoune/default.nix @@ -1,3 +1,5 @@ { callPackage, kakoune, ... }: kakoune.override { - plugins = (callPackage ./plugins.nix { }).plugins; + plugins = (callPackage ./plugins.nix { }) ++ [ + ./kaktex + ]; } diff --git a/packages/common/nki-kakoune/kaktex/default.nix b/packages/common/nki-kakoune/kaktex/default.nix new file mode 100644 index 0000000..a8005d5 --- /dev/null +++ b/packages/common/nki-kakoune/kaktex/default.nix @@ -0,0 +1,22 @@ +{ fish, lib, writeScript, writeTextDir, kakouneUtils, ... }: +let + kaktex-script = writeScript "kaktex" '' + #!/usr/bin/env ${lib.getExe fish} + + ${builtins.readFile ./kaktex.fish} + ''; + kaktex = writeTextDir "kaktex.kak" '' + hook global WinSetOption filetype=(tex|latex) %{ + hook window WinDisplay '.*' %{ + eval %sh{ + ${kaktex-script} set $kak_client $kak_session + } + } + } + ''; +in +kakouneUtils.buildKakounePluginFrom2Nix { + pname = "kaktex"; + version = "latest"; + src = kaktex; +} diff --git a/packages/common/nki-kakoune/kaktex/kaktex.fish b/packages/common/nki-kakoune/kaktex/kaktex.fish new file mode 100755 index 0000000..bb6690b --- /dev/null +++ b/packages/common/nki-kakoune/kaktex/kaktex.fish @@ -0,0 +1,26 @@ +function usage + echo "Usage: " + echo " kaktex set [client] [session]" + echo " kaktex jump [file] [line] [column]" + exit 1 +end + +if test (count $argv) -lt 3 + usage +end + +switch $argv[1] + case "set" + set -U _kaktex_client $argv[2] + set -U _kaktex_session $argv[3] + case "jump" + echo " + evaluate-commands -client $_kaktex_client %{ + evaluate-commands -try-client $_kaktex_client %{ + edit -existing -- $argv[2] $(math $argv[3] + 1) $(math $argv[4] + 1) + } + } + " | kak -p $_kaktex_session + case '*' + usage +end diff --git a/packages/common/nki-kakoune/plugins.nix b/packages/common/nki-kakoune/plugins.nix index a16c898..b524a14 100644 --- a/packages/common/nki-kakoune/plugins.nix +++ b/packages/common/nki-kakoune/plugins.nix @@ -34,176 +34,172 @@ let }; }; in -{ - plugins = builtins.map kakounePlugin - [ - # My own scripts - { - name = "latex.kak"; - src = toDir "latex.kak" ./autoload/latex.kak; - } - { - name = "markdown.kak"; - src = toDir "markdown.kak" ./autoload/markdown.kak; - } +builtins.map kakounePlugin [ + # My own scripts + { + name = "latex.kak"; + src = toDir "latex.kak" ./autoload/latex.kak; + } + { + name = "markdown.kak"; + src = toDir "markdown.kak" ./autoload/markdown.kak; + } - # Plugins - { - name = "luar"; - src = pkgs.fetchFromGitHub { - owner = "gustavo-hms"; - repo = "luar"; - rev = "2f430316f8fc4d35db6c93165e2e77dc9f3d0450"; - sha256 = "sha256-vHn/V3sfzaxaxF8OpA5jPEuPstOVwOiQrogdSGtT6X4="; - }; - activationScript = '' - # Enable luar - require-module luar - # Use luajit - set-option global luar_interpreter ${pkgs.luajit}/bin/luajit - ''; - } - { - name = "peneira"; - src = pkgs.fetchFromGitHub { - owner = "natsukagami"; - repo = "peneira"; - rev = "743b9971472853a752475e7c070ce99089c6840c"; - sha256 = "sha256-E4ndbF9YC1p0KrvSuGgwmG1Y2IGTuGKJo/AuMixhzlM="; - }; - activationScript = '' - require-module peneira + # Plugins + { + name = "luar"; + src = pkgs.fetchFromGitHub { + owner = "gustavo-hms"; + repo = "luar"; + rev = "2f430316f8fc4d35db6c93165e2e77dc9f3d0450"; + sha256 = "sha256-vHn/V3sfzaxaxF8OpA5jPEuPstOVwOiQrogdSGtT6X4="; + }; + activationScript = '' + # Enable luar + require-module luar + # Use luajit + set-option global luar_interpreter ${pkgs.luajit}/bin/luajit + ''; + } + { + name = "peneira"; + src = pkgs.fetchFromGitHub { + owner = "natsukagami"; + repo = "peneira"; + rev = "743b9971472853a752475e7c070ce99089c6840c"; + sha256 = "sha256-E4ndbF9YC1p0KrvSuGgwmG1Y2IGTuGKJo/AuMixhzlM="; + }; + activationScript = '' + require-module peneira - # Change selection color - set-face global PeneiraSelected @PrimarySelection + # Change selection color + set-face global PeneiraSelected @PrimarySelection - # Buffers list - define-command -hidden peneira-buffers %{ - peneira 'buffers: ' %{ printf '%s\n' $kak_quoted_buflist } %{ - buffer %arg{1} - } + # Buffers list + define-command -hidden peneira-buffers %{ + peneira 'buffers: ' %{ printf '%s\n' $kak_quoted_buflist } %{ + buffer %arg{1} } + } - # Grep in the current location - define-command peneira-grep %{ - peneira 'line: ' "rg -n ." %{ - lua %arg{1} %{ - local file, line = arg[1]:match("([^:]+):(%d+):") - kak.edit(file, line) - } - } + # Grep in the current location + define-command peneira-grep %{ + peneira 'line: ' "rg -n ." %{ + lua %arg{1} %{ + local file, line = arg[1]:match("([^:]+):(%d+):") + kak.edit(file, line) } - - # A peneira menu - declare-user-mode fuzzy-match-menu - - map -docstring "Switch to buffer" global fuzzy-match-menu b ": peneira-buffers" - map -docstring "Symbols" global fuzzy-match-menu s ": peneira-symbols" - map -docstring "Lines" global fuzzy-match-menu l ": peneira-lines" - map -docstring "Lines in the current directory" global fuzzy-match-menu g ": peneira-grep" - map -docstring "Files in project" global fuzzy-match-menu f ": peneira-files" - map -docstring "Files in currently opening file's directory" global fuzzy-match-menu F ": peneira-local-files" - - # Bind menu to user mode - map -docstring "Fuzzy matching" global user f ": enter-user-mode fuzzy-match-menu" - ''; + } } + + # A peneira menu + declare-user-mode fuzzy-match-menu + + map -docstring "Switch to buffer" global fuzzy-match-menu b ": peneira-buffers" + map -docstring "Symbols" global fuzzy-match-menu s ": peneira-symbols" + map -docstring "Lines" global fuzzy-match-menu l ": peneira-lines" + map -docstring "Lines in the current directory" global fuzzy-match-menu g ": peneira-grep" + map -docstring "Files in project" global fuzzy-match-menu f ": peneira-files" + map -docstring "Files in currently opening file's directory" global fuzzy-match-menu F ": peneira-local-files" + + # Bind menu to user mode + map -docstring "Fuzzy matching" global user f ": enter-user-mode fuzzy-match-menu" + ''; + } + { + name = "kakoune-focus"; + src = pkgs.fetchFromGitHub { + owner = "caksoylar"; + repo = "kakoune-focus"; + rev = "949c0557cd4c476822acfa026ca3c50f3d38a3c0"; + sha256 = "sha256-ZV7jlLJQyL420YG++iC9rq1SMjo3WO5hR9KVvJNUiCs="; + }; + activationScript = '' + map global user ': focus-toggle' -docstring "toggle selections focus" + ''; + } + { + name = "kakoune-inc-dec"; + src = pkgs.fetchFromGitLab { + owner = "Screwtapello"; + repo = "kakoune-inc-dec"; + rev = "7bfe9c51"; + sha256 = "0f33wqxqbfygxypf348jf1fiscac161wf2xvnh8zwdd3rq5yybl0"; + }; + } + { + name = "racket.kak"; + src = (builtins.fetchTree { + type = "git"; + url = "https://bitbucket.org/KJ_Duncan/kakoune-racket.kak.git"; + rev = "e397042009b46916ff089d79166ec0e8ca813a18"; + narHash = "sha256-IcxFmvG0jqpMCG/dT9crVRgPgMGKkic6xwrnW5z4+bc="; + }) + "/rc"; + } + # { + # name = "kakoune-discord"; + # src = (builtins.getFlake "github:natsukagami/kakoune-discord/03f95e40d6efd8fd3de7bca31653d43de2dcfc5f").packages.${pkgs.system}.kakoune-discord-rc + "/rc"; + # } + rec { + name = "kakoune-mirror"; + src = pkgs.fetchFromGitHub { - name = "kakoune-focus"; - src = pkgs.fetchFromGitHub { - owner = "caksoylar"; - repo = "kakoune-focus"; - rev = "949c0557cd4c476822acfa026ca3c50f3d38a3c0"; - sha256 = "sha256-ZV7jlLJQyL420YG++iC9rq1SMjo3WO5hR9KVvJNUiCs="; - }; - activationScript = '' - map global user ': focus-toggle' -docstring "toggle selections focus" - ''; - } - { - name = "kakoune-inc-dec"; - src = pkgs.fetchFromGitLab { - owner = "Screwtapello"; - repo = "kakoune-inc-dec"; - rev = "7bfe9c51"; - sha256 = "0f33wqxqbfygxypf348jf1fiscac161wf2xvnh8zwdd3rq5yybl0"; - }; - } - { - name = "racket.kak"; - src = (builtins.fetchTree { - type = "git"; - url = "https://bitbucket.org/KJ_Duncan/kakoune-racket.kak.git"; - rev = "e397042009b46916ff089d79166ec0e8ca813a18"; - narHash = "sha256-IcxFmvG0jqpMCG/dT9crVRgPgMGKkic6xwrnW5z4+bc="; - }) + "/rc"; - } - # { - # name = "kakoune-discord"; - # src = (builtins.getFlake "github:natsukagami/kakoune-discord/03f95e40d6efd8fd3de7bca31653d43de2dcfc5f").packages.${pkgs.system}.kakoune-discord-rc + "/rc"; - # } - rec { - name = "kakoune-mirror"; - src = pkgs.fetchFromGitHub - { - owner = "Delapouite"; - repo = "kakoune-mirror"; - rev = "5710635f440bcca914d55ff2ec1bfcba9efe0f15"; - sha256 = "sha256-uslx4zZhvjUylrPWvTOugsKYKKpF0EEz1drc1Ckrpjk="; - } + "/mirror.kak"; - wrapAsModule = true; - activationScript = '' - require-module ${name} + owner = "Delapouite"; + repo = "kakoune-mirror"; + rev = "5710635f440bcca914d55ff2ec1bfcba9efe0f15"; + sha256 = "sha256-uslx4zZhvjUylrPWvTOugsKYKKpF0EEz1drc1Ckrpjk="; + } + "/mirror.kak"; + wrapAsModule = true; + activationScript = '' + require-module ${name} - # Bind to ${name} - map global normal ': enter-user-mode -lock mirror' - ''; - } - { - name = "unicode-math"; - src = pkgs.fetchFromGitHub { - owner = "natsukagami"; - repo = "kakoune-unicode-math"; - rev = "08dff25da2b86ee0b0777091992bc7fb28c3cb1d"; - # sha256 = lib.fakeSha256; - sha256 = "sha256-j0L1ARex1i2ma8sGLYwgkfAbh0jWKh/6QGHFaxPXIKc="; - fetchSubmodules = true; - }; - activationScript = '' - require-module unicode-math + # Bind to ${name} + map global normal ': enter-user-mode -lock mirror' + ''; + } + { + name = "unicode-math"; + src = pkgs.fetchFromGitHub { + owner = "natsukagami"; + repo = "kakoune-unicode-math"; + rev = "08dff25da2b86ee0b0777091992bc7fb28c3cb1d"; + # sha256 = lib.fakeSha256; + sha256 = "sha256-j0L1ARex1i2ma8sGLYwgkfAbh0jWKh/6QGHFaxPXIKc="; + fetchSubmodules = true; + }; + activationScript = '' + require-module unicode-math - # Bind to the menu - map global insert ': insert-unicode ' - ''; - } - { - name = "kakoune-buffers"; - src = pkgs.fetchFromGitHub { - owner = "Delapouite"; - repo = "kakoune-buffers"; - rev = "6b2081f5b7d58c72de319a5cba7bf628b6802881"; - sha256 = "sha256-jOSrzGcLJjLK1GiTSsl2jLmQMPbPxjycR0pwF5t/eV0="; - }; - activationScript = '' - # Suggested hook + # Bind to the menu + map global insert ': insert-unicode ' + ''; + } + { + name = "kakoune-buffers"; + src = pkgs.fetchFromGitHub { + owner = "Delapouite"; + repo = "kakoune-buffers"; + rev = "6b2081f5b7d58c72de319a5cba7bf628b6802881"; + sha256 = "sha256-jOSrzGcLJjLK1GiTSsl2jLmQMPbPxjycR0pwF5t/eV0="; + }; + activationScript = '' + # Suggested hook - hook global WinDisplay .* info-buffers + hook global WinDisplay .* info-buffers - # Suggested mappings + # Suggested mappings - map global user b ':enter-buffers-mode' -docstring 'buffers…' - map global normal ^ ':enter-buffers-mode' -docstring 'buffers…' - map global user B ':enter-user-mode -lock buffers' -docstring 'buffers (lock)…' + map global user b ':enter-buffers-mode' -docstring 'buffers…' + map global normal ^ ':enter-buffers-mode' -docstring 'buffers…' + map global user B ':enter-user-mode -lock buffers' -docstring 'buffers (lock)…' - # Suggested aliases - - alias global bd delete-buffer - alias global bf buffer-first - alias global bl buffer-last - alias global bo buffer-only - alias global bo! buffer-only-force - ''; - } - ]; -} + # Suggested aliases + alias global bd delete-buffer + alias global bf buffer-first + alias global bl buffer-last + alias global bo buffer-only + alias global bo! buffer-only-force + ''; + } +] From 8e886fd13bf50bd01f8b8f685bf3ea6cd71bbfab Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Sat, 28 Sep 2024 16:54:39 +0200 Subject: [PATCH 23/32] kakoune: add back themes --- packages/common/nki-kakoune/default.nix | 4 +- packages/common/nki-kakoune/themes.nix | 9 +++ .../nki-kakoune/themes/catppuccin-latte.kak | 79 +++++++++++++++++++ 3 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 packages/common/nki-kakoune/themes.nix create mode 100644 packages/common/nki-kakoune/themes/catppuccin-latte.kak diff --git a/packages/common/nki-kakoune/default.nix b/packages/common/nki-kakoune/default.nix index 53622ec..2c6a83d 100644 --- a/packages/common/nki-kakoune/default.nix +++ b/packages/common/nki-kakoune/default.nix @@ -1,5 +1,7 @@ { callPackage, kakoune, ... }: kakoune.override { - plugins = (callPackage ./plugins.nix { }) ++ [ + plugins = callPackage ./plugins.nix { } + ++ callPackage ./themes.nix { } + ++ [ ./kaktex ]; } diff --git a/packages/common/nki-kakoune/themes.nix b/packages/common/nki-kakoune/themes.nix new file mode 100644 index 0000000..5be9a6d --- /dev/null +++ b/packages/common/nki-kakoune/themes.nix @@ -0,0 +1,9 @@ +{ writeScriptDir, ... }: +let + themes = [ + { name = "catppuccin-latte"; src = ./themes/catppucin-latte.kak; } + ]; + + themeToColorscheme = name: src: writeScriptDir "share/kak/colors/${name}.kak" (builtins.readFile src); +in +builtins.map themeToColorscheme themes diff --git a/packages/common/nki-kakoune/themes/catppuccin-latte.kak b/packages/common/nki-kakoune/themes/catppuccin-latte.kak new file mode 100644 index 0000000..bd40ead --- /dev/null +++ b/packages/common/nki-kakoune/themes/catppuccin-latte.kak @@ -0,0 +1,79 @@ +# Catppuccin theme for Kakoune + +declare-option str rosewater "rgb:dc8a78" +declare-option str flamingo "rgb:dd7878" +declare-option str pink "rgb:ea76cb" +declare-option str mauve "rgb:8839ef" +declare-option str red "rgb:d20f39" +declare-option str maroon "rgb:e64553" +declare-option str peach "rgb:fe640b" +declare-option str yellow "rgb:df8e1d" +declare-option str green "rgb:40a02b" +declare-option str teal "rgb:179299" +declare-option str sky "rgb:04a5e5" +declare-option str sapphire "rgb:209fb5" +declare-option str blue "rgb:1e66f5" +declare-option str lavender "rgb:7287fd" +declare-option str text "rgb:4c4f69" +declare-option str subtext1 "rgb:5c5f77" +declare-option str subtext0 "rgb:6c6f85" +declare-option str overlay2 "rgb:7c7f93" +declare-option str overlay1 "rgb:8c8fa1" +declare-option str overlay0 "rgb:9ca0b0" +declare-option str surface2 "rgb:acb0be" +declare-option str surface1 "rgb:bcc0cc" +declare-option str surface0 "rgb:ccd0da" +declare-option str base "rgb:eff1f5" +declare-option str mantle "rgb:e6e9ef" +declare-option str crust "rgb:dce0e8" + + +set-face global title "%opt{text}+b" +set-face global header "%opt{subtext0}+b" +set-face global bold "%opt{maroon}+b" +set-face global italic "%opt{maroon}+i" +set-face global mono "%opt{green}" +set-face global block "%opt{sapphire}" +set-face global link "%opt{blue}" +set-face global bullet "%opt{peach}" +set-face global list "%opt{peach}" + +set-face global Default "%opt{text},%opt{base}" +set-face global PrimarySelection "%opt{text},%opt{surface2}" +set-face global SecondarySelection "%opt{text},%opt{surface2}" +set-face global PrimaryCursor "%opt{crust},%opt{rosewater}" +set-face global SecondaryCursor "%opt{text},%opt{overlay0}" +set-face global PrimaryCursorEol "%opt{surface2},%opt{lavender}" +set-face global SecondaryCursorEol "%opt{surface2},%opt{overlay1}" +set-face global LineNumbers "%opt{overlay1},%opt{base}" +set-face global LineNumberCursor "%opt{rosewater},%opt{surface2}+b" +set-face global LineNumbersWrapped "%opt{rosewater},%opt{surface2}+i" +set-face global MenuForeground "%opt{text},%opt{surface1}+b" +set-face global MenuBackground "%opt{text},%opt{surface0}" +set-face global MenuInfo "%opt{crust},%opt{teal}" +set-face global Information "%opt{crust},%opt{teal}" +set-face global Error "%opt{crust},%opt{red}" +set-face global StatusLine "%opt{text},%opt{mantle}" +set-face global StatusLineMode "%opt{crust},%opt{yellow}" +set-face global StatusLineInfo "%opt{crust},%opt{teal}" +set-face global StatusLineValue "%opt{crust},%opt{yellow}" +set-face global StatusCursor "%opt{crust},%opt{rosewater}" +set-face global Prompt "%opt{teal},%opt{base}+b" +set-face global MatchingChar "%opt{maroon},%opt{base}" +set-face global Whitespace "%opt{overlay1},%opt{base}+f" +set-face global WrapMarker "Whitespace" +set-face global BufferPadding "%opt{base},%opt{base}" + +set-face global value "%opt{peach}" +set-face global type "%opt{blue}" +set-face global variable "%opt{text}" +set-face global module "%opt{maroon}" +set-face global function "%opt{blue}" +set-face global string "%opt{green}" +set-face global keyword "%opt{mauve}" +set-face global operator "%opt{sky}" +set-face global attribute "%opt{green}" +set-face global comment "%opt{overlay0}" +set-face global documentation "comment" +set-face global meta "%opt{yellow}" +set-face global builtin "%opt{red}" From 8a19a3d900db4ad1148e661aaff78e56e8c4bcca Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Mon, 7 Oct 2024 14:30:47 +0200 Subject: [PATCH 24/32] Add lsp and rc --- home/common.nix | 1 + overlay.nix | 2 + packages/common/nki-kakoune/default.nix | 22 +- packages/common/nki-kakoune/kakrc | 191 ++++++++++++ packages/common/nki-kakoune/lsp.nix | 307 ++++++++++++++++++++ packages/common/nki-kakoune/rc.nix | 18 ++ packages/common/nki-kakoune/source-pwd.fish | 14 + packages/common/nki-kakoune/themes.nix | 6 +- packages/common/nki-kakoune/utils.nix | 5 + 9 files changed, 560 insertions(+), 6 deletions(-) create mode 100644 packages/common/nki-kakoune/kakrc create mode 100644 packages/common/nki-kakoune/lsp.nix create mode 100644 packages/common/nki-kakoune/rc.nix create mode 100755 packages/common/nki-kakoune/source-pwd.fish create mode 100644 packages/common/nki-kakoune/utils.nix diff --git a/home/common.nix b/home/common.nix index 253c8b1..feeab1c 100644 --- a/home/common.nix +++ b/home/common.nix @@ -41,6 +41,7 @@ unzip zstd atool + nki-kakoune ]; home.sessionVariables = { diff --git a/overlay.nix b/overlay.nix index 88159df..60fa42d 100644 --- a/overlay.nix +++ b/overlay.nix @@ -113,6 +113,8 @@ let buildInputs = (with final; lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [ Security SystemConfiguration CoreServices ]) ) ++ (with final; [ libiconv ]); + + meta.mainProgram = "kak-lsp"; }; zen-browser-bin = final.callPackage ./packages/x86_64-linux/zen-browser-bin.nix { diff --git a/packages/common/nki-kakoune/default.nix b/packages/common/nki-kakoune/default.nix index 2c6a83d..bb65355 100644 --- a/packages/common/nki-kakoune/default.nix +++ b/packages/common/nki-kakoune/default.nix @@ -1,7 +1,23 @@ -{ callPackage, kakoune, ... }: kakoune.override { +{ callPackage, kakoune, kakoune-unwrapped, ... }: +let + lsp = callPackage ./lsp.nix { }; +in +(kakoune.override { plugins = callPackage ./plugins.nix { } ++ callPackage ./themes.nix { } ++ [ - ./kaktex + (callPackage ./kaktex { }) + (callPackage ./rc.nix { }) + lsp.plugin ]; -} +}).overrideAttrs (attrs: { + buildCommand = '' + ${attrs.buildCommand or ""} + # location of kak binary is used to find ../share/kak/autoload, + # unless explicitly overriden with KAKOUNE_RUNTIME + rm "$out/bin/kak" + makeWrapper "${kakoune-unwrapped}/bin/kak" "$out/bin/kak" \ + --set KAKOUNE_RUNTIME "$out/share/kak" \ + --suffix PATH ":" "${lsp.extraPaths}" + ''; +}) diff --git a/packages/common/nki-kakoune/kakrc b/packages/common/nki-kakoune/kakrc new file mode 100644 index 0000000..aafa044 --- /dev/null +++ b/packages/common/nki-kakoune/kakrc @@ -0,0 +1,191 @@ +# Enable kak-tree-sitter +eval %sh{test -z "$WE_STARTED_KAK" && kak-tree-sitter --kakoune -d --server --init $kak_session} +map global normal ": enter-user-mode tree-sitter" +# ## Set some color overrides +# set global kts_yellow "rgb:e2b75e" +# set global kts_teal "rgb:008080" +# set global kts_mauve "rgb:c264ff" +# set global kts_sky "rgb:6aa622" +# Color scheme +colorscheme catppuccin-latte +set global base "default" + +# Set indentation guides +add-highlighter global/indent-guides show-whitespaces -tab " " -spc " " -lf " " -nbsp " " +set-face global Whitespace default,default +set-face global WhitespaceIndent +d@comment + +# Assistant +set global ui_options terminal_assistant=cat + +# Enable line numbers +hook global WinCreate .* %{ + addhl window/number-lines number-lines +} + +set global grepcmd "rg --line-number --no-column --no-heading --color=never " + +# Kitty-specific options +hook -group windowing global KakBegin .* %{ + set global kitty_window_type os-window +} + +# Comment line and block +map global normal <#> ': comment-line' +map global normal ': comment-block' + +# Go to grep-jump +map global goto f -docstring "current grep-jump match" ': grep-jump' + +# System clipboard interactions +hook global RegisterModified '"' %{ nop %sh{ + printf "%s" "$kak_main_reg_dquote" | pbcopy >/dev/null 2>/dev/null & +}} +map global user P -docstring "Paste before cursor from clipboard" '! pbpaste -n | cat' +map global user p -docstring "Paste after cursor from clipboard" ' pbpaste -n | cat' +map global user R -docstring "Replace selection with text from clipboard" '! pbpaste -n | cat' +define-command -params 0 -docstring "Copy line down" copyline %{ + execute-keys -draft 'xy'%val{count}'P' +} +map global normal <+> -docstring "Copy line down" ': copyline' +define-command -params 0 -docstring "Delete current pair of brackets" delete-current-brackets %{ + execute-keys 'm' + execute-keys -draft 'd' + execute-keys 'H' +} +map global normal D ": delete-current-brackets" + +# Disable write-to +# unalias global w +# define-command -params 0 -docstring "Writes the current file" w "write" + +# Tab sizes +hook global InsertChar \t %{ exec -draft -itersel h@ } +set global tabstop 2 +set global indentwidth 2 + +# Language-specific tabstop with override +hook global WinSetOption filetype=(rust) %{ + set window tabstop 4 + set window indentwidth 4 +} + +# Ctrl + a in insert mode = esc +map global insert '' + +# Tab completion +hook global InsertCompletionShow .* %{ + try %{ + # this command temporarily removes cursors preceded by whitespace; + # if there are no cursors left, it raises an error, does not + # continue to execute the mapping commands, and the error is eaten + # by the `try` command so no warning appears. + execute-keys -draft 'h\h' + map window insert + map window insert + } +} +hook global InsertCompletionHide .* %{ + unmap window insert + unmap window insert +} + +# in Insert mode moves to end of line. +map global insert 'A' + +hook global WinSetOption filetype=(fsharp) %{ + set-option window comment_line "//" + # Set up formatting + # set-option window formatcmd "~/.dotnet/tools/fantomas --stdin --stdout" + # hook window -group fsharp-format BufWritePre .* %{ format } +} + +hook global WinSetOption filetype=(ocaml) %{ + unset-option buffer comment_line + set-option buffer comment_block_begin "(*" + set-option buffer comment_block_end "*)" +} + +hook global WinSetOption filetype=(haskell) %{ + set-option buffer makecmd "cabal build" +} + +hook global WinSetOption filetype=(rust) %{ + set-option buffer makecmd "cargo check" +} + +hook global WinSetOption filetype=(scala) %{ + # Format the document if possible + hook -group scala-fmt window BufWritePre .* %{ lsp-formatting-sync } +} + +hook global WinSetOption filetype=(typst) %{ + set-option window comment_line "//" + set-option window comment_block_begin "/*" + set-option window comment_block_end "*/" + + # borrow markdown's hooks + require-module markdown + + hook window ModeChange pop:insert:.* -group markdown-trim-indent markdown-trim-indent + hook window InsertChar \n -group markdown-insert markdown-insert-on-new-line + hook window InsertChar \n -group markdown-indent markdown-indent-on-new-line + hook -once -always window WinSetOption filetype=.* %{ remove-hooks window markdown-.+ } +} + +define-command -params 0 -docstring "Set up build" scala-build-connect %{ + lsp-execute-command 'build-connect' '"[]"' +} + +define-command -params 0 -docstring "Import build" scala-build-import %{ + lsp-execute-command 'build-import' '"[]"' +} + +def -hidden insert-c-n %{ + try %{ + lsp-snippets-select-next-placeholders + exec 'd' + } catch %{ + exec -with-hooks '' + } +} +map global insert ": insert-c-n" + +# Use C++ for .h headers +hook global BufCreate .*[.](h) %{ + set-option buffer filetype cpp +} + +hook global BufCreate .*[.]kakrc %{ + set-option buffer filetype kak +} + +hook global BufCreate .*[.]md %{ + add-highlighter buffer/ wrap +} + +hook global BufCreate .*[.](sc|sbt) %{ + set-option buffer filetype scala +} + +hook global BufCreate .*[.]typ %{ + set-option buffer filetype typst + add-highlighter buffer/ wrap +} + +hook global BufCreate .*[.]templ %{ + set-option buffer filetype templ + set-option buffer comment_line "//" +} + +hook global BufCreate .*[.]hylo %{ + set-option buffer filetype hylo + set-option buffer comment_line "//" +} + +hook global BufOpenFile .* %{ + modeline-parse +} + +map global normal ':inc-dec-modify-numbers + %val{count}' +map global normal ':inc-dec-modify-numbers - %val{count}' diff --git a/packages/common/nki-kakoune/lsp.nix b/packages/common/nki-kakoune/lsp.nix new file mode 100644 index 0000000..3712d6f --- /dev/null +++ b/packages/common/nki-kakoune/lsp.nix @@ -0,0 +1,307 @@ +{ lib +, writeTextDir +, formats +, kak-lsp +, # LSP packages + ccls +, gopls +, nil +, nixpkgs-fmt +, python311Packages +, ltex-ls +, nodePackages +, tailwindcss-language-server +, fsautocomplete +, metals +, texlab +, marksman +, rust-analyzer +, ... +}: +let + # Configuration for kak-lsp + config = { + languageIDs = { + c = "c_cpp"; + cpp = "c_cpp"; + javascript = "javascriptreact"; + typescript = "typescriptreact"; + protobuf = "proto"; + sh = "shellscript"; + }; + + languageServers = + let + vscodeServerOf = name: { + name = "vscode-${name}-language-server"; + value = { + args = [ "--stdio" ]; + command = "vscode-${name}-language-server"; + filetypes = [ name "templ" ]; + roots = [ "package.json" ".git" ]; + }; + package = nodePackages.vscode-langservers-extracted; + }; + in + { + ccls = { + args = [ "-v=2" "-log-file=/tmp/ccls.log" ]; + package = ccls; + command = "ccls"; + filetypes = [ "c" "cpp" ]; + roots = [ "compile_commands.json" ".cquery" ".git" ]; + }; + gopls = { + command = "gopls"; + package = gopls; + filetypes = [ "go" ]; + offset_encoding = "utf-8"; + roots = [ "Gopkg.toml" "go.mod" ".git" ".hg" ]; + settings = { gopls = { hoverKind = "SynopsisDocumentation"; semanticTokens = true; }; }; + settings_section = "gopls"; + }; + haskell-language-server = { + args = [ "--lsp" ]; + command = "haskell-language-server-wrapper"; + filetypes = [ "haskell" ]; + roots = [ "Setup.hs" "stack.yaml" "*.cabal" "package.yaml" ]; + settings_section = "haskell"; + }; + nil = { + command = "nil"; + package = nil; + filetypes = [ "nix" ]; + roots = [ "flake.nix" "shell.nix" ".git" ]; + settings.nil = { + formatting.command = [ "${lib.getExe nixpkgs-fmt}" ]; + }; + }; + pylsp = { + command = "pylsp"; + package = python311Packages.python-lsp-server; + filetypes = [ "python" ]; + offset_encoding = "utf-8"; + roots = [ "requirements.txt" "setup.py" ".git" ".hg" ]; + }; + # Spellchecking server + ltex-ls = { + command = "ltex-ls"; + args = [ "--log-file=/tmp" ]; + filetypes = [ "latex" "typst" ]; + roots = [ "main.tex" "main.typ" ".git" ]; + package = ltex-ls; + }; + tailwind = { + command = "tailwindcss-language-server"; + args = [ "--stdio" ]; + filetypes = [ "html" "css" "javascript" "typescript" "templ" ]; + roots = [ "tailwind.config.{js,cjs,mjs,ts}" "package.json" ".git" ]; + settings_section = "tailwindCSS"; + settings.tailwindCSS = { + validate = "warning"; + userLanguages.templ = "html"; + }; + package = tailwindcss-language-server; + }; + elixir-ls = { + args = [ ]; + command = "elixir-ls"; + filetypes = [ "elixir" ]; + roots = [ "mix.exs" ]; + }; + typescript-language-server = { + args = [ "--stdio" ]; + command = "typescript-language-server"; + filetypes = [ "typescript" "javascript" ]; + roots = [ "package.json" ]; + package = nodePackages.typescript-language-server; + }; + fsautocomplete = { + args = [ "--adaptive-lsp-server-enabled" "--project-graph-enabled" "--source-text-factory" "RoslynSourceText" ]; + command = "fsautocomplete"; + filetypes = [ "fsharp" ]; + roots = [ "*.fsproj" ]; + settings_section = "FSharp"; + settings.FSharp = { + AutomaticWorkspaceInit = true; + }; + package = fsautocomplete; + }; + metals = { + command = "metals"; + filetypes = [ "scala" ]; + roots = [ "build.sbt" "build.sc" ]; + settings_section = "metals"; + settings.metals = { + enableSemanticHighlighting = true; + showInferredType = true; + decorationProvider = true; + inlineDecorationProvider = true; + # From kakoune-lsp's own options + icons = "unicode"; + isHttpEnabled = true; + statusBarProvider = "log-message"; + compilerOptions = { overrideDefFormat = "unicode"; }; + }; + package = metals; + }; + texlab = { + command = "texlab"; + filetypes = [ "latex" ]; + roots = [ "main.tex" "all.tex" ".git" ]; + settings_section = "texlab"; + settings.texlab = { + build.executable = "latexmk"; + build.args = [ "-pdf" "-shell-escape" "-interaction=nonstopmode" "-synctex=1" "%f" ]; + + build.forwardSearchAfter = true; + build.onSave = true; + + # forwardSearch = + # (if pkgs.stdenv.isDarwin then { + # executable = "/Applications/Skim.app/Contents/SharedSupport/displayline"; + # args = [ "-r" "-g" "%l" "%p" "%f" ]; + # } else + # { + # executable = "${pkgs.zathura}/bin/zathura"; + # args = [ "--synctex-forward" "%l:1:%f" "%p" "-x" "${./kaktex} jump %%{input} %%{line} %%{column}" ]; + # }); + }; + package = texlab; + }; + typst-lsp = { + command = "typst-lsp"; + filetypes = [ "typst" ]; + roots = [ "main.typ" ".git" ]; + settings_section = "typst-lsp"; + settings.typst-lsp = { + experimentalFormatterMode = "on"; + }; + }; + marksman = { + command = "marksman"; + filetypes = [ "markdown" ]; + roots = [ ".marksman.toml" ".git" ]; + package = marksman; + }; + rust-analyzer = { + args = [ ]; + command = "rust-analyzer"; + filetypes = [ "rust" ]; + roots = [ "Cargo.toml" ]; + package = rust-analyzer; + }; + + } // (builtins.listToAttrs (builtins.map vscodeServerOf [ "html" "css" "json" ])); + + faces = [ + ## Items + # (Rust) Macros + { face = "attribute"; token = "attribute"; } + { face = "attribute"; token = "derive"; } + { face = "macro"; token = "macro"; } # Function-like Macro + # Keyword and Fixed Tokens + { face = "keyword"; token = "keyword"; } + { face = "operator"; token = "operator"; } + # Functions and Methods + { face = "function"; token = "function"; } + { face = "method"; token = "method"; } + # Constants + { face = "string"; token = "string"; } + { face = "format_specifier"; token = "formatSpecifier"; } + # Variables + { face = "variable"; token = "variable"; modifiers = [ "readonly" ]; } + { face = "mutable_variable"; token = "variable"; } + { face = "module"; token = "namespace"; } + { face = "variable"; token = "type_parameter"; } + { face = "class"; token = "enum"; } + { face = "class"; token = "struct"; } + { face = "class"; token = "trait"; } + { face = "class"; token = "union"; } + { face = "class"; token = "class"; } + + ## Comments + { face = "documentation"; token = "comment"; modifiers = [ "documentation" ]; } + { face = "comment"; token = "comment"; } + + # Typst + { face = "header"; token = "heading"; } + { face = "ts_markup_link_url"; token = "link"; } + { face = "ts_markup_link_uri"; token = "ref"; } + { face = "ts_markup_link_label"; token = "label"; } + { face = "ts_property"; token = "pol"; } + { face = "ts_markup_list_checked"; token = "marker"; } + { face = "ts_constant_builtin_boolean"; token = "bool"; } + { face = "ts_keyword_control"; token = "delim"; } + { face = "ts_number"; token = "text"; modifiers = [ "math" ]; } + { face = "ts_markup_bold"; token = "text"; modifiers = [ "strong" ]; } + { face = "ts_markup_italic"; token = "text"; modifiers = [ "emph" ]; } + ]; + + raw = { + server = { timeout = 1800; }; + snippet_support = false; + verbosity = 255; + }; + }; + + kak-lsp-config = + let + toml = formats.toml { }; + toLspConfig = attrs: builtins.removeAttrs attrs [ "package" ]; + in + toml.generate "kak-lsp.toml" ({ + semantic_tokens.faces = config.faces; + language_server = toLspConfig config.languageServers; + language_ids = config.languageIDs; + } // config.raw); + + serverPackages = + builtins.filter (v: v != null) + (lib.mapAttrsToList (_: serv: serv.package or null) config.languageServers); +in +{ + extraPaths = lib.makeBinPath serverPackages; + plugin = writeTextDir "share/kak/autoload/kak-lsp.kak" '' + hook global KakBegin .* %{ + try %{ + eval %sh{${lib.getExe kak-lsp} --config ${kak-lsp-config} -s $kak_session} + } + + lsp-enable + map window lsp N -docstring "Display the next message request" ": lsp-show-message-request-next" + map window normal ": enter-user-mode lsp" + map window normal ": lsp-hover" + map window normal ": lsp-hover-buffer" + # lsp-auto-hover-insert-mode-enable + set window lsp_hover_anchor true + map global insert ':try lsp-snippets-select-next-placeholders catch %{ execute-keys -with-hooks tab> }' -docstring 'Select next snippet placeholder' + map global object a 'lsp-object' -docstring 'LSP any symbol' + map global object 'lsp-object' -docstring 'LSP any symbol' + map global object f 'lsp-object Function Method' -docstring 'LSP function or method' + map global object t 'lsp-object Class Interface Struct' -docstring 'LSP class interface or struct' + map global object d 'lsp-diagnostic-object --include-warnings' -docstring 'LSP errors and warnings' + map global object D 'lsp-diagnostic-object' -docstring 'LSP errors' + + hook global WinSetOption filetype=(racket|rust|python|go|javascript|typescript|c|cpp|tex|latex|haskell|nix|fsharp|templ) %{ + # Format the document if possible + hook window BufWritePre .* %{ lsp-formatting-sync } + } + + hook global WinSetOption filetype=(rust|scala|fsharp) %{ + # Enable inlay hints + lsp-inlay-hints-enable window + } + + hook global WinSetOption filetype=(rust|go|fsharp|typst|scala) %{ + hook window -group semantic-tokens BufReload .* lsp-semantic-tokens + hook window -group semantic-tokens NormalIdle .* lsp-semantic-tokens + hook window -group semantic-tokens InsertIdle .* lsp-semantic-tokens + hook -once -always window WinSetOption filetype=.* %{ + remove-hooks window semantic-tokens + } + } + } + ''; +} + diff --git a/packages/common/nki-kakoune/rc.nix b/packages/common/nki-kakoune/rc.nix new file mode 100644 index 0000000..fa4c94d --- /dev/null +++ b/packages/common/nki-kakoune/rc.nix @@ -0,0 +1,18 @@ +{ lib, fish, writeScript, writeTextDir, ... }: + +let + source-pwd = writeScript "source-pwd" '' + #!/usr/bin/env ${lib.getExe fish} + + ${builtins.readFile ./source-pwd.fish} + ''; +in +writeTextDir "share/kak/kakrc.local" '' + ${builtins.readFile ./kakrc} + + # Source any settings in the current working directory, + # recursive upwards + evaluate-commands %sh{ + ${source-pwd} + } +'' diff --git a/packages/common/nki-kakoune/source-pwd.fish b/packages/common/nki-kakoune/source-pwd.fish new file mode 100755 index 0000000..aa9aa37 --- /dev/null +++ b/packages/common/nki-kakoune/source-pwd.fish @@ -0,0 +1,14 @@ +if test (pwd) = "/home/natsukagami/.config/kak" + exit 0 +end + +while true + set kakrc (pwd)/.kakrc + if test -f $kakrc + echo source $kakrc + end + if test (pwd) = "/" + exit 0 + end + cd .. +end diff --git a/packages/common/nki-kakoune/themes.nix b/packages/common/nki-kakoune/themes.nix index 5be9a6d..5c24299 100644 --- a/packages/common/nki-kakoune/themes.nix +++ b/packages/common/nki-kakoune/themes.nix @@ -1,9 +1,9 @@ -{ writeScriptDir, ... }: +{ writeTextDir, ... }: let themes = [ - { name = "catppuccin-latte"; src = ./themes/catppucin-latte.kak; } + { name = "catppuccin-latte"; src = ./themes/catppuccin-latte.kak; } ]; - themeToColorscheme = name: src: writeScriptDir "share/kak/colors/${name}.kak" (builtins.readFile src); + themeToColorscheme = { name, src }: writeTextDir "share/kak/colors/${name}.kak" (builtins.readFile src); in builtins.map themeToColorscheme themes diff --git a/packages/common/nki-kakoune/utils.nix b/packages/common/nki-kakoune/utils.nix new file mode 100644 index 0000000..47e7c75 --- /dev/null +++ b/packages/common/nki-kakoune/utils.nix @@ -0,0 +1,5 @@ +{ lib, writeFile, ... }: { + mkFacesScript = name: faces: writeFile "${name}-faces.kak" ( + lib.concatStringsSep "\n" (builtins.attrValues (builtins.mapAttrs (name: face: "face global ${name} \"${face}\"") faces)) + ); +} From 32e5d3a3a5eb2af508dba9c52828df20773c1c3e Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Mon, 7 Oct 2024 16:31:33 +0200 Subject: [PATCH 25/32] Add tree-sitter --- packages/common/kak-tree-sitter.nix | 2 + packages/common/nki-kakoune/default.nix | 7 +- packages/common/nki-kakoune/kakrc | 3 - packages/common/nki-kakoune/rc.nix | 11 +- .../nki-kakoune/tree-sitter/default.nix | 171 ++++++++++++++++++ .../nki-kakoune/tree-sitter/grammars.nix | 119 ++++++++++++ packages/common/nki-kakoune/utils.nix | 10 +- 7 files changed, 314 insertions(+), 9 deletions(-) create mode 100644 packages/common/nki-kakoune/tree-sitter/default.nix create mode 100644 packages/common/nki-kakoune/tree-sitter/grammars.nix diff --git a/packages/common/kak-tree-sitter.nix b/packages/common/kak-tree-sitter.nix index 3e0c6a9..9819e3a 100644 --- a/packages/common/kak-tree-sitter.nix +++ b/packages/common/kak-tree-sitter.nix @@ -35,6 +35,8 @@ let self.runtime_dir.join("sources").join(url_dir) '') ]; + + meta.mainProgram = "kak-tree-sitter"; }; in kak-tree-sitter diff --git a/packages/common/nki-kakoune/default.nix b/packages/common/nki-kakoune/default.nix index bb65355..0d48b06 100644 --- a/packages/common/nki-kakoune/default.nix +++ b/packages/common/nki-kakoune/default.nix @@ -1,13 +1,18 @@ { callPackage, kakoune, kakoune-unwrapped, ... }: let lsp = callPackage ./lsp.nix { }; + tree-sitter = callPackage ./tree-sitter { }; + rc = (callPackage ./rc.nix { + prependRc = tree-sitter.rc; + }); in (kakoune.override { plugins = callPackage ./plugins.nix { } ++ callPackage ./themes.nix { } ++ [ (callPackage ./kaktex { }) - (callPackage ./rc.nix { }) + rc + tree-sitter.plugin lsp.plugin ]; }).overrideAttrs (attrs: { diff --git a/packages/common/nki-kakoune/kakrc b/packages/common/nki-kakoune/kakrc index aafa044..dc06ca3 100644 --- a/packages/common/nki-kakoune/kakrc +++ b/packages/common/nki-kakoune/kakrc @@ -1,6 +1,3 @@ -# Enable kak-tree-sitter -eval %sh{test -z "$WE_STARTED_KAK" && kak-tree-sitter --kakoune -d --server --init $kak_session} -map global normal ": enter-user-mode tree-sitter" # ## Set some color overrides # set global kts_yellow "rgb:e2b75e" # set global kts_teal "rgb:008080" diff --git a/packages/common/nki-kakoune/rc.nix b/packages/common/nki-kakoune/rc.nix index fa4c94d..ac579c9 100644 --- a/packages/common/nki-kakoune/rc.nix +++ b/packages/common/nki-kakoune/rc.nix @@ -1,4 +1,11 @@ -{ lib, fish, writeScript, writeTextDir, ... }: +{ lib +, fish +, writeScript +, writeTextDir +, prependRc ? "" +, appendRc ? "" +, ... +}: let source-pwd = writeScript "source-pwd" '' @@ -8,7 +15,9 @@ let ''; in writeTextDir "share/kak/kakrc.local" '' + ${prependRc} ${builtins.readFile ./kakrc} + ${appendRc} # Source any settings in the current working directory, # recursive upwards diff --git a/packages/common/nki-kakoune/tree-sitter/default.nix b/packages/common/nki-kakoune/tree-sitter/default.nix new file mode 100644 index 0000000..ce16343 --- /dev/null +++ b/packages/common/nki-kakoune/tree-sitter/default.nix @@ -0,0 +1,171 @@ +{ lib +, callPackage +, formats +, runCommandLocal +, kak-tree-sitter +, ... +}: +let + utils = callPackage ../utils.nix { }; + grammars = (callPackage ./grammars.nix { }).grammars; + # Highlighter groups to add to the `highlighterGroups`. Maps from group names to face names. + highlighterGroups = { + attribute = "@attribute"; + comment = "@comment"; + conceal = "%opt{mauve}+i"; + constant = "%opt{peach}"; + constant_builtin_boolean = "%opt{sky}"; + constant_character = "%opt{yellow}"; + constant_macro = "%opt{mauve}"; + constant_numeric = "%opt{peach}"; + constructor = "%opt{sapphire}"; + diff_plus = "%opt{green}"; + diff_minus = "%opt{red}"; + diff_delta = "%opt{blue}"; + diff_delta_moved = "%opt{mauve}"; + error = "%opt{red}+b"; + function = "@function"; + function_builtin = "@builtin"; + function_macro = "+i@ts_function"; + hint = "%opt{blue}+b"; + info = "%opt{green}+b"; + keyword = "keyword"; + keyword_conditional = "+i@ts_keyword"; + keyword_control_conditional = "+i@ts_keyword"; + keyword_control_directive = "+i@ts_keyword"; + keyword_control_import = "+i@ts_keyword"; + keyword_directive = "+i@ts_keyword"; + label = "%opt{sapphire}+i"; + markup_bold = "%opt{peach}+b"; + markup_heading = "%opt{red}"; + markup_heading_1 = "%opt{red}"; + markup_heading_2 = "%opt{mauve}"; + markup_heading_3 = "%opt{green}"; + markup_heading_4 = "%opt{yellow}"; + markup_heading_5 = "%opt{pink}"; + markup_heading_6 = "%opt{teal}"; + markup_heading_marker = "%opt{peach}+b"; + markup_italic = "%opt{pink}+i"; + markup_list_checked = "%opt{green}"; + markup_list_numbered = "%opt{blue}+i"; + markup_list_unchecked = "%opt{teal}"; + markup_list_unnumbered = "%opt{mauve}"; + markup_link_label = "%opt{blue}"; + markup_link_url = "%opt{teal}+u"; + markup_link_uri = "%opt{teal}+u"; + markup_link_text = "%opt{blue}"; + markup_quote = "%opt{crust}"; + markup_raw = "%opt{sky}"; + markup_raw_block = "%opt{sky}"; + markup_raw_inline = "%opt{green}"; + markup_strikethrough = "%opt{crust}+s"; + namespace = "@module"; + operator = "@operator"; + property = "%opt{sky}"; + punctuation = "%opt{overlay2}"; + punctuation_special = "%opt{sky}"; + special = "%opt{blue}"; + spell = "%opt{mauve}"; + string = "%opt{green}"; + string_regex = "%opt{peach}"; + string_regexp = "%opt{peach}"; + string_escape = "%opt{mauve}"; + string_special = "%opt{blue}"; + string_special_path = "%opt{green}"; + string_special_symbol = "%opt{mauve}"; + string_symbol = "%opt{red}"; + tag = "%opt{teal}"; + tag_error = "%opt{red}"; + text_title = "%opt{mauve}"; + type = "@type"; + type_enum_variant = "+i@ts_type"; + variable = "@variable"; + variable_builtin = "@builtin"; + variable_other_member = "%opt{teal}"; + variable_parameter = "+i@variable"; + warning = "%opt{peach}+b"; + }; + + # Highlighter groups to be aliased by other groups + aliases = { + comment_block = "comment"; + comment_line = "comment"; + constant_character_escape = "constant_character"; + constant_numeric_float = "constant_numeric"; + constant_numeric_integer = "constant_numeric"; + function_method = "function"; + function_special = "function"; + keyword_control = "keyword"; + keyword_control_repeat = "keyword"; + keyword_control_return = "keyword"; + keyword_control_except = "keyword"; + keyword_control_exception = "keyword"; + keyword_function = "keyword"; + keyword_operator = "keyword"; + keyword_special = "keyword"; + keyword_storage = "keyword"; + keyword_storage_modifier = "keyword"; + keyword_storage_modifier_mut = "keyword"; + keyword_storage_modifier_ref = "keyword"; + keyword_storage_type = "keyword"; + punctuation_bracket = "punctuation"; + punctuation_delimiter = "punctuation"; + text = "string"; + type_builtin = "type"; + + # Scala stuff + method = "function"; + module = "namespace"; + function_call = "function"; + method_call = "method"; + + boolean = "constant_builtin_boolean"; + number = "constant_numeric"; + float = "constant_numeric_float"; + + type_qualifier = "keyword_special"; + storageclass = "keyword_storage_modifier"; + conditional = "keyword_conditional"; + include = "keyword_control_import"; + }; + + configDir = + let + toScm = name: lib.concatStringsSep "." (lib.splitString "_" name); + + toml = formats.toml { }; + file = + toml.generate "config.toml" { + highlight.groups = builtins.map toScm (builtins.attrNames highlighterGroups ++ builtins.attrNames aliases); + features = { + highlighting = true; + text_objects = true; + }; + language = grammars; + }; + in + runCommandLocal "kak-tree-sitter-config" { } '' + mkdir -p $out/kak-tree-sitter + ln -s ${file} $out/kak-tree-sitter/config.toml + ''; + + extraFaces = + let + toTs = name: "ts_${lib.concatStringsSep "_" (lib.splitString "." name)}"; + + definedFaces = lib.mapAttrs' (name: value: { inherit value; name = toTs name; }) highlighterGroups; + aliasFaces = lib.mapAttrs' (name: value: { name = toTs name; value = "@${toTs value}"; }) aliases; + faces = lib.recursiveUpdate definedFaces aliasFaces; + in + faces; +in +{ + rc = '' + # Enable kak-tree-sitter + eval %sh{env XDG_CONFIG_DIR=${configDir} ${lib.getExe' kak-tree-sitter "kak-tree-sitter"} --kakoune -d --server --init $kak_session} + map global normal ": enter-user-mode tree-sitter" + ''; + + plugin = utils.mkFacesScript "kak-tree-sitter" extraFaces; +} + diff --git a/packages/common/nki-kakoune/tree-sitter/grammars.nix b/packages/common/nki-kakoune/tree-sitter/grammars.nix new file mode 100644 index 0000000..426edb3 --- /dev/null +++ b/packages/common/nki-kakoune/tree-sitter/grammars.nix @@ -0,0 +1,119 @@ +{ lib, stdenv, fetchFromGitHub, runCommandLocal, ... }: +let + mkGrammarPackage = + { name + , src + , grammarPath ? "src" + , grammarCompileArgs ? [ "-O3" "-c" "-fpic" "../parser.c" "../scanner.c" "-I" ".." ] + , grammarLinkArgs ? [ "-shared" "-fpic" "parser.o" "scanner.o" ] + , ... + }: stdenv.mkDerivation { + inherit src; + name = "kak-tree-sitter-grammar-${name}"; + version = "latest"; + buildPhase = '' + mkdir ${grammarPath}/build + cd ${grammarPath}/build + $CC ${lib.concatStringsSep " " grammarCompileArgs} + $CC ${lib.concatStringsSep " " grammarLinkArgs} -o ${name}.so + ''; + installPhase = '' + mkdir $out + cp ${name}.so $out + ''; + }; + mkGrammar = + args @ { name + , src + , grammarPath ? "src" + , grammarCompileArgs ? [ "-O3" "-c" "-fpic" "../parser.c" "../scanner.c" "-I" ".." ] + , grammarLinkArgs ? [ "-shared" "-fpic" "parser.o" "scanner.o" ] + , querySrc ? src + , queryPath ? "runtime/queries/${name}" + , + }: { + grammar.source.local.path = "${mkGrammarPackage args}"; + queries.source.local.path = querySrc; + queries.path = queryPath; + }; + + tree-sitter-go = fetchFromGitHub { + owner = "tree-sitter"; + repo = "tree-sitter-go"; + rev = "v0.20.0"; + hash = "sha256-G7d8CHCyKDAb9j6ijRfHk/HlgPqSI+uvkuRIRRvjkHI="; + }; +in +{ + grammars = builtins.mapAttrs (name: value: mkGrammar ({ inherit name; } // value)) { + scala = { + src = fetchFromGitHub { + owner = "tree-sitter"; + repo = "tree-sitter-scala"; + rev = "70afdd5632d57dd63a960972ab25945e353a52f6"; + hash = "sha256-bi0Lqo/Zs2Uaz1efuKAARpEDg5Hm59oUe7eSXgL1Wow="; + }; + queryPath = "queries/scala"; + }; + haskell = { + src = fetchFromGitHub { + owner = "tree-sitter"; + repo = "tree-sitter-haskell"; + rev = "ba0bfb0e5d8e9e31c160d287878c6f26add3ec08"; + hash = "sha256-ZSOF0CLOn82GwU3xgvFefmh/AD2j5zz8I0t5YPwfan0="; + }; + grammarCompileArgs = [ "-O3" "-c" "-fpic" "../parser.c" "../scanner.c" "../unicode.h" "-I" ".." ]; + queryPath = "queries"; + }; + yaml = { + src = fetchFromGitHub { + owner = "ikatyang"; + repo = "tree-sitter-yaml"; + rev = "0e36bed171768908f331ff7dff9d956bae016efb"; + hash = "sha256-bpiT3FraOZhJaoiFWAoVJX1O+plnIi8aXOW2LwyU23M="; + }; + grammarCompileArgs = [ "-c" "-fpic" "../scanner.cc" "../parser.c" "-I" ".." ]; + grammarLinkArgs = [ "-lstdc++" "-shared" "-fpic" "scanner.o" "parser.o" ]; + querySrc = fetchFromGitHub { + owner = "helix-editor"; + repo = "helix"; + rev = "dbd248fdfa680373d94fbc10094a160aafa0f7a7"; + hash = "sha256-wk8qVUDFXhAOi1Ibc6iBMzDCXb6t+YiWZcTd0IJybqc="; + }; + }; + templ = rec { + src = fetchFromGitHub { + owner = "vrischmann"; + repo = "tree-sitter-templ"; + rev = "044ad200092170727650fa6d368df66a8da98f9d"; + hash = "sha256-hJuB3h5pp+LLfP0/7bAYH0uLVo+OQk5jpzJb3J9BNkY="; + }; + querySrc = runCommandLocal "templ-tree-sitter-queries" { } '' + mkdir -p $out/queries + # copy most stuff from tree-sitter-templ + install -m644 ${src}/queries/templ/* $out/queries + # override inherited files + cat ${tree-sitter-go}/queries/highlights.scm ${src}/queries/templ/highlights.scm > $out/queries/highlights.scm + ''; + queryPath = "queries"; + }; + go = { + src = tree-sitter-go; + grammarCompileArgs = [ "-O3" "-c" "-fpic" "../parser.c" "-I" ".." ]; + grammarLinkArgs = [ "-shared" "-fpic" "parser.o" ]; + queryPath = "queries"; + }; + hylo = { + src = fetchFromGitHub { + owner = "natsukagami"; + repo = "tree-sitter-hylo"; + rev = "494cbdff0d13cbc67348316af2efa0286dbddf6f"; + hash = "sha256-R5UeoglCTl0do3VDJ/liCTeqbxU9slvmVKNRA/el2VY="; + }; + grammarCompileArgs = [ "-O3" "-c" "-fpic" "../parser.c" "-I" ".." ]; + grammarLinkArgs = [ "-shared" "-fpic" "parser.o" ]; + queryPath = "queries"; + }; + }; +} + diff --git a/packages/common/nki-kakoune/utils.nix b/packages/common/nki-kakoune/utils.nix index 47e7c75..4183aa6 100644 --- a/packages/common/nki-kakoune/utils.nix +++ b/packages/common/nki-kakoune/utils.nix @@ -1,5 +1,7 @@ -{ lib, writeFile, ... }: { - mkFacesScript = name: faces: writeFile "${name}-faces.kak" ( - lib.concatStringsSep "\n" (builtins.attrValues (builtins.mapAttrs (name: face: "face global ${name} \"${face}\"") faces)) - ); +{ lib, writeTextDir, ... }: { + mkFacesScript = name: faces: writeTextDir "share/kak/autoload/${name}/faces.kak" '' + hook global KakBegin .* { + ${lib.concatStringsSep "\n" (builtins.attrValues (builtins.mapAttrs (name: face: " face global ${name} \"${face}\"") faces))} + } + ''; } From 2a2cbc295f96e9e3a0bc6d2a5b01d5775236d9a5 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Mon, 7 Oct 2024 21:11:48 +0200 Subject: [PATCH 26/32] Make tree-sitter kinda work --- home/common.nix | 2 +- overlay.nix | 2 +- .../default.nix} | 1 + .../common/kak-tree-sitter/user_config.patch | 129 ++++++++++++++++++ packages/common/nki-kakoune/default.nix | 4 +- packages/common/nki-kakoune/faces.nix | 31 +++++ packages/common/nki-kakoune/lsp.nix | 14 +- .../nki-kakoune/tree-sitter/default.nix | 28 ++-- .../nki-kakoune/tree-sitter/grammars.nix | 1 + packages/common/nki-kakoune/utils.nix | 2 +- 10 files changed, 187 insertions(+), 27 deletions(-) rename packages/common/{kak-tree-sitter.nix => kak-tree-sitter/default.nix} (98%) create mode 100644 packages/common/kak-tree-sitter/user_config.patch create mode 100644 packages/common/nki-kakoune/faces.nix diff --git a/home/common.nix b/home/common.nix index feeab1c..49b62ae 100644 --- a/home/common.nix +++ b/home/common.nix @@ -2,7 +2,7 @@ { imports = [ - ./kakoune/kak.nix + # ./kakoune/kak.nix ./fish/fish.nix ./modules/programs/my-broot.nix ./modules/programs/my-sway diff --git a/overlay.nix b/overlay.nix index 60fa42d..75da770 100644 --- a/overlay.nix +++ b/overlay.nix @@ -101,7 +101,7 @@ let }; overlay-packages = final: prev: { - kak-tree-sitter = final.callPackage ./packages/common/kak-tree-sitter.nix { rustPlatform = final.unstable.rustPlatform; }; + kak-tree-sitter = final.callPackage ./packages/common/kak-tree-sitter { rustPlatform = final.unstable.rustPlatform; }; kak-lsp = let diff --git a/packages/common/kak-tree-sitter.nix b/packages/common/kak-tree-sitter/default.nix similarity index 98% rename from packages/common/kak-tree-sitter.nix rename to packages/common/kak-tree-sitter/default.nix index 9819e3a..69da116 100644 --- a/packages/common/kak-tree-sitter.nix +++ b/packages/common/kak-tree-sitter/default.nix @@ -34,6 +34,7 @@ let self.runtime_dir.join("sources").join(url_dir) '') + ./user_config.patch ]; meta.mainProgram = "kak-tree-sitter"; diff --git a/packages/common/kak-tree-sitter/user_config.patch b/packages/common/kak-tree-sitter/user_config.patch new file mode 100644 index 0000000..b2b1b6a --- /dev/null +++ b/packages/common/kak-tree-sitter/user_config.patch @@ -0,0 +1,129 @@ +diff --git a/kak-tree-sitter-config/src/lib.rs b/kak-tree-sitter-config/src/lib.rs +index e4edc42..a9c92cb 100644 +--- a/kak-tree-sitter-config/src/lib.rs ++++ b/kak-tree-sitter-config/src/lib.rs +@@ -52,9 +52,13 @@ impl Config { + } + + /// Load the default configuration, the user configuration, and merge both. +- pub fn load_default_user() -> Result { ++ pub fn load_default_user(path: Option>) -> Result { + let mut config = Self::load_default_config()?; +- match UserConfig::load_from_xdg() { ++ let user_config = match path { ++ Some(p) => UserConfig::load(p), ++ None => UserConfig::load_from_xdg(), ++ }; ++ match user_config { + Ok(user_config) => { + config.merge_user_config(user_config)?; + } +@@ -448,7 +452,7 @@ impl UserConfig { + } + + /// Load the configuration from a given path. +- fn load(path: impl AsRef) -> Result { ++ pub fn load(path: impl AsRef) -> Result { + let path = path.as_ref(); + + log::debug!("loading configuration at {path}", path = path.display()); +diff --git a/kak-tree-sitter/src/cli.rs b/kak-tree-sitter/src/cli.rs +index b8102cd..923312c 100644 +--- a/kak-tree-sitter/src/cli.rs ++++ b/kak-tree-sitter/src/cli.rs +@@ -22,6 +22,10 @@ pub struct Cli { + #[clap(short, long)] + pub server: bool, + ++ /// Specify a custom path for the user config. ++ #[clap(short, long)] ++ pub user_config: Option, ++ + /// Try to daemonize, if not already done. + #[clap(short, long)] + pub daemonize: bool, +diff --git a/kak-tree-sitter/src/main.rs b/kak-tree-sitter/src/main.rs +index bee9698..cbd7b39 100644 +--- a/kak-tree-sitter/src/main.rs ++++ b/kak-tree-sitter/src/main.rs +@@ -43,7 +43,7 @@ fn start() -> Result<(), OhNo> { + } + } + +- let config = Config::load_default_user()?; ++ let config = Config::load_default_user(cli.user_config.as_ref())?; + + // inject rc if we start from Kakoune + if cli.kakoune && cli.init.is_some() { +diff --git a/kak-tree-sitter/src/server.rs b/kak-tree-sitter/src/server.rs +index f3b7723..000c81d 100644 +--- a/kak-tree-sitter/src/server.rs ++++ b/kak-tree-sitter/src/server.rs +@@ -73,6 +73,7 @@ impl Server { + log::debug!("creating IO handler"); + let io_handler = IOHandler::new( + config, ++ cli.user_config.clone(), + cli.is_standalone(), + cli.with_highlighting || config.features.highlighting, + resources, +@@ -165,6 +166,7 @@ struct IOHandler { + connections: HashMap, + enqueue_response: EnqueueResponse, + handler: Handler, ++ user_config_path: Option, + } + + impl IOHandler { +@@ -173,6 +175,7 @@ impl IOHandler { + + fn new( + config: &Config, ++ user_config_path: Option, + is_standalone: bool, + with_highlighting: bool, + resources: ServerResources, +@@ -203,6 +206,7 @@ impl IOHandler { + connections, + enqueue_response, + handler, ++ user_config_path, + }) + } + +@@ -450,7 +454,7 @@ impl IOHandler { + } + + fn reload(&mut self) { +- let config = match Config::load_default_user() { ++ let config = match Config::load_default_user(self.user_config_path.as_ref()) { + Ok(config) => config, + Err(err) => { + log::error!("reloading config failed: {err}"); +diff --git a/ktsctl/src/cli.rs b/ktsctl/src/cli.rs +index dfac5c3..09f86f3 100644 +--- a/ktsctl/src/cli.rs ++++ b/ktsctl/src/cli.rs +@@ -11,6 +11,9 @@ pub struct Cli { + #[clap(long)] + pub verbose: bool, + ++ #[clap(short, long)] ++ pub user_config: Option, ++ + #[clap(subcommand)] + pub cmd: Cmd, + } +diff --git a/ktsctl/src/main.rs b/ktsctl/src/main.rs +index f9a3499..f823633 100644 +--- a/ktsctl/src/main.rs ++++ b/ktsctl/src/main.rs +@@ -37,7 +37,7 @@ fn start() -> Result<(), HellNo> { + simple_logger::init_with_level(log::Level::Debug)?; + } + +- let config = Config::load_default_user()?; ++ let config = Config::load_default_user(cli.user_config.as_ref())?; + log::debug!("ktsctl configuration:\n{config:#?}"); + + match cli.cmd { diff --git a/packages/common/nki-kakoune/default.nix b/packages/common/nki-kakoune/default.nix index 0d48b06..4cb34c7 100644 --- a/packages/common/nki-kakoune/default.nix +++ b/packages/common/nki-kakoune/default.nix @@ -11,6 +11,7 @@ in ++ callPackage ./themes.nix { } ++ [ (callPackage ./kaktex { }) + (callPackage ./faces.nix { }) rc tree-sitter.plugin lsp.plugin @@ -23,6 +24,7 @@ in rm "$out/bin/kak" makeWrapper "${kakoune-unwrapped}/bin/kak" "$out/bin/kak" \ --set KAKOUNE_RUNTIME "$out/share/kak" \ - --suffix PATH ":" "${lsp.extraPaths}" + --suffix PATH ":" "${lsp.extraPaths}" \ + --suffix PATH ":" "${tree-sitter.extraPaths}" ''; }) diff --git a/packages/common/nki-kakoune/faces.nix b/packages/common/nki-kakoune/faces.nix new file mode 100644 index 0000000..367472c --- /dev/null +++ b/packages/common/nki-kakoune/faces.nix @@ -0,0 +1,31 @@ +{ callPackage, ... } : +let +utils = callPackage ./utils.nix { }; +faces = { + Default = "%opt{text},%opt{base}"; + BufferPadding = "%opt{base},%opt{base}"; + MenuForeground = "%opt{blue},white+bF"; + MenuBackground = "%opt{sky},white+F"; + Information = "%opt{sky},white"; + # Markdown help color scheme + InfoDefault = "Information"; + InfoBlock = "@block"; + InfoBlockQuote = "+i@block"; + InfoBullet = "@bullet"; + InfoHeader = "@header"; + InfoLink = "@link"; + InfoLinkMono = "+b@mono"; + InfoMono = "@mono"; + InfoRule = "+b@Information"; + InfoDiagnosticError = "@DiagnosticError"; + InfoDiagnosticHint = "@DiagnosticHint"; + InfoDiagnosticInformation = "@Information"; + InfoDiagnosticWarning = "@DiagnosticWarning"; + # Extra faces + macro = "+u@function"; + method = "@function"; + format_specifier = "+i@string"; + mutable_variable = "+i@variable"; + class = "+b@variable"; +}; +in utils.mkFacesScript "default-faces" faces diff --git a/packages/common/nki-kakoune/lsp.nix b/packages/common/nki-kakoune/lsp.nix index 3712d6f..6511ee9 100644 --- a/packages/common/nki-kakoune/lsp.nix +++ b/packages/common/nki-kakoune/lsp.nix @@ -248,7 +248,7 @@ let kak-lsp-config = let toml = formats.toml { }; - toLspConfig = attrs: builtins.removeAttrs attrs [ "package" ]; + toLspConfig = builtins.mapAttrs (_: attrs: builtins.removeAttrs attrs [ "package" ]); in toml.generate "kak-lsp.toml" ({ semantic_tokens.faces = config.faces; @@ -265,16 +265,16 @@ in plugin = writeTextDir "share/kak/autoload/kak-lsp.kak" '' hook global KakBegin .* %{ try %{ - eval %sh{${lib.getExe kak-lsp} --config ${kak-lsp-config} -s $kak_session} + eval %sh{${lib.getExe kak-lsp} --kakoune --config ${kak-lsp-config} -s $kak_session} } lsp-enable - map window lsp N -docstring "Display the next message request" ": lsp-show-message-request-next" - map window normal ": enter-user-mode lsp" - map window normal ": lsp-hover" - map window normal ": lsp-hover-buffer" + map global lsp N -docstring "Display the next message request" ": lsp-show-message-request-next" + map global normal ": enter-user-mode lsp" + map global normal ": lsp-hover" + map global normal ": lsp-hover-buffer" # lsp-auto-hover-insert-mode-enable - set window lsp_hover_anchor true + set global lsp_hover_anchor true map global insert ':try lsp-snippets-select-next-placeholders catch %{ execute-keys -with-hooks tab> }' -docstring 'Select next snippet placeholder' map global object a 'lsp-object' -docstring 'LSP any symbol' map global object 'lsp-object' -docstring 'LSP any symbol' diff --git a/packages/common/nki-kakoune/tree-sitter/default.nix b/packages/common/nki-kakoune/tree-sitter/default.nix index ce16343..b94a771 100644 --- a/packages/common/nki-kakoune/tree-sitter/default.nix +++ b/packages/common/nki-kakoune/tree-sitter/default.nix @@ -129,25 +129,19 @@ let include = "keyword_control_import"; }; - configDir = + configFile = let toScm = name: lib.concatStringsSep "." (lib.splitString "_" name); - toml = formats.toml { }; - file = - toml.generate "config.toml" { - highlight.groups = builtins.map toScm (builtins.attrNames highlighterGroups ++ builtins.attrNames aliases); - features = { - highlighting = true; - text_objects = true; - }; - language = grammars; - }; in - runCommandLocal "kak-tree-sitter-config" { } '' - mkdir -p $out/kak-tree-sitter - ln -s ${file} $out/kak-tree-sitter/config.toml - ''; + toml.generate "config.toml" { + highlight.groups = builtins.map toScm (builtins.attrNames highlighterGroups ++ builtins.attrNames aliases); + features = { + highlighting = true; + text_objects = true; + }; + language = grammars; + }; extraFaces = let @@ -162,10 +156,12 @@ in { rc = '' # Enable kak-tree-sitter - eval %sh{env XDG_CONFIG_DIR=${configDir} ${lib.getExe' kak-tree-sitter "kak-tree-sitter"} --kakoune -d --server --init $kak_session} + eval %sh{kak-tree-sitter --kakoune -d --server --init $kak_session --user-config ${configFile}} map global normal ": enter-user-mode tree-sitter" ''; + extraPaths = "${kak-tree-sitter}/bin"; + plugin = utils.mkFacesScript "kak-tree-sitter" extraFaces; } diff --git a/packages/common/nki-kakoune/tree-sitter/grammars.nix b/packages/common/nki-kakoune/tree-sitter/grammars.nix index 426edb3..d1f6417 100644 --- a/packages/common/nki-kakoune/tree-sitter/grammars.nix +++ b/packages/common/nki-kakoune/tree-sitter/grammars.nix @@ -33,6 +33,7 @@ let , }: { grammar.source.local.path = "${mkGrammarPackage args}"; + grammar.link_args = grammarLinkArgs ++ [ "-o" "${name}.so" ]; queries.source.local.path = querySrc; queries.path = queryPath; }; diff --git a/packages/common/nki-kakoune/utils.nix b/packages/common/nki-kakoune/utils.nix index 4183aa6..0307bc6 100644 --- a/packages/common/nki-kakoune/utils.nix +++ b/packages/common/nki-kakoune/utils.nix @@ -1,6 +1,6 @@ { lib, writeTextDir, ... }: { mkFacesScript = name: faces: writeTextDir "share/kak/autoload/${name}/faces.kak" '' - hook global KakBegin .* { + hook global KakBegin .* %{ ${lib.concatStringsSep "\n" (builtins.attrValues (builtins.mapAttrs (name: face: " face global ${name} \"${face}\"") faces))} } ''; From 12dcbcb3f6e93a21040e5f50156009925b3858e5 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Mon, 7 Oct 2024 22:25:59 +0200 Subject: [PATCH 27/32] Cleanup the home kakoune module, restore tree-sitter --- home/common.nix | 3 +- home/kakoune/kak.nix | 374 +----------------- home/modules/programs/my-kakoune/default.nix | 94 +---- home/modules/programs/my-kakoune/kak-lsp.nix | 213 ---------- .../programs/my-kakoune/tree-sitter.nix | 59 +-- packages/common/nki-kakoune/default.nix | 8 +- packages/common/nki-kakoune/kakrc | 1 + 7 files changed, 58 insertions(+), 694 deletions(-) delete mode 100644 home/modules/programs/my-kakoune/kak-lsp.nix diff --git a/home/common.nix b/home/common.nix index 49b62ae..253c8b1 100644 --- a/home/common.nix +++ b/home/common.nix @@ -2,7 +2,7 @@ { imports = [ - # ./kakoune/kak.nix + ./kakoune/kak.nix ./fish/fish.nix ./modules/programs/my-broot.nix ./modules/programs/my-sway @@ -41,7 +41,6 @@ unzip zstd atool - nki-kakoune ]; home.sessionVariables = { diff --git a/home/kakoune/kak.nix b/home/kakoune/kak.nix index c39fca2..cfd5d6a 100644 --- a/home/kakoune/kak.nix +++ b/home/kakoune/kak.nix @@ -1,67 +1,9 @@ { pkgs, lib, ... }: - let - kak-lsp-frontend = { pkgs, lib, ... }: - let - langserver = name: { - name = "vscode-${name}-language-server"; - value = { - args = [ "--stdio" ]; - command = "vscode-${name}-language-server"; - filetypes = [ name ]; - roots = [ "package.json" ".git" ]; - }; - package = pkgs.nodePackages.vscode-langservers-extracted; - }; - - tailwind = { - command = "tailwindcss-language-server"; - args = [ "--stdio" ]; - filetypes = [ "html" "css" "javascript" "typescript" "templ" ]; - roots = [ "tailwind.config.{js,cjs,mjs,ts}" "package.json" ".git" ]; - settings_section = "tailwindCSS"; - settings.tailwindCSS = { - validate = "warning"; - userLanguages.templ = "html"; - }; - package = pkgs.tailwindcss-language-server; - }; - - templModule = { pkgs, lib, ... }: { - programs.kak-lsp.languageServers."vscode-html-language-server".filetypes = [ "templ" ]; - programs.kak-lsp.languageServers."tailwindcss-language-server".filetypes = [ "templ" ]; - programs.kak-lsp.languageServers.templ = { - command = "templ"; - args = [ "lsp" ]; - filetypes = [ "templ" ]; - roots = [ "go.mod" ".git" ]; - package = pkgs.unstable.templ; - }; - - }; - - in - { - imports = [ templModule ]; - - programs.kak-lsp.languageServers = (builtins.listToAttrs (map langserver [ "html" "css" "json" ])) // { - tailwindcss-language-server = tailwind; - }; - }; - - ltexLsp = { pkgs, lib, ... }: { - programs.kak-lsp.languageServers.ltex-ls = { - command = "ltex-ls"; - args = [ "--log-file=/tmp" ]; - filetypes = [ "latex" "typst" ]; - roots = [ "main.tex" "main.typ" ".git" ]; - package = pkgs.ltex-ls; - }; - }; in { - imports = [ ../modules/programs/my-kakoune ./kaktex.nix kak-lsp-frontend ltexLsp ]; + imports = [ ../modules/programs/my-kakoune ./kaktex.nix ]; home.packages = with pkgs; [ # ctags for peneira @@ -75,109 +17,6 @@ in # Enable the kakoune package. programs.my-kakoune.enable = true; programs.my-kakoune.enable-fish-session = true; - programs.kak-lsp.enable = true; - programs.kak-lsp.semanticTokens.additionalFaces = [ - # Typst - { face = "header"; token = "heading"; } - { face = "ts_markup_link_url"; token = "link"; } - { face = "ts_markup_link_uri"; token = "ref"; } - { face = "ts_markup_link_label"; token = "label"; } - { face = "ts_property"; token = "pol"; } - { face = "ts_markup_list_checked"; token = "marker"; } - { face = "ts_constant_builtin_boolean"; token = "bool"; } - { face = "ts_keyword_control"; token = "delim"; } - { face = "ts_number"; token = "text"; modifiers = [ "math" ]; } - { face = "ts_markup_bold"; token = "text"; modifiers = [ "strong" ]; } - { face = "ts_markup_italic"; token = "text"; modifiers = [ "emph" ]; } - ]; - - programs.kak-lsp.languageServers.elixir-ls = { - args = [ ]; - command = "elixir-ls"; - filetypes = [ "elixir" ]; - roots = [ "mix.exs" ]; - }; - programs.kak-lsp.languageServers.typescript-language-server = { - args = [ "--stdio" ]; - command = "typescript-language-server"; - filetypes = [ "typescript" "javascript" ]; - roots = [ "package.json" ]; - package = pkgs.nodePackages.typescript-language-server; - }; - programs.kak-lsp.languageServers.fsautocomplete = { - args = [ "--adaptive-lsp-server-enabled" "--project-graph-enabled" "--source-text-factory" "RoslynSourceText" ]; - command = "fsautocomplete"; - filetypes = [ "fsharp" ]; - roots = [ "*.fsproj" ]; - settings_section = "FSharp"; - settings.FSharp = { - AutomaticWorkspaceInit = true; - }; - }; - programs.kak-lsp.languageServers.metals = { - command = "metals"; - filetypes = [ "scala" ]; - roots = [ "build.sbt" "build.sc" ]; - settings_section = "metals"; - settings.metals = { - enableSemanticHighlighting = true; - showInferredType = true; - decorationProvider = true; - inlineDecorationProvider = true; - # From kakoune-lsp's own options - icons = "unicode"; - isHttpEnabled = true; - statusBarProvider = "log-message"; - compilerOptions = { overrideDefFormat = "unicode"; }; - }; - package = pkgs.metals; - }; - programs.kak-lsp.languageServers.texlab = { - command = "texlab"; - filetypes = [ "latex" ]; - roots = [ "main.tex" "all.tex" ".git" ]; - settings_section = "texlab"; - settings.texlab = { - build.executable = "latexmk"; - build.args = [ "-pdf" "-shell-escape" "-interaction=nonstopmode" "-synctex=1" "%f" ]; - - build.forwardSearchAfter = true; - build.onSave = true; - - forwardSearch = - (if pkgs.stdenv.isDarwin then { - executable = "/Applications/Skim.app/Contents/SharedSupport/displayline"; - args = [ "-r" "-g" "%l" "%p" "%f" ]; - } else - { - executable = "${pkgs.zathura}/bin/zathura"; - args = [ "--synctex-forward" "%l:1:%f" "%p" "-x" "${./kaktex} jump %%{input} %%{line} %%{column}" ]; - }); - }; - package = pkgs.texlab; - }; - programs.kak-lsp.languageServers.typst-lsp = { - command = "typst-lsp"; - filetypes = [ "typst" ]; - roots = [ "main.typ" ".git" ]; - settings_section = "typst-lsp"; - settings.typst-lsp = { - experimentalFormatterMode = "on"; - }; - }; - programs.kak-lsp.languageServers.marksman = { - command = "marksman"; - filetypes = [ "markdown" ]; - roots = [ ".marksman.toml" ".git" ]; - package = pkgs.marksman; - }; - programs.kak-lsp.languageServers.rust-analyzer = { - args = [ ]; - command = "rust-analyzer"; - filetypes = [ "rust" ]; - roots = [ "Cargo.toml" ]; - package = pkgs.rust-analyzer; - }; programs.my-kakoune.tree-sitter.extraAliases = { # Scala stuff @@ -300,216 +139,5 @@ in queries.path = "queries"; }; }; - - programs.my-kakoune.package = pkgs.kakoune; - programs.my-kakoune.rc = - builtins.readFile ./kakrc + '' - - # Source any settings in the current working directory, - # recursive upwards - evaluate-commands %sh{ - ${pkgs.writeScript "source-pwd" (builtins.readFile ./source-pwd)} - } - ''; - - programs.my-kakoune.extraFaces = { - Default = "%opt{text},%opt{base}"; - BufferPadding = "%opt{base},%opt{base}"; - MenuForeground = "%opt{blue},white+bF"; - MenuBackground = "%opt{sky},white+F"; - Information = "%opt{sky},white"; - # Markdown help color scheme - InfoDefault = "Information"; - InfoBlock = "@block"; - InfoBlockQuote = "+i@block"; - InfoBullet = "@bullet"; - InfoHeader = "@header"; - InfoLink = "@link"; - InfoLinkMono = "+b@mono"; - InfoMono = "@mono"; - InfoRule = "+b@Information"; - InfoDiagnosticError = "@DiagnosticError"; - InfoDiagnosticHint = "@DiagnosticHint"; - InfoDiagnosticInformation = "@Information"; - InfoDiagnosticWarning = "@DiagnosticWarning"; - # Extra faces - macro = "+u@function"; - method = "@function"; - format_specifier = "+i@string"; - mutable_variable = "+i@variable"; - class = "+b@variable"; - }; - programs.my-kakoune.autoload = [ - # My own scripts - { - name = "latex.kak"; - src = ./autoload/latex.kak; - } - { - name = "markdown.kak"; - src = ./autoload/markdown.kak; - } - - # Plugins - { - name = "luar"; - src = pkgs.fetchFromGitHub { - owner = "gustavo-hms"; - repo = "luar"; - rev = "2f430316f8fc4d35db6c93165e2e77dc9f3d0450"; - sha256 = "sha256-vHn/V3sfzaxaxF8OpA5jPEuPstOVwOiQrogdSGtT6X4="; - }; - activationScript = '' - # Enable luar - require-module luar - # Use luajit - set-option global luar_interpreter ${pkgs.luajit}/bin/luajit - ''; - } - { - name = "peneira"; - src = pkgs.fetchFromGitHub { - owner = "natsukagami"; - repo = "peneira"; - rev = "743b9971472853a752475e7c070ce99089c6840c"; - sha256 = "sha256-E4ndbF9YC1p0KrvSuGgwmG1Y2IGTuGKJo/AuMixhzlM="; - }; - activationScript = '' - require-module peneira - - # Change selection color - set-face global PeneiraSelected @PrimarySelection - - # Buffers list - define-command -hidden peneira-buffers %{ - peneira 'buffers: ' %{ printf '%s\n' $kak_quoted_buflist } %{ - buffer %arg{1} - } - } - - # Grep in the current location - define-command peneira-grep %{ - peneira 'line: ' "rg -n ." %{ - lua %arg{1} %{ - local file, line = arg[1]:match("([^:]+):(%d+):") - kak.edit(file, line) - } - } - } - - # A peneira menu - declare-user-mode fuzzy-match-menu - - map -docstring "Switch to buffer" global fuzzy-match-menu b ": peneira-buffers" - map -docstring "Symbols" global fuzzy-match-menu s ": peneira-symbols" - map -docstring "Lines" global fuzzy-match-menu l ": peneira-lines" - map -docstring "Lines in the current directory" global fuzzy-match-menu g ": peneira-grep" - map -docstring "Files in project" global fuzzy-match-menu f ": peneira-files" - map -docstring "Files in currently opening file's directory" global fuzzy-match-menu F ": peneira-local-files" - - # Bind menu to user mode - map -docstring "Fuzzy matching" global user f ": enter-user-mode fuzzy-match-menu" - ''; - } - { - name = "kakoune-focus"; - src = pkgs.fetchFromGitHub { - owner = "caksoylar"; - repo = "kakoune-focus"; - rev = "949c0557cd4c476822acfa026ca3c50f3d38a3c0"; - sha256 = "sha256-ZV7jlLJQyL420YG++iC9rq1SMjo3WO5hR9KVvJNUiCs="; - }; - activationScript = '' - map global user ': focus-toggle' -docstring "toggle selections focus" - ''; - } - { - name = "kakoune-inc-dec"; - src = pkgs.fetchFromGitLab { - owner = "Screwtapello"; - repo = "kakoune-inc-dec"; - rev = "7bfe9c51"; - sha256 = "0f33wqxqbfygxypf348jf1fiscac161wf2xvnh8zwdd3rq5yybl0"; - }; - } - { - name = "racket.kak"; - src = (builtins.fetchTree { - type = "git"; - url = "https://bitbucket.org/KJ_Duncan/kakoune-racket.kak.git"; - rev = "e397042009b46916ff089d79166ec0e8ca813a18"; - narHash = "sha256-IcxFmvG0jqpMCG/dT9crVRgPgMGKkic6xwrnW5z4+bc="; - }) + "/rc"; - } - # { - # name = "kakoune-discord"; - # src = (builtins.getFlake "github:natsukagami/kakoune-discord/03f95e40d6efd8fd3de7bca31653d43de2dcfc5f").packages.${pkgs.system}.kakoune-discord-rc + "/rc"; - # } - rec { - name = "kakoune-mirror"; - src = pkgs.fetchFromGitHub - { - owner = "Delapouite"; - repo = "kakoune-mirror"; - rev = "5710635f440bcca914d55ff2ec1bfcba9efe0f15"; - sha256 = "sha256-uslx4zZhvjUylrPWvTOugsKYKKpF0EEz1drc1Ckrpjk="; - } + "/mirror.kak"; - wrapAsModule = true; - activationScript = '' - require-module ${name} - - # Bind to ${name} - map global normal ': enter-user-mode -lock mirror' - ''; - } - { - name = "unicode-math"; - src = pkgs.fetchFromGitHub { - owner = "natsukagami"; - repo = "kakoune-unicode-math"; - rev = "08dff25da2b86ee0b0777091992bc7fb28c3cb1d"; - # sha256 = lib.fakeSha256; - sha256 = "sha256-j0L1ARex1i2ma8sGLYwgkfAbh0jWKh/6QGHFaxPXIKc="; - fetchSubmodules = true; - }; - activationScript = '' - require-module unicode-math - - # Bind to the menu - map global insert ': insert-unicode ' - ''; - } - { - name = "kakoune-buffers"; - src = pkgs.fetchFromGitHub { - owner = "Delapouite"; - repo = "kakoune-buffers"; - rev = "6b2081f5b7d58c72de319a5cba7bf628b6802881"; - sha256 = "sha256-jOSrzGcLJjLK1GiTSsl2jLmQMPbPxjycR0pwF5t/eV0="; - }; - activationScript = '' - # Suggested hook - - hook global WinDisplay .* info-buffers - - # Suggested mappings - - map global user b ':enter-buffers-mode' -docstring 'buffers…' - map global normal ^ ':enter-buffers-mode' -docstring 'buffers…' - map global user B ':enter-user-mode -lock buffers' -docstring 'buffers (lock)…' - - # Suggested aliases - - alias global bd delete-buffer - alias global bf buffer-first - alias global bl buffer-last - alias global bo buffer-only - alias global bo! buffer-only-force - ''; - } - ]; - programs.my-kakoune.themes = { - catppuccin-latte = ./catppuccin-latte.kak; - }; } diff --git a/home/modules/programs/my-kakoune/default.nix b/home/modules/programs/my-kakoune/default.nix index 125484a..62a9cb1 100644 --- a/home/modules/programs/my-kakoune/default.nix +++ b/home/modules/programs/my-kakoune/default.nix @@ -1,40 +1,17 @@ -{ config, pkgs, lib, ... }: +{ config, options, pkgs, lib, ... }: with lib; let cfg = config.programs.my-kakoune; - - autoloadModule = types.submodule { - options = { - name = mkOption { - type = types.str; - description = "Name of the autoload script/folder. It might affect kakoune's load order."; - }; - src = mkOption { - type = types.path; - description = "Path to the autoload script/folder."; - }; - wrapAsModule = mkOption { - type = types.bool; - default = false; - description = "Wrap the given source file in a `provide-module` command. Fails if the `src` is not a single file."; - }; - activationScript = mkOption { - type = types.nullOr types.lines; - default = null; - description = "Add an activation script to the module. It will be wrapped in a `hook global KakBegin .*` wrapper."; - }; - }; - }; in { - imports = [ ./kak-lsp.nix ./fish-session.nix ./tree-sitter.nix ]; + imports = [ ./fish-session.nix ./tree-sitter.nix ]; options.programs.my-kakoune = { enable = mkEnableOption "My version of the kakoune configuration"; package = mkOption { type = types.package; - default = pkgs.kakoune; + default = pkgs.nki-kakoune; description = "The kakoune package to be installed"; }; rc = mkOption { @@ -42,22 +19,16 @@ in default = ""; description = "Content of the kakrc file. A line-concatenated string"; }; - autoload = mkOption { - type = types.listOf autoloadModule; - default = [ ]; - description = "Sources to autoload"; - }; - themes = mkOption { - type = types.attrsOf types.path; - default = { }; - description = "Themes to load"; - }; - extraFaces = mkOption { type = types.attrsOf types.str; default = { }; description = "Extra faces to include"; }; + autoloadFile = mkOption { + type = options.xdg.configFile.type; + default = { }; + description = "Extra autoload files"; + }; }; config = mkIf cfg.enable { @@ -65,37 +36,6 @@ in xdg.configFile = let - kakouneAutoload = { name, src, wrapAsModule ? false, activationScript ? null }: - [ - (if !wrapAsModule then { - name = "kak/autoload/${name}"; - value.source = src; - } else { - name = "kak/autoload/${name}/module.kak"; - value.text = '' - provide-module ${name} %◍ - ${readFile src} - ◍ - ''; - }) - ] ++ (if activationScript == null then [ ] else [{ - name = "kak/autoload/on-load/${name}.kak"; - value.text = '' - hook global KakBegin .* %{ - ${activationScript} - } - ''; - }]); - - kakouneThemes = builtins.listToAttrs (builtins.attrValues ( - builtins.mapAttrs - (name: src: { - name = "kak/colors/${name}.kak"; - value.source = src; - }) - cfg.themes - )); - kakouneFaces = let txt = strings.concatStringsSep "\n" (builtins.attrValues (builtins.mapAttrs (name: face: "face global ${name} \"${face}\"") cfg.extraFaces)); @@ -103,6 +43,7 @@ in pkgs.writeText "faces.kak" txt; in { + "kak/autoload/builtin".source = "${cfg.package}/share/kak/autoload"; # kakrc "kak/kakrc".text = '' ${cfg.rc} @@ -110,15 +51,14 @@ in # Load faces source ${kakouneFaces} ''; - } // - (builtins.listToAttrs (lib.lists.flatten (map kakouneAutoload ([ - # include the original autoload files - { - name = "rc"; - src = "${cfg.package}/share/kak/autoload/rc"; - } - ] ++ cfg.autoload)))) - // kakouneThemes; + } // lib.mapAttrs' + (name: attrs: { + name = "kak/autoload/${name}"; + value = attrs // { + target = "kak/autoload/${name}"; + }; + }) + cfg.autoloadFile; }; } diff --git a/home/modules/programs/my-kakoune/kak-lsp.nix b/home/modules/programs/my-kakoune/kak-lsp.nix deleted file mode 100644 index eaf3b6b..0000000 --- a/home/modules/programs/my-kakoune/kak-lsp.nix +++ /dev/null @@ -1,213 +0,0 @@ -{ config, pkgs, lib, ... }: - -with lib; -let - lspConfig = - { - language_ids = { - c = "c_cpp"; - cpp = "c_cpp"; - javascript = "javascriptreact"; - typescript = "typescriptreact"; - protobuf = "proto"; - sh = "shellscript"; - }; - - language_servers = { - ccls = { - args = [ "-v=2" "-log-file=/tmp/ccls.log" ]; - command = "ccls"; - filetypes = [ "c" "cpp" ]; - roots = [ "compile_commands.json" ".cquery" ".git" ]; - }; - gopls = { - command = "gopls"; - filetypes = [ "go" ]; - offset_encoding = "utf-8"; - roots = [ "Gopkg.toml" "go.mod" ".git" ".hg" ]; - settings = { gopls = { hoverKind = "SynopsisDocumentation"; semanticTokens = true; }; }; - settings_section = "gopls"; - }; - haskell-language-server = { - args = [ "--lsp" ]; - command = "haskell-language-server-wrapper"; - filetypes = [ "haskell" ]; - roots = [ "Setup.hs" "stack.yaml" "*.cabal" "package.yaml" ]; - settings_section = "haskell"; - }; - nil = { - command = "${pkgs.nil}/bin/nil"; - filetypes = [ "nix" ]; - roots = [ "flake.nix" "shell.nix" ".git" ]; - settings.nil = { - formatting.command = [ "${getExe pkgs.nixpkgs-fmt}" ]; - }; - }; - pyls = { - command = "pyls"; - filetypes = [ "python" ]; - offset_encoding = "utf-8"; - roots = [ "requirements.txt" "setup.py" ".git" ".hg" ]; - }; - }; - semantic_tokens.faces = [ - ## Items - # (Rust) Macros - { face = "attribute"; token = "attribute"; } - { face = "attribute"; token = "derive"; } - { face = "macro"; token = "macro"; } # Function-like Macro - # Keyword and Fixed Tokens - { face = "keyword"; token = "keyword"; } - { face = "operator"; token = "operator"; } - # Functions and Methods - { face = "function"; token = "function"; } - { face = "method"; token = "method"; } - # Constants - { face = "string"; token = "string"; } - { face = "format_specifier"; token = "formatSpecifier"; } - # Variables - { face = "variable"; token = "variable"; modifiers = [ "readonly" ]; } - { face = "mutable_variable"; token = "variable"; } - { face = "module"; token = "namespace"; } - { face = "variable"; token = "type_parameter"; } - { face = "class"; token = "enum"; } - { face = "class"; token = "struct"; } - { face = "class"; token = "trait"; } - { face = "class"; token = "union"; } - { face = "class"; token = "class"; } - - ## Comments - { face = "documentation"; token = "comment"; modifiers = [ "documentation" ]; } - { face = "comment"; token = "comment"; } - ]; - server = { timeout = 1800; }; - snippet_support = false; - verbosity = 255; - }; - - languageServerOption = types.submodule { - options = { - filetypes = mkOption { - type = types.listOf types.str; - description = "The list of filetypes to assign the language to"; - }; - roots = mkOption { - type = types.listOf types.str; - description = "The list of root filenames that are used to determine the project root"; - }; - command = mkOption { - type = types.str; - description = "The LSP server command to be called."; - }; - args = mkOption { - type = types.listOf types.str; - default = [ ]; - description = "The arguments passed onto the LSP server."; - }; - offset_encoding = mkOption { - type = types.nullOr (types.enum [ "utf-8" ]); - default = null; - description = "The offset encoding used by the LSP server."; - }; - settings_section = mkOption { - type = types.nullOr types.str; - default = null; - description = "The settings section to be sent to LSP server."; - }; - settings = mkOption { - type = types.nullOr (types.attrsOf types.anything); - default = null; - description = "Additional settings to be passed to the LSP server."; - }; - package = mkOption { - type = types.nullOr types.package; - default = null; - description = "The default package of the language server. Will be appended as the ending segments of the PATH to kak-lsp"; - }; - }; - }; - - cfg = config.programs.kak-lsp; - - serverPackages = - filter (v: v != null) - (lib.mapAttrsToList (_: serv: serv.package) cfg.languageServers); - - wrappedPackage = pkgs.symlinkJoin { - name = "kak-lsp-wrapped"; - nativeBuildInputs = [ pkgs.makeWrapper ]; - paths = [ cfg.package ]; - postBuild = '' - wrapProgram $out/bin/kak-lsp --suffix PATH ":" ${lib.makeBinPath serverPackages} - ''; - }; -in -{ - options.programs.kak-lsp = { - enable = mkEnableOption "Enable kak-lsp support"; - - package = mkOption { - type = types.package; - default = pkgs.kak-lsp; - }; - - enableSnippets = mkOption { - type = types.bool; - default = false; - description = "Enable snippet support"; - }; - - semanticTokens.faces = mkOption { - type = types.listOf types.anything; - default = lspConfig.semantic_tokens.faces; - description = "The semantic tokens faces mapping given to kak"; - }; - semanticTokens.additionalFaces = mkOption { - type = types.listOf types.anything; - default = [ ]; - description = "The semantic tokens faces mapping given to kak"; - }; - - serverTimeout = mkOption { - type = types.int; - default = 1000; - description = "Server timeout"; - }; - - languageServers = mkOption { - type = types.attrsOf languageServerOption; - default = { }; - description = "The language options"; - }; - - languageIds = mkOption { - type = types.attrsOf types.str; - default = { }; - description = "Language IDs to be sent to the LSP"; - }; - }; - - config = mkIf cfg.enable - { - home.packages = [ wrappedPackage ]; - - # Configurations - xdg.configFile."kak-lsp/kak-lsp.toml" = - let - toml = pkgs.formats.toml { }; - toLspConfig = lib.filterAttrsRecursive (n: v: n != "package" && v != null); - in - { - source = toml.generate "config.toml" - { - semantic_tokens.faces = cfg.semanticTokens.faces ++ cfg.semanticTokens.additionalFaces; - server.timeout = cfg.serverTimeout; - snippet_support = cfg.enableSnippets; - verbosity = 255; - language_server = toLspConfig (lspConfig.language_servers // cfg.languageServers); - language_ids = lspConfig.language_ids // cfg.languageIds; - }; - }; - }; -} - diff --git a/home/modules/programs/my-kakoune/tree-sitter.nix b/home/modules/programs/my-kakoune/tree-sitter.nix index 4304ca5..07f12cf 100644 --- a/home/modules/programs/my-kakoune/tree-sitter.nix +++ b/home/modules/programs/my-kakoune/tree-sitter.nix @@ -33,6 +33,27 @@ let }; }; }; + mkGrammarPackage = + { name + , src + , grammarPath ? "src" + , grammarCompileArgs ? [ "-O3" "-c" "-fpic" "../parser.c" "../scanner.c" "-I" ".." ] + , grammarLinkArgs ? [ "-shared" "-fpic" "parser.o" "scanner.o" ] + }: pkgs.stdenv.mkDerivation { + inherit src; + name = "kak-tree-sitter-grammar-${name}.so"; + version = "latest"; + buildPhase = '' + mkdir ${grammarPath}/build + cd ${grammarPath}/build + $CC ${lib.concatStringsSep " " grammarCompileArgs} + $CC ${lib.concatStringsSep " " grammarLinkArgs} -o ${name}.so + ''; + installPhase = '' + cp ${name}.so $out + ''; + }; + in { options.programs.my-kakoune.tree-sitter = { @@ -200,24 +221,15 @@ in toml = pkgs.formats.toml { }; - srcName = src: lib.removePrefix "/nix/store/" src.outPath; - mkGitRepo = src: pkgs.runCommandLocal "${src.name}-git" { } '' - cp -r --no-preserve=all ${src} $out - cd $out - if ! test -d $out/.git; then - ${lib.getExe pkgs.git} init -b ${srcName src} - ${lib.getExe pkgs.git} config user.email "a@b.com" - ${lib.getExe pkgs.git} config user.name "a" - ${lib.getExe pkgs.git} add . - ${lib.getExe pkgs.git} commit -m "Just making a git commit" - fi - ''; - toLanguageConf = name: lang: with lang; { grammar = { - inherit (grammar) path; - source.git.url = "${mkGitRepo grammar.src}"; - source.git.pin = "${srcName grammar.src}"; + source.local.path = mkGrammarPackage { + inherit name; + src = grammar.src; + grammarPath = grammar.path; + grammarCompileArgs = grammar.compile.flags ++ grammar.compile.args; + grammarLinkArgs = grammar.link.flags ++ grammar.link.args; + }; compile = grammar.compile.command; compile_args = grammar.compile.args; compile_flags = grammar.compile.flags; @@ -225,10 +237,9 @@ in link_args = grammar.link.args ++ [ "-o" "${name}.so" ]; link_flags = grammar.link.flags; }; - queries = { - source.git.url = "${mkGitRepo queries.src}"; - source.git.pin = "${srcName queries.src}"; + queries = rec { path = if queries.path == null then "runtime/queries/${name}" else queries.path; + source.local.path = "${queries.src}/${path}"; }; }; in @@ -249,14 +260,14 @@ in features = cfg.features; language = builtins.mapAttrs toLanguageConf cfg.languages; }; - - onChange = '' - export PATH=$PATH:${lib.getBin pkgs.gcc} - ${cfg.package}/bin/ktsctl sync -a - ''; }; programs.my-kakoune.extraFaces = faces; + programs.my-kakoune.autoloadFile."kak-tree-sitter.kak".text = '' + # Enable kak-tree-sitter + eval %sh{kak-tree-sitter --kakoune -d --server --init $kak_session} + map global normal ": enter-user-mode tree-sitter" + ''; }; } diff --git a/packages/common/nki-kakoune/default.nix b/packages/common/nki-kakoune/default.nix index 4cb34c7..c7d4324 100644 --- a/packages/common/nki-kakoune/default.nix +++ b/packages/common/nki-kakoune/default.nix @@ -1,9 +1,8 @@ { callPackage, kakoune, kakoune-unwrapped, ... }: let lsp = callPackage ./lsp.nix { }; - tree-sitter = callPackage ./tree-sitter { }; rc = (callPackage ./rc.nix { - prependRc = tree-sitter.rc; + # prependRc = tree-sitter.rc; }); in (kakoune.override { @@ -13,7 +12,7 @@ in (callPackage ./kaktex { }) (callPackage ./faces.nix { }) rc - tree-sitter.plugin + # tree-sitter.plugin lsp.plugin ]; }).overrideAttrs (attrs: { @@ -24,7 +23,6 @@ in rm "$out/bin/kak" makeWrapper "${kakoune-unwrapped}/bin/kak" "$out/bin/kak" \ --set KAKOUNE_RUNTIME "$out/share/kak" \ - --suffix PATH ":" "${lsp.extraPaths}" \ - --suffix PATH ":" "${tree-sitter.extraPaths}" + --suffix PATH ":" "${lsp.extraPaths}" ''; }) diff --git a/packages/common/nki-kakoune/kakrc b/packages/common/nki-kakoune/kakrc index dc06ca3..0bc3dc0 100644 --- a/packages/common/nki-kakoune/kakrc +++ b/packages/common/nki-kakoune/kakrc @@ -5,6 +5,7 @@ # set global kts_sky "rgb:6aa622" # Color scheme colorscheme catppuccin-latte +set-face global module "%opt{sapphire}" set global base "default" # Set indentation guides From 139af8729f9a6345d6cbb1775e740d37c26e4f02 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Mon, 7 Oct 2024 22:26:49 +0200 Subject: [PATCH 28/32] Revert tree-sitter --- packages/common/kak-tree-sitter/default.nix | 1 - .../common/kak-tree-sitter/user_config.patch | 129 -------------- packages/common/nki-kakoune/default.nix | 5 +- .../nki-kakoune/tree-sitter/default.nix | 167 ------------------ .../nki-kakoune/tree-sitter/grammars.nix | 120 ------------- 5 files changed, 1 insertion(+), 421 deletions(-) delete mode 100644 packages/common/kak-tree-sitter/user_config.patch delete mode 100644 packages/common/nki-kakoune/tree-sitter/default.nix delete mode 100644 packages/common/nki-kakoune/tree-sitter/grammars.nix diff --git a/packages/common/kak-tree-sitter/default.nix b/packages/common/kak-tree-sitter/default.nix index 69da116..9819e3a 100644 --- a/packages/common/kak-tree-sitter/default.nix +++ b/packages/common/kak-tree-sitter/default.nix @@ -34,7 +34,6 @@ let self.runtime_dir.join("sources").join(url_dir) '') - ./user_config.patch ]; meta.mainProgram = "kak-tree-sitter"; diff --git a/packages/common/kak-tree-sitter/user_config.patch b/packages/common/kak-tree-sitter/user_config.patch deleted file mode 100644 index b2b1b6a..0000000 --- a/packages/common/kak-tree-sitter/user_config.patch +++ /dev/null @@ -1,129 +0,0 @@ -diff --git a/kak-tree-sitter-config/src/lib.rs b/kak-tree-sitter-config/src/lib.rs -index e4edc42..a9c92cb 100644 ---- a/kak-tree-sitter-config/src/lib.rs -+++ b/kak-tree-sitter-config/src/lib.rs -@@ -52,9 +52,13 @@ impl Config { - } - - /// Load the default configuration, the user configuration, and merge both. -- pub fn load_default_user() -> Result { -+ pub fn load_default_user(path: Option>) -> Result { - let mut config = Self::load_default_config()?; -- match UserConfig::load_from_xdg() { -+ let user_config = match path { -+ Some(p) => UserConfig::load(p), -+ None => UserConfig::load_from_xdg(), -+ }; -+ match user_config { - Ok(user_config) => { - config.merge_user_config(user_config)?; - } -@@ -448,7 +452,7 @@ impl UserConfig { - } - - /// Load the configuration from a given path. -- fn load(path: impl AsRef) -> Result { -+ pub fn load(path: impl AsRef) -> Result { - let path = path.as_ref(); - - log::debug!("loading configuration at {path}", path = path.display()); -diff --git a/kak-tree-sitter/src/cli.rs b/kak-tree-sitter/src/cli.rs -index b8102cd..923312c 100644 ---- a/kak-tree-sitter/src/cli.rs -+++ b/kak-tree-sitter/src/cli.rs -@@ -22,6 +22,10 @@ pub struct Cli { - #[clap(short, long)] - pub server: bool, - -+ /// Specify a custom path for the user config. -+ #[clap(short, long)] -+ pub user_config: Option, -+ - /// Try to daemonize, if not already done. - #[clap(short, long)] - pub daemonize: bool, -diff --git a/kak-tree-sitter/src/main.rs b/kak-tree-sitter/src/main.rs -index bee9698..cbd7b39 100644 ---- a/kak-tree-sitter/src/main.rs -+++ b/kak-tree-sitter/src/main.rs -@@ -43,7 +43,7 @@ fn start() -> Result<(), OhNo> { - } - } - -- let config = Config::load_default_user()?; -+ let config = Config::load_default_user(cli.user_config.as_ref())?; - - // inject rc if we start from Kakoune - if cli.kakoune && cli.init.is_some() { -diff --git a/kak-tree-sitter/src/server.rs b/kak-tree-sitter/src/server.rs -index f3b7723..000c81d 100644 ---- a/kak-tree-sitter/src/server.rs -+++ b/kak-tree-sitter/src/server.rs -@@ -73,6 +73,7 @@ impl Server { - log::debug!("creating IO handler"); - let io_handler = IOHandler::new( - config, -+ cli.user_config.clone(), - cli.is_standalone(), - cli.with_highlighting || config.features.highlighting, - resources, -@@ -165,6 +166,7 @@ struct IOHandler { - connections: HashMap, - enqueue_response: EnqueueResponse, - handler: Handler, -+ user_config_path: Option, - } - - impl IOHandler { -@@ -173,6 +175,7 @@ impl IOHandler { - - fn new( - config: &Config, -+ user_config_path: Option, - is_standalone: bool, - with_highlighting: bool, - resources: ServerResources, -@@ -203,6 +206,7 @@ impl IOHandler { - connections, - enqueue_response, - handler, -+ user_config_path, - }) - } - -@@ -450,7 +454,7 @@ impl IOHandler { - } - - fn reload(&mut self) { -- let config = match Config::load_default_user() { -+ let config = match Config::load_default_user(self.user_config_path.as_ref()) { - Ok(config) => config, - Err(err) => { - log::error!("reloading config failed: {err}"); -diff --git a/ktsctl/src/cli.rs b/ktsctl/src/cli.rs -index dfac5c3..09f86f3 100644 ---- a/ktsctl/src/cli.rs -+++ b/ktsctl/src/cli.rs -@@ -11,6 +11,9 @@ pub struct Cli { - #[clap(long)] - pub verbose: bool, - -+ #[clap(short, long)] -+ pub user_config: Option, -+ - #[clap(subcommand)] - pub cmd: Cmd, - } -diff --git a/ktsctl/src/main.rs b/ktsctl/src/main.rs -index f9a3499..f823633 100644 ---- a/ktsctl/src/main.rs -+++ b/ktsctl/src/main.rs -@@ -37,7 +37,7 @@ fn start() -> Result<(), HellNo> { - simple_logger::init_with_level(log::Level::Debug)?; - } - -- let config = Config::load_default_user()?; -+ let config = Config::load_default_user(cli.user_config.as_ref())?; - log::debug!("ktsctl configuration:\n{config:#?}"); - - match cli.cmd { diff --git a/packages/common/nki-kakoune/default.nix b/packages/common/nki-kakoune/default.nix index c7d4324..f4851af 100644 --- a/packages/common/nki-kakoune/default.nix +++ b/packages/common/nki-kakoune/default.nix @@ -1,9 +1,7 @@ { callPackage, kakoune, kakoune-unwrapped, ... }: let lsp = callPackage ./lsp.nix { }; - rc = (callPackage ./rc.nix { - # prependRc = tree-sitter.rc; - }); + rc = (callPackage ./rc.nix { }); in (kakoune.override { plugins = callPackage ./plugins.nix { } @@ -12,7 +10,6 @@ in (callPackage ./kaktex { }) (callPackage ./faces.nix { }) rc - # tree-sitter.plugin lsp.plugin ]; }).overrideAttrs (attrs: { diff --git a/packages/common/nki-kakoune/tree-sitter/default.nix b/packages/common/nki-kakoune/tree-sitter/default.nix deleted file mode 100644 index b94a771..0000000 --- a/packages/common/nki-kakoune/tree-sitter/default.nix +++ /dev/null @@ -1,167 +0,0 @@ -{ lib -, callPackage -, formats -, runCommandLocal -, kak-tree-sitter -, ... -}: -let - utils = callPackage ../utils.nix { }; - grammars = (callPackage ./grammars.nix { }).grammars; - # Highlighter groups to add to the `highlighterGroups`. Maps from group names to face names. - highlighterGroups = { - attribute = "@attribute"; - comment = "@comment"; - conceal = "%opt{mauve}+i"; - constant = "%opt{peach}"; - constant_builtin_boolean = "%opt{sky}"; - constant_character = "%opt{yellow}"; - constant_macro = "%opt{mauve}"; - constant_numeric = "%opt{peach}"; - constructor = "%opt{sapphire}"; - diff_plus = "%opt{green}"; - diff_minus = "%opt{red}"; - diff_delta = "%opt{blue}"; - diff_delta_moved = "%opt{mauve}"; - error = "%opt{red}+b"; - function = "@function"; - function_builtin = "@builtin"; - function_macro = "+i@ts_function"; - hint = "%opt{blue}+b"; - info = "%opt{green}+b"; - keyword = "keyword"; - keyword_conditional = "+i@ts_keyword"; - keyword_control_conditional = "+i@ts_keyword"; - keyword_control_directive = "+i@ts_keyword"; - keyword_control_import = "+i@ts_keyword"; - keyword_directive = "+i@ts_keyword"; - label = "%opt{sapphire}+i"; - markup_bold = "%opt{peach}+b"; - markup_heading = "%opt{red}"; - markup_heading_1 = "%opt{red}"; - markup_heading_2 = "%opt{mauve}"; - markup_heading_3 = "%opt{green}"; - markup_heading_4 = "%opt{yellow}"; - markup_heading_5 = "%opt{pink}"; - markup_heading_6 = "%opt{teal}"; - markup_heading_marker = "%opt{peach}+b"; - markup_italic = "%opt{pink}+i"; - markup_list_checked = "%opt{green}"; - markup_list_numbered = "%opt{blue}+i"; - markup_list_unchecked = "%opt{teal}"; - markup_list_unnumbered = "%opt{mauve}"; - markup_link_label = "%opt{blue}"; - markup_link_url = "%opt{teal}+u"; - markup_link_uri = "%opt{teal}+u"; - markup_link_text = "%opt{blue}"; - markup_quote = "%opt{crust}"; - markup_raw = "%opt{sky}"; - markup_raw_block = "%opt{sky}"; - markup_raw_inline = "%opt{green}"; - markup_strikethrough = "%opt{crust}+s"; - namespace = "@module"; - operator = "@operator"; - property = "%opt{sky}"; - punctuation = "%opt{overlay2}"; - punctuation_special = "%opt{sky}"; - special = "%opt{blue}"; - spell = "%opt{mauve}"; - string = "%opt{green}"; - string_regex = "%opt{peach}"; - string_regexp = "%opt{peach}"; - string_escape = "%opt{mauve}"; - string_special = "%opt{blue}"; - string_special_path = "%opt{green}"; - string_special_symbol = "%opt{mauve}"; - string_symbol = "%opt{red}"; - tag = "%opt{teal}"; - tag_error = "%opt{red}"; - text_title = "%opt{mauve}"; - type = "@type"; - type_enum_variant = "+i@ts_type"; - variable = "@variable"; - variable_builtin = "@builtin"; - variable_other_member = "%opt{teal}"; - variable_parameter = "+i@variable"; - warning = "%opt{peach}+b"; - }; - - # Highlighter groups to be aliased by other groups - aliases = { - comment_block = "comment"; - comment_line = "comment"; - constant_character_escape = "constant_character"; - constant_numeric_float = "constant_numeric"; - constant_numeric_integer = "constant_numeric"; - function_method = "function"; - function_special = "function"; - keyword_control = "keyword"; - keyword_control_repeat = "keyword"; - keyword_control_return = "keyword"; - keyword_control_except = "keyword"; - keyword_control_exception = "keyword"; - keyword_function = "keyword"; - keyword_operator = "keyword"; - keyword_special = "keyword"; - keyword_storage = "keyword"; - keyword_storage_modifier = "keyword"; - keyword_storage_modifier_mut = "keyword"; - keyword_storage_modifier_ref = "keyword"; - keyword_storage_type = "keyword"; - punctuation_bracket = "punctuation"; - punctuation_delimiter = "punctuation"; - text = "string"; - type_builtin = "type"; - - # Scala stuff - method = "function"; - module = "namespace"; - function_call = "function"; - method_call = "method"; - - boolean = "constant_builtin_boolean"; - number = "constant_numeric"; - float = "constant_numeric_float"; - - type_qualifier = "keyword_special"; - storageclass = "keyword_storage_modifier"; - conditional = "keyword_conditional"; - include = "keyword_control_import"; - }; - - configFile = - let - toScm = name: lib.concatStringsSep "." (lib.splitString "_" name); - toml = formats.toml { }; - in - toml.generate "config.toml" { - highlight.groups = builtins.map toScm (builtins.attrNames highlighterGroups ++ builtins.attrNames aliases); - features = { - highlighting = true; - text_objects = true; - }; - language = grammars; - }; - - extraFaces = - let - toTs = name: "ts_${lib.concatStringsSep "_" (lib.splitString "." name)}"; - - definedFaces = lib.mapAttrs' (name: value: { inherit value; name = toTs name; }) highlighterGroups; - aliasFaces = lib.mapAttrs' (name: value: { name = toTs name; value = "@${toTs value}"; }) aliases; - faces = lib.recursiveUpdate definedFaces aliasFaces; - in - faces; -in -{ - rc = '' - # Enable kak-tree-sitter - eval %sh{kak-tree-sitter --kakoune -d --server --init $kak_session --user-config ${configFile}} - map global normal ": enter-user-mode tree-sitter" - ''; - - extraPaths = "${kak-tree-sitter}/bin"; - - plugin = utils.mkFacesScript "kak-tree-sitter" extraFaces; -} - diff --git a/packages/common/nki-kakoune/tree-sitter/grammars.nix b/packages/common/nki-kakoune/tree-sitter/grammars.nix deleted file mode 100644 index d1f6417..0000000 --- a/packages/common/nki-kakoune/tree-sitter/grammars.nix +++ /dev/null @@ -1,120 +0,0 @@ -{ lib, stdenv, fetchFromGitHub, runCommandLocal, ... }: -let - mkGrammarPackage = - { name - , src - , grammarPath ? "src" - , grammarCompileArgs ? [ "-O3" "-c" "-fpic" "../parser.c" "../scanner.c" "-I" ".." ] - , grammarLinkArgs ? [ "-shared" "-fpic" "parser.o" "scanner.o" ] - , ... - }: stdenv.mkDerivation { - inherit src; - name = "kak-tree-sitter-grammar-${name}"; - version = "latest"; - buildPhase = '' - mkdir ${grammarPath}/build - cd ${grammarPath}/build - $CC ${lib.concatStringsSep " " grammarCompileArgs} - $CC ${lib.concatStringsSep " " grammarLinkArgs} -o ${name}.so - ''; - installPhase = '' - mkdir $out - cp ${name}.so $out - ''; - }; - mkGrammar = - args @ { name - , src - , grammarPath ? "src" - , grammarCompileArgs ? [ "-O3" "-c" "-fpic" "../parser.c" "../scanner.c" "-I" ".." ] - , grammarLinkArgs ? [ "-shared" "-fpic" "parser.o" "scanner.o" ] - , querySrc ? src - , queryPath ? "runtime/queries/${name}" - , - }: { - grammar.source.local.path = "${mkGrammarPackage args}"; - grammar.link_args = grammarLinkArgs ++ [ "-o" "${name}.so" ]; - queries.source.local.path = querySrc; - queries.path = queryPath; - }; - - tree-sitter-go = fetchFromGitHub { - owner = "tree-sitter"; - repo = "tree-sitter-go"; - rev = "v0.20.0"; - hash = "sha256-G7d8CHCyKDAb9j6ijRfHk/HlgPqSI+uvkuRIRRvjkHI="; - }; -in -{ - grammars = builtins.mapAttrs (name: value: mkGrammar ({ inherit name; } // value)) { - scala = { - src = fetchFromGitHub { - owner = "tree-sitter"; - repo = "tree-sitter-scala"; - rev = "70afdd5632d57dd63a960972ab25945e353a52f6"; - hash = "sha256-bi0Lqo/Zs2Uaz1efuKAARpEDg5Hm59oUe7eSXgL1Wow="; - }; - queryPath = "queries/scala"; - }; - haskell = { - src = fetchFromGitHub { - owner = "tree-sitter"; - repo = "tree-sitter-haskell"; - rev = "ba0bfb0e5d8e9e31c160d287878c6f26add3ec08"; - hash = "sha256-ZSOF0CLOn82GwU3xgvFefmh/AD2j5zz8I0t5YPwfan0="; - }; - grammarCompileArgs = [ "-O3" "-c" "-fpic" "../parser.c" "../scanner.c" "../unicode.h" "-I" ".." ]; - queryPath = "queries"; - }; - yaml = { - src = fetchFromGitHub { - owner = "ikatyang"; - repo = "tree-sitter-yaml"; - rev = "0e36bed171768908f331ff7dff9d956bae016efb"; - hash = "sha256-bpiT3FraOZhJaoiFWAoVJX1O+plnIi8aXOW2LwyU23M="; - }; - grammarCompileArgs = [ "-c" "-fpic" "../scanner.cc" "../parser.c" "-I" ".." ]; - grammarLinkArgs = [ "-lstdc++" "-shared" "-fpic" "scanner.o" "parser.o" ]; - querySrc = fetchFromGitHub { - owner = "helix-editor"; - repo = "helix"; - rev = "dbd248fdfa680373d94fbc10094a160aafa0f7a7"; - hash = "sha256-wk8qVUDFXhAOi1Ibc6iBMzDCXb6t+YiWZcTd0IJybqc="; - }; - }; - templ = rec { - src = fetchFromGitHub { - owner = "vrischmann"; - repo = "tree-sitter-templ"; - rev = "044ad200092170727650fa6d368df66a8da98f9d"; - hash = "sha256-hJuB3h5pp+LLfP0/7bAYH0uLVo+OQk5jpzJb3J9BNkY="; - }; - querySrc = runCommandLocal "templ-tree-sitter-queries" { } '' - mkdir -p $out/queries - # copy most stuff from tree-sitter-templ - install -m644 ${src}/queries/templ/* $out/queries - # override inherited files - cat ${tree-sitter-go}/queries/highlights.scm ${src}/queries/templ/highlights.scm > $out/queries/highlights.scm - ''; - queryPath = "queries"; - }; - go = { - src = tree-sitter-go; - grammarCompileArgs = [ "-O3" "-c" "-fpic" "../parser.c" "-I" ".." ]; - grammarLinkArgs = [ "-shared" "-fpic" "parser.o" ]; - queryPath = "queries"; - }; - hylo = { - src = fetchFromGitHub { - owner = "natsukagami"; - repo = "tree-sitter-hylo"; - rev = "494cbdff0d13cbc67348316af2efa0286dbddf6f"; - hash = "sha256-R5UeoglCTl0do3VDJ/liCTeqbxU9slvmVKNRA/el2VY="; - }; - grammarCompileArgs = [ "-O3" "-c" "-fpic" "../parser.c" "-I" ".." ]; - grammarLinkArgs = [ "-shared" "-fpic" "parser.o" ]; - queryPath = "queries"; - }; - }; -} - From 89ca51d7e22004d132bd96424c73be6935882793 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Mon, 7 Oct 2024 22:30:13 +0200 Subject: [PATCH 29/32] Further cleanup --- home/common.nix | 2 +- home/{kakoune/kak.nix => kakoune.nix} | 2 +- home/kakoune/autoload/latex.kak | 133 --------------- home/kakoune/autoload/markdown.kak | 29 ---- home/kakoune/catppuccin-latte.kak | 79 --------- home/kakoune/kakrc | 233 -------------------------- home/kakoune/kaktex | 28 ---- home/kakoune/kaktex.nix | 14 -- home/kakoune/source-pwd | 16 -- 9 files changed, 2 insertions(+), 534 deletions(-) rename home/{kakoune/kak.nix => kakoune.nix} (98%) delete mode 100644 home/kakoune/autoload/latex.kak delete mode 100644 home/kakoune/autoload/markdown.kak delete mode 100644 home/kakoune/catppuccin-latte.kak delete mode 100644 home/kakoune/kakrc delete mode 100755 home/kakoune/kaktex delete mode 100644 home/kakoune/kaktex.nix delete mode 100755 home/kakoune/source-pwd diff --git a/home/common.nix b/home/common.nix index 253c8b1..e7eb15b 100644 --- a/home/common.nix +++ b/home/common.nix @@ -2,7 +2,7 @@ { imports = [ - ./kakoune/kak.nix + ./kakoune.nix ./fish/fish.nix ./modules/programs/my-broot.nix ./modules/programs/my-sway diff --git a/home/kakoune/kak.nix b/home/kakoune.nix similarity index 98% rename from home/kakoune/kak.nix rename to home/kakoune.nix index cfd5d6a..1963430 100644 --- a/home/kakoune/kak.nix +++ b/home/kakoune.nix @@ -3,7 +3,7 @@ let in { - imports = [ ../modules/programs/my-kakoune ./kaktex.nix ]; + imports = [ ./modules/programs/my-kakoune ]; home.packages = with pkgs; [ # ctags for peneira diff --git a/home/kakoune/autoload/latex.kak b/home/kakoune/autoload/latex.kak deleted file mode 100644 index 4bb9c9d..0000000 --- a/home/kakoune/autoload/latex.kak +++ /dev/null @@ -1,133 +0,0 @@ -## Author: @natsukagami (https://github.com/natsukagami) -## -## To activate, source the file into kakrc and add: -### require-module latex-kak -## -## NOTE: This overrides , so if you don't like it, remove it. - -# Create a simple begin block, put the cursors in and remove multi-cursor on exit. -define-command -hidden create-begin-block %{ - execute-keys "i\begin{b0}\end{b0}" - execute-keys "b0" - execute-keys -with-hooks -with-maps "c" - hook -once buffer ModeChange .*:normal %{ - execute-keys -with-maps ",gl" - } -} -# Create a begin block with the given parameter as block name. -define-command -params 1 create-begin-block-with %{ - execute-keys "i\begin{b0}\end{b0}" - execute-keys "b0c%arg{1}," - execute-keys "ok" - execute-keys -with-maps "gl" -} -# Create a \param{} block and put the cursor in the middle. -define-command -params 2 -hidden create-delims %{ - execute-keys "i%arg{1}hZa%arg{2}zl" - execute-keys -with-hooks -with-maps "i" -} -define-command -params 1 create-block-with %{ - create-delims "\%arg{1}{" "}" -} - -# The font-menu -declare-user-mode latex-font -## Semantics -map -docstring "Text" global latex-font t ": create-block-with text" -map -docstring "Emphasize (emph)" global latex-font e ": create-block-with emph" -## Shape -map -docstring "Italics (textit)" global latex-font i ": create-block-with textit" -map -docstring "Upright (textup)" global latex-font u ": create-block-with textup" -# map -docstring "Slanted (textsl)" global latex-font S ": create-block-with textsl" -# map -docstring "Swash font (textsw)" global latex-font W ": create-block-with textsw" -# map -docstring "Small caps (textsc)" global latex-font C ": create-block-with textsc" -# Weight -map -docstring "Bold text (textbf)" global latex-font b ": create-block-with textbf" -# map -docstring "Medium bold (textmd)" global latex-font M ": create-block-with textmd" -# map -docstring "Normal (textnormal)" global latex-font N ": create-block-with textnormal" -## Family -# map -docstring "Serif font (textsf)" global latex-font s ": create-block-with textsf" -# map -docstring "Roman text (textrm)" global latex-font r ": create-block-with textrm" -map -docstring "Monospace (texttt)" global latex-font m ": create-block-with texttt" -## Math styles -map -docstring "Math Calligraphic (mathcal)" global latex-font ": create-block-with mathcal" -map -docstring "Math Blackboard (mathbb)" global latex-font ": create-block-with mathbb" -# map -docstring "Math Fraktur (mathfr)" global latex-font ": create-block-with mathfr" -# map -docstring "Math Roman (mathrm)" global latex-font ": create-block-with mathrm" -# map -docstring "Math Italics (mathit)" global latex-font ": create-block-with mathit" -# map -docstring "Math Bold (mathbf)" global latex-font ": create-block-with mathbf" -# map -docstring "Serif font (mathsf)" global latex-font ": create-block-with mathsf" -map -docstring "Math Monospace (mathtt)" global latex-font ": create-block-with mathtt" -map -docstring "Math Fraktur (mathfrak)" global latex-font f ": create-block-with mathfrak" - -# "Insert block" menu -declare-user-mode latex-insert-block -## Common normal text blocks -map -docstring "Unordered list" global latex-insert-block u ": create-begin-block-with itemize" -map -docstring "Ordered list" global latex-insert-block o ": create-begin-block-with enumerate" -## Common math blocks -map -docstring "Theorem" global latex-insert-block t ": create-begin-block-with theorem" -map -docstring "Definition" global latex-insert-block d ": create-begin-block-with definition" -map -docstring "Lemma" global latex-insert-block l ": create-begin-block-with lemma" -map -docstring "Example" global latex-insert-block e ": create-begin-block-with example" -map -docstring "Proof" global latex-insert-block p ": create-begin-block-with proof" -map -docstring "Remark" global latex-insert-block r ": create-begin-block-with remark" -map -docstring "Proposition" global latex-insert-block ": create-begin-block-with proposition" -map -docstring "Corollary" global latex-insert-block C ": create-begin-block-with corollary" -## Common environments -map -docstring "align*" global latex-insert-block a ": create-begin-block-with align*" -map -docstring "align" global latex-insert-block ": create-begin-block-with align" -map -docstring "equation" global latex-insert-block E ": create-begin-block-with equation" -map -docstring "equation*" global latex-insert-block ": create-begin-block-with equation*" -map -docstring "Matrix" global latex-insert-block m ": create-begin-block-with bmatrix" -map -docstring "Cases" global latex-insert-block C ": create-begin-block-with cases" -map -docstring "Table" global latex-insert-block T ": create-begin-block-with tabular" -## Custom -map -docstring "Custom" global latex-insert-block c ": create-begin-block" - -# Pairs of delimiters -declare-user-mode latex-insert-delims -map -docstring "Grouping" global latex-insert-delims g ": create-delims { }" -map -docstring "Parentheses" global latex-insert-delims p ": create-delims ( )" -map -docstring "Large Parentheses" global latex-insert-delims P ": create-delims \left( \right)" -map -docstring "Brackets" global latex-insert-delims b ": create-delims \left[ \right]" -map -docstring "Sets" global latex-insert-delims s ": create-delims \{ \}" -map -docstring "Large Sets" global latex-insert-delims S ": create-delims \left\{ \right\}" - - -hook global WinSetOption filetype=(tex|latex) %{ - ## Create delims (shortcuts) - map buffer normal ": enter-user-mode latex-insert-delimsp" - map buffer insert ": enter-user-mode latex-insert-delimsp" - map buffer normal ": enter-user-mode latex-insert-delimsg" - map buffer insert ": enter-user-mode latex-insert-delimsg" - map buffer normal "i\(\)Zhhi" - map buffer insert "\(\)Z2h" - map buffer normal "i\[\]Zhhi" - map buffer insert "\[\]Z2h" - map buffer normal ": enter-user-mode latex-insert-delims" - map buffer insert ": enter-user-mode latex-insert-delims" - - ## Quickly create begin/end blocks - map buffer normal ": create-begin-block" - map buffer insert ": create-begin-block" - - ## Font menu - map buffer normal ": enter-user-mode latex-font" - map buffer insert ": enter-user-mode latex-font" - - ## Insert menu - map buffer normal ": enter-user-mode latex-insert-block" - map buffer insert ": enter-user-mode latex-insert-block" - - ## Select math equations and environment blocks - map buffer object e -docstring "Inline Math equation \( \)" "c\\\\\\(,\\\\\\)" - map buffer object E -docstring "Display Math equation \[ \]" "c\\\\\\[,\\\\\\]" - map buffer object v -docstring "Simple environment \env{}" "c\\\\\\w+\\{,\\}" - map buffer object V -docstring "Full environment \begin{env}\end{env}" "c\\\\begin\\{\\w+\\}(?:\\{[\\w\\s]*\\})*(?:\\[[\\w\\s]*\\])*,\\\\end\\{\\w+\\}" - - ## Quickly get a new item - map buffer normal "o\item " - map buffer insert "o\item " -} - diff --git a/home/kakoune/autoload/markdown.kak b/home/kakoune/autoload/markdown.kak deleted file mode 100644 index fb10581..0000000 --- a/home/kakoune/autoload/markdown.kak +++ /dev/null @@ -1,29 +0,0 @@ -hook global WinSetOption filetype=(markdown) %{ - map buffer normal ": enter-user-mode markdown-menu" -} - -# A menu for common markdown actions -declare-user-mode markdown-menu - -map -docstring "Toggle the checkboxes on the same line" global markdown-menu t ": markdown-toggle-checkbox" - -define-command -hidden markdown-toggle-checkbox %{ - try %{ - execute-keys -draft "xs^\s*- \[( |x)\]h: markdown-toggle-checkbox-selections" - } -} - -define-command -hidden markdown-toggle-checkbox-selections %{ - try %{ - execute-keys -draft -itersel ": markdown-toggle-checkbox-one" - } -} - -define-command -hidden markdown-toggle-checkbox-one %{ - try %{ - execute-keys -draft "sxr " - } catch %{ - execute-keys -draft "s rx" - } -} - diff --git a/home/kakoune/catppuccin-latte.kak b/home/kakoune/catppuccin-latte.kak deleted file mode 100644 index bd40ead..0000000 --- a/home/kakoune/catppuccin-latte.kak +++ /dev/null @@ -1,79 +0,0 @@ -# Catppuccin theme for Kakoune - -declare-option str rosewater "rgb:dc8a78" -declare-option str flamingo "rgb:dd7878" -declare-option str pink "rgb:ea76cb" -declare-option str mauve "rgb:8839ef" -declare-option str red "rgb:d20f39" -declare-option str maroon "rgb:e64553" -declare-option str peach "rgb:fe640b" -declare-option str yellow "rgb:df8e1d" -declare-option str green "rgb:40a02b" -declare-option str teal "rgb:179299" -declare-option str sky "rgb:04a5e5" -declare-option str sapphire "rgb:209fb5" -declare-option str blue "rgb:1e66f5" -declare-option str lavender "rgb:7287fd" -declare-option str text "rgb:4c4f69" -declare-option str subtext1 "rgb:5c5f77" -declare-option str subtext0 "rgb:6c6f85" -declare-option str overlay2 "rgb:7c7f93" -declare-option str overlay1 "rgb:8c8fa1" -declare-option str overlay0 "rgb:9ca0b0" -declare-option str surface2 "rgb:acb0be" -declare-option str surface1 "rgb:bcc0cc" -declare-option str surface0 "rgb:ccd0da" -declare-option str base "rgb:eff1f5" -declare-option str mantle "rgb:e6e9ef" -declare-option str crust "rgb:dce0e8" - - -set-face global title "%opt{text}+b" -set-face global header "%opt{subtext0}+b" -set-face global bold "%opt{maroon}+b" -set-face global italic "%opt{maroon}+i" -set-face global mono "%opt{green}" -set-face global block "%opt{sapphire}" -set-face global link "%opt{blue}" -set-face global bullet "%opt{peach}" -set-face global list "%opt{peach}" - -set-face global Default "%opt{text},%opt{base}" -set-face global PrimarySelection "%opt{text},%opt{surface2}" -set-face global SecondarySelection "%opt{text},%opt{surface2}" -set-face global PrimaryCursor "%opt{crust},%opt{rosewater}" -set-face global SecondaryCursor "%opt{text},%opt{overlay0}" -set-face global PrimaryCursorEol "%opt{surface2},%opt{lavender}" -set-face global SecondaryCursorEol "%opt{surface2},%opt{overlay1}" -set-face global LineNumbers "%opt{overlay1},%opt{base}" -set-face global LineNumberCursor "%opt{rosewater},%opt{surface2}+b" -set-face global LineNumbersWrapped "%opt{rosewater},%opt{surface2}+i" -set-face global MenuForeground "%opt{text},%opt{surface1}+b" -set-face global MenuBackground "%opt{text},%opt{surface0}" -set-face global MenuInfo "%opt{crust},%opt{teal}" -set-face global Information "%opt{crust},%opt{teal}" -set-face global Error "%opt{crust},%opt{red}" -set-face global StatusLine "%opt{text},%opt{mantle}" -set-face global StatusLineMode "%opt{crust},%opt{yellow}" -set-face global StatusLineInfo "%opt{crust},%opt{teal}" -set-face global StatusLineValue "%opt{crust},%opt{yellow}" -set-face global StatusCursor "%opt{crust},%opt{rosewater}" -set-face global Prompt "%opt{teal},%opt{base}+b" -set-face global MatchingChar "%opt{maroon},%opt{base}" -set-face global Whitespace "%opt{overlay1},%opt{base}+f" -set-face global WrapMarker "Whitespace" -set-face global BufferPadding "%opt{base},%opt{base}" - -set-face global value "%opt{peach}" -set-face global type "%opt{blue}" -set-face global variable "%opt{text}" -set-face global module "%opt{maroon}" -set-face global function "%opt{blue}" -set-face global string "%opt{green}" -set-face global keyword "%opt{mauve}" -set-face global operator "%opt{sky}" -set-face global attribute "%opt{green}" -set-face global comment "%opt{overlay0}" -set-face global documentation "comment" -set-face global meta "%opt{yellow}" -set-face global builtin "%opt{red}" diff --git a/home/kakoune/kakrc b/home/kakoune/kakrc deleted file mode 100644 index c254669..0000000 --- a/home/kakoune/kakrc +++ /dev/null @@ -1,233 +0,0 @@ -# Enable kak-tree-sitter -eval %sh{test -z "$WE_STARTED_KAK" && kak-tree-sitter --kakoune -d --server --init $kak_session} -map global normal ": enter-user-mode tree-sitter" -# ## Set some color overrides -# set global kts_yellow "rgb:e2b75e" -# set global kts_teal "rgb:008080" -# set global kts_mauve "rgb:c264ff" -# set global kts_sky "rgb:6aa622" -# Color scheme -colorscheme catppuccin-latte -set global base "default" - -# Set indentation guides -add-highlighter global/indent-guides show-whitespaces -tab " " -spc " " -lf " " -nbsp " " -set-face global Whitespace default,default -set-face global WhitespaceIndent +d@comment - -# Assistant -set global ui_options terminal_assistant=cat - -# Enable line numbers -hook global WinCreate .* %{ - addhl window/number-lines number-lines -} - -set global grepcmd "rg --line-number --no-column --no-heading --color=never " - -# Kitty-specific options -hook -group windowing global KakBegin .* %{ - set global kitty_window_type os-window -} - -# Comment line and block -map global normal <#> ': comment-line' -map global normal ': comment-block' - -# Go to grep-jump -map global goto f -docstring "current grep-jump match" ': grep-jump' - -# System clipboard interactions -hook global RegisterModified '"' %{ nop %sh{ - printf "%s" "$kak_main_reg_dquote" | pbcopy >/dev/null 2>/dev/null & -}} -map global user P -docstring "Paste before cursor from clipboard" '! pbpaste -n | cat' -map global user p -docstring "Paste after cursor from clipboard" ' pbpaste -n | cat' -map global user R -docstring "Replace selection with text from clipboard" '! pbpaste -n | cat' -define-command -params 0 -docstring "Copy line down" copyline %{ - execute-keys -draft 'xy'%val{count}'P' -} -map global normal <+> -docstring "Copy line down" ': copyline' -define-command -params 0 -docstring "Delete current pair of brackets" delete-current-brackets %{ - execute-keys 'm' - execute-keys -draft 'd' - execute-keys 'H' -} -map global normal D ": delete-current-brackets" - -# Disable write-to -# unalias global w -# define-command -params 0 -docstring "Writes the current file" w "write" - -# Tab sizes -hook global InsertChar \t %{ exec -draft -itersel h@ } -set global tabstop 2 -set global indentwidth 2 - -# Language-specific tabstop with override -hook global WinSetOption filetype=(rust) %{ - set window tabstop 4 - set window indentwidth 4 -} - -# Ctrl + a in insert mode = esc -map global insert '' - -# Tab completion -hook global InsertCompletionShow .* %{ - try %{ - # this command temporarily removes cursors preceded by whitespace; - # if there are no cursors left, it raises an error, does not - # continue to execute the mapping commands, and the error is eaten - # by the `try` command so no warning appears. - execute-keys -draft 'h\h' - map window insert - map window insert - } -} -hook global InsertCompletionHide .* %{ - unmap window insert - unmap window insert -} - -# Enable LSP -try %{ - eval %sh{test -z "$WE_STARTED_KAK" && kak-lsp --kakoune -s $kak_session} - set-option global lsp_cmd "kak-lsp -s %val{session}" -} -hook global WinSetOption filetype=(racket|rust|python|go|javascript|typescript|c|cpp|tex|latex|fsharp|ocaml|haskell|nix|scala|typst|html|css|json|markdown|templ|elixir) %{ - lsp-enable-window - map window lsp N -docstring "Display the next message request" ": lsp-show-message-request-next" - map window normal ": enter-user-mode lsp" - map window normal ": lsp-hover" - map window normal ": lsp-hover-buffer" - # lsp-auto-hover-insert-mode-enable - set window lsp_hover_anchor true - map global insert ':try lsp-snippets-select-next-placeholders catch %{ execute-keys -with-hooks tab> }' -docstring 'Select next snippet placeholder' - map global object a 'lsp-object' -docstring 'LSP any symbol' - map global object 'lsp-object' -docstring 'LSP any symbol' - map global object f 'lsp-object Function Method' -docstring 'LSP function or method' - map global object t 'lsp-object Class Interface Struct' -docstring 'LSP class interface or struct' - map global object d 'lsp-diagnostic-object --include-warnings' -docstring 'LSP errors and warnings' - map global object D 'lsp-diagnostic-object' -docstring 'LSP errors' -} - -hook global WinSetOption filetype=(racket|rust|python|go|javascript|typescript|c|cpp|tex|latex|haskell|nix|fsharp|templ) %{ - # Format the document if possible - hook window BufWritePre .* %{ lsp-formatting-sync } -} - -hook global WinSetOption filetype=(rust|scala|fsharp) %{ - # Enable inlay hints - lsp-inlay-hints-enable window -} - -hook global WinSetOption filetype=(rust|go|fsharp|typst|scala) %{ - hook window -group semantic-tokens BufReload .* lsp-semantic-tokens - hook window -group semantic-tokens NormalIdle .* lsp-semantic-tokens - hook window -group semantic-tokens InsertIdle .* lsp-semantic-tokens - hook -once -always window WinSetOption filetype=.* %{ - remove-hooks window semantic-tokens - } -} - -# in Insert mode moves to end of line. -map global insert 'A' - -hook global WinSetOption filetype=(fsharp) %{ - set-option window comment_line "//" - # Set up formatting - # set-option window formatcmd "~/.dotnet/tools/fantomas --stdin --stdout" - # hook window -group fsharp-format BufWritePre .* %{ format } -} - -hook global WinSetOption filetype=(ocaml) %{ - unset-option buffer comment_line - set-option buffer comment_block_begin "(*" - set-option buffer comment_block_end "*)" -} - -hook global WinSetOption filetype=(haskell) %{ - set-option buffer makecmd "cabal build" -} - -hook global WinSetOption filetype=(rust) %{ - set-option buffer makecmd "cargo check" -} - -hook global WinSetOption filetype=(scala) %{ - # Format the document if possible - hook -group scala-fmt window BufWritePre .* %{ lsp-formatting-sync } -} - -hook global WinSetOption filetype=(typst) %{ - set-option window comment_line "//" - set-option window comment_block_begin "/*" - set-option window comment_block_end "*/" - - # borrow markdown's hooks - require-module markdown - - hook window ModeChange pop:insert:.* -group markdown-trim-indent markdown-trim-indent - hook window InsertChar \n -group markdown-insert markdown-insert-on-new-line - hook window InsertChar \n -group markdown-indent markdown-indent-on-new-line - hook -once -always window WinSetOption filetype=.* %{ remove-hooks window markdown-.+ } -} - - -define-command -params 0 -docstring "Set up build" scala-build-connect %{ - lsp-execute-command 'build-connect' '"[]"' -} - -define-command -params 0 -docstring "Import build" scala-build-import %{ - lsp-execute-command 'build-import' '"[]"' -} - -def -hidden insert-c-n %{ - try %{ - lsp-snippets-select-next-placeholders - exec 'd' - } catch %{ - exec -with-hooks '' - } -} -map global insert ": insert-c-n" - -# Use C++ for .h headers -hook global BufCreate .*[.](h) %{ - set-option buffer filetype cpp -} - -hook global BufCreate .*[.]kakrc %{ - set-option buffer filetype kak -} - -hook global BufCreate .*[.]md %{ - add-highlighter buffer/ wrap -} - -hook global BufCreate .*[.](sc|sbt) %{ - set-option buffer filetype scala -} - -hook global BufCreate .*[.]typ %{ - set-option buffer filetype typst - add-highlighter buffer/ wrap -} - -hook global BufCreate .*[.]templ %{ - set-option buffer filetype templ - set-option buffer comment_line "//" -} - -hook global BufCreate .*[.]hylo %{ - set-option buffer filetype hylo - set-option buffer comment_line "//" -} - -hook global BufOpenFile .* %{ - modeline-parse -} - -map global normal ':inc-dec-modify-numbers + %val{count}' -map global normal ':inc-dec-modify-numbers - %val{count}' diff --git a/home/kakoune/kaktex b/home/kakoune/kaktex deleted file mode 100755 index bdcf722..0000000 --- a/home/kakoune/kaktex +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env fish - -function usage - echo "Usage: " - echo " kaktex set [client] [session]" - echo " kaktex jump [file] [line] [column]" - exit 1 -end - -if test (count $argv) -lt 3 - usage -end - -switch $argv[1] - case "set" - set -U _kaktex_client $argv[2] - set -U _kaktex_session $argv[3] - case "jump" - echo " - evaluate-commands -client $_kaktex_client %{ - evaluate-commands -try-client $_kaktex_client %{ - edit -existing -- $argv[2] $(math $argv[3] + 1) $(math $argv[4] + 1) - } - } - " | kak -p $_kaktex_session - case '*' - usage -end diff --git a/home/kakoune/kaktex.nix b/home/kakoune/kaktex.nix deleted file mode 100644 index 1256c79..0000000 --- a/home/kakoune/kaktex.nix +++ /dev/null @@ -1,14 +0,0 @@ -{ config, pkgs, lib, ... }: - -{ - # Source kaktex whenever we have a tex file - programs.my-kakoune.rc = '' - hook global WinSetOption filetype=(tex|latex) %{ - hook window WinDisplay '.*' %{ - eval %sh{ - ${./kaktex} set $kak_client $kak_session - } - } - } - ''; -} diff --git a/home/kakoune/source-pwd b/home/kakoune/source-pwd deleted file mode 100755 index 35e5b0f..0000000 --- a/home/kakoune/source-pwd +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env fish - -if test (pwd) = "/home/natsukagami/.config/kak" - exit 0 -end - -while true - set kakrc (pwd)/.kakrc - if test -f $kakrc - echo source $kakrc - end - if test (pwd) = "/" - exit 0 - end - cd .. -end From 75b3f8d1f4c296c0ffa58cc2e650a12c122bd4b4 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Tue, 22 Oct 2024 15:36:22 +0200 Subject: [PATCH 30/32] podman: add slirp4netns to the wrapper --- modules/common/linux/default.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/common/linux/default.nix b/modules/common/linux/default.nix index 2fae826..91c37ab 100644 --- a/modules/common/linux/default.nix +++ b/modules/common/linux/default.nix @@ -71,6 +71,7 @@ let virtualisation = { pkgs, ... }: mkIf cfg.enable { virtualisation.podman = { enable = true; + extraPackages = [ pkgs.slirp4netns ]; dockerCompat = true; defaultNetwork.settings.dns_enabled = true; }; From 75f8ce74c5fa91af40f7860c18edba732e2097ea Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Mon, 4 Nov 2024 14:48:54 +0100 Subject: [PATCH 31/32] Update templ and vscode langservers --- home/kakoune.nix | 4 ++-- packages/common/nki-kakoune/lsp.nix | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/home/kakoune.nix b/home/kakoune.nix index 1963430..5e10869 100644 --- a/home/kakoune.nix +++ b/home/kakoune.nix @@ -98,8 +98,8 @@ in src = pkgs.fetchFromGitHub { owner = "vrischmann"; repo = "tree-sitter-templ"; - rev = "044ad200092170727650fa6d368df66a8da98f9d"; - hash = "sha256-hJuB3h5pp+LLfP0/7bAYH0uLVo+OQk5jpzJb3J9BNkY="; + rev = "4519e3ec9ca92754ca25659bb1fd410d5e0f8d88"; + hash = "sha256-ic5SlqDEZoYakrJFe0H9GdzravqovlL5sTaHjyhe74M="; }; in { diff --git a/packages/common/nki-kakoune/lsp.nix b/packages/common/nki-kakoune/lsp.nix index 6511ee9..82f0b51 100644 --- a/packages/common/nki-kakoune/lsp.nix +++ b/packages/common/nki-kakoune/lsp.nix @@ -39,8 +39,8 @@ let command = "vscode-${name}-language-server"; filetypes = [ name "templ" ]; roots = [ "package.json" ".git" ]; + package = nodePackages.vscode-langservers-extracted; }; - package = nodePackages.vscode-langservers-extracted; }; in { From 1f7294581f367736da4cc436c07bf8dd49ea4905 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Mon, 18 Nov 2024 15:31:38 +0100 Subject: [PATCH 32/32] Remove vulkan fork patch --- overlay.nix | 7 ------- 1 file changed, 7 deletions(-) diff --git a/overlay.nix b/overlay.nix index 75da770..d5f72de 100644 --- a/overlay.nix +++ b/overlay.nix @@ -87,13 +87,6 @@ let }) ]; }; - - # https://github.com/NixOS/nixpkgs/issues/334822 - vulkan-validation-layers = prev.vulkan-validation-layers.overrideAttrs (attrs: { - buildInputs = attrs.buildInputs ++ [ - final.spirv-tools - ]; - }); }; overlay-libs = final: prev: {