From 0053166018dac893acdeb1601a9ea55877af5664 Mon Sep 17 00:00:00 2001 From: ADoyle Date: Mon, 5 Dec 2022 00:04:08 +0800 Subject: [PATCH] docs: do not create keymaps and commands in configFn --- README.md | 11 +++++++++++ README.zh.md | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/README.md b/README.md index 5eac93a..90d841a 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/README.zh.md b/README.zh.md index 0465caf..6ae1db8 100644 --- a/README.zh.md +++ b/README.zh.md @@ -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#插件参数)。你可以覆盖配色和快捷键设置。