How to Write Neovim Plugin from Scratch

Neovim Plugin Development

What you will learn?

What you’ll learn

  • Understand runtimepath.
  • Learn how to install plugins without plugin manager.
  • Create a very minimal plugin called “confy”.
  • Publish your shiny new plugin!.

Course Content

  • Introduction –> 1 lecture • 2min.
  • All About Runtimepath –> 3 lectures • 9min.
  • Vim Plugins –> 3 lectures • 12min.
  • Lua and require –> 3 lectures • 4min.
  • Your First Plugin [ confy ] –> 5 lectures • 12min.
  • Traditional Vim Plugin Approach –> 3 lectures • 6min.

Auto Draft

Requirements

What you will learn?

Basics

  • What is runtime path?
  • Relationship between Vim Plugins and Runtime Path
  • How to install Plugins without “Plugin Manager”?
  • Difference between pack/start and pack/opt
  • What does “require” do?
  • Module reloading without closing Neovim.

Plugin No.1 [ confy.lua ]

  • writing up confy from scratch
  • simple plugin to open and reload your init.vim or init.lua
  • this should get you started on basic plugin structure
  • and finallay publishing it so that others can use your shiny new plugin!

Plugin No.2 [ Wrap Console Log ]

  • writing up wrapper from scratch
  • port of VSCode extension Wrap Console Log
  • it wraps the word under the cursor into a template

My future courses?

  • auto pair
  • splitjoin
  • key chain
  • key layer
  • zettelkasten link jumper
  • real-time floating window logger
  • smooth scroller ( on github )
  • IDE backspace ( on github )
  • cursor flasher ( on github )
  • n flasher ( on github )
  • star flasher ( on github )
  • vimscript virtual text echo ( probably could extend to other languages )
  • and if you are adventurous… your own fuzzy finder! Boooooom! ?

 

An introductory course on Neovim plugin development would cover the basics of creating plugins for the popular text editor, Neovim. Neovim is a fork of the Vim text editor and offers several new features and enhancements. The course would begin with an overview of some internal understanding of Vim, runtime path in particular.

“runtime path” is the list of directories where Vim looks for its runtime files, such as syntax highlighting files, plugin scripts, and documentation. These directories are typically stored in the ‘runtimepath’ option, which is a comma-separated list of directory paths.

The runtime path is important because it determines where Vim looks for its runtime files when it starts up.  If a user installs a new plugin, for example, they may need to add the plugin’s directory to the runtime path so that Vim can find the plugin’s script files.

After doing some experimentation with runtime path, we look at how vim handles installation of plugins before and after the introduction of package feature in Vim8. We also try installing the plugins without plugin managers.

Then we see how Lua module fit into the picture and how they are loaded using the “require” function.

Finally we create a very minimal plugin called confy!

First by following the Lua Plugin convention using the setup function.

Second by following the Vimscript convention using plugin directory and vim global variables.

By the end of the course, students should be able to create their own Neovim plugins and understand the fundamentals of Neovim plugin development.

Get Tutorial