alert!!! site for the old dublang version 0.6.x, see the latest version here
home - plugins - tutorials - history - manual - design
dublang system includes a plugin with same name, the
dublang
plugin
this plugin doesn't connect to external servives as others plugins
but instead it allows to run lua code, the code evaluated by
"CTRL + e"
is executed by lua 5.1, and it provides access
to dublang system api and also to the neovim api
example (using the neovim api)
#!dublang
-- set environment variable
vim.env.COLOR = 'blue'
-- get environment variable
return vim.env.COLOR
-- change vim colorsheme
vim.cmd('colorscheme ${COLOR}')
in addition to providing access to the neovim api this
dublang
plugin allows mixing other languages provided by
the others plugins on the same block
any other plugin can be executed through a lua function under a
#!dublang
region, for example tidalcycles code can be
executed through the function tidalcycles()
example (combining tidalcycles and mpv)
#!dublang
tidalcycles([[ d1 $ sound "cp" ]])
mpv([[ video mymovie:01 ]])
alert! when running plugins this way filters, triggers, etc are not executed
example of others plugins functions:
obs()
supercollider()
mpv()
sm()
espeak()
festival()
sardine()
alda()
etc...
besides the plugins functions the dublang
plugin
provides some others useful functions
schedule
schedule()
function enqueue a sequence of events to be
executed over time
the time is defined in seconds and the sequence starts at the second 1
example (schedule 4 events)
#!dublang
schedule({
[1] = function()
mpv([[clear]])
tidalcycles([[hush]])
end,
[5] = function()
mpv([[loadfile "${PWD}/videos/buzz/slice1.mp4"]])
tidalcycles([[xfadeIn 1 8 $ sound "808bd*8"]])
end,
[10] = function()
mpv([[curves $ pre color_negative]])
tidalcycles([[xfadeIn 1 4 $ sound "[808bd*8, bd*2]"]])
end,
[15] = function()
mpv([[loadfile "${PWD}/videos/buzz/slice4.mp4"]])
tidalcycles([[xfadeIn 1 16 $ sound "[~ ~ jazz:7 jazz:7/2]"]])
end,
})
the example above schedules 4 events to be executed on the time: 1s, 5s, 10s and the final event at the time 15s
see below a video demo created with the function
schedule()
(video demo source
code)
cycle
cycle()
executes a list of anonymous functions in a
infinite loop, the loop length is 1 second by default, the list of
functions is spreaded on the loop length
example (the 1st function is executed on time 0 and the 2nd on time 500 ms)
#!dublang
cycle({
function()
vim.notify("run function 1")
end,
function()
vim.notify("run function 2")
end,
})
it is possible to modify the default length of a cycle using the
function length()
see below a video demonstration using the function
cycle()
length
length()
modifies the default cycle length in
milliseconds
example (set the cycle length as 10 seconds)
#!dublang
length(10000)