From da7035666495a278bfc7885e4d9f11557f210357 Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Mon, 17 Mar 2025 15:34:15 +0100 Subject: checkpoint --- Makefile | 2 +- after/ftplugin/c.lua | 7 ++++--- init.lua | 1 + lua/config/lazy.lua | 54 ++++++++++++++++++++++++++++++++++++++++++++++++- lua/config/map.lua | 2 ++ lua/config/projects.lua | 24 ++++++++++++++++++++++ 6 files changed, 85 insertions(+), 5 deletions(-) create mode 100644 lua/config/projects.lua diff --git a/Makefile b/Makefile index 6187cee..946cac8 100644 --- a/Makefile +++ b/Makefile @@ -3,5 +3,5 @@ LUA_FILES := $(shell find . -type f -name "*.lua") check: - luacheck --no-color --globals=vim -- $(LUA_FILES) stylua $(LUA_FILES) + luacheck --no-color --globals=vim -- $(LUA_FILES) diff --git a/after/ftplugin/c.lua b/after/ftplugin/c.lua index af85156..a33d4e5 100644 --- a/after/ftplugin/c.lua +++ b/after/ftplugin/c.lua @@ -16,13 +16,14 @@ 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", "", mapcmd("make"), { desc = "Make" }) map("i", "", "#if 1#endifO", { 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.IsInProject then + vim.bo.makeprg = "./build.sh" +end vim.cmd("TSDisable indent") diff --git a/init.lua b/init.lua index 320638f..5185f90 100644 --- a/init.lua +++ b/init.lua @@ -3,3 +3,4 @@ require("config.set") require("config.map") require("config.lsp") require("config.autocmds") +require("config.projects") diff --git a/lua/config/lazy.lua b/lua/config/lazy.lua index d29aa3a..1bd0b8a 100644 --- a/lua/config/lazy.lua +++ b/lua/config/lazy.lua @@ -19,7 +19,59 @@ require("lazy").setup({ "lewis6991/gitsigns.nvim", "tpope/vim-vinegar", "tpope/vim-eunuch", - "mg979/vim-visual-multi", + -- "mg979/vim-visual-multi", + { + "brenton-leighton/multiple-cursors.nvim", + version = "*", -- Use the latest tagged version + opts = { + custom_key_maps = { + { + "n", + "", + function() + require("multiple-cursors").align() + end, + }, + }, + }, + keys = { + { "", "MultipleCursorsAddDown", mode = { "n", "x" }, desc = "Add cursor and move down" }, + { "", "MultipleCursorsAddUp", mode = { "n", "x" }, desc = "Add cursor and move up" }, + + { "", "MultipleCursorsAddUp", mode = { "n", "i", "x" }, desc = "Add cursor and move up" }, + { + "", + "MultipleCursorsAddDown", + mode = { "n", "i", "x" }, + desc = "Add cursor and move down", + }, + + { + "m", + "MultipleCursorsAddVisualArea", + mode = { "x" }, + desc = "Add cursors to the lines of the visual area", + }, + + { "a", "MultipleCursorsAddMatches", mode = { "n", "x" }, desc = "Add cursors to cword" }, + { + "A", + "MultipleCursorsAddMatchesV", + mode = { "n", "x" }, + desc = "Add cursors to cword in previous area", + }, + + { + "d", + "MultipleCursorsAddJumpNextMatch", + mode = { "n", "x" }, + desc = "Add cursor and jump to next cword", + }, + { "D", "MultipleCursorsJumpNextMatch", mode = { "n", "x" }, desc = "Jump to next cword" }, + + { "l", "MultipleCursorsLock", mode = { "n", "x" }, desc = "Lock virtual cursors" }, + }, + }, "jghauser/follow-md-links.nvim", "stevearc/conform.nvim", "norcalli/nvim-colorizer.lua", diff --git a/lua/config/map.lua b/lua/config/map.lua index 7dcf82a..058acbf 100644 --- a/lua/config/map.lua +++ b/lua/config/map.lua @@ -109,3 +109,5 @@ vim.api.nvim_create_user_command("Scratch", function() setlocal noswapfile ]]) end, {}) + +map("n", "", "make", { desc = "Make" }) diff --git a/lua/config/projects.lua b/lua/config/projects.lua new file mode 100644 index 0000000..9a6ecda --- /dev/null +++ b/lua/config/projects.lua @@ -0,0 +1,24 @@ +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 = { + Path = HOME .. "/proj/metac", + Options = function() + vim.o.makeprg = M.Projects.Metac.Path .. "/misc/build.sh" + end, + }, +} + +for _, Project in pairs(M.Projects) do + if string.find(CWD, Project.Path) then + M.IsInProject = true + Project.Options() + end +end + +return M -- cgit v1.2.3