diff options
author | Raymaekers Luca <luca@spacehb.net> | 2025-03-17 15:34:15 +0100 |
---|---|---|
committer | Raymaekers Luca <luca@spacehb.net> | 2025-03-17 15:34:15 +0100 |
commit | da7035666495a278bfc7885e4d9f11557f210357 (patch) | |
tree | dee15f2eaa55b7e392bff39aaff2e2f966751377 | |
parent | 53f6e19f84ba06bbf143339deba84bc51cd6706e (diff) |
checkpoint
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | after/ftplugin/c.lua | 7 | ||||
-rw-r--r-- | init.lua | 1 | ||||
-rw-r--r-- | lua/config/lazy.lua | 54 | ||||
-rw-r--r-- | lua/config/map.lua | 2 | ||||
-rw-r--r-- | lua/config/projects.lua | 24 |
6 files changed, 85 insertions, 5 deletions
@@ -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", "<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.IsInProject 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/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", + "<S-Tab>", + function() + require("multiple-cursors").align() + end, + }, + }, + }, + keys = { + { "<C-j>", "<Cmd>MultipleCursorsAddDown<CR>", mode = { "n", "x" }, desc = "Add cursor and move down" }, + { "<C-k>", "<Cmd>MultipleCursorsAddUp<CR>", mode = { "n", "x" }, desc = "Add cursor and move up" }, + + { "<C-Up>", "<Cmd>MultipleCursorsAddUp<CR>", mode = { "n", "i", "x" }, desc = "Add cursor and move up" }, + { + "<C-Down>", + "<Cmd>MultipleCursorsAddDown<CR>", + mode = { "n", "i", "x" }, + desc = "Add cursor and move down", + }, + + { + "<Leader>m", + "<Cmd>MultipleCursorsAddVisualArea<CR>", + mode = { "x" }, + desc = "Add cursors to the lines of the visual area", + }, + + { "<Leader>a", "<Cmd>MultipleCursorsAddMatches<CR>", mode = { "n", "x" }, desc = "Add cursors to cword" }, + { + "<Leader>A", + "<Cmd>MultipleCursorsAddMatchesV<CR>", + mode = { "n", "x" }, + desc = "Add cursors to cword in previous area", + }, + + { + "<Leader>d", + "<Cmd>MultipleCursorsAddJumpNextMatch<CR>", + mode = { "n", "x" }, + desc = "Add cursor and jump to next cword", + }, + { "<Leader>D", "<Cmd>MultipleCursorsJumpNextMatch<CR>", mode = { "n", "x" }, desc = "Jump to next cword" }, + + { "<Leader>l", "<Cmd>MultipleCursorsLock<CR>", 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", "<M-b>", "<cmd>make<cr>", { 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 |