xeluxee / competitest.nvim

CompetiTest.nvim is a Neovim plugin for Competitive Programming: it can manage and check testcases, download problems and contests from online judges and much more
GNU Lesser General Public License v3.0
381 stars 15 forks source link

Unable to get compile directory working #43

Closed manavkush closed 9 months ago

manavkush commented 9 months ago

Hi all, I discovered this plugin yesterday and I'm amazed at the level of customization and documentation.

So I tried setting the plugin in my neovim config. Using the default configuration, it worked as expected. But I wanted a cleaner directory structure with the executable files in a seperate folder as well as the testcases.

So the basic folder structure that I desired was:

-> File.cpp
-> testcases 
        | -> Testcase files (input & output)
-> bin
        | -> Executables

For this I specified the following:

 testcases_directory = './testcases',
 compile_directory = '.',
 running_directory = './bin',
 compile_command = {
        cpp = { exec = "g++", "$(FNAME)", "-o", "./bin/$(FNOEXT)"}
 },

But the CompetiTest run gave an error.

Error executing luv callback: vim/_editor.lua:0: E5560: nvim_err_writeln must not be called in a lua loop callback stack traceback: [C]: in function 'nvim_err_writeln' vim/_editor.lua: in function 'notify' ...are/nvim/lazy/competitest.nvim/lua/competitest/utils.lua:8: in function 'notify' ...re/nvim/lazy/competitest.nvim/lua/competitest/runner.lua:205: in function 'execute_testcase' ...re/nvim/lazy/competitest.nvim/lua/competitest/runner.lua:128: in function 'run_first_testcases' ...re/nvim/lazy/competitest.nvim/lua/competitest/runner.lua:138: in function 'callback' ...re/nvim/lazy/competitest.nvim/lua/competitest/runner.lua:201: in function <...re/nvim/lazy/competitest.nvim/lua/competitest/runner.lua:167>

I also tried another way.

 testcases_directory = './testcases',
 compile_directory = './bin',
 running_directory = './bin',
 compile_command = {
        cpp = { exec = "g++", "../$(FNAME)", "-o", "./$(FNOEXT)"}
 },

which resulted in compilation error:

cc1plus: fatal error: B. Friendly Arrays.cpp: No such file or directory
compilation terminated.

Could anyone give any details on how to use the mentioned options or any of the corresponding commands(like compile_command) ?

Thanks

xeluxee commented 9 months ago

I discovered this plugin yesterday and I'm amazed at the level of customization and documentation.

Thanks!

-> testcases 
      | -> Testcase files (input & output)

Have you considered using single file instead of a folder?

Anyway the config you're looking for is the following:

testcases_directory = 'testcases',
compile_directory = 'bin',
running_directory = 'bin',
compile_command = {
    c = { exec = 'gcc', args = { '$(FABSPATH)', '-o', '$(FNOEXT)' } },
    cpp = { exec = 'g++', args = { '$(FABSPATH)', '-o', '$(FNOEXT)' } },
},

Please mind that compile_command requires two argument for each language, exec and args, otherwise unexpected errors like this could happen.

manavkush commented 9 months ago

Yes, the compile command needed args which I didn't provide. Thank you!!!