Neovim: “E492: 不是编辑命令”

huangapple go评论59阅读模式
英文:

Neovim: "E492: Not an editor command"

问题

I am trying to set up Neovim as an IDE for data science. 我正在尝试将Neovim设置为数据科学的集成开发环境。

I want to be able to execute highligted code blocks in a terminal session running IPython or R. 我希望能够在运行IPython或R的终端会话中执行突出显示的代码块。

For this I want to install the plugin iron.nvim. 为此,我想安装插件 iron.nvim

The official readme suggests, that the terminal session can be launched with the command :IronRepl, but when I do this I get the error: E492: Not an editor command: IronRepl. 官方的说明建议使用命令 :IronRepl 启动终端会话,但当我这样做时,我收到错误消息:E492: Not an editor command: IronRepl

I've settled on using lazy.nvim as my package manager and have managed to install and apply a colourscheme correctly. This tells me, I am mostly doing this correctly. 我已经决定使用 lazy.nvim 作为我的包管理器,并成功安装和正确应用了配色方案。这告诉我,我大部分操作都是正确的。

I have bootstrapped lazy.nvim in ~/.config/nvim/init.lua as described in the official readme. 我已经按照官方说明~/.config/nvim/init.lua 中引导了 lazy.nvim

In the same file I have specified the location of the plugins-list to be loaded: 在相同的文件中,我已经指定了要加载的插件列表的位置:

require("lazy").setup({
        import = "plugins"
    })
require("lazy").setup({
        import = "plugins"
    })

In ~/.config/nvim/lua/plugins/plugins.lua I have specified: 在 ~/.config/nvim/lua/plugins/plugins.lua 中,我已经指定了:

return {
    'hkupty/iron.nvim'
}
return {
    'hkupty/iron.nvim'
}

Running :Lazy reveals that the plugin has been installed correctly (and is in fact loaded). Running h: Iron opens the help pages, which also suggests it is correctly installed. 运行 :Lazy 显示插件已经正确安装(实际上已加载)。运行 h: Iron 打开帮助页面,这也表明它已经正确安装。

Any thoughts on how I can resolve this error? 有关如何解决这个错误的想法吗?

英文:

I am trying to set up Neovim as an IDE for data science. I want to be able to execute highligted code blocks in a terminal session running IPython or R. For this I want to install the plugin iron.nvim.

The official readme suggests, that the terminal session can be launched with the command :IronRepl, but when I do this I get the error: E492: Not an editor command: IronRepl.

I've settled on using lazy.nvim as my package manager and have managed to install and apply a colourscheme correctly. This tells me, I am mostly doing this correctly.

I have bootstrapped lazy.nvim in ~/.config/nvim/init.lua as described in the official readme.

In the same file I have specified the location of the plugins-list to be loaded:

require("lazy").setup({
        import = "plugins"
    })

In ~/.config/nvim/lua/plugins/plugins.lua I have specified:

return {
    'hkupty/iron.nvim'
}

Running :Lazy reveals that the plugin has been installed correctly (and is in fact loaded). Running h: Iron opens the help pages, which also suggests it is correctly installed.

Any thoughts on how I can resolve this error?

I installed iron.nvim and tried to open a terminal session with the plugin as suggested in the official readme. I got an error message saying: E492: Not an editor command: IronRepl.

答案1

得分: 0

首先,欢迎来到Stack Overflow!

你已经快要完成了!请查看 README 的 How to configure 部分。重要的行是:

local iron = require("iron.core")

iron.setup {
    -- ...
}

iron.setup 函数 实际上是插件准备的一部分,包括之后可以使用的命令。因此,您需要按照以下方式更改配置:

不要使用:

return {
    'hkupty/iron.nvim'
}

而是需要更改为:

return {
    {
        'hkupty/iron.nvim',
        -- 请注意,`init` 将禁用懒加载!
        init = function()
            local iron = require("iron.core")

            iron.setup({
                -- 如果需要,添加其他选项
                config = {}
            })
        end
    }
}

或者(我建议的方式)您可以利用懒文件分离的“特性”,允许您在单独的文件中声明插件 Neovim: “E492: 不是编辑命令” 请查看 Lazy's README 以了解此情况,或者您可以查看 我的插件目录

英文:

First of all: Welcome to stack overflow!

You're almost there! Take a look into the How to configure part of the README.
The important lines are:

local iron = require("iron.core")

iron.setup {
    -- ...
}

The iron.setup function does the actual plugin-preparation which includes
the commands which you'll be able to use afterwards. So you need to change your
config as follows:

Instead of having

return {
    'hkupty/iron.nvim'
}

you'll need to change it to:

return {
    {
        'hkupty/iron.nvim',
        -- note that `init` will disable lazy-loading!
        init = function()
            local iron = require("iron.core")

            iron.setup({
                -- add the other options if you want
                config = {}
            })
        end
    }
}

Alternatively (which I suggest) you can make use of lazy-file-separation
"feature" which allows you to declare a plugin in a separate file Neovim: “E492: 不是编辑命令”
Take a look into Lazy's README for this case or you can take a look into my
plugin directory
.

huangapple
  • 本文由 发表于 2023年5月6日 19:13:10
  • 转载请务必保留本文链接:https://go.coder-hub.com/76188555.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定