CRAG666/code_runner.nvim

Why we need to do this ?

Closed this issue · 3 comments

ysl2 commented

if command == no_sub_command then
command = command .. " " .. path
end

I inject my cofig like this:

require('code_runner').setup({
  mode = 'toggleterm',
  filetype = {
    c = (function()
      if vim.fn.has('win32') == 1 then
        result = ('cd %s && clang %s -o %s.exe && .\\%s.exe'):format(vim.fn.expand('%:p:h'), vim.fn.expand('%:t'), vim.fn.expand('%:t:r'), vim.fn.expand('%:t:r')):gsub('/', '\\')
        return result
      end
      return 'cd $dir && clang $fileName -o $fileNameWithoutExt && ./$fileNameWithoutExt'
    end)()
  }
})

The command I desire is:

cd C:\Users\aaba\Documents\_Documents\code-playground && clang main.c -o main.exe && .\main.exe

But it will auto append working directory path like this:

cd C:\Users\aaba\Documents\_Documents\code-playground && clang main.c -o main.exe && .\main.exe C:\Users\aaba\Documents\_Documents\code-playground

change return result for return result .. '$end'

@ysl2 Please read README

ysl2 commented

thanks bro !