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