From 2149a7664d240f2fb99edcdfb1c8d374848b6960 Mon Sep 17 00:00:00 2001 From: Steven Arcangeli <506791+stevearc@users.noreply.github.com> Date: Sun, 9 Jun 2024 12:39:50 -0400 Subject: [PATCH] fix: no autocommand file name to substitute for (#416) Co-authored-by: Steven Arcangeli --- lua/neotest/client/init.lua | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lua/neotest/client/init.lua b/lua/neotest/client/init.lua index ee7a214..42ee533 100644 --- a/lua/neotest/client/init.lua +++ b/lua/neotest/client/init.lua @@ -390,8 +390,8 @@ function neotest.Client:_start(args) }) end - autocmd({ "BufAdd", "BufWritePost" }, function() - local file_path = vim.fn.expand(":p") + autocmd({ "BufAdd", "BufWritePost" }, function(ev) + local file_path = vim.fn.fnamemodify(ev.file, ":p") if not lib.files.exists(file_path) then return @@ -446,8 +446,8 @@ function neotest.Client:_start(args) end) end) - autocmd({ "BufAdd", "BufDelete" }, function() - local updated_dir = vim.fn.expand(":p:h") + autocmd({ "BufAdd", "BufDelete" }, function(ev) + local updated_dir = vim.fn.fnamemodify(ev.file, ":p:h") nio.run(function() local adapter_id = self:_get_adapter(updated_dir, nil) if not adapter_id then @@ -460,8 +460,8 @@ function neotest.Client:_start(args) end) end) - autocmd("BufEnter", function() - local path = vim.fn.expand(":p") + autocmd("BufEnter", function(ev) + local path = vim.fn.fnamemodify(ev.file, ":p") if not lib.files.exists(path) then return @@ -473,7 +473,7 @@ function neotest.Client:_start(args) end) autocmd({ "CursorHold", "BufEnter" }, function() - local path, line = vim.fn.expand(":p"), vim.fn.line(".") + local path, line = vim.fn.expand("%:p"), vim.fn.line(".") if not lib.files.exists(path) then return