diff options
-rw-r--r-- | after/ftplugin/c.lua | 3 | ||||
-rw-r--r-- | lua/config/lsp.lua | 12 | ||||
-rw-r--r-- | lua/config/map.lua | 3 | ||||
-rw-r--r-- | lua/config/projects.lua | 12 |
4 files changed, 18 insertions, 12 deletions
diff --git a/after/ftplugin/c.lua b/after/ftplugin/c.lua index a33d4e5..df01cb4 100644 --- a/after/ftplugin/c.lua +++ b/after/ftplugin/c.lua @@ -21,8 +21,9 @@ 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" + local projects = require("config.projects") -if projects and not projects.IsInProject then +if projects and not projects.InProject then vim.bo.makeprg = "./build.sh" end 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 058acbf..27c6bb9 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 index 9a6ecda..0b81def 100644 --- a/lua/config/projects.lua +++ b/lua/config/projects.lua @@ -1,22 +1,22 @@ local M = {} --- TODO: windows local HOME = os.getenv("HOME") local CWD = vim.fn.getcwd() --- NOTE(luca): This must be global so that the path can be referenced in the Options function M.Projects = { - Metac = { + MetaC = { Path = HOME .. "/proj/metac", Options = function() - vim.o.makeprg = M.Projects.Metac.Path .. "/misc/build.sh" + vim.o.makeprg = M.Projects.MetaC.Path .. "/misc/build.sh" end, }, } -for _, Project in pairs(M.Projects) do +M.InProject = false + +for At, Project in pairs(M.Projects) do if string.find(CWD, Project.Path) then - M.IsInProject = true + M.InProject = true Project.Options() end end |