summaryrefslogtreecommitdiff
path: root/after
diff options
context:
space:
mode:
authorRaymaekers Luca <raymaekers.luca@gmail.com>2024-10-29 19:32:50 +0100
committerRaymaekers Luca <raymaekers.luca@gmail.com>2024-10-29 19:32:50 +0100
commitf2254f8ff19bc4268ed70245926f800342bbac40 (patch)
tree271a0e62f2dbeccf09be1b01e4260aa3482c4105 /after
parentb51afe268a6015ce31cf9162545411dd9fce93ad (diff)
checkpoint
Diffstat (limited to 'after')
-rw-r--r--after/ftplugin/c.lua16
-rw-r--r--after/plugin/conform.lua2
2 files changed, 18 insertions, 0 deletions
diff --git a/after/ftplugin/c.lua b/after/ftplugin/c.lua
index 58f46a6..b5b06d0 100644
--- a/after/ftplugin/c.lua
+++ b/after/ftplugin/c.lua
@@ -1,3 +1,19 @@
+local function mapcmd(command)
+ return function()
+ vim.cmd(command)
+ end
+end
+
local map = vim.keymap.set
map("n", ",p", [[<cmd>s/\(\s*\)\(.\+\)/\1printf("\2: %d\\n", \2);<cr>]], { desc = "Surround var with printf" })
+map("n", ",i", function()
+ local word = vim.fn.expand("<cword>")
+ vim.cmd([[
+ normal m'
+ 0/^#include/
+ normal O
+ .!include.sh ]] .. word)
+ vim.cmd("normal ''")
+end, { desc = "Include header for word under cursor" })
+map("n", ",f", mapcmd("CF"), { desc = "Toggle formatting" })
vim.o.commentstring = "// %s"
diff --git a/after/plugin/conform.lua b/after/plugin/conform.lua
index 3d2deed..7a8bbce 100644
--- a/after/plugin/conform.lua
+++ b/after/plugin/conform.lua
@@ -24,6 +24,8 @@ conform.formatters["clang-format"] = {
.. "AllowShortIfStatementsOnASingleLine: true, "
.. "AllowShortLoopsOnASingleLine: true, "
.. "AllowAllArgumentsOnNextLine: true, "
+ .. "AllowShortCaseLabelsOnASingleLine: true, "
+ .. "BreakAfterReturnType: AllDefinitions, "
.. "ColumnLimit: "
.. vim.o.tw
.. "}",