Home
Head's Up: I'm in the middle of upgrading my site. Most things are in place, but there are something missing and/or broken including image alt text. Please bear with me while I'm getting things fixed.

Create A Hello World Neovim Plugin In Lua

This uses a .vim file for the plugin. I'm working on making that .lua

This is a basic setup I used for creating a Neovim plugin in Lua. After adding the files and restarting Neovim, you can run [TODO: Code shorthand span ] which will print "Hello, Lua Plugin" on the command line.

~/.config/nvim/plugin/hello_world.vim

vimscript
if exists('g:loaded_hello_world') | finish | endif

let s:save_cpo = &cpo
set cpo&vim

command! HelloWorld lua require'hello_world'.hello_world()

let &cpo = s:save_cpo
unlet s:save_cpo

let g:loaded_hello_world = 1

~/.config/nvim/lua/hello_world.lua

lua
local function hello_world()
    print("Hello, Lua Plugin")
end

return {
    hello_world = hello_world
}