Closed ayham-1 closed 1 year ago
In order to accommodate for multiple languages, $(FEXT) modifier is used.
Modifiers looks like an unnecessary complication for this task.
I think a template_files
option would be clearer:
template_files = {
c = "/path/to/file.c", -- absoulte path
cpp = "~/path/to/file.cpp", -- path starting from home directory
py = "~/path/to/file.py",
}
CompetiTest asks for file extension when download a problem or a contest, so you can use it to determine if a template file is configured. If it's not configured you just create an empty file.
In order to accommodate for multiple languages, $(FEXT) modifier is used.
Modifiers looks like an unnecessary complication for this task.
I think a
template_files
option would be clearer:template_files = { c = "/path/to/file.c", -- absoulte path cpp = "~/path/to/file.cpp", -- path starting from home directory py = "~/path/to/file.py", }
CompetiTest asks for file extension when download a problem or a contest, so you can use it to determine if a template file is configured. If it's not configured you just create an empty file.
I would say that there is no real use to having explicit per language template file configuration. The only real situation where this is useful is when one has templates all over his system, which is unorganized.
It should also be noted that if the user has the template files in the same directory he would need to write multiple file paths for multiple templates, which most likely would have the pattern of path/template.$(FEXT)
.
which most likely would have the pattern of
path/template.$(FEXT)
.
Agree
It should also be noted that if the user has the template files in the same directory he would need to write multiple file paths for multiple templates, which most likely would have the pattern of
path/template.$(FEXT)
.
You're right, but this could be constraining for some users.
So I propose the following changes:
template_file
is false
, no template file will be used. This should be default value since every user uses its own template file.template_file
is a string, it will be evaluated with CompetiTest modifiers (like $(FEXT)
)
template_file = "~/path/to/template.$(FEXT)"
template_file
is a table, it will store path to template file for every file extension (no modifers allowed here)
template_file = {
c = "/path/to/file.c", -- absoulte path
cpp = "~/path/to/file.cpp", -- path starting from home directory
py = "~/path/to/file.py",
}
@ayham-1 @MuhammadSawalhy please try out latest commit
🎉 It works
But I don't get any error message when the template file doesn't exist.
But I don't get any error message when the template file doesn't exist.
That's intended, because users may like to use templates only for some filetypes
That's intended, because users may like to use templates only for some filetypes
Ok, I think this is a good idea for this.
template_file = "~/myp/problem-solving/template.$(FEXT)"
But this should display something indicating that the file doesn't exist. I'm ok with the current behaviour but let's make it better.
template_file = {
cpp = "~/myp/problem-solving/tempate.cpp"
},
I can't test the template feature with contests. The issue exists in the master branch.
@ayham-1 @MuhammadSawalhy please try out latest commit
Does work on my side.
I can't test the template feature with contests. The issue exists in the master branch.
Contest clone does work using the latest comment in add-template-functionality branch
It also doesn't work with latest commit in master branch of xeluxee/competitest.nvim
I can't test the template feature with contests. The issue exists in the master branch.
Cannot reproduce. What command have you launched? What commit are you using?
But this should display something indicating that the file doesn't exist. I'm ok with the current behaviour but let's make it better.
Thanks for pointing that out. Fixed with 054738c
Added template_file configuration option.
In order to accommodate for multiple languages, $(FEXT) modifier is used.