From db3584dd13be89651e5f85e38df50d321e6a2b8a Mon Sep 17 00:00:00 2001 From: Corentin Godeau Date: Sat, 14 Nov 2026 18:01:52 +0100 Subject: [PATCH 1/2] workspace: update nvim configuration Add `source.organizeImports` to the action ran before save. --- .nvim.lua | 102 ++++++++++++++++++++++++++---------------------------- 1 file changed, 49 insertions(+), 53 deletions(-) diff --git a/.nvim.lua b/.nvim.lua index 9982de80..fe7f2610 100644 --- a/.nvim.lua +++ b/.nvim.lua @@ -4,63 +4,59 @@ local cwd = vim.fn.getcwd() -- Load the local config file if it exists local f, err = loadfile(".nvim.local.lua") if not err then - local ok, err_f = pcall(f) - if not ok then - vim.print(err_f) - end + local ok, err_f = pcall(f) + if not ok then + vim.print(err_f) + end else - vim.lsp.config("zls", { - cmd = { cwd .. "/tools/zls.sh" }, - }) - vim.lsp.enable("zls") + vim.lsp.config("zls", { + cmd = { cwd .. "/tools/zls.sh" }, + }) + vim.lsp.enable("zls") - function runFixAll() - local params = vim.lsp.util.make_range_params() - params.context = { - only = { "source.fixAll" }, - diagnostics = {}, - } + function runFixAll() + local bufnr = vim.api.nvim_get_current_buf() + for _, client in ipairs(vim.lsp.get_clients({ bufnr = bufnr, name = "zls" })) do + -- Request each action after applying the previous action's edits. + for _, kind in ipairs({ "source.fixAll", "source.organizeImports" }) do + local params = vim.lsp.util.make_range_params(0, client.offset_encoding) + params.context = { only = { kind }, diagnostics = {} } + local response = client:request_sync("textDocument/codeAction", params, 2000, bufnr) + if response and not response.err then + for _, action in ipairs(response.result or {}) do + if action.edit then + vim.lsp.util.apply_workspace_edit(action.edit, client.offset_encoding) + end + if action.command then + client:exec_cmd(type(action.command) == "table" and action.command or action, + { bufnr = bufnr }) + end + end + end + end + end + end - -- Send synchronous request (timeout 2 seconds) - local responses = vim.lsp.buf_request_sync(0, "textDocument/codeAction", params, 1000) - if not responses then - return - end + vim.api.nvim_create_autocmd("BufWritePre", { + pattern = { "*.zig", "*.zon" }, + callback = runFixAll, + }) - for _, resp in pairs(responses) do - for _, action in ipairs(resp.result or {}) do - -- If action has edits, apply them - if action.edit then - vim.lsp.util.apply_workspace_edit(action.edit, "utf-16") - end - -- If the action has a command, execute it - if action.command then - vim.lsp.buf.execute_command(action.command) - end - end - end - end + local ok, conform = pcall(require, "conform") - vim.api.nvim_create_autocmd("BufWritePre", { - pattern = { "*.zig", "*.zon" }, - callback = runFixAll, - }) + if ok then + conform.formatters_by_ft.bzl = { "buildifier" } + conform.formatters.buildifier = { + command = cwd .. "/tools/buildifier.sh", + } - local ok, conform = pcall(require, "conform") - - if ok then - conform.formatters_by_ft.bzl = { "buildifier" } - conform.formatters.buildifier = { - command = cwd .. "/tools/buildifier.sh", - } - - vim.api.nvim_create_autocmd("FileType", { - pattern = "bzl", - callback = function() - vim.keymap.set("n", "f", function() - conform.format() - end, { remap = false, silent = true }) - end, - }) - end + vim.api.nvim_create_autocmd("FileType", { + pattern = "bzl", + callback = function() + vim.keymap.set("n", "f", function() + conform.format() + end, { remap = false, silent = true }) + end, + }) + end end From 1a26a051a50ed8293e8c9edb539a93ef0858ca7a Mon Sep 17 00:00:00 2001 From: erwanvivien <44021072+erwanvivien@users.noreply.github.com> Date: Mon, 16 Nov 2026 14:17:19 +0100 Subject: [PATCH 2/2] zml/tensor: return a distinct tensor from toMemory on single-memory platforms (#1087) On cpu, neuron and metal, `toMemory` returned self. Donating a result to a device buffer and its `toMemory` copy to a host buffer then called `reuseBuffer` twice on the same tensor id: the second donation replaced the first, and compilation panicked because both outputs aliased the host buffer. This broke llmd async scheduling on Metal and CPU. Return the same value under a new tensor id instead. --- zml/tensor.zig | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/zml/tensor.zig b/zml/tensor.zig index a09a5d38..ee084835 100644 --- a/zml/tensor.zig +++ b/zml/tensor.zig @@ -282,7 +282,13 @@ pub const Tensor = struct { pub fn toMemory(self: Tensor, kind: Memory.Kind) Tensor { const ctx = Compiler.current(); switch (ctx.platform.target) { - .cpu, .neuron, .metal => return self, + .cpu, .neuron, .metal => { + // A single memory needs no copy, but the result must still be a distinct + // tensor: `reuseBuffer` donations are keyed by tensor id. + var res = _result(self._shape, self.value()); + res._shape._sharding = self._shape._sharding; + return res; + }, .cuda, .rocm, .tpu, .oneapi, .furiosa => {}, }