在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):jacobsimpson/nvim-example-lua-plugin开源软件地址(OpenSource Url):https://github.com/jacobsimpson/nvim-example-lua-plugin开源编程语言(OpenSource Language):Lua 45.1%开源软件介绍(OpenSource Introduction):nvim-example-lua-pluginIntroductionNewer versions of Neovim include an embedded lua interpreter, making it possible to write non-remote plugins using Lua instead of Vimscript. This is a minimal example of an embedded Lua plugin. When you want to create a new Lua plugin, you should be able start from a working plugin by running: bash \
<(curl -o- https://raw.githubusercontent.com/jacobsimpson/nvim-example-lua-plugin/master/install.sh) \
mynewplugin and following the instructions on the screen. Installing ManuallyThe intention of this repository is to make it quick and easy to start a new plugin. If you don’t want to run the included bash script, it is also possible to do the steps manually. git clone --depth 1 \
https://github.com/jacobsimpson/nvim-example-lua-plugin \
~/nvim-example-lua-plugin
rm -Rf ~/nvim-example-lua-plugin/.git After that, to load Neovim with the development version of your plugin, execute
a command to modify the nvim --cmd "set rtp+=./nvim-example-lua-plugin" Testing the New PluginThere are some messages that should be printed to the console as Neovim is starting up, to confirm that the different parts of the plugin are executing correctly:
There is a function defined in the VimL portion of the plugin which echos some text. You can execute the function like this: :exec LuaDoItVimL() There is a function defined in the same VimL file, in a Lua block. You can execute the function like this: :luado lua_do_it_lua() Plugin DevelopmentDebuggingTo test changes quickly, I usually reload the current file into the embedded Lua interpreter after changes: :luafile % Handy Vim/Lua CommandsSee the Lua version you have available: :lua print(_VERSION) Directly execute an arbitrary Lua function that has been defined in the Lua interpreter embedded in Neovim. :lua doit() To apply a Lua function to each line:
To define an arbitrary function in the Lua interpreter embedded in Neovim:
function execute_lua_block()
print("this is the thing.")
end To map an arbitrary Lua function to a Neovim keybinding: nmap <C-l-e> :lua execute_lua_block()<CR> To see information about the Neovim API available in Lua: :help api.txt |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论