marilari88 / neotest-vitest

Vitest adapter for Neovim Neotest plugin
92 stars 34 forks source link

docs: default keymap for running watch file results in an error #61

Open polukarp opened 3 weeks ago

polukarp commented 3 weeks ago

This keymap from docs

vim.api.nvim_set_keymap(
      'n',
      '<leader>twf',
      "<cmd>lua require('neotest').run.run({ vim.fn.expand(" % "), vitestCommand = 'vitest --watch' })<cr>",
      { desc = 'Run Watch File' }
    )

Returns the following error upon execution: attempt to perform arithmetic on a string value because of double quotes surrounding % sign. They should be changed to single quotes - that's the solution that worked for me. Because unless you change it, lua thinks that string is like this "lua require('neotest').run.run({ vim.fn.expand("

Fix:

vim.api.nvim_set_keymap(
      'n',
      '<leader>twf',
      "<cmd>lua require('neotest').run.run({ vim.fn.expand(' % '), vitestCommand = 'vitest --watch' })<cr>",
      { desc = 'Run Watch File' }
    )