Enable gx
in NvChad🔗
The command gx
opens the filename under the the cursor with vim.ui.open()
(see :help netrw-gx
).
Then handling is provided by the internal netrw
plugin. This plugin is
disabled when using NvChad.
NvChad is using nvim-tree/nvim-tree.lua. In the
configuration of this plugin, NvChad disables netrw
, but allows the usage
of netrw
by the hijacking setup option (see lua/plugins/configs/nvimtree.lua
).
This options will allow the usage of gx
. But NvChad also disables the plugin
in the configuration of the plugin manager folke/lazy.nvim.
The netrw
plugin is disabled with the option
performance.rtp.disabled_plugins
in the file plugins/configs/lazy_nvim.lua
.
To enable the gx
command the entry netrwPlugin
must be removed from this
option. But the configuration mechanism in NvChad allows only to overwrite an
option. Therefore the most straightforward way is to overwrite the option with
the complete list without netrwPlugin
in custom/chadrc.lua
:
local M = {}
M.lazy_vim = {
performance = {
rtp = {
disabled_plugins = {
"2html_plugin",
...
"ftplugin",
}
}
}
}
return M
The drawback of this method is, that whenever the NvChad configuration is changed, this list must be updated.
The better solution is to load the list and remove the favored plugins:
local M = {}
-- load default list of disabled plugins in NvChad
local default = require('plugins.configs.lazy_nvim')
local default_disabled_plugins = default.performance.rtp.disabled_plugins
-- specify which plugins should be removed from default disabled list
local enabled = {
netrwPlugin = true,
}
-- enable those plugins
local i=1
while i <= #default_disabled_plugins do
if enabled[default_disabled_plugins[i]] then
table.remove(default_disabled_plugins, i)
else
i = i + 1
end
end
M.lazy_nvim = {
performance = {
rtp = {
disabled_plugins = default_disabled_plugins,
},
},
}
return M
Info
When you only want to use the gx
command, there are other solutions like
using a separate plugin, e.g., chrishrb/gx.nvim. This is also an
example, how to overwrite configuration settings by removing an option in
NvChad.