https://kristoff.it/blog/improving-your-zls-experience/
i use vscode, and i already have the build on save option enabled. does this article do anything different?
#Build on save not working
1 messages · Page 1 of 1 (latest)
This creates another step that ends up using -fno-emit-bin. That makes the build much quicker since there’s no need to call llvm
ok, so it is slighty better
i dont have a config for zls. do i just create one in the same location as the exe?
Iirc you run zls --show-config-location
i ran it, and the config just doesnt exist
VSCode might have some interface for it though. Probably use that if it’s a thing
If none of that’s a thing, try zls env. That should show where zls will look for the config
Docs say zls env will show you where zls looks
Yeah, so use the VSCode interface since it’s there
zls env isnt a valid command
Oh it’s since 0.14.0-dev.50+3354fdcb, sorry
typing in zig build -h shows the step
Try running the step yourself
it works when i run it myself
Build on save not working
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const exe = b.addExecutable(.{
.name = "hello_world",
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
});
b.installArtifact(exe);
const run_cmd = b.addRunArtifact(exe);
run_cmd.step.dependOn(b.getInstallStep());
if (b.args) |args| {
run_cmd.addArgs(args);
}
const run_step = b.step("run", "Run the app");
run_step.dependOn(&run_cmd.step);
const exe_unit_tests = b.addTest(.{
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
});
const run_exe_unit_tests = b.addRunArtifact(exe_unit_tests);
const test_step = b.step("test", "Run unit tests");
test_step.dependOn(&run_exe_unit_tests.step);
// check step
const exe_check = b.addExecutable(.{
.name = "hello_world",
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
});
const check = b.step("check", "Check if program compiles without invoking llvm");
check.dependOn(&exe_check.step);
}
this is the build script, in case that helps
what does the Zig Language Sever output panel say
also why did u make the build on save step "install" instead of "check"
i didnt, i was just showing them it exists
i changed it to check
install is just the default
restarting the server does not do anything either
tf is this?
const std = @import("std");
fn m(x: anytype) void {
std.debug.print("{d}", .{x.len});
}
pub fn main() !void {
m(100);
}
not at all
i removed the check function
fuck it, clean reinstall of zls
i’m still struggling with this, if anyone has any tips, please @ me
take a look at this zls hack I did, give it a try: https://github.com/Syndica/sig/blob/main/build.zig
the makeZlsNotInstallAnythingDuringBuildOnSave thing
this is how we avoid emitting the binary proper with little editing of the core build.zig logic
also see the zls json file
i am using vscode, this is what i get
info : ( main ): Starting ZLS 0.13.0 @ 'c:\Users\radei\AppData\Roaming\Code\User\globalStorage\ziglang.vscode-zig\zls_install\zls.exe'
info : (server): Client is 'Visual Studio Code-1.91.1'
info : (server): No config file zls.json found. This is not an error.
info : (server): Set config option 'builtin_path' to 'C:\Users\radei\AppData\Local\Temp\zls\builtin.zig'
info : (server): Set config option 'zig_lib_path' to 'C:\dev\zig-windows-x86_64-0.13.0\lib'
info : (server): Set config option 'zig_exe_path' to 'C:\dev\zig-windows-x86_64-0.13.0\zig.exe'
info : (server): Set config option 'build_runner_path' to 'C:\Users\radei\AppData\Local\Temp\zls\build_runner\21872970afd69e48a0847077e5196711\build_runner.zig'
info : (server): Set config option 'global_cache_path' to 'C:\Users\radei\AppData\Local\Temp\zls'
info : (server): Set config option 'enable_argument_placeholders' to 'false'
info : (server): Set config option 'enable_build_on_save' to 'true'
info : (server): Set config option 'build_on_save_step' to 'check'
info : (server): Set config option 'semantic_tokens' to 'partial'
info : (server): Set config option 'warn_style' to 'true'
info : (server): Set config option 'zig_exe_path' to 'C:\dev\zig-windows-x86_64-0.13.0\zig.EXE'
info : (server): Set config option 'enable_build_on_save' to 'true'
info : (server): Set config option 'build_on_save_step' to 'check'
it seems to recognize the change
is there any other log i can check? this is just the vscode output terminal
nope, but ive never seen it do that when it was working before
also, this should be check, is it?
yup, that was changed. i was just showing them the setting exists
what's the current code you are testing on, still this?
const std = @import("std");
fn m(x: anytype) void {
std.debug.print("{d}", .{x.len});
}
pub fn main() !void {
const x = @as(u32, -1);
_ = x;
m(100);
}
pretty much the same
the problem is, idk if it is a vscode issue or a zls issue
try something inline just to be sure, ie _ = x.len;
probably won't change anything
but best to rule out the possibility
nothing
there might well be a vscode setting you need to enable
because afaict this should be working
quick check: what's your OS
do you have any antivirus, and if so, have you given behaviour exceptions to both zig and zls
i do, but its one my school forces me to download. i dont think it does anything
Sentinel One
i know nothing about it, i was required to download it because my schooll network requires it or some bs like that
Cyber Vigilance
Path Exclusion is a feature in SentinelOne that allows an administrator to suppress false positive events originating from specific files and processes. It also enables an administrator to exclude a path or file from monitoring where there are any interoperability issues. The exclusion also applies to processes whose route process is in the excl...
all it does is give me warnings when i run cmake
I would add zig and zls to the exclusion paths to be sure
and mayhaps your entire dev directory
clangd works fine (another lsp) but ill try that
clangd is probably recognized/signed software
hmmmmm
lol
i cant even find the setting to do this
this is all that shows
even when running as an admin
just to check, I know the log said it is, but is zls --version 0.13?
yup, it is 0.13.0
what does the install dir for the vscode zls look like
Directory: C:\Users\radei\AppData\Roaming\Code\User\globalStorage\ziglang.vscode-zig\zls_install
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 7/26/2024 8:32 PM 3366912 zls.exe
just the exe
not even a config, which is weird
im relying on vscode's config
wait a sec, is that the same as the one in your path?
run that zls.exe
with --version
zls is not set on my path, vs code sets the path of zls
I see
wait lemme check my path, maybe i did put it on the path and forgot
yeah its not there, its just set by vscode
honestly haven't the foggiest clue what could be going wrong
my last hunch is that zls 0.13.0 is just broken on windows
doesnt vscode have a place to put flags/options for zls?
if you wanna try confirming that, try downgrading to 0.12.0
and see if that suddenly makes it work
yeah vscode has a json config
ill try that
very annoying, I know
still not working
well damn
i changed the path of zls in the settings to the 0.12 version
this is smelling like a vscode thing?
i think so
i have been looking for an excuse to use nvim 👀
it used to work though
I'll be that guy and say try helix :p
i could try that out too, im guessing it wouldnt need to do as much configuring
but arent the bindings different from vim?
yeah, comes a bit more out of the box ready - and yeah, it uses a sort of opposite paradigm. vim is verb+noun, whilst helix is noun+verb
so in vim you decide what you're going to do, and then you select what you're doing it to
whereas in helix, you select something, and then you apply an action
for me the latter was more intuitive, but you'll have to be the judge
but also, yeah idk, common experience with vscode lol
I mean
wild thought, it could suddenly resume working next time you restart your computer
yeah no problem, sorry to not be of more help