FIX: fixed lua to not use global function but local to stop nil error

This commit is contained in:
DarthMooMancer
2025-05-07 11:31:49 -04:00
parent 20a375aaf5
commit 15913c75b7
3 changed files with 4 additions and 13 deletions
+3 -2
View File
@@ -6,12 +6,13 @@ M.opts = nil
function M.setup(opts)
M.opts = vim.tbl_deep_extend("force", {}, require("Polydev.configs").get("cpp"), opts or {})
vim.api.nvim_create_user_command("NewCppHeaderFile", M.create_new_header_file, {})
vim.api.nvim_create_user_command("CppRun", M.run, {})
for key, command in pairs(M.opts.keybinds) do
M.keybinds[command] = key
end
vim.api.nvim_create_user_command("NewCppHeaderFile", M.create_new_header_file, {})
vim.api.nvim_create_user_command("CppRun", M.run, {})
if M.keybinds.CppRun then
vim.keymap.set("n", M.keybinds.CppRun, ":CppRun<CR>", { silent = true })
+1 -1
View File
@@ -38,7 +38,7 @@ function M.run()
---@return string
local function get_project_name()
return vim.fn.glob((M.get_project_root() or "") .. "/*.polydev"):match("([^/]+)%.polydev$")
return vim.fn.glob((get_project_root() or "") .. "/*.polydev"):match("([^/]+)%.polydev$")
end
---@return string
-10
View File
@@ -1,26 +1,18 @@
---@module "Polydev.presets"
local presets = require("Polydev.presets")
---@type table
local M = {}
---@type table
M.opts = {}
---@param opts table
function M.setup(opts)
M.opts = vim.tbl_deep_extend("force", {}, require("Polydev.configs").get("terminal"), opts or {})
end
---@param path string
---@return boolean
function M.is_dir(path)
local stat = vim.loop.fs_stat(path)
return stat and stat.type == "directory"
end
---@param path string
---@param content string
function M.write_file(path, content)
local file = assert(io.open(path, "w"), "Error creating file: " .. path)
file:write(content)
@@ -28,8 +20,6 @@ function M.write_file(path, content)
vim.cmd("edit " .. path)
end
---@param cmd string
---@return boolean?, table?, nil?
function M.open_float_terminal(cmd)
local presets_opts = {}
if presets.getPresets(M.opts.presets) == nil then return nil end