diff options
Diffstat (limited to '.nvim.lua')
| -rw-r--r-- | .nvim.lua | 88 |
1 files changed, 20 insertions, 68 deletions
@@ -7,26 +7,7 @@ vim.opt.fixeol = false -- Enable Doxygen vim.g.load_doxygen_syntax = true -local function safe_require(module) - local ok, mod = pcall(require, module) - if not ok then return nil end - return mod -end - -- C++ -local default_clangd_config = vim.deepcopy(vim.lsp.config["clangd"]) or {} -default_clangd_config.cmd = { - "clangd", - "--background-index", - "--clang-tidy", - "--header-insertion=iwyu", - "--completion-style=detailed", - string.format("--compile-commands-dir=%s/build", workspace_folder), - "--query-driver=**/x86_64-pc-elf-g++" -} - -vim.lsp.config("clangd", default_clangd_config) - vim.filetype.add({ pattern = { [".*/include/kstd/.*"] = function(path, _) @@ -37,21 +18,6 @@ vim.filetype.add({ } }) --- File Browser -local neo_tree = safe_require("neo-tree") -if neo_tree then - local current_config = neo_tree.config or {} - local project_config = vim.tbl_deep_extend("force", current_config, { - nesting_rules = { - ['*.hpp'] = { - pattern = "(.*).hpp", - files = { "%1.cpp", "%1.test.cpp", "%1.tests.cpp" } - } - } - }) - neo_tree.setup(project_config) -end - -- Debugging local dap = require("dap") local qemu_job_id = nil @@ -76,8 +42,14 @@ local function launch_qemu(artifact_path, is_debug) local paths = resolve_build_paths(artifact_path) local debug_flag = is_debug and "1" or "0" - local shell_cmd = string.format("%s/scripts/qemu-wrapper.sh '%s' '%s' '%s' '%s'", - workspace_folder, workspace_folder, paths.build_type, paths.iso, debug_flag) + + local cmd_args = { + workspace_folder .. "/scripts/qemu-wrapper.sh", + workspace_folder, + paths.build_type, + paths.iso, + debug_flag + } vim.cmd("botright vsplit | enew") qemu_bufnr = vim.api.nvim_get_current_buf() @@ -86,7 +58,8 @@ local function launch_qemu(artifact_path, is_debug) vim.opt_local.relativenumber = false vim.opt_local.signcolumn = "no" - qemu_job_id = vim.fn.termopen(shell_cmd, { + qemu_job_id = vim.fn.jobstart(cmd_args, { + term = true, on_exit = function() qemu_job_id = nil end }) @@ -135,35 +108,14 @@ dap.listeners.after.event_terminated["teachos_qemu_teardown"] = teardown_qemu dap.listeners.after.event_exited["teachos_qemu_teardown"] = teardown_qemu dap.listeners.after.disconnect["teachos_qemu_teardown"] = teardown_qemu -local cmake_tools = safe_require("cmake-tools") -if cmake_tools then - require("cmake-tools").setup({ - cmake_compile_commands_options = { - action = "copy", - target = string.format("%s/build", workspace_folder), - }, - cmake_dap_configuration = { - name = "(gdb) QEMU MI Attach", - type = "teachos_qemu_mi", - request = "launch", - MIMode = "gdb", - cwd = workspace_folder, - miDebuggerServerAddress = "localhost:1234", - miDebuggerPath = "x86_64-pc-elf-gdb", - stopAtEntry = true, - } - }) - - vim.api.nvim_create_user_command("TeachOSRun", function() - local cmake = safe_require("cmake-tools") - if not cmake then return end - local is_ready, target = pcall(cmake.get_launch_target_path) - if is_ready and target then - launch_qemu(target, false) - else - vim.notify("Fatal: Cannot determine CMake target path.", vim.log.levels.ERROR) - end - end, {}) +vim.api.nvim_create_user_command("TeachOSRun", function() + local cmake = require("cmake-tools") + local is_ready, target = pcall(cmake.get_launch_target_path) + if is_ready and target then + launch_qemu(target, false) + else + vim.notify("Fatal: Cannot determine CMake target path.", vim.log.levels.ERROR) + end +end, {}) - vim.keymap.set('n', '<S-F5>', '<cmd>TeachOSRun<CR>', { noremap = true, desc = "Run TeachOS QEMU (No Debug)" }) -end +vim.keymap.set('n', '<S-F5>', '<cmd>TeachOSRun<CR>', { noremap = true, desc = "Run TeachOS QEMU (No Debug)" }) |
