小编Ber*_*kin的帖子

在 Neovim 中运行异步 Lua 函数

我试图让 Vim 在白天自动更改其主题,每 30 秒运行一次检查。我正在遵循指南。不过,我想借助这个网站将他的 Vimscript 功能移植到 Lua 上。问题是,当我运行代码时,它在前台运行,这意味着在杀死它之前我无法执行任何操作。

这是 Vimscript 代码:

" Automatic light mode / dark mode switcher
function! ChangeColorScheme(channel, msg)
  let time = trim(a:msg)
  if time ==# "day"
    call LightMode()
  else
    call DarkMode()
  endif
endfunction

function! Sunshine(timer)
  if executable("sunshine")
    " Add your desired location here instead of '@45 15' (I probably could have
    " made it into a variable)
    let job = job_start(["sunshine", "-s", "@45 15"], {"out_cb": "ChangeColorScheme"})
  else
    call DarkMode()
  endif
endfunction …
Run Code Online (Sandbox Code Playgroud)

lua asynchronous neovim

3
推荐指数
1
解决办法
3237
查看次数

标签 统计

asynchronous ×1

lua ×1

neovim ×1