fix(utils): fixed bottom split and added sizing for splits

This commit is contained in:
DarthMooMancer
2025-05-20 09:27:04 -04:00
parent e6c3353b51
commit 14b302151b
4 changed files with 52 additions and 45 deletions
+42 -35
View File
@@ -5,39 +5,46 @@ local M = {}
---@return table ---@return table
local function default_languages(project_root) local function default_languages(project_root)
return { return {
rust = { rust = {
project_root = project_root .. "/Rust", project_root = project_root .. "/Rust",
keybinds = { keybinds = {
["<leader>pr"] = "RustRun", ["<leader>pr"] = "RustRun",
}, },
}, },
java = { java = {
project_root = project_root .. "/Java", project_root = project_root .. "/Java",
keybinds = { keybinds = {
["<leader>pr"] = "JavaRun", ["<leader>pr"] = "JavaRun",
}, },
}, },
lua = { lua = {
project_root = project_root .. "/Lua", project_root = project_root .. "/Lua",
keybinds = { keybinds = {
["<leader>pr"] = "LuaRun", ["<leader>pr"] = "LuaRun",
}, },
}, },
c = { c = {
project_root = project_root .. "/C", project_root = project_root .. "/C",
keybinds = { keybinds = {
["<leader>pr"] = "CRun", ["<leader>pr"] = "CRun",
}, },
}, },
cpp = { cpp = {
project_root = project_root .. "/CPP", project_root = project_root .. "/CPP",
keybinds = { keybinds = {
["<leader>pr"] = "CppRun", ["<leader>pr"] = "CppRun",
}, },
}, },
html = { python = {
project_root = project_root .. "/Html", project_root = project_root .. "/Python",
}, keybinds = {
["<leader>pr"] = "PythonRun",
["<leader>pb"] = "PythonPip",
},
},
html = {
project_root = project_root .. "/Html",
},
} }
end end
@@ -55,7 +62,7 @@ function M.setup(user_opts)
terminal = { terminal = {
mode = "split", -- floating or split mode = "split", -- floating or split
win = { win = {
type = "vertical", anchor = "right" -- type: "vertical" or "horizonal" -- anchor: "below" or "right" or "center" or "corner" type = "horizontal", anchor = "bottom", size = "20" -- type: "vertical" or "horizonal" -- anchor: "below" or "right" or "center" or "corner" -- size: amount of cols or rows based on percentage without percente symbol
}, },
border = { border = {
enabled = true, enabled = true,
@@ -73,7 +80,7 @@ function M.setup(user_opts)
-- Inject languages into the config, respecting user overrides -- Inject languages into the config, respecting user overrides
for lang, conf in pairs(langs) do for lang, conf in pairs(langs) do
M.user_config[lang] = vim.tbl_deep_extend("force", conf, M.user_config[lang] or {}) M.user_config[lang] = vim.tbl_deep_extend("force", conf, M.user_config[lang] or {})
end end
end end
+1 -1
View File
@@ -245,7 +245,7 @@ M.extras = {
extras("_H", ".h", file_name) extras("_H", ".h", file_name)
print("Successful creation of " .. file_name .. ".h") print("Successful creation of " .. file_name .. ".h")
end end
if lang == "cpp" then if lang == "cpp" then
extras("_HPP", ".hpp", file_name) extras("_HPP", ".hpp", file_name)
print("Successful creation of " .. file_name .. ".hpp") print("Successful creation of " .. file_name .. ".hpp")
end end
+6 -6
View File
@@ -67,10 +67,10 @@ function M.manager(project_root)
local current_view = vim.deepcopy(entries) local current_view = vim.deepcopy(entries)
-- Create a new custom highlight group with Normal background and NormalFloat foreground -- Create a new custom highlight group with Normal background and NormalFloat foreground
-- vim.api.nvim_set_hl(0, "PolydevNormal", { -- vim.api.nvim_set_hl(0, "PolydevNormal", {
-- fg = vim.api.nvim_get_hl(0, { name = "NormalFloat", link = true }).fg, -- fg = vim.api.nvim_get_hl(0, { name = "NormalFloat", link = true }).fg,
-- bg = vim.api.nvim_get_hl(0, { name = "Normal", link = true }).bg, -- bg = vim.api.nvim_get_hl(0, { name = "Normal", link = true }).bg,
-- }) -- })
local popup, search, preview = Popup({ local popup, search, preview = Popup({
enter = true, enter = true,
@@ -139,7 +139,7 @@ function M.manager(project_root)
local lines = {} local lines = {}
local fd = io.open(entry.full_path, "r") local fd = io.open(entry.full_path, "r")
if fd then if fd then
for i = 1, 100 do for _ = 1, 100 do
local line = fd:read("*line") local line = fd:read("*line")
if not line then break end if not line then break end
table.insert(lines, line) table.insert(lines, line)
@@ -293,7 +293,7 @@ function M.manager(project_root)
if not lang or lang == "" then return print("Project creation canceled") end if not lang or lang == "" then return print("Project creation canceled") end
opts = vim.tbl_deep_extend("force", {}, require("Polydev.configs").get(lang), opts or {}) opts = vim.tbl_deep_extend("force", {}, require("Polydev.configs").get(lang), opts or {})
if languages.load_language_module(lang) and templates.projects[lang] and templates.projects[lang].run then if languages.load_language_module(lang) and templates.projects[lang] and templates.projects[lang].run then
-- if templates.projects[lang] and templates.projects[lang].run then -- if templates.projects[lang] and templates.projects[lang].run then
popup:unmount() popup:unmount()
vim.schedule(function() vim.schedule(function()
vim.ui.input({ prompt = "Enter project name: " }, function(project_name) vim.ui.input({ prompt = "Enter project name: " }, function(project_name)
+3 -3
View File
@@ -91,16 +91,16 @@ function M.terminal(cmd)
end end
end end
if M.opts.win.type == "horizontal" then if M.opts.win.type == "horizontal" then
if M.opts.anchor == "bottom" then if M.opts.win.anchor == "bottom" then
vim.cmd("set splitbelow") vim.cmd("set splitbelow")
end end
end end
if M.opts.win.type == "vertical" then if M.opts.win.type == "vertical" then
vim.cmd("vsplit") vim.cmd(M.opts.win.size .. " vsplit")
end end
if M.opts.win.type == "horizontal" then if M.opts.win.type == "horizontal" then
vim.cmd("split") vim.cmd(M.opts.win.size .. " split")
end end
local buf = vim.api.nvim_create_buf(false, true) local buf = vim.api.nvim_create_buf(false, true)
vim.api.nvim_win_set_buf(0, buf) vim.api.nvim_win_set_buf(0, buf)