docs: removed .polydev mentions and changed presets names
fix: presets had improper variable names on call fix: java now builds properly and runs
This commit is contained in:
@@ -12,7 +12,6 @@ M.defaults = {
|
||||
rust = {
|
||||
project_root = "~/Projects/Rust",
|
||||
keybinds = {
|
||||
["<leader>pb"] = "RustBuild",
|
||||
["<leader>pr"] = "RustRun",
|
||||
},
|
||||
},
|
||||
@@ -39,7 +38,6 @@ M.defaults = {
|
||||
project_root = "~/Projects/C",
|
||||
keybinds = {
|
||||
["<leader>pr"] = "CRun",
|
||||
["<leader>pb"] = "NewCHeaderFile",
|
||||
},
|
||||
build_attributes = "",
|
||||
},
|
||||
@@ -47,7 +45,6 @@ M.defaults = {
|
||||
project_root = "~/Projects/Cpp",
|
||||
keybinds = {
|
||||
["<leader>pr"] = "CppRun",
|
||||
["<leader>pb"] = "NewCppHeaderFile",
|
||||
},
|
||||
build_attributes = "",
|
||||
},
|
||||
|
||||
@@ -1,25 +1,21 @@
|
||||
local M = {}
|
||||
|
||||
function M.setup(opts)
|
||||
local opts = opts or {}
|
||||
local config = require("Polydev.configs")
|
||||
local ui = require("Polydev.ui")
|
||||
config.setup(opts)
|
||||
require("Polydev.utils").setup(opts)
|
||||
for lang, user_opts in pairs(opts) do
|
||||
local default = config.defaults[lang] or {}
|
||||
config.user_config[lang] = vim.tbl_deep_extend("force", default, user_opts)
|
||||
config.user_config[lang] = vim.tbl_deep_extend("force", config.defaults[lang] or {}, user_opts)
|
||||
end
|
||||
|
||||
vim.api.nvim_create_user_command("PolydevOpen", ui.open_project_manager, {})
|
||||
vim.api.nvim_create_user_command("PolydevGet", require("Polydev.utils").get_project_root, {})
|
||||
|
||||
local keys = vim.tbl_deep_extend("force", {}, config.get("globals").keybinds, opts or {})
|
||||
for key, command in pairs(keys) do
|
||||
for key, _ in pairs(keys) do
|
||||
vim.keymap.set("n", key, ":PolydevOpen<CR>", { silent = true })
|
||||
break
|
||||
end
|
||||
vim.keymap.set("n", "<leader>tt", ":PolydevGet<CR>", { silent = true })
|
||||
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = "*",
|
||||
|
||||
@@ -21,21 +21,19 @@ function M.run()
|
||||
local root = utils.get_project_root()
|
||||
local out_dir = root .. "/build"
|
||||
|
||||
if not utils.is_dir(out_dir) then
|
||||
vim.fn.mkdir(out_dir, "p")
|
||||
end
|
||||
local cmd = string.format("javac -d %s %s", out_dir, root .. "/src/*.java")
|
||||
local output = vim.fn.system(cmd)
|
||||
local success = vim.v.shell_error == 0
|
||||
|
||||
local compile_command = string.format("javac -d %s %s/*.java", out_dir, root .. "/src")
|
||||
local compile_status = vim.fn.system(compile_command)
|
||||
|
||||
if vim.v.shell_error == 0 then
|
||||
utils.open_float_terminal("java -cp " .. root .. "/build" .. " Main")
|
||||
if not success then
|
||||
local term_buf = utils.open_float_terminal(cmd)
|
||||
vim.api.nvim_buf_set_option(term_buf, "modifiable", true)
|
||||
vim.api.nvim_buf_set_lines(term_buf, 0, -1, false,
|
||||
vim.list_extend({ "Error during compilation:" }, vim.split(output, "\n", { trimempty = true }))
|
||||
)
|
||||
vim.api.nvim_buf_set_option(term_buf, "modifiable", false)
|
||||
else
|
||||
print("Error during compilation. Opening terminal for details...")
|
||||
local term_buf = utils.open_float_terminal(compile_command)
|
||||
vim.api.nvim_buf_set_option(term_buf, "modifiable", true)
|
||||
vim.api.nvim_buf_set_lines(term_buf, 0, -1, false, vim.split(compile_status, "\n", { trimempty = true }))
|
||||
vim.api.nvim_buf_set_option(term_buf, "modifiable", false)
|
||||
utils.open_float_terminal("java -cp " .. root .. "/build" .. " Main")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -29,15 +29,13 @@ local presets = {
|
||||
|
||||
function M.getPresets(preset)
|
||||
if preset == "max" then
|
||||
return presets.centered
|
||||
return presets.max
|
||||
elseif preset == "center" then
|
||||
return presets.center_panel
|
||||
return presets.center
|
||||
elseif preset == "right" then
|
||||
return presets.right_panel
|
||||
return presets.right
|
||||
elseif preset == "corner" then
|
||||
return presets.cornered
|
||||
elseif preset == nil then
|
||||
print("Preset returns nil value")
|
||||
return presets.corner
|
||||
else
|
||||
print("Preset option: " .. preset .. " does not exist")
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user