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.

How To Make A Hello World Neovim Plugin With Lua

### TL;DR

NOTE : I don't think this is the best way to do this. It uses VimScript as well as Lua and seems to do a weird dance. Probably more strightforward to call lua directly

I'm looking to build a Neovim plugin with Lua. I couldn't find an article with a simple example. Digging through the docs I was able to put this one together. Setting up these files will provide a new command :

:HelloNeovim

Running it will print [TODO: Code shorthand span ] on the first line of the open document.

### The Files

### File : ~/.config/nvim/autoload/hello _ neovim.vim

function hello _ neovim#print _ it() call setline(1, luaeval('require("hello _ neovim").hello')) endfunction

### File : ~/.config/nvim/lua/hello _ neovim.lua

return { hello = "Hello, Neovim! This is Lua!" }

### File : ~/.config/nvim/plugin/hello _ neovim.vim

if exists('g : hello _ neovim _ loaded') finish endif let g : hello _ neovim _ loaded = 1

command HelloNeovim : call hello _ neovim#print _ it()

### Notes

The main tutorial that comes in the search results for making a neovim plugin with lua is this one . It's 153 lines of code, creates windows with borders, uses git calls, and doesn't show you how to actually install it. I wasn't able to follow it.

I think there's a way to isolate plugins during development, but I haven't figure that out yet.