aboutsummaryrefslogtreecommitdiff
path: root/.nvim.lua
diff options
context:
space:
mode:
authorFelix Morgner <felix.morgner@ost.ch>2026-04-06 19:09:34 +0200
committerFelix Morgner <felix.morgner@ost.ch>2026-04-06 19:09:34 +0200
commit8ad4fad2440c20aa19e26ade8cdb881cab7734e2 (patch)
tree2a3e308d8b633487c2da69f02e204d055c079d1a /.nvim.lua
parentfe26083101537df306153e7bea7c291a041897f7 (diff)
downloadteachos-8ad4fad2440c20aa19e26ade8cdb881cab7734e2.tar.xz
teachos-8ad4fad2440c20aa19e26ade8cdb881cab7734e2.zip
kernel/tests: fix link issue
Diffstat (limited to '.nvim.lua')
-rw-r--r--.nvim.lua78
1 files changed, 78 insertions, 0 deletions
diff --git a/.nvim.lua b/.nvim.lua
new file mode 100644
index 0000000..2cd34d6
--- /dev/null
+++ b/.nvim.lua
@@ -0,0 +1,78 @@
+local workspace_folder = vim.fn.getcwd()
+
+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 = {
+ [".*/kstd/include/kstd/.*"] = "cpp",
+ }
+})
+
+-- Debugging
+local dap = require("dap")
+local qemu_job = nil
+
+dap.adapters.teachos_qemu_mi = function(callback, config)
+ if qemu_job then
+ qemu_job:kill(9)
+ end
+
+ local artifact_path = config.program
+ if not artifact_path then
+ vim.notify("Fatal: No artifact path resolved by CMake", vim.log.levels.ERROR)
+ return
+ end
+
+ local elf_path = string.gsub(artifact_path, "%.sym$", ".elf")
+
+ qemu_job = vim.system({
+ "qemu-system-x86_64",
+ "-kernel", elf_path,
+ "-s", "-S",
+ "-nographic"
+ }, { text = true })
+
+ vim.defer_fn(function()
+ callback({
+ type = "executable",
+ command = vim.fn.stdpath("data") .. "/mason/bin/OpenDebugAD7",
+ })
+ end, 500)
+end
+
+dap.listeners.after.event_terminated["teachos_qemu_teardown"] = function()
+ if qemu_job then
+ qemu_job:kill(9)
+ qemu_job = nil
+ end
+end
+
+require("cmake-tools").setup({
+ cmake_dap_configuration = {
+ name = "(gdb) QEMU MI Attach",
+ type = "teachos_qemu_mi",
+ request = "launch",
+ miDebuggerServerAddress = "localhost:1234",
+ miDebuggerPath = "x86_64-pc-elf-gdb",
+ stopAtEntry = true,
+ }
+})
+