Home

Awesome

tstoluaplugin.nvim

A quick proof of concept nvim Lua plugin transpiled from TypeScript.

What is tstoluaplugin?

tstoluaplugin.nvim is nothing more than a proof of concept. It's the scaffolding of the transpiling toolchain thats just barely enough to function as the bare minimum.

The transpiling is facilitated by way of the TypeScriptToLua project.

Some notable(?) development features I wanted to support:

What does this give you?

A very simple plugin with some command completion. The completion and structure is heavily inspired (as in stolen from) @tjdevries's telescope.nvim.

I've butchered what he did.

Installation

Clone the repo locally (eg. ~/development/tstoluaplugin.vim).

Using packer.nvim

use {
  '~/development/tstoluaplugin.vim',
  requires = {{'nvim-lua/plenary.nvim'}}
}

Using vim-plug

Plug 'nvim-lua/plenary.nvim'
Plug '~/development/tstoluaplugin.vim'

Fire up nvim.

The transpiled lua is in the repo so that the plugin can be run right after cloning, without having to "build" first.

Usage

Try the command :TsToLuaPlugin dump 1 2 3 4 to see if tstoluaplugin is installed correctly.

You should see: { 1, 2, 3, 4 } printed. So much wow.

To see the other commands available just use your standard completion and you should see a few more options pop-up.

It should have a few "builtin" commands and two settings that will be printed to the console.

Commands available:
shell this will invoke a shell application and print its stdout. Additionally, it will also print the cmd and args used.

:TsToLuaPlugin shell ls -al

dump
this will print out whatever arguments are supplied.

:TsToLuaPlugin dump 1 2 three four

not_implemented
this will just use the nivm api to print a little error message saying "not implemented".

:TsToLuaPlugin not_implemented

config_value_(one|two)
this will print the value of the config entry. You can override them using the .setup() method (below).

:TsToLuaPlugin config_value_one

Configuration

require('tstoluaplugin').setup{
  defaults = {
      config_value_two = 42
  }
}

You can verify this has been applied by printing the value using the method outlined above.

Modifying the plugin

cd ~/development/tstoluaplugin.nvim
npm install

Create new/modify any of the files in ./typescript. Use npm run to run a build step.

npm run build

... will transpile the .ts to the ./lua directory.

npm run dev

... will do the same as above but watching for changes.

npm run clean

... will rm -rf the ./lua directory if you want to be sure of a fresh start.

Why did you bother?

Because it seemed like fun.

Something to keep in mind

I am neither an expert in TypeScript nor Lua. I just enjoy tinkering and exploring the patterns/implementations that these languages make available. I'm aware everything in this repository could be done better.

It seems to work though, so thats a plus.

Contributing

Even though I'm not sure why... Sure. Just open a pull request.

Or don't.

Your call.