Changing files to use opts and simplify config
This commit is contained in:
+10
-7
@@ -1,6 +1,6 @@
|
|||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
M.config = {
|
M.defaults = {
|
||||||
terminal = {
|
terminal = {
|
||||||
right_padding = 0,
|
right_padding = 0,
|
||||||
bottom_padding = 0,
|
bottom_padding = 0,
|
||||||
@@ -11,13 +11,16 @@ M.config = {
|
|||||||
relativenumber = true,
|
relativenumber = true,
|
||||||
scroll = 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)
|
-- This will be updated by setup()
|
||||||
opts = opts or {}
|
M.user_config = vim.deepcopy(M.defaults)
|
||||||
|
|
||||||
-- Make sure nested tables are deep-merged
|
|
||||||
M.config.terminal = vim.tbl_deep_extend("force", M.config.terminal, opts.terminal or {})
|
|
||||||
end
|
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
M.loaded_languages = {}
|
M.loaded_languages = {}
|
||||||
M.configs = require("Polydev.configs")
|
M.config = require("Polydev.configs")
|
||||||
M.java = require("Polydev.languages.java")
|
M.java = require("Polydev.languages.java")
|
||||||
M.c = require("Polydev.languages.c")
|
M.c = require("Polydev.languages.c")
|
||||||
M.cpp = require("Polydev.languages.cpp")
|
M.cpp = require("Polydev.languages.cpp")
|
||||||
@@ -49,6 +49,10 @@ end
|
|||||||
|
|
||||||
function M.setup(opts)
|
function M.setup(opts)
|
||||||
opts = opts or {}
|
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("NewProject", M.create_project, {})
|
||||||
vim.api.nvim_create_user_command("NewFile", M.create_new_file, {})
|
vim.api.nvim_create_user_command("NewFile", M.create_new_file, {})
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
local M = {}
|
local config = require("Polydev.config")
|
||||||
local utils = require("Polydev.utils")
|
local utils = require("Polydev.utils")
|
||||||
|
local M = {}
|
||||||
|
|
||||||
M.c_run = nil
|
M.c_run = nil
|
||||||
M.new_pip_module = nil
|
M.new_pip_module = nil
|
||||||
@@ -98,23 +99,25 @@ setup(
|
|||||||
end
|
end
|
||||||
|
|
||||||
function M.create_new_file()
|
function M.create_new_file()
|
||||||
vim.ui.input({ prompt = "Enter file name: " }, function(file_name)
|
local opts = config.user_config.python
|
||||||
if not file_name or file_name == "" then
|
print("Creating Python project with formatter: " .. opts.formatter)
|
||||||
return print("File creation canceled.")
|
-- vim.ui.input({ prompt = "Enter file name: " }, function(file_name)
|
||||||
end
|
-- if not file_name or file_name == "" then
|
||||||
|
-- return print("File creation canceled.")
|
||||||
if not file_name:match("%.py$") then
|
-- end
|
||||||
file_name = file_name .. ".py"
|
--
|
||||||
end
|
-- if not file_name:match("%.py$") then
|
||||||
|
-- file_name = file_name .. ".py"
|
||||||
local root_dir = M.get_project_root()
|
-- end
|
||||||
if not root_dir then
|
--
|
||||||
return print("Error: Project root not found.")
|
-- local root_dir = M.get_project_root()
|
||||||
end
|
-- if not root_dir then
|
||||||
|
-- return print("Error: Project root not found.")
|
||||||
local file_path = root_dir .. "/include/" .. file_name
|
-- end
|
||||||
utils.write_file(file_path, "")
|
--
|
||||||
end)
|
-- local file_path = root_dir .. "/include/" .. file_name
|
||||||
|
-- utils.write_file(file_path, "")
|
||||||
|
-- end)
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.install_dependency()
|
function M.install_dependency()
|
||||||
|
|||||||
Reference in New Issue
Block a user