aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.lazy.lua67
-rw-r--r--.nvim.lua88
2 files changed, 85 insertions, 70 deletions
diff --git a/.lazy.lua b/.lazy.lua
index 1c2df6e0..76e8eb30 100644
--- a/.lazy.lua
+++ b/.lazy.lua
@@ -1,5 +1,62 @@
+local workspace_folder = vim.fn.getcwd()
+
return {
{
+ "neovim/nvim-lspconfig",
+ opts = {
+ servers = {
+ clangd = {
+ cmd = {
+ "clangd",
+ "--background-index",
+ "--clang-tidy",
+ "--compile-commands-dir=" .. workspace_folder .. "/build",
+ "--completion-style=detailed",
+ "--header-insertion=iwyu",
+ "--query-driver=**/x86_64-pc-elf-g++"
+ },
+ },
+ },
+ },
+ },
+ {
+ "lucaSartore/fastspell.nvim",
+ config = function()
+ local fastspell = require("fastspell")
+
+ fastspell.setup({
+ cspell_json_file_path = workspace_folder .. "/cspell.json",
+ })
+
+ vim.api.nvim_create_autocmd({ "TextChanged", "TextChangedI", "BufEnter", "WinScrolled" }, {
+ callback = function(_)
+ local first_line = vim.fn.line('w0') - 1
+ local last_line = vim.fn.line('w$')
+ fastspell.sendSpellCheckRequest(first_line, last_line)
+ end,
+ })
+ end
+ },
+ {
+ "Civitasv/cmake-tools.nvim",
+ opts = {
+ cmake_compile_commands_options = {
+ action = "copy",
+ target = workspace_folder .. "/build",
+ },
+ 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,
+ },
+ },
+ },
+ {
"nvim-neo-tree/neo-tree.nvim",
opts = {
filesystem = {
@@ -8,6 +65,12 @@ return {
hide_gitignored = true,
},
},
- }
- }
+ nesting_rules = {
+ ['cpp_under_hpp'] = {
+ pattern = "(.*).hpp",
+ files = { "%1.cpp", "%1.test.cpp", "%1.tests.cpp", "%1.S" }
+ },
+ },
+ },
+ },
}
diff --git a/.nvim.lua b/.nvim.lua
index 0748af9c..14ca59ca 100644
--- a/.nvim.lua
+++ b/.nvim.lua
@@ -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)" })