Changing files to use opts and simplify config

This commit is contained in:
DarthMooMancer
2025-04-14 22:54:23 -04:00
parent a029fbc5f5
commit 13d16ae329
3 changed files with 36 additions and 26 deletions
+10 -7
View File
@@ -1,6 +1,6 @@
local M = {}
M.config = {
M.defaults = {
terminal = {
right_padding = 0,
bottom_padding = 0,
@@ -11,13 +11,16 @@ M.config = {
relativenumber = true,
scroll = true,
}
-- java = { indent = 4 },
-- python = { formatter = "black", linting = true },
-- lua = { diagnostics = true },
-- c = { compiler = "gcc" },
-- cpp = { compiler = "g++" },
-- rust = { edition = "2021" },
-- html = { use_tailwind = false },
}
function M.setup(opts)
opts = opts or {}
-- Make sure nested tables are deep-merged
M.config.terminal = vim.tbl_deep_extend("force", M.config.terminal, opts.terminal or {})
end
-- This will be updated by setup()
M.user_config = vim.deepcopy(M.defaults)
return M
+5 -1
View File
@@ -1,7 +1,7 @@
local M = {}
M.loaded_languages = {}
M.configs = require("Polydev.configs")
M.config = require("Polydev.configs")
M.java = require("Polydev.languages.java")
M.c = require("Polydev.languages.c")
M.cpp = require("Polydev.languages.cpp")
@@ -49,6 +49,10 @@ end
function M.setup(opts)
opts = opts or {}
for lang, user_opts in pairs(opts) do
local default = M.config.defaults[lang] or {}
M.config.user_config[lang] = vim.tbl_deep_extend("force", default, user_opts)
end
vim.api.nvim_create_user_command("NewProject", M.create_project, {})
vim.api.nvim_create_user_command("NewFile", M.create_new_file, {})
+21 -18
View File
@@ -1,5 +1,6 @@
local M = {}
local config = require("Polydev.config")
local utils = require("Polydev.utils")
local M = {}
M.c_run = nil
M.new_pip_module = nil
@@ -98,23 +99,25 @@ setup(
end
function M.create_new_file()
vim.ui.input({ prompt = "Enter file name: " }, function(file_name)
if not file_name or file_name == "" then
return print("File creation canceled.")
end
if not file_name:match("%.py$") then
file_name = file_name .. ".py"
end
local root_dir = M.get_project_root()
if not root_dir then
return print("Error: Project root not found.")
end
local file_path = root_dir .. "/include/" .. file_name
utils.write_file(file_path, "")
end)
local opts = config.user_config.python
print("Creating Python project with formatter: " .. opts.formatter)
-- vim.ui.input({ prompt = "Enter file name: " }, function(file_name)
-- if not file_name or file_name == "" then
-- return print("File creation canceled.")
-- end
--
-- if not file_name:match("%.py$") then
-- file_name = file_name .. ".py"
-- end
--
-- local root_dir = M.get_project_root()
-- if not root_dir then
-- return print("Error: Project root not found.")
-- end
--
-- local file_path = root_dir .. "/include/" .. file_name
-- utils.write_file(file_path, "")
-- end)
end
function M.install_dependency()