Skip to content

Commit

Permalink
docs(readme): default imports
Browse files Browse the repository at this point in the history
  • Loading branch information
kawre committed Feb 26, 2024
1 parent 05a8e73 commit 14c1de4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,18 @@ logging = true

Inject code before or after your solution, injected code won't be submitted or run.

#### default imports

You can also pass `before = true` to inject default imports for the language.
Supported languages are `python`, `python3`, `java`

Access default imports via `require("leetcode.config.imports)`

```lua
injector = { ---@type table<lc.lang, lc.inject>
["python3"] = {
before = true
},
["cpp"] = {
before = { "#include <bits/stdc++.h>", "using namespace std;" },
after = "int main() {}",
Expand Down
9 changes: 9 additions & 0 deletions README.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,13 @@ logging = true

在你的答案前后注入额外代码,注入的代码不会被提交或测试。

#### 默认导入

您还可以传递 `before = true` 以注入语言的默认导入。
支持的语言为 `python``python3``java`

通过 `require("leetcode.config.imports)` 访问默认导入

```lua
injector = { ---@type table<lc.lang, lc.inject>
["cpp"] = {
Expand Down Expand Up @@ -316,6 +323,8 @@ image_support = false, -- 将此设置为 `true` 将禁用问题描述的换行

- `restore` 尝试恢复默认问题布局

- `inject` 重新注入当前问题的代码

- `session`

- `create` 创建一个新的会话
Expand Down

0 comments on commit 14c1de4

Please sign in to comment.