Layer#
You’ve seen a high-level overview of what a layer is and how it’s the central
piece of your visimp configuration in the introduction. More concretely, a layer L is a structure with the
following fields:
L.identifieris a unique string that identifies the layer. This identifier is usually a meaningful name, often matching with the Lua filename;L.default_configis the layer’s default configuration to be extended via a merge with the configuration given toL.configure(...). Please see the next bullet point for further reference;L.configis the structure obtained from the merging of the actual config provided by the user with the layer’s default.L.deprecatedis a boolean stating whether the layer is deprecated or not. If it is, a notice asking the user to disable said layer is shown when the layer is loaded.
There’s a specific set of methods that can act on any given layer. They get
called automatically by visimp via the loader component or the setup
lifecycle. Each method has a default implementation. For side effects methods,
it is a no-op. They can be overwritten by assigning a function to the
appropriate field of the layer Below is a list of available methods.
L.configure(cfg)receives as input the actual config provided by the user. Its job is to populate theL.configfield, usually with a merge ofcfgandL.default_config. This implementation is the one provided by default and is rarely changed.L.dependencies()returns a list of layers on which the current layerLdepends. The default implementation returns an empty slice.L.packages()returns a list of plugins which the current layerLnecessitates. Plugins are usually a string composed of the suffix of a GitHub repository URL (i.e.https://github.com/tpope/fugitivewould betpope/fugitive).L.preload()is called on all layers before theloadmethod is called on any of them. This is used to modify behavior of other layers’loadmethods. An example is the interaction with thelsplayer: in order to enable a desired LSP, other layers need to specify it in theirpreloadsection before thelsplayerloadmethod gets called.L.load()is designed to let layers apply side effects on the Neovim client. This is where plugins are enabled, the Neovim configuration is set, etcetera.