Skip to content

REPL for neovim, luatex, ..., lua plugin for powerlevel10k style prompt and WakaTime time tracking.

License

Notifications You must be signed in to change notification settings

wakatime/prompt-style.lua

Repository files navigation

prompt-style.lua

readthedocs pre-commit.ci status github/workflow codecov DeepSource

github/downloads github/downloads/latest github/issues github/issues-closed github/issues-pr github/issues-pr-closed github/discussions github/milestones github/forks github/stars github/watchers github/contributors github/commit-activity github/last-commit github/release-date

github/license github/languages github/languages/top github/directory-file-count github/code-size github/repo-size github/v

luarocks

This project provides some tools related to luaprompt:

A prompt with powerlevel10k style

luap

~/.config/luaprc.lua:

local prompt = require "prompt"
local style = require "prompt.style"

prompt.prompts = { style.generate_ps1(), "    " }

A wakatime plugin to statistic how much time you write lua in REPL

wakatime

If there is a git repository, the project name can be achieved by git. Else use the base name of current working directory. You can call (require "prompt.style").wakatime("wakatime-cli XXX") to customize it.

See readthedocs.

REPLs for many programs containing a lua interpreters

Lua 5.1/LuaJIT

cmd

~/.config/nvim/init.lua:

local l_flag = false
for _, arg in ipairs(vim.v.argv) do
    if l_flag == true then
        vim.g.script_name = vim.fs.basename(arg)
        break
    end
    if arg == "-l" then
        l_flag = true
    end
end
if vim.g.script_name == "nvimp" then
    require"prompt".name = "nvim"
    loadfile(vim.fs.joinpath(os.getenv("HOME"), ".config", "luaprc.lua"))()
    -- skip loading unnecessary vim plugins
    return
end

luajittex

Refer luatex.

Lua 5.3

luatex

texluap

luatex use kpse to search lua modules and binary lua modules.

$ kpsewhich -progname=luatex -format=clua prompt
/run/current-system/sw/lib/lua/5.1/prompt.so
$ kpsewhich -progname=luatex -format=lua prompt/utils
/home/wzy/.local/share/lua/5.1/prompt/utils.lua

You can edit web2c config to modify its default values. Such as, default config is:

/usr/share/texmf-dist/web2c/texmf.cnf:

LUAINPUTS = $TEXMFDOTDIR;$TEXMF/scripts/{$progname,$engine,}/{lua,}//;$TEXMF/tex/{luatex,plain,generic,latex,}//
CLUAINPUTS = $TEXMFDOTDIR;$SELFAUTOLOC/lib/{$progname,$engine,}/lua//

Add your changes to /usr/share/texmf.cnf. Or use environment variables. Assume this project is installed to ~/.local/share/lua/5.1.

# for -progname=luajitex
export LUAINPUTS_luajittex='$TEXMFDOTDIR;'"$HOME/.local/share/lua/5.1"';$TEXMF/tex/{luatex,plain,generic,latex}//'
export CLUAINPUTS_luajittex='$TEXMFDOTDIR;'"$HOME/.local/lib/lua/5.1"
# for any -progname=
export LUAINPUTS="$LUAINPUTS_luajittex"
export CLUAINPUTS="$CLUAINPUTS_luajittex"

Check your changes:

kpsewhich -progname=luatex -var-value=LUAINPUTS
kpsewhich -progname=luatex -var-value=CLUAINPUTS
kpsewhich -progname=luajittex -var-value=LUAINPUTS
kpsewhich -progname=luajittex -var-value=CLUAINPUTS

If you want to use lua REPL in \directlua{}, you can insert:

\directlua{require'prompt.tex'}

As example:

luajittex --shell-escape main.tex

Then you will get:

directlua

Broken in upstream

Lua 5.4

pandocp

Install

paru -S lua{,51,52,53}-prompt-style
luarocks install prompt-style

Related Projects

Use neovim as lua interpreter

  • neolua: Another lua interpreter based on neovim like nvimp. It doesn't provide a REPL like lua.
  • nlua: Another lua interpreter based on neovim like nvimp. It doesn't provide a REPL like lua.

Other luas

  • wezterm:
    • wezterm --config-file /the/path/weztermp
    • doesn't support shebang
    • can't load C modules in safe mode
  • xmake:
    • xmake l /the/path/xmake.lua
    • doesn't support shebang
    • xmake doesn't provide require()