fix: tres not available in a nix environment. (#855)

This commit is contained in:
Álan Crístoffer 2022-12-29 19:36:38 +01:00 committed by GitHub
parent aabdb0c6ec
commit c6d74dbca5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 35 additions and 14 deletions

View File

@ -92,7 +92,9 @@ pub fn build(b: *std.build.Builder) !void {
const known_folders_path = b.option([]const u8, "known-folders", "Path to known-folders package (default: " ++ KNOWN_FOLDERS_DEFAULT_PATH ++ ")") orelse KNOWN_FOLDERS_DEFAULT_PATH; const known_folders_path = b.option([]const u8, "known-folders", "Path to known-folders package (default: " ++ KNOWN_FOLDERS_DEFAULT_PATH ++ ")") orelse KNOWN_FOLDERS_DEFAULT_PATH;
exe.addPackage(.{ .name = "known-folders", .source = .{ .path = known_folders_path } }); exe.addPackage(.{ .name = "known-folders", .source = .{ .path = known_folders_path } });
exe.addPackage(.{ .name = "tres", .source = .{ .path = "src/tres/tres.zig" } }); const TRES_DEFAULT_PATH = "src/tres/tres.zig";
const tres_path = b.option([]const u8, "tres", "Path to tres package (default: " ++ TRES_DEFAULT_PATH ++ ")") orelse TRES_DEFAULT_PATH;
exe.addPackage(.{ .name = "tres", .source = .{ .path = tres_path } });
if (enable_tracy) { if (enable_tracy) {
const client_cpp = "src/tracy/TracyClient.cpp"; const client_cpp = "src/tracy/TracyClient.cpp";
@ -148,7 +150,7 @@ pub fn build(b: *std.build.Builder) !void {
} }
tests.addPackage(.{ .name = "zls", .source = .{ .path = "src/zls.zig" }, .dependencies = exe.packages.items }); tests.addPackage(.{ .name = "zls", .source = .{ .path = "src/zls.zig" }, .dependencies = exe.packages.items });
tests.addPackage(.{ .name = "tres", .source = .{ .path = "src/tres/tres.zig" } }); tests.addPackage(.{ .name = "tres", .source = .{ .path = tres_path } });
tests.setBuildMode(.Debug); tests.setBuildMode(.Debug);
tests.setTarget(target); tests.setTarget(target);
test_step.dependOn(&tests.step); test_step.dependOn(&tests.step);

View File

@ -68,11 +68,11 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1670086663, "lastModified": 1672057183,
"narHash": "sha256-hT8C8AQB74tdoCPwz4nlJypLMD7GI2F5q+vn+VE/qQk=", "narHash": "sha256-GN7/10DNNvs1FPj9tlZA2qgNdFuYKKuS3qlHTqAxasQ=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "813836d64fa57285d108f0dbf2356457ccd304e3", "rev": "b139e44d78c36c69bcbb825b20dbfa51e7738347",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -88,9 +88,26 @@
"gitignore": "gitignore", "gitignore": "gitignore",
"known-folders": "known-folders", "known-folders": "known-folders",
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs",
"tres": "tres",
"zig-overlay": "zig-overlay" "zig-overlay": "zig-overlay"
} }
}, },
"tres": {
"flake": false,
"locked": {
"lastModified": 1672008284,
"narHash": "sha256-AtM9SV56PEud1MfbKDZMU2FlsNrI46PkcFQh3yMcDX0=",
"owner": "ziglibs",
"repo": "tres",
"rev": "16774b94efa61757a5302a690837dfb8cf750a11",
"type": "github"
},
"original": {
"owner": "ziglibs",
"repo": "tres",
"type": "github"
}
},
"zig-overlay": { "zig-overlay": {
"inputs": { "inputs": {
"flake-utils": "flake-utils_2", "flake-utils": "flake-utils_2",
@ -99,11 +116,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1670113356, "lastModified": 1672142864,
"narHash": "sha256-43aMRMU0OuBin6M2LM+nxVG+whazyHuHnUvu92xoth0=", "narHash": "sha256-uXljuSZK8DP5c4o9u+gcF+Yc3dKYH1wsHmDpWcFBVRQ=",
"owner": "mitchellh", "owner": "mitchellh",
"repo": "zig-overlay", "repo": "zig-overlay",
"rev": "17352071583eda4be43fa2a312f6e061326374f7", "rev": "16e9191142d2a13d7870c03e500842321a466a74",
"type": "github" "type": "github"
}, },
"original": { "original": {

View File

@ -12,9 +12,12 @@
known-folders.url = "github:ziglibs/known-folders"; known-folders.url = "github:ziglibs/known-folders";
known-folders.flake = false; known-folders.flake = false;
tres.url = "github:ziglibs/tres";
tres.flake = false;
}; };
outputs = { self, nixpkgs, zig-overlay, gitignore, flake-utils, known-folders }: outputs = { self, nixpkgs, zig-overlay, gitignore, flake-utils, known-folders, tres }:
let let
systems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ]; systems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
inherit (gitignore.lib) gitignoreSource; inherit (gitignore.lib) gitignoreSource;
@ -35,7 +38,7 @@
dontInstall = true; dontInstall = true;
buildPhase = '' buildPhase = ''
mkdir -p $out mkdir -p $out
zig build install -Dcpu=baseline -Drelease-safe=true -Ddata_version=master -Dknown-folders=${known-folders}/known-folders.zig --prefix $out zig build install -Dcpu=baseline -Drelease-safe=true -Ddata_version=master -Dtres=${tres}/tres.zig -Dknown-folders=${known-folders}/known-folders.zig --prefix $out
''; '';
XDG_CACHE_HOME = ".cache"; XDG_CACHE_HOME = ".cache";
}; };

View File

@ -24,7 +24,7 @@ const ComptimeInterpreter = @import("ComptimeInterpreter.zig");
const data = @import("data/data.zig"); const data = @import("data/data.zig");
const snipped_data = @import("data/snippets.zig"); const snipped_data = @import("data/snippets.zig");
const tres = @import("tres/tres.zig"); const tres = @import("tres");
const log = std.log.scoped(.server); const log = std.log.scoped(.server);
@ -188,7 +188,7 @@ fn generateDiagnostics(server: *Server, handle: DocumentStore.Handle) !types.Pub
defer tracy_zone.end(); defer tracy_zone.end();
std.debug.assert(server.client_capabilities.supports_publish_diagnostics); std.debug.assert(server.client_capabilities.supports_publish_diagnostics);
const tree = handle.tree; const tree = handle.tree;
var allocator = server.arena.allocator(); var allocator = server.arena.allocator();
@ -1885,7 +1885,7 @@ fn openDocumentHandler(server: *Server, notification: types.DidOpenTextDocumentP
defer tracy_zone.end(); defer tracy_zone.end();
const handle = try server.document_store.openDocument(notification.textDocument.uri, notification.textDocument.text); const handle = try server.document_store.openDocument(notification.textDocument.uri, notification.textDocument.text);
if (server.client_capabilities.supports_publish_diagnostics) { if (server.client_capabilities.supports_publish_diagnostics) {
const diagnostics = try server.generateDiagnostics(handle); const diagnostics = try server.generateDiagnostics(handle);
server.sendNotification("textDocument/publishDiagnostics", diagnostics); server.sendNotification("textDocument/publishDiagnostics", diagnostics);
@ -2128,7 +2128,6 @@ fn hoverHandler(server: *Server, request: types.HoverParams) !?types.Hover {
else => null, else => null,
}; };
// TODO: Figure out a better solution for comptime interpreter diags // TODO: Figure out a better solution for comptime interpreter diags
if (server.client_capabilities.supports_publish_diagnostics) { if (server.client_capabilities.supports_publish_diagnostics) {
const diagnostics = try server.generateDiagnostics(handle.*); const diagnostics = try server.generateDiagnostics(handle.*);