aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/language_java.lua106
-rw-r--r--plugins/language_php.lua177
-rw-r--r--plugins/language_phps.lua140
-rw-r--r--plugins/language_rescript.lua59
-rw-r--r--plugins/language_toml.lua2
-rw-r--r--plugins/linenumbers.lua2
-rw-r--r--plugins/minimap.lua7
-rw-r--r--plugins/texcompile.lua169
8 files changed, 445 insertions, 217 deletions
diff --git a/plugins/language_java.lua b/plugins/language_java.lua
index 8c6e98e..e6d3735 100644
--- a/plugins/language_java.lua
+++ b/plugins/language_java.lua
@@ -20,55 +20,63 @@ syntax.add {
{ pattern = "[%a_][%w_]*", type = "symbol" },
},
symbols = {
- ["if"] = "keyword",
- ["then"] = "keyword",
- ["else"] = "keyword",
- ["else if"] = "keyword",
- ["do"] = "keyword",
- ["while"] = "keyword",
- ["for"] = "keyword",
- ["new"] = "keyword",
- ["break"] = "keyword",
- ["continue"] = "keyword",
- ["return"] = "keyword",
- ["goto"] = "keyword",
- ["class"] = "keyword",
- ["implements"] = "keyword",
- ["extends"] = "keyword",
- ["private"] = "keyword",
- ["protected"] = "keyword",
- ["public"] = "keyword",
- ["abstract"] = "keyword",
- ["interface"] = "keyword",
- ["assert"] = "keyword",
- ["import"] = "keyword",
- ["native"] = "keyword",
- ["package"] = "keyword",
- ["super"] = "keyword",
- ["synchronized"] = "keyword",
- ["instanceof"] = "keyword",
- ["enum"] = "keyword",
- ["catch"] = "keyword",
- ["throw"] = "keyword",
- ["throws"] = "keyword",
- ["try"] = "keyword",
- ["transient"] = "keyword",
- ["finally"] = "keyword",
- ["static"] = "keyword",
- ["volatile"] = "keyword",
- ["final"] = "keyword",
- ["switch"] = "keyword",
- ["case"] = "keyword",
- ["default"] = "keyword",
- ["void"] = "keyword",
- ["int"] = "keyword2",
- ["short"] = "keyword2",
- ["byte"] = "keyword2",
- ["long"] = "keyword2",
- ["float"] = "keyword2",
- ["double"] = "keyword2",
- ["char"] = "keyword2",
- ["boolean"] = "keyword2",
+ ["abstract"] = "keyword",
+ ["assert"] = "keyword",
+ ["break"] = "keyword",
+ ["case"] = "keyword",
+ ["catch"] = "keyword",
+ ["class"] = "keyword",
+ ["const"] = "keyword",
+ ["continue"] = "keyword",
+ ["default"] = "keyword",
+ ["do"] = "keyword",
+ ["else"] = "keyword",
+ ["enum"] = "keyword",
+ ["extends"] = "keyword",
+ ["final"] = "keyword",
+ ["finally"] = "keyword",
+ ["for"] = "keyword",
+ ["if"] = "keyword",
+ ["goto"] = "keyword",
+ ["implements"] = "keyword",
+ ["import"] = "keyword",
+ ["instanceof"] = "keyword",
+ ["interface"] = "keyword",
+ ["native"] = "keyword",
+ ["new"] = "keyword",
+ ["package"] = "keyword",
+ ["permits"] = "keyword",
+ ["private"] = "keyword",
+ ["protected"] = "keyword",
+ ["public"] = "keyword",
+ ["record"] = "keyword",
+ ["return"] = "keyword",
+ ["sealed"] = "keyword",
+ ["static"] = "keyword",
+ ["strictfp"] = "keyword",
+ ["super"] = "keyword",
+ ["switch"] = "keyword",
+ ["synchronized"] = "keyword",
+ ["this"] = "keyword",
+ ["throw"] = "keyword",
+ ["throws"] = "keyword",
+ ["transient"] = "keyword",
+ ["try"] = "keyword",
+ ["var"] = "keyword",
+ ["void"] = "keyword",
+ ["volatile"] = "keyword",
+ ["while"] = "keyword",
+ ["yield"] = "keyword",
+
+ ["boolean"] = "keyword2",
+ ["byte"] = "keyword2",
+ ["char"] = "keyword2",
+ ["double"] = "keyword2",
+ ["float"] = "keyword2",
+ ["int"] = "keyword2",
+ ["long"] = "keyword2",
+ ["short"] = "keyword2",
+
["true"] = "literal",
["false"] = "literal",
["null"] = "literal",
diff --git a/plugins/language_php.lua b/plugins/language_php.lua
index 4f107aa..5ee6a93 100644
--- a/plugins/language_php.lua
+++ b/plugins/language_php.lua
@@ -1,13 +1,149 @@
-- mod-version:2 -- lite-xl 2.0
--[[
- language_php.lua
- provides php syntax support allowing mixed html, css and js
- version: 20210513_144200
-
- Depends on plugin language_phps.lua version >= 20210512_181200
+ language_php.lua
+ provides php syntax support allowing mixed html, css and js
+ version: 20210902_1
--]]
local syntax = require "core.syntax"
+-- load syntax dependencies to add additional rules
+require "plugins.language_css"
+require "plugins.language_js"
+
+-- define the core php syntax coloring
+syntax.add {
+ files = { "%.phps$" },
+ headers = "^<%?php",
+ comment = "//",
+ patterns = {
+ -- Attributes
+ { pattern = {"#%[", "%]"}, type = "normal" },
+ -- Comments
+ { pattern = "//.-\n", type = "comment" },
+ { pattern = "#.-\n", type = "comment" },
+ { pattern = { "/%*", "%*/" }, type = "comment" },
+ -- The '\\' is for escaping to work on " or '
+ { pattern = { '"', '"', '\\' }, type = "string" },
+ { pattern = { "'", "'", '\\' }, type = "string" },
+ { pattern = "0[bB][%d]+", type = "number" },
+ { pattern = "0[xX][%da-fA-F]+", type = "number" },
+ { pattern = "-?%d[%d_%.eE]*", type = "number" },
+ { pattern = "-?%.?%d+", type = "number" },
+ { pattern = "[%.%+%-=/%*%^%%<>!~|&%?:]", type = "operator" },
+ -- Variables
+ { pattern = "%$[%w_]+", type = "keyword2" },
+ -- Respect control structures, treat as keyword not function
+ { pattern = "if[%s]*%f[(]", type = "keyword" },
+ { pattern = "else[%s]*%f[(]", type = "keyword" },
+ { pattern = "elseif[%s]*%f[(]", type = "keyword" },
+ { pattern = "for[%s]*%f[(]", type = "keyword" },
+ { pattern = "foreach[%s]*%f[(]", type = "keyword" },
+ { pattern = "while[%s]*%f[(]", type = "keyword" },
+ { pattern = "catch[%s]*%f[(]", type = "keyword" },
+ { pattern = "switch[%s]*%f[(]", type = "keyword" },
+ { pattern = "match[%s]*%f[(]", type = "keyword" },
+ { pattern = "fn[%s]*%f[(]", type = "keyword" },
+ -- All functions that aren't control structures
+ { pattern = "[%a_][%w_]*[%s]*%f[(]", type = "function" },
+ -- Array type hint not added on symbols to also make it work
+ -- as a function call
+ { pattern = "array", type = "literal" },
+ -- Match static or namespace container on sub element access
+ { pattern = "[%a_][%w_]*[%s]*%f[:]", type = "literal" },
+ -- Uppercase constants of at least 3 characters in len
+ { pattern = "%u[%u_][%u%d_]+", type = "number" },
+ -- Magic constants
+ { pattern = "__[%u]+__", type = "number" },
+ -- Everything else
+ { pattern = "[%a_][%w_]*", type = "symbol" },
+ },
+ symbols = {
+ ["return"] = "keyword",
+ ["if"] = "keyword",
+ ["else"] = "keyword",
+ ["elseif"] = "keyword",
+ ["endif"] = "keyword",
+ ["declare"] = "keyword",
+ ["enddeclare"] = "keyword",
+ ["switch"] = "keyword",
+ ["endswitch"] = "keyword",
+ ["as"] = "keyword",
+ ["do"] = "keyword",
+ ["for"] = "keyword",
+ ["endfor"] = "keyword",
+ ["foreach"] = "keyword",
+ ["endforeach"] = "keyword",
+ ["while"] = "keyword",
+ ["endwhile"] = "keyword",
+ ["match"] = "keyword",
+ ["case"] = "keyword",
+ ["continue"] = "keyword",
+ ["default"] = "keyword",
+ ["break"] = "keyword",
+ ["goto"] = "keyword",
+
+ ["try"] = "keyword",
+ ["catch"] = "keyword",
+ ["throw"] = "keyword",
+ ["finally"] = "keyword",
+
+ ["class"] = "keyword",
+ ["trait"] = "keyword",
+ ["interface"] = "keyword",
+ ["public"] = "keyword",
+ ["static"] = "keyword",
+ ["protected"] = "keyword",
+ ["private"] = "keyword",
+ ["abstract"] = "keyword",
+ ["final"] = "keyword",
+ ["$this"] = "literal",
+
+ ["function"] = "keyword",
+ ["fn"] = "keyword",
+ ["global"] = "keyword",
+ ["var"] = "keyword",
+ ["const"] = "keyword",
+
+ ["bool"] = "literal",
+ ["boolean"] = "literal",
+ ["int"] = "literal",
+ ["integer"] = "literal",
+ ["real"] = "literal",
+ ["double"] = "literal",
+ ["float"] = "literal",
+ ["string"] = "literal",
+ ["object"] = "literal",
+ ["callable"] = "literal",
+ ["iterable"] = "literal",
+ ["void"] = "literal",
+ ["parent"] = "literal",
+ ["self"] = "literal",
+ ["mixed"] = "literal",
+
+ ["namespace"] = "keyword",
+ ["extends"] = "keyword",
+ ["implements"] = "keyword",
+ ["instanceof"] = "keyword",
+ ["require"] = "keyword",
+ ["require_once"] = "keyword",
+ ["include"] = "keyword",
+ ["include_once"] = "keyword",
+ ["use"] = "keyword",
+ ["new"] = "keyword",
+ ["clone"] = "keyword",
+
+ ["true"] = "number",
+ ["false"] = "number",
+ ["NULL"] = "number",
+ ["null"] = "number",
+
+ ["print"] = "function",
+ ["echo"] = "function",
+ ["exit"] = "function",
+ },
+}
+
+-- allows html, css and js coloring on php files
syntax.add {
files = { "%.php$", "%.phtml" },
patterns = {
@@ -68,3 +204,34 @@ syntax.add {
symbols = {},
}
+-- allow coloring of php code inside css and js code
+local syntaxes = { "css", "js" }
+for _, ext in pairs(syntaxes) do
+ local syntax_table = syntax.get("file."..ext, "")
+
+ table.insert(
+ syntax_table.patterns,
+ 1,
+ {
+ pattern = {
+ "<%?=?",
+ "%?>"
+ },
+ syntax = ".phps",
+ type = "keyword2"
+ }
+ )
+
+ table.insert(
+ syntax_table.patterns,
+ 1,
+ {
+ pattern = {
+ "<%?php%s+",
+ "%?>"
+ },
+ syntax = ".phps",
+ type = "keyword2"
+ }
+ )
+end
diff --git a/plugins/language_phps.lua b/plugins/language_phps.lua
deleted file mode 100644
index 082b962..0000000
--- a/plugins/language_phps.lua
+++ /dev/null
@@ -1,140 +0,0 @@
--- mod-version:2 -- lite-xl 2.0
---[[
- language_phps.lua
- complement to language_php.lua providing the php syntax support
- version: 20210512_181200
---]]
-local syntax = require "core.syntax"
-
-syntax.add {
- files = { "%.phps$" },
- headers = "^<%?php",
- comment = "//",
- patterns = {
- -- Attributes
- { pattern = {"#%[", "%]"}, type = "normal" },
- -- Comments
- { pattern = "//.-\n", type = "comment" },
- { pattern = "#.-\n", type = "comment" },
- { pattern = { "/%*", "%*/" }, type = "comment" },
- -- The '\\' is for escaping to work on " or '
- { pattern = { '"', '"', '\\' }, type = "string" },
- { pattern = { "'", "'", '\\' }, type = "string" },
- { pattern = "0[bB][%d]+", type = "number" },
- { pattern = "0[xX][%da-fA-F]+", type = "number" },
- { pattern = "-?%d[%d_%.eE]*", type = "number" },
- { pattern = "-?%.?%d+", type = "number" },
- { pattern = "[%.%+%-=/%*%^%%<>!~|&%?:]", type = "operator" },
- -- Variables
- { pattern = "%$[%w_]+", type = "keyword2" },
- -- Respect control structures, treat as keyword not function
- { pattern = "if[%s]*%f[(]", type = "keyword" },
- { pattern = "else[%s]*%f[(]", type = "keyword" },
- { pattern = "elseif[%s]*%f[(]", type = "keyword" },
- { pattern = "for[%s]*%f[(]", type = "keyword" },
- { pattern = "foreach[%s]*%f[(]", type = "keyword" },
- { pattern = "while[%s]*%f[(]", type = "keyword" },
- { pattern = "catch[%s]*%f[(]", type = "keyword" },
- { pattern = "switch[%s]*%f[(]", type = "keyword" },
- { pattern = "match[%s]*%f[(]", type = "keyword" },
- { pattern = "fn[%s]*%f[(]", type = "keyword" },
- -- All functions that aren't control structures
- { pattern = "[%a_][%w_]*[%s]*%f[(]", type = "function" },
- -- Array type hint not added on symbols to also make it work
- -- as a function call
- { pattern = "array", type = "literal" },
- -- Match static or namespace container on sub element access
- { pattern = "[%a_][%w_]*[%s]*%f[:]", type = "literal" },
- -- Uppercase constants of at least 3 characters in len
- { pattern = "%u[%u_][%u%d_]+", type = "number" },
- -- Magic constants
- { pattern = "__[%u]+__", type = "number" },
- -- Everything else
- { pattern = "[%a_][%w_]*", type = "symbol" },
- },
- symbols = {
- ["return"] = "keyword",
- ["if"] = "keyword",
- ["else"] = "keyword",
- ["elseif"] = "keyword",
- ["endif"] = "keyword",
- ["declare"] = "keyword",
- ["enddeclare"] = "keyword",
- ["switch"] = "keyword",
- ["endswitch"] = "keyword",
- ["as"] = "keyword",
- ["do"] = "keyword",
- ["for"] = "keyword",
- ["endfor"] = "keyword",
- ["foreach"] = "keyword",
- ["endforeach"] = "keyword",
- ["while"] = "keyword",
- ["endwhile"] = "keyword",
- ["switch"] = "keyword",
- ["match"] = "keyword",
- ["case"] = "keyword",
- ["continue"] = "keyword",
- ["default"] = "keyword",
- ["break"] = "keyword",
- ["goto"] = "keyword",
-
- ["try"] = "keyword",
- ["catch"] = "keyword",
- ["throw"] = "keyword",
- ["finally"] = "keyword",
-
- ["class"] = "keyword",
- ["trait"] = "keyword",
- ["interface"] = "keyword",
- ["public"] = "keyword",
- ["static"] = "keyword",
- ["protected"] = "keyword",
- ["private"] = "keyword",
- ["abstract"] = "keyword",
- ["final"] = "keyword",
- ["$this"] = "literal",
-
- ["function"] = "keyword",
- ["fn"] = "keyword",
- ["global"] = "keyword",
- ["var"] = "keyword",
- ["const"] = "keyword",
-
- ["bool"] = "literal",
- ["boolean"] = "literal",
- ["int"] = "literal",
- ["integer"] = "literal",
- ["real"] = "literal",
- ["double"] = "literal",
- ["float"] = "literal",
- ["string"] = "literal",
- ["object"] = "literal",
- ["callable"] = "literal",
- ["iterable"] = "literal",
- ["void"] = "literal",
- ["parent"] = "literal",
- ["self"] = "literal",
- ["mixed"] = "literal",
-
- ["namespace"] = "keyword",
- ["extends"] = "keyword",
- ["implements"] = "keyword",
- ["instanceof"] = "keyword",
- ["require"] = "keyword",
- ["require_once"] = "keyword",
- ["include"] = "keyword",
- ["include_once"] = "keyword",
- ["use"] = "keyword",
- ["new"] = "keyword",
- ["clone"] = "keyword",
-
- ["true"] = "number",
- ["false"] = "number",
- ["NULL"] = "number",
- ["null"] = "number",
-
- ["print"] = "function",
- ["echo"] = "function",
- ["exit"] = "function",
- },
-}
diff --git a/plugins/language_rescript.lua b/plugins/language_rescript.lua
new file mode 100644
index 0000000..94dc964
--- /dev/null
+++ b/plugins/language_rescript.lua
@@ -0,0 +1,59 @@
+-- mod-version:2 -- lite-xl 2.0
+local syntax = require "core.syntax"
+
+syntax.add {
+ files = { "%.res$" },
+ comment = "//",
+ patterns = {
+ { pattern = "//.-\n", type = "comment" },
+ { pattern = { "/%*", "%*/" }, type = "comment" },
+ { pattern = { '"', '"', '\\' }, type = "string" },
+ { pattern = { "'", "'", '\\' }, type = "string" },
+ { pattern = { "`", "`", '\\' }, type = "string" },
+ { pattern = "#[%a_][%w_]*", type = "literal" },
+ { pattern = "0x[%da-fA-F]+", type = "number" },
+ { pattern = "-?%d+[%d%.eE]*", type = "number" },
+ { pattern = "-?%.?%d+", type = "number" },
+ { pattern = "[%+%-=/%*%^%%<>!~|&]", type = "operator" },
+ { pattern = "%f[^%.>]%l[%w_]*", type = "function" },
+ { pattern = "%l[%w_]*%f[(]", type = "function" },
+ { pattern = "%u[%w_]*", type = "keyword2" },
+ { pattern = "[%l_][%w_%.]*", type = "symbol" },
+ { pattern = "@%l[%w_]*", type = "string" },
+ },
+ symbols = {
+ ["and"] = "keyword",
+ ["array"] = "keyword2",
+ ["as"] = "keyword",
+ ["assert"] = "keyword",
+ ["bool"] = "keyword2",
+ ["constraint"] = "keyword",
+ ["downto"] = "keyword",
+ ["else"] = "keyword",
+ ["exception"] = "keyword",
+ ["external"] = "keyword",
+ ["false"] = "literal",
+ ["for"] = "keyword",
+ ["if"] = "keyword",
+ ["in"] = "keyword",
+ ["int"] = "keyword2",
+ ["include"] = "keyword",
+ ["lazy"] = "keyword",
+ ["let"] = "keyword",
+ ["module"] = "keyword",
+ ["mutable"] = "keyword",
+ ["of"] = "keyword",
+ ["open"] = "keyword",
+ ["option"] = "keyword2",
+ ["rec"] = "keyword",
+ ["switch"] = "keyword",
+ ["string"] = "keyword2",
+ ["to"] = "keyword",
+ ["true"] = "literal",
+ ["try"] = "keyword",
+ ["type"] = "keyword",
+ ["when"] = "keyword",
+ ["while"] = "keyword",
+ ["with"] = "keyword",
+ }
+}
diff --git a/plugins/language_toml.lua b/plugins/language_toml.lua
index 9de31f9..3774dfb 100644
--- a/plugins/language_toml.lua
+++ b/plugins/language_toml.lua
@@ -1,4 +1,4 @@
--- lite-xl 1.16
+-- mod-version:2
local syntax = require "core.syntax"
diff --git a/plugins/linenumbers.lua b/plugins/linenumbers.lua
index fde0a08..1b0bdc6 100644
--- a/plugins/linenumbers.lua
+++ b/plugins/linenumbers.lua
@@ -1,4 +1,4 @@
--- mod-version:1 -- lite-xl 1.16
+-- mod-version:2 -- lite-xl 2.0
local config = require "core.config"
local style = require "core.style"
local DocView = require "core.docview"
diff --git a/plugins/minimap.lua b/plugins/minimap.lua
index c9e1c54..3f4a2a2 100644
--- a/plugins/minimap.lua
+++ b/plugins/minimap.lua
@@ -289,6 +289,13 @@ DocView.draw_scrollbar = function(self)
end
+local prev_update = DocView.update
+DocView.update = function (self)
+ if not config.plugins.minimap.enabled then return prev_update(self) end
+ self.size.x = self.size.x - config.plugins.minimap.width * SCALE
+ return prev_update(self)
+end
+
command.add(nil, {
["minimap:toggle-visibility"] = function()
config.plugins.minimap.enabled = not config.plugins.minimap.enabled
diff --git a/plugins/texcompile.lua b/plugins/texcompile.lua
index 2f53513..517aa9b 100644
--- a/plugins/texcompile.lua
+++ b/plugins/texcompile.lua
@@ -1,44 +1,171 @@
-- mod-version:2 -- lite-xl 2.0
local core = require "core"
+local config = require "core.config"
local command = require "core.command"
+local common = require "core.common"
local keymap = require "core.keymap"
-command.add("core.docview", {
- ["texcompile:tex-compile"] = function()
- local av = core.active_view
+-- This code use an adaptation of the rxi/console plugin code to
+-- start commands.
+
+local pending_threads = {}
+local thread_active = false
--- User's home directory
- local homedir = ""
+local function push_output(str, opt)
+ -- By default we just ignore the output of a command.
+ -- print(">>OUTPUT:", str)
+end
+
+local function read_file(filename, offset)
+ local fp = io.open(filename, "rb")
+ fp:seek("set", offset or 0)
+ local res = fp:read("*a")
+ fp:close()
+ return res
+end
+
+local function write_file(filename, text)
+ local fp = io.open(filename, "w")
+ fp:write(text)
+ fp:close()
+end
+
+local function init_opt(opt)
+ local res = {
+ command = "",
+ arguments = {},
+ on_complete = function() end,
+ }
+ for k, v in pairs(res) do
+ res[k] = opt[k] or v
+ end
+ return res
+end
+local files = {
+ script = core.temp_filename(PLATFORM == "Windows" and ".bat"),
+ script2 = core.temp_filename(PLATFORM == "Windows" and ".bat"),
+ output = core.temp_filename(),
+ complete = core.temp_filename(),
+}
+
+local function command_run(opt)
+ opt = init_opt(opt)
+
+ local function thread()
+ -- init script file(s)
+ local args_quoted = {}
+ for i, arg in ipairs(opt.arguments) do args_quoted[i] = string.format("%q", arg) end
+ local args_concat = table.concat(args_quoted, " ")
+ local working_dir = opt.working_dir or "."
if PLATFORM == "Windows" then
- homedir = os.getenv("USERPROFILE")
+ write_file(files.script, string.format("%s %s\n", opt.command, args_concat))
+ write_file(files.script2, string.format([[
+ @echo off
+ cd %q
+ call %q >%q 2>&1
+ echo "" >%q
+ exit
+ ]], working_dir, files.script, files.output, files.complete))
+ system.exec(string.format("call %q", files.script2))
+ else
+ write_file(files.script, string.format([[
+ cd %q
+ %s %s
+ touch %q
+ ]], working_dir, opt.command, args_concat, files.complete))
+ system.exec(string.format("bash %q >%q 2>&1", files.script, files.output))
+ end
+
+ -- checks output file for change and reads
+ local last_size = 0
+ local function check_output_file()
+ if PLATFORM == "Windows" then
+ local fp = io.open(files.output)
+ if fp then fp:close() end
+ end
+ local info = system.get_file_info(files.output)
+ if info and info.size > last_size then
+ local text = read_file(files.output, last_size)
+ push_output(text, opt)
+ last_size = info.size
+ end
+ end
+
+ -- read output file until we get a file indicating completion
+ while not system.get_file_info(files.complete) do
+ check_output_file()
+ coroutine.yield(0.1)
+ end
+ check_output_file()
+
+ -- clean up and finish
+ for _, file in pairs(files) do
+ os.remove(file)
+ end
+ opt.on_complete()
+
+ -- handle pending thread
+ local pending = table.remove(pending_threads, 1)
+ if pending then
+ core.add_thread(pending)
else
- homedir = os.getenv("HOME")
+ thread_active = false
end
+ end
+
+ -- push/init thread
+ if thread_active then
+ table.insert(pending_threads, thread)
+ else
+ core.add_thread(thread)
+ thread_active = true
+ end
+end
--- The current (La)TeX file and path
+command.add("core.docview", {
+ ["texcompile:tex-compile"] = function()
+ local av = core.active_view
+
+ -- The current (La)TeX file and path
local texname = av:get_name()
- local texpath = av:get_filename()
- texpath = string.gsub(texpath, '~', homedir)
- texpath = string.gsub(texpath, texname, '')
+ local texpath = common.dirname(av:get_filename())
+
+ -- Add in your user's config file something like:
+ --
+ -- config.texcompile = {
+ -- latex_command = "pdflatex",
+ -- view_command = "evince",
+ -- }
+ --
+ -- On windows you may use the full path for the command like:
+ --
+ -- latex_command = [[c:\miktex\miktex\bin\x64\pdflatex.exe]],
--- LaTeX compiler - is there any provided by the environment
- local texcmd = os.getenv("LITE_LATEX_COMPILER")
+ -- LaTeX compiler - is there any provided by the environment
+ local texcmd = config.texcompile and config.texcompile.latex_command
+ local viewcmd = config.texcompile and config.texcompile.view_command
- if texcmd == nil then
+ if not texcmd then
core.log("No LaTeX compiler found")
else
core.log("LaTeX compiler is %s, compiling %s", texcmd, texname)
- system.exec(string.format("cd %q && %q %q", texpath, texcmd, texname))
- end
+ command_run {
+ command = texcmd,
+ arguments = { texname },
+ working_dir = texpath,
+ on_complete = function() core.log("Tex compiling command terminated.") end
+ }
--- core.add_thread(function()
--- coroutine.yield(5)
--- os.remove(htmlfile)
--- end)
+ local pdfname = texname:gsub("%.tex$", ".pdf")
+ command_run {
+ command = viewcmd,
+ arguments = { pdfname },
+ working_dir = texpath
+ }
+ end
end
})
-
keymap.add { ["ctrl+shift+t"] = "texcompile:tex-compile" }