diff options
author | Raymaekers Luca <luca@spacehb.net> | 2025-03-17 15:43:07 +0100 |
---|---|---|
committer | Raymaekers Luca <luca@spacehb.net> | 2025-03-17 15:43:32 +0100 |
commit | 4e31578c1e4b9e989cec824e3e832ac2aa66efcd (patch) | |
tree | c7d3851efcb6c31953b6af2cce102ae315f4cfb4 | |
parent | 53f6e19f84ba06bbf143339deba84bc51cd6706e (diff) |
checkpoint
-rw-r--r-- | after/ftplugin/c.lua | 6 | ||||
-rw-r--r-- | init.lua | 1 | ||||
-rw-r--r-- | lua/config/lsp.lua | 12 | ||||
-rw-r--r-- | lua/config/map.lua | 3 | ||||
-rw-r--r-- | lua/config/projects.lua | 24 |
5 files changed, 39 insertions, 7 deletions
diff --git a/after/ftplugin/c.lua b/after/ftplugin/c.lua index af85156..df01cb4 100644 --- a/after/ftplugin/c.lua +++ b/after/ftplugin/c.lua @@ -16,13 +16,15 @@ map("n", ",i", function() vim.cmd("normal ''") end, { desc = "Include header for word under cursor" }) map("n", ",f", mapcmd("CF"), { desc = "Toggle formatting" }) -map("n", "<M-b>", mapcmd("make"), { desc = "Make" }) map("i", "<M-1>", "#if 1<cr>#endif<esc>O", { desc = "Insert `#if 1` block" }) vim.opt.commentstring = "// %s" -- disable indent in switch statement vim.opt.cinoptions = "l1" -vim.bo.makeprg = "./build.sh" +local projects = require("config.projects") +if projects and not projects.InProject then + vim.bo.makeprg = "./build.sh" +end vim.cmd("TSDisable indent") @@ -3,3 +3,4 @@ require("config.set") require("config.map") require("config.lsp") require("config.autocmds") +require("config.projects") diff --git a/lua/config/lsp.lua b/lua/config/lsp.lua index 49f415f..10235bf 100644 --- a/lua/config/lsp.lua +++ b/lua/config/lsp.lua @@ -143,14 +143,16 @@ ls.add_snippets("c", { parse_snippet( "uints", [[#include <stdint.h> -typedef uint8_t u8; +typedef uint8_t u8; typedef uint16_t u16; typedef uint32_t u32; typedef uint64_t u64; -typedef int8_t s8; -typedef int16_t s16; -typedef int32_t s32; -typedef int64_t s64; +typedef int8_t i8; +typedef int16_t i16; +typedef int32_t i32; +typedef int64_t i64; +typedef float f32; +typedef double f64; ]] ), }) diff --git a/lua/config/map.lua b/lua/config/map.lua index 7dcf82a..a39f362 100644 --- a/lua/config/map.lua +++ b/lua/config/map.lua @@ -4,6 +4,7 @@ local map = vim.keymap.set vim.g.mapleader = " " vim.g.maplocalleader = "," + -- open config map("n", " c", function() vim.cmd("cd ~/.config/nvim") @@ -13,6 +14,8 @@ end, { desc = "Open neovim config file" }) map("v", "J", ":m '>+1<CR>gv=gv", { desc = "Move selected text up" }) map("v", "K", ":m '<-2<CR>gv=gv", { desc = "Move selected text down" }) +map("n", "<M-b>", "<cmd>make<cr>", { desc = "Make" }) + -- better find next and previous map("n", "n", "nzzzv", { desc = "Keep cursor in middle with search" }) map("n", "N", "Nzzzv", { desc = "Keep cursor in middle with search" }) diff --git a/lua/config/projects.lua b/lua/config/projects.lua new file mode 100644 index 0000000..0b81def --- /dev/null +++ b/lua/config/projects.lua @@ -0,0 +1,24 @@ +local M = {} + +local HOME = os.getenv("HOME") +local CWD = vim.fn.getcwd() + +M.Projects = { + MetaC = { + Path = HOME .. "/proj/metac", + Options = function() + vim.o.makeprg = M.Projects.MetaC.Path .. "/misc/build.sh" + end, + }, +} + +M.InProject = false + +for At, Project in pairs(M.Projects) do + if string.find(CWD, Project.Path) then + M.InProject = true + Project.Options() + end +end + +return M |