From 08967f90706549668bd7c62ec070a1443d5dff59 Mon Sep 17 00:00:00 2001 From: Andrew Haynes Date: Fri, 30 Oct 2026 14:17:01 -0400 Subject: [PATCH] chore(deprecation): removed old deprecated files (#7), cleaned c/c++ code --- lua/vern-nvim/actions/c.lua | 69 +++++------ lua/vern-nvim/actions/cpp.lua | 60 +++++----- lua/vern-nvim/actions/java.lua | 14 +-- lua/vern-nvim/actions/lua.lua | 15 +-- lua/vern-nvim/actions/python.lua | 1 + lua/vern-nvim/health-deprecated.lua | 157 ------------------------- lua/vern-nvim/languages-deprecated.lua | 87 -------------- lua/vern-nvim/templates-deprecated.lua | 82 ------------- 8 files changed, 72 insertions(+), 413 deletions(-) delete mode 100644 lua/vern-nvim/health-deprecated.lua delete mode 100644 lua/vern-nvim/languages-deprecated.lua delete mode 100644 lua/vern-nvim/templates-deprecated.lua diff --git a/lua/vern-nvim/actions/c.lua b/lua/vern-nvim/actions/c.lua index 83b6c53..12f658c 100644 --- a/lua/vern-nvim/actions/c.lua +++ b/lua/vern-nvim/actions/c.lua @@ -6,49 +6,40 @@ local utils = require("vern-nvim.utils") function M.run(opts) opts = opts or {} - local build_cmd = - string.format("cd %s/build && cmake --build .", utils.proj_root()) + local build_dir = vim.fn.fnameescape((utils.proj_root() or ".") .. "/build") - vim.system({ "sh", "-c", build_cmd }, { text = true }, function(obj) - if obj.code ~= 0 then - vim.schedule(function() - local error_obj = (obj.stderr ~= "" and obj.stderr) - or obj.stdout - or "" - local error_lines = vim.list_extend( - { "Error During compilation" }, - vim.split(error_obj, "\n", { trimempty = true }) - ) - local buf, _ = utils.term( - { "echo 'compilation failed'" }, - opts.terminal, - true - ) - if buf and vim.api.nvim_buf_is_valid(buf) then - vim.api.nvim_set_option_value( - "modifiable", - true, - { buf = buf } + vim.system( + { "sh", "-c", string.format("cd %s && cmake --build .", build_dir) }, + { text = true }, + function(obj) + if obj.code ~= 0 then + vim.schedule(function() + local error_obj = (obj.stderr ~= "" and obj.stderr) + or obj.stdout + or "" + local error_lines = vim.list_extend( + { "Error During compilation" }, + vim.split(error_obj, "\n", { trimempty = true }) ) - vim.api.nvim_buf_set_lines(buf, 0, -1, false, error_lines) - vim.api.nvim_set_option_value( - "modifiable", - false, - { buf = buf } + local buf, _ = utils.term( + { "echo 'compilation failed'" }, + opts.terminal, + true ) - end - end) - else - vim.schedule(function() - local run_cmd = string.format( - "cd %s/build && ./%s", - utils.proj_root(), - utils.proj_name() - ) - utils.term({ run_cmd }, opts.terminal, false) - end) + utils.term_override(buf, error_lines) + end) + else + vim.schedule(function() + local run_cmd = string.format( + "cd %s && ./%s", + build_dir, + utils.proj_name() + ) + utils.term({ run_cmd }, opts.terminal, false) + end) + end end - end) + ) end return M diff --git a/lua/vern-nvim/actions/cpp.lua b/lua/vern-nvim/actions/cpp.lua index d80dfa0..96daf4e 100644 --- a/lua/vern-nvim/actions/cpp.lua +++ b/lua/vern-nvim/actions/cpp.lua @@ -6,36 +6,40 @@ local utils = require("vern-nvim.utils") function M.run(opts) opts = opts or {} - local build_dir = (utils.proj_root() or ".") .. "/build" - local build_cmd = "cd " .. build_dir .. " && cmake --build ." + local build_dir = vim.fn.fnameescape((utils.proj_root() or ".") .. "/build") - vim.system({ "sh", "-c", build_cmd }, { text = true }, function(obj) - if obj.code ~= 0 then - vim.schedule(function() - local error_obj = (obj.stderr ~= "" and obj.stderr) - or obj.stdout - or "" - local error_lines = vim.list_extend( - { "Error During compilation" }, - vim.split(error_obj, "\n", { trimempty = true }) - ) - local buf, _ = utils.term( - { "echo 'compilation failed'" }, - opts.terminal, - true - ) - utils.term_override(buf, error_lines) - end) - else - vim.schedule(function() - local run_cmd = "cd '" - .. build_dir - .. "' && ./" - .. utils.proj_name() - utils.term({ run_cmd }, opts.terminal, false) - end) + vim.system( + { "sh", "-c", string.format("cd %s && cmake --build .", build_dir) }, + { text = true }, + function(obj) + if obj.code ~= 0 then + vim.schedule(function() + local error_obj = (obj.stderr ~= "" and obj.stderr) + or obj.stdout + or "" + local error_lines = vim.list_extend( + { "Error During compilation" }, + vim.split(error_obj, "\n", { trimempty = true }) + ) + local buf, _ = utils.term( + { "echo 'compilation failed'" }, + opts.terminal, + true + ) + utils.term_override(buf, error_lines) + end) + else + vim.schedule(function() + local run_cmd = string.format( + "cd %s && ./%s", + build_dir, + utils.proj_name() + ) + utils.term({ run_cmd }, opts.terminal, false) + end) + end end - end) + ) end return M diff --git a/lua/vern-nvim/actions/java.lua b/lua/vern-nvim/actions/java.lua index 490b751..25119b8 100644 --- a/lua/vern-nvim/actions/java.lua +++ b/lua/vern-nvim/actions/java.lua @@ -39,19 +39,7 @@ function M.run(opts) opts.terminal, true ) - if buf and vim.api.nvim_buf_is_valid(buf) then - vim.api.nvim_set_option_value( - "modifiable", - true, - { buf = buf } - ) - vim.api.nvim_buf_set_lines(buf, 0, -1, false, error_lines) - vim.api.nvim_set_option_value( - "modifiable", - false, - { buf = buf } - ) - end + utils.term_override(buf, error_lines) end) else vim.schedule(function() diff --git a/lua/vern-nvim/actions/lua.lua b/lua/vern-nvim/actions/lua.lua index 21cda73..55a1b87 100644 --- a/lua/vern-nvim/actions/lua.lua +++ b/lua/vern-nvim/actions/lua.lua @@ -5,14 +5,15 @@ local utils = require("vern-nvim.utils") ---@param opts VernLuaConfig Takes a table for the runtime function M.run(opts) opts = opts or {} - local full_path = - vim.fs.joinpath(utils.proj_root(), "lua", utils.proj_name()) - utils.term( - { "lua " .. full_path .. "/init.lua" }, - opts.terminal or {}, - false - ) + utils.term({ + "lua " .. vim.fs.joinpath( + utils.proj_root(), + "lua", + utils.proj_name(), + "/init.lua" + ), + }, opts.terminal or {}, false) end return M diff --git a/lua/vern-nvim/actions/python.lua b/lua/vern-nvim/actions/python.lua index ac6cda7..ce1a250 100644 --- a/lua/vern-nvim/actions/python.lua +++ b/lua/vern-nvim/actions/python.lua @@ -17,6 +17,7 @@ function M.run(opts) or "src/{project_name}/main.py" local exe_path = utils.resolve_path(exe, opts.python.dirs, context) local full_path = vim.fs.joinpath(vim.fn.expand(root), exe_path) + utils.term({ "python3 " .. full_path }, opts.terminal or {}, false) end diff --git a/lua/vern-nvim/health-deprecated.lua b/lua/vern-nvim/health-deprecated.lua deleted file mode 100644 index ad822ce..0000000 --- a/lua/vern-nvim/health-deprecated.lua +++ /dev/null @@ -1,157 +0,0 @@ -local ok, health = pcall(require, "vim.health") -if not ok then - health = nil -end - -local new_api = health ~= nil and type(health.start) == "function" - -local function report_start(name) - if new_api then health.start(name) else vim.health.report_start(name) end -end - -local function report_ok(msg) - if new_api then health.ok(msg) else vim.health.report_ok(msg) end -end - -local function report_info(msg) - if new_api then health.info(msg) else vim.health.report_info(msg) end -end - -local function report_warn(msg, advice) - if new_api then - health.warn(msg, advice) - else - vim.health.report_warn(msg, advice) - end -end - -local function report_error(msg, advice) - if new_api then - health.error(msg, advice) - else - vim.health.report_error(msg, advice) - end -end - -local M = {} - -local function fmt_langs(langs) - if type(langs) == "table" then - return "[" .. table.concat(langs, ", ") .. "]" - end - return "[" .. tostring(langs) .. "]" -end - -local function check_nvim_version() - if vim.fn.has("nvim-0.10") == 1 then - report_ok(string.format("Neovim %s detected.", tostring(vim.version()))) - else - report_error("Polydev requires Neovim 0.10 or newer.", "You are running " .. tostring(vim.version())) - end -end - -local function check_setup() - local ok_configs, configs = pcall(require, "Polydev.configs") - if not ok_configs then - report_error("Could not load Polydev.configs", tostring(configs)) - return nil - end - if next(configs.user_config or {}) == nil then - report_warn("Polydev.setup() has not run.", - "Add require('Polydev').setup() to your Neovim config, or make sure plugin/Polydev.lua is sourced by your plugin manager.") - return nil - end - report_ok("Polydev.setup() ran and the config is loaded.") - return configs -end - -local function check_project_root(configs) - if not configs then return end - local root = configs.get("globals").project_root - local expanded = vim.fn.expand(root) - if vim.fn.isdirectory(expanded) == 1 then - if vim.fn.filewritable(expanded) == 2 then - report_ok(string.format("project_root exists and is writable: %s", expanded)) - else - report_warn(string.format("project_root exists but is not writable: %s", expanded)) - end - else - report_warn(string.format("project_root does not exist yet: %s", expanded), - "It is created automatically the first time the manager is opened.") - end -end - -local function check_ui_input() - local ok_default, default = pcall(require, "vim.ui") - if ok_default and default.input and vim.ui.input ~= default.input then - report_warn("vim.ui.input has been overridden, likely by a UI plugin such as dressing.nvim or nui.nvim.", - "An asynchronous override can break project/file creation from the manager. Polydev now uses callbacks, but report here if it still misbehaves.") - else - report_ok("vim.ui.input is Neovim's default (synchronous) implementation.") - end -end - -local function check_tools() - local tools = { - { name = "git", langs = "all" }, - { name = "node", langs = "javascript" }, - { name = "python3", langs = "python" }, - { name = "pip3", langs = "python" }, - { name = "javac", langs = "java" }, - { name = "java", langs = "java" }, - { name = "cmake", langs = { "c", "cpp" } }, - { name = "cc", langs = { "c", "cpp" } }, - { name = "clang", langs = { "c", "cpp" } }, - { name = "clang-format", langs = { "c", "cpp" } }, - { name = "clang-tidy", langs = { "c", "cpp" } }, - { name = "cargo", langs = "rust" }, - { name = "lua", langs = "lua" }, - { name = "luajit", langs = "lua" }, - } - for _, t in ipairs(tools) do - if vim.fn.executable(t.name) == 1 then - report_ok(string.format("%s is available for %s.", t.name, fmt_langs(t.langs))) - else - report_warn(string.format("%s was not found.", t.name), - "Project templates for " .. fmt_langs(t.langs) .. " may fail without it.") - end - end - - if vim.fn.executable("python3") == 1 then - vim.fn.system("python3 -c 'import venv' 2>/dev/null") - if vim.v.shell_error == 0 then - report_ok("python3 venv module is available.") - else - report_warn("python3 venv module is missing.", - "Python project creation sets up a virtualenv and needs python3 -m venv.") - end - end -end - -local function check_walkup() - local scripts = vim.api.nvim_get_runtime_file("bash_scripts/walkup.sh", false) - if #scripts == 0 then - report_error("bash_scripts/walkup.sh was not found on the runtimepath.", - "Reinstall the plugin so bash_scripts/ sits next to lua/ and plugin/.") - return - end - local script = scripts[1] - if vim.fn.executable(script) == 1 then - report_ok(string.format("bash_scripts/walkup.sh found and executable: %s", script)) - else - report_warn(string.format("bash_scripts/walkup.sh is not executable: %s", script), - "Run: chmod +x " .. script) - end -end - -function M.check() - report_start("Polydev") - check_nvim_version() - local configs = check_setup() - check_project_root(configs) - check_ui_input() - check_tools() - check_walkup() -end - -return M diff --git a/lua/vern-nvim/languages-deprecated.lua b/lua/vern-nvim/languages-deprecated.lua deleted file mode 100644 index 64bd781..0000000 --- a/lua/vern-nvim/languages-deprecated.lua +++ /dev/null @@ -1,87 +0,0 @@ -local utils = require("Polydev.utils") -local configs = require("Polydev.configs") -local M = {} - -M.languages = { - javascript = { - setup = function(self, user_opts) - local opts = - vim.tbl_deep_extend("force", {}, configs.get("javascript"), user_opts or {}) - vim.api.nvim_create_user_command("JavascriptRun", function() - self:run() - end, {}) - for key, _ in pairs(opts.keybinds) do - vim.keymap.set("n", key, ":JavascriptRun", { silent = true }) - end - end, - run = function() - local root = utils.get_project_root() - - local cmd = string.format("node " .. root .. "/main.js") - local output = vim.fn.system(cmd) - - if not vim.v.shell_error == 0 then - local term_buf = utils.terminal({ cmd }) - vim.api.nvim_set_option_value("modifiable", true, { buf = term_buf }) - vim.api.nvim_buf_set_lines( - term_buf, - 0, - -1, - false, - vim.list_extend( - { "Error during compilation:" }, - vim.split(output, "\n", { trimempty = true }) - ) - ) - vim.api.nvim_set_option_value("modifiable", false, { buf = term_buf }) - else - utils.terminal({ "node " .. root .. "/main.js" }) - end - end, - }, - html = { - setup = function(user_opts) - vim.tbl_deep_extend("force", {}, configs.get("html"), user_opts or {}) - end, - }, - rust = { - setup = function(self, user_opts) - local opts = vim.tbl_deep_extend("force", {}, configs.get("rust"), user_opts or {}) - vim.api.nvim_create_user_command("RustRun", function() - self:run() - end, {}) - for key, _ in pairs(opts.keybinds) do - vim.keymap.set("n", key, ":RustRun", { silent = true }) - end - end, - run = function() - local root = utils.get_project_root() - if not root then - return print("Error: Project root not found.") - end - - local cmd = { "cargo build" } - local output = vim.fn.system(table.concat(cmd)) - - if not vim.v.shell_error == 0 then - local term_buf = utils.terminal(cmd) - vim.api.nvim_set_option_value("modifiable", true, { buf = term_buf }) - vim.api.nvim_buf_set_lines( - term_buf, - 0, - -1, - false, - vim.list_extend( - { "Error during compilation:" }, - vim.split(output, "\n", { trimempty = true }) - ) - ) - vim.api.nvim_set_option_value("modifiable", false, { buf = term_buf }) - else - utils.terminal({ "cargo run" }) - end - end, - }, -} - -return M diff --git a/lua/vern-nvim/templates-deprecated.lua b/lua/vern-nvim/templates-deprecated.lua deleted file mode 100644 index 7c10782..0000000 --- a/lua/vern-nvim/templates-deprecated.lua +++ /dev/null @@ -1,82 +0,0 @@ -local utils = require("Polydev.utils") - -local M = {} - -M.projects = { - javascript = { - run = function(project_name, project_root) - local full_project_root = vim.fn.expand(project_root) .. "/" .. project_name - vim.fn.mkdir(full_project_root, "p") - utils.write_file( - { full_project_root, "main.js" }, - [[ -console.log("Hello World!"); -]] - ) - local gitignore = { "" } - utils.init_git(full_project_root, gitignore) - vim.cmd("edit " .. full_project_root .. "/main.js") - end, - }, - rust = { - run = function(project_name, project_root) - local full_project_root = vim.fn.expand(project_root) .. "/" .. project_name - vim.fn.system("cargo new " .. full_project_root) - vim.cmd("edit " .. full_project_root .. "/src/main.rs") - end, - }, - html = { - run = function(project_name, project_root) - local full_project_root = vim.fn.expand(project_root) .. "/" .. project_name - if vim.fn.isdirectory(full_project_root) == 0 then - vim.fn.mkdir(full_project_root, "p") -- Create directory with parent directories - end - local main_html_content = [[ - - - - Page Title - - - -

My First Heading

-

My first paragraph.

- - - -]] - utils.write_file({ full_project_root, "index.html" }, main_html_content) - end, - }, -} - -M.files = { - rust = { - run = function(file_name) - utils.write_file({ utils.get_project_root(), "src", file_name .. ".rs" }, "") - end, - }, - html = { - run = function(file_name) - utils.write_file( - { ".", file_name .. ".html" }, - string.format([[ - - - - Page Title - - - -

My First Heading

-

My first paragraph.

- - - -]]) - ) - end, - }, -} - -return M