Skip to content

PZ31k0nauT/lua-plainstart.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lua-plainstart.nvim

This is a nvim plugin completely written from scratch

Sources

The Primeagen way

Getting your options

When you want to do something and you can remember the command you can use:h nvim. With that you will see a list of every function nvim has to over.

When you want you want to use those commands you have to prefix those with vim.api.. Others can be accessed via vim.fn.

When you have variables defined in vimscript like let g:your_value = 42, you can access this ariable with vim.g["value"]. Remember when you make changes to a vimscript you have to source this file afterwards with :so %

Setting up the structure of the project (another possibility)

A good starting point are the standard git files. Besides that we need at least two files lua/pluginname.lua and plugin/pluginname.vim. It all could be put in one file but it seems to better to split lua from vimscript.

In the plugin/pluginname.vim following elements making sense:

This is the first line and prevents that the plugin is loaded twice.

if exists('g:loaded_pluginname') | finish | endif

After that we manage the user coptions.

let s:save_cpo = &cpo " save user option
set cpo&vim " reset them to defaults

Then we can give the command to run the plugin

command! Pluginname lua require'pluginname'.pluginname()

After the command has been run we can restore the coptions for the user.

let &cpo = s:save_cpo
unlet s:save_cpo

At last we set the plugin as loaded.

let g:loaded_pluginname = 1

Since plugins writen in lua we should communicate that.

if !has('nvim')
    echohl Error
    echom "Sorry this plugin only works with versions of neovim that support lua"
    echohl clear
    finish
endif

About

This is a nvim plugin completely written from scratch

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published