clearloop / leetcode-cli

May the code be with you 👻
MIT License
308 stars 49 forks source link

Unable to specify editor's arguments at configuration file #111

Closed illia-danko closed 1 year ago

illia-danko commented 1 year ago

Use case: As a user I want to use my editor (nvim) without any plugins and configuration to have a clean and similar to white board code interview experience. Neovim has --clean argument for this purpose (see nvim --help).

It seems that existing ~/.leetcode/leetcode.toml doesn't have this possibility to teach leetcode-cli to run editor with arguments.

if the code block section is modified to something like:

[code]
editor = "nvim --clean"
lang = "golang"
pick = "${fid}.${slug}"
submission = "${fid}.${slug}.${sid}.${ac}"

leetcode-cli command returns: error: No such file or directory (os error 2), please try again

clearloop commented 1 year ago

source code is here https://github.com/clearloop/leetcode-cli/blob/930064f6ae6fd6f48af602f9a524137a9a9d1908/src/cmds/edit.rs#L155

plz try

[code]
editor = "nvim"
editor_args = ["--clean"]
lang = "golang"
pick = "${fid}.${slug}"
submission = "${fid}.${slug}.${sid}.${ac}"
illia-danko commented 1 year ago

@clearloop I've just reinstalled leetcode-cli using cargo install leetcode-cli. The snippet above doesn't work for me. Moreover editor_args disappears in the configuration file once I run the leetcode-cli command. So the issue is still there

illia-danko commented 1 year ago

Ok, finally got it:

[code]
editor = "nvim"
editor-args = ["--clean"] # NOTE: in the master branch use editor_args, instead of editor-args
lang = "golang"
pick = "${fid}.${slug}"
submission = "${fid}.${slug}.${sid}.${ac}"

after checking out the latest master, figured out that the argument is editor-args not editor_args. It seems a minor issue: other params have snake case syntax, not kebab case...

illia-danko commented 1 year ago

@clearloop If you like to have editor_args over editor-args checkout https://github.com/clearloop/leetcode-cli/pull/112