Comments (4)
Starting from the example in the README:
local core = require "core"
local command = require "core.command"
local keymap = require "core.keymap"
local console = require "plugins.console"
command.add("core.docview", {
["project:build-project"] = function()
core.log "Building..."
local build_command
if string.match(core.active_view.doc.filename, "%.lua$") then
build_command = "./build_lua.sh"
elseif string.match(core.active_view.doc.filename, "%.c$") then
build_command = "./build_c.sh"
else
return
end
console.run {
command = build_command,
file_pattern = "(.*):(%d+):(%d+): (.*)$",
cwd = ".",
on_complete = function(retcode) core.log("Build complete with return code "..retcode) end,
}
end
})
keymap.add { ["ctrl+b"] = "project:build-project" }
this will run build_lua.sh
if you're currently in a Lua file, or build_c.sh
if you're in a C file.
from console.
@Guldoman Consider this scenario, lets say I have a folder called "Project" and in that folder I have multiple python files file1.py, file2.py,.....file10.py How do I write a general build script such that when lite-xl focus file1.py it should only run that python script (ctrl+b) and if I change my focus to file3.py and run (ctrl+b) it should only run that python script.
from console.
Starting from the example I provided, add a new string.match
condition that matches python files and set the build_command
variable like this:
build_command = string.format("python %q", core.active_view.doc.abs_filename)
This will run python /path/to/current_file.py
.
from console.
it worked and thank you for helping me. A suggestion if possible can you edit the readme to include this information as well, for noobs like me this is much more simpler.
local core = require "core"
local command = require "core.command"
local keymap = require "core.keymap"
local console = require "plugins.console"
command.add("core.docview", {
["project:build-project"] = function()
core.log "Building..."
local build_command
if string.match(core.active_view.doc.filename, "%.py$") then
build_command = string.format("python %q", core.active_view.doc.abs_filename)
elseif string.match(core.active_view.doc.filename, "%.c$") then
build_command = "./build_c.sh"
elseif string.match(core.active_view.doc.filename, "%.lua$") then
build_command = "./build_lua.sh"
else
return
end
console.run {
command = build_command,
file_pattern = "(.*):(%d+):(%d+): (.*)$",
cwd = ".",
on_complete = function(retcode) core.log("Build complete with return code "..retcode) end,
}
end
})
keymap.add { ["ctrl+b"] = "project:build-project" }
from console.
Related Issues (8)
- Closing opened files
- can i change console position to right?
- No all compilers return line and col number, but a range! HOT 1
- Update to work with Lite XL 2.0 HOT 2
- REPL loop. HOT 2
- Node issues on Windows
- Love.exe creates its own console, instead of using the launch console so the output is not captured
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from console.