Skip to content

Commit

Permalink
docs: do not create keymaps and commands in configFn
Browse files Browse the repository at this point in the history
  • Loading branch information
adoyle-h committed Dec 4, 2022
1 parent 7748c47 commit 0053166
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,17 @@ require('one').setup {
}
```

**Notice**: Do not create keymaps and commands in `configFn`, it may be overridden by plugins.
Because `configFn` is invoked before all plugins' config/keymaps/commands/autocmds/filetypes/completions/signs/telescopes.

If you need to invoke `vim.keymap.set` and `vim.api.nvim_create_user_command`, please put codes after one.nvim setup. For example,

```lua
require('one').setup {}
vim.keymap.set('n', 'w', 'WWW', { noremap = true })
vim.api.nvim_create_user_command('Hellow', 'echo "world"', {})
```

### Override Plugin Options

You can override any [plugin options](./doc/plugin.md#plugin-options) in `require('one').setup {plugins = {}}`. You can override highlights and keymaps.
Expand Down
11 changes: 11 additions & 0 deletions README.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,17 @@ require('one').setup {
}
```

**注意**:别在 `configFn` 里创建 keymap 或者命令,它可能会被插件覆盖。
因为 `configFn` 在所有插件的 config/keymaps/commands/autocmds/filetypes/completions/signs/telescopes 之前调用。

如果你需要调用 `vim.keymap.set``vim.api.nvim_create_user_command`,请把代码放在 one.nvim setup 函数之后。例如,

```lua
require('one').setup {}
vim.keymap.set('n', 'w', 'WWW', { noremap = true })
vim.api.nvim_create_user_command('Hellow', 'echo "world"', {})
```

### 覆盖插件参数

通过 `require('one').setup {plugins = {}}`,你可以覆盖任何[插件参数](./doc/plugin.zh.md#插件参数)。你可以覆盖配色和快捷键设置。
Expand Down

0 comments on commit 0053166

Please sign in to comment.