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

-- Author : swytch
-- Created : Saturday Oct. 30, 2021 11:43:34 CET
-- License : GPLv3
-- Description : c settings file
local opt = vim.opt
local g = vim.g
opt.formatoptions = "trq1jp"
-- 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
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({ "", "}"}),
}),
}, {
key = "c"
})