1. Run is now handled by the global run function instead of language specific runs 2. Fixed some notifications, making them more unified and informational 3. Cleaned up c/c++ code that was broken from create_file changes 4. Create_file has new architecture. It still takes in a function but can be disabled to be skipped (this will most likely change later as its unoptimized) 5. Added rust support 6. Keybinds are now only setup for language specific 7. Project creation has error and nil checking allowing for skipping and more customizable templates and setups for future languages
71 lines
2.2 KiB
Lua
71 lines
2.2 KiB
Lua
local M = {}
|
|
|
|
local utils = require("vern-nvim.utils")
|
|
|
|
---@param opts VernJavaConfig Takes a table for the runtime
|
|
function M.run(opts)
|
|
opts = opts or {}
|
|
local root = utils.proj_root() or "."
|
|
local context = {
|
|
project_name = utils.proj_name(),
|
|
company_name = opts.env.author,
|
|
file_name = "",
|
|
}
|
|
|
|
local src_root = vim.fs.joinpath(
|
|
root,
|
|
utils.resolve_path(opts.java.dirs.src, opts.java.dirs, context)
|
|
)
|
|
local build_dir = root .. "/bin"
|
|
local build_cmd = string.format(
|
|
"javac -d %s -sourcepath %s $(find %s -name '*java')",
|
|
build_dir,
|
|
src_root,
|
|
src_root
|
|
)
|
|
|
|
vim.system({ "sh", "-c", build_cmd }, { text = true }, function(obj)
|
|
if obj.code ~= 0 then
|
|
vim.schedule(function()
|
|
local error_obj = (obj.stderr ~= "" and obj.stderr)
|
|
or obj.stdout
|
|
or ""
|
|
local error_lines = vim.list_extend(
|
|
{ "Error During compilation" },
|
|
vim.split(error_obj, "\n", { trimempty = true })
|
|
)
|
|
local buf, _ = utils.term(
|
|
{ "echo 'compilation failed'" },
|
|
opts.terminal,
|
|
true
|
|
)
|
|
if buf and vim.api.nvim_buf_is_valid(buf) then
|
|
vim.api.nvim_set_option_value(
|
|
"modifiable",
|
|
true,
|
|
{ buf = buf }
|
|
)
|
|
vim.api.nvim_buf_set_lines(buf, 0, -1, false, error_lines)
|
|
vim.api.nvim_set_option_value(
|
|
"modifiable",
|
|
false,
|
|
{ buf = buf }
|
|
)
|
|
end
|
|
end)
|
|
else
|
|
vim.schedule(function()
|
|
local run_cmd = string.format(
|
|
"java -cp %s com.%s.%s.Main",
|
|
build_dir,
|
|
context.company_name,
|
|
context.project_name
|
|
)
|
|
utils.term({ run_cmd }, opts.terminal, false)
|
|
end)
|
|
end
|
|
end)
|
|
end
|
|
|
|
return M
|