{"pageProps":{"metadata":{"date":"2022-04-20 18:36:23 +08:00","date_modified":"2022-04-20 18:39:40 +08:00","language":"en","source":""},"title":"Neovim Lua modules","hast":{"type":"root","children":[{"type":"element","tagName":"nav","properties":{"className":"toc"},"children":[{"type":"element","tagName":"ol","properties":{"className":"toc-level toc-level-1"},"children":[]}]},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Neovim will load the requires files from its runtime paths;\n see "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"runtimepath"}]},{"type":"text","value":" from the "},{"type":"element","tagName":"a","properties":{"href":"/editor.neovim.help-system"},"children":[{"type":"text","value":"Neovim help system"}]}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"built on top of the already existing "},{"type":"element","tagName":"a","properties":{"href":"/lang.lua.modules"},"children":[{"type":"text","value":"Lua modules"}]},{"type":"text","value":" system\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"while searching for the runtime paths, Neovim will search for certain folders\n"}]},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"plugin/"}]},{"type":"text","value":" will load all of the Lua files that are placed in that subdirectory\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"lua/"}]},{"type":"text","value":" also contains Lua files but does not automatically load until some other module will call "},{"type":"element","tagName":"code","properties":{"className":["inline-code"]},"children":[{"type":"text","value":"require"}]},{"type":"text","value":" to that module\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"init.lua"}]},{"type":"text","value":" is basically the "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"index.html"}]},{"type":"text","value":" for HTML files, "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"default.nix"}]},{"type":"text","value":" for "},{"type":"element","tagName":"a","properties":{"href":"/lang.nix"},"children":[{"type":"text","value":"Nix language"}]},{"type":"text","value":", or "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"mod.rs"}]},{"type":"text","value":" for "},{"type":"element","tagName":"a","properties":{"href":"/lang.rust"},"children":[{"type":"text","value":"Rust language"}]}]}]}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"in module names that are "},{"type":"element","tagName":"code","properties":{"className":["inline-code"]},"children":[{"type":"text","value":"require"}]},{"type":"text","value":"'d, "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":" is treated as a separator and representing as a directory in the file tree;\n e.g., when running "},{"type":"element","tagName":"code","properties":{"className":["inline-code"]},"children":[{"type":"text","value":"require(\"custom.plugins\")"}]},{"type":"text","value":", "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"custom.plugins"}]},{"type":"text","value":" should have a module at "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"$RUNTIMEPATH/lua/custom/plugins/init.lua"}]}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"at some point, Neovim can make use of more Lua modules with "},{"type":"element","tagName":"a","properties":{"href":"https://luarocks.org/"},"children":[{"type":"text","value":"Luarocks"}]}]}]}]}]},"backlinks":[{"path":"/editor.neovim.lua","title":"Neovim Lua integration"}]},"__N_SSG":true}