Skip to content

Commit

Permalink
Replace "call " with "lua " at many places
Browse files Browse the repository at this point in the history
  • Loading branch information
jalvesaq committed Feb 8, 2024
1 parent a65ccb7 commit 0ba459f
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 20 deletions.
4 changes: 2 additions & 2 deletions R/nvimcom/DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: nvimcom
Version: 0.9.10
Date: 2024-02-06
Version: 0.9.11
Date: 2024-02-08
Title: Intermediate the Communication Between R and Either Neovim or Vim
Author: Jakson Aquino
Maintainer: Jakson Alves de Aquino <[email protected]>
Expand Down
2 changes: 1 addition & 1 deletion R/pdf_evince_back.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def on_window_close(self):
def on_sync_source(self, input_file, source_link, timestamp):
input_file = input_file.replace("file://", "")
input_file = input_file.replace("%20", " ")
nvimr_cmd("call SyncTeX_backward('" + input_file + "', " + str(source_link[0]) + ")\n")
nvimr_cmd("lua require('r.pdf.evince').SyncTeX_backward('" + input_file + "', " + str(source_link[0]) + ")\n")

def sigint_handler(sig, frame):
if sig == signal.SIGTERM:
Expand Down
2 changes: 1 addition & 1 deletion R/pdf_evince_forward.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def SyncView(self, input_file, data):
self._tmp_syncview = [input_file, data, 0]
self._handler = self._syncview_handler
self._get_dbus_name(True)
nvimr_cmd("call Evince_Again()")
nvimr_cmd("lua require('r.pdf.evince').again()")
else:
self.window.SyncView(input_file, data, 0, dbus_interface = "org.gnome.evince.Window")
nvimr_cmd("let g:rplugin.evince_loop = 0") # FIXME: don't use global variable
Expand Down
7 changes: 1 addition & 6 deletions lua/r/job.lua
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,7 @@ M.on_stdout = function(job_id, data, _)
end
end

if
cmd:match("^lua ")
or cmd:match("^call ")
or cmd:match("^let ")
or cmd:match("^unlet ")
then
if cmd:match("^lua ") or cmd:match("^call ") or cmd:match("^let ") then
vim.fn.execute(cmd)
else
if cmd:len() > 128 then cmd = cmd:sub(1, 128) .. " [...]" end
Expand Down
9 changes: 5 additions & 4 deletions lua/r/pdf/evince.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ local evince_list = {}
local py = nil
local evince_loop = 0
local config = require("r.config").get_config()
local rnw = require("r.rnw")

-- Check if python3 is executable, otherwise use python
if vim.fn.executable("python3") > 0 then
Expand Down Expand Up @@ -37,8 +38,8 @@ M.SyncTeX_forward = function(tpath, ppath, texln, _)
require("r.pdf").raise_window(string.gsub(ppath, ".*/", ""))
end

M.run_EvinceBackward = function()
local basenm = vim.fn.SyncTeX_GetMaster() .. ".pdf"
M.SyncTeX_backward = function()
local basenm = rnw.SyncTeX_GetMaster() .. ".pdf"
local pdfpath = vim.b.rplugin_pdfdir
.. "/"
.. vim.fn.substitute(basenm, ".*/", "", "")
Expand All @@ -62,9 +63,9 @@ M.run_EvinceBackward = function()
end

-- Avoid possible infinite loop
M.Evince_Again = function()
M.again = function()
evince_loop = evince_loop + 1
vim.fn.SyncTeX_forward()
rnw.SyncTeX_forward()
end

return M
6 changes: 3 additions & 3 deletions lua/r/pdf/okular.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ local config = require("r.config").get_config()

local on_okular_stdout = function(_, data, _)
for _, cmd in ipairs(data) do
if vim.startswith(cmd, "call ") then vim.cmd(cmd) end
if vim.startswith(cmd, "lua ") then vim.cmd(cmd) end
end
end

Expand All @@ -14,7 +14,7 @@ M.open = function(fullpath)
"okular",
"--unique",
"--editor-cmd",
'echo \'call SyncTeX_backward("%f", "%l")\'',
'echo \'lua require("r.rnw").SyncTeX_backward("%f", "%l")\'',
fullpath,
}, {
detach = true,
Expand All @@ -30,7 +30,7 @@ M.SyncTeX_forward = function(tpath, ppath, texln, _)
"okular",
"--unique",
"--editor-cmd",
'echo \'call SyncTeX_backward("%f", "%l")\'',
'echo \'lua require("r.rnw").SyncTeX_backward("%f", "%l")\'',
pdfname .. "#src:" .. texln .. texname,
}, {
detach = true,
Expand Down
5 changes: 3 additions & 2 deletions lua/r/pdf/zathura.lua
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
local warn = require("r").warn
local config = require("r.config").get_config()
local pdf = require("r.pdf")
local rnw = require("r.rnw")

local zathura_pid = {}

local has_dbus_send = vim.fn.executable("dbus-send") > 0 and 1 or 0

local ZathuraJobStdout = function(_, data, _)
for _, cmd in ipairs(data) do
if vim.startswith(cmd, "call ") then vim.cmd(cmd) end
if vim.startswith(cmd, "lua ") then vim.cmd(cmd) end
end
end

local start2 = function(fullpath)
local job_id = vim.fn.jobstart({
"zathura",
"--synctex-editor-command",
'echo \'call SyncTeX_backward("%{input}", "%{line}")\'',
'echo \'lua require("r.rnw").SyncTeX_backward("%{input}", "%{line}")\'',
fullpath,
}, {
detach = true,
Expand Down
2 changes: 1 addition & 1 deletion lua/r/send.lua
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ local knit_child = function(line, godown)
M.cmd("require(knitr); knit('" .. cfile .. "', output=NULL)")
if godown:find("down") then
vim.api.nvim_win_set_cursor(0, { vim.fn.line(".") + 1, 1 })
vim.cmd("call cursor.move_next_line()")
cursor.move_next_line()
end
else
warn("File not found: '" .. cfile .. "'")
Expand Down

0 comments on commit 0ba459f

Please sign in to comment.