This repository has been archived on 2023-03-02. You can view files and clone it, but cannot push or open issues or pull requests.
dotfiles/.config/nvim/after/ftplugin/c.lua

52 lines
1.1 KiB
Lua
Raw Normal View History

2021-10-30 15:31:39 +02:00
-- Author : swytch
-- Created : Saturday Oct. 30, 2021 11:43:34 CET
-- License : GPLv3
-- Description : c settings file
2021-12-09 16:47:22 +01:00
local opt = vim.opt
local g = vim.g
2021-10-30 15:31:39 +02:00
opt.formatoptions = "trq1jp"
2021-12-09 16:47:22 +01:00
-- Snippets
local ls = require("luasnip")
-- some shorthands...
local s = ls.snippet
local t = ls.text_node
local i = ls.insert_node
local f = ls.function_node
local copy = utils.copy
2022-04-29 00:20:18 +02:00
ls.add_snippets( "c", {
s("main", {
t({ "int main(int argc, char* argv[])" }),
t({ "", "{", "\t" }),
i(0),
t({ "", "\treturn 0;"}),
t({ "", "}"}),
}),
s("fn", {
-- Simple static text.
t("//Parameters: "),
-- function, first parameter is the function, second the Placeholders
-- whose text it gets as input.
f(copy, 2),
t({ "", "" }),
-- Placeholder/Insert.
i(1),
t("("),
-- Placeholder with initial text.
i(2, "int foo"),
-- Linebreak
t({ ")", "{", "\t" }),
i(0),
t({ "", "\treturn 0;"}),
t({ "", "}"}),
2022-04-29 00:20:18 +02:00
}),
}, {
key = "c"
})