Browse Source

[nvim] feat: c snippets

dev
David JULIEN 5 months ago
parent
commit
f35c6599c0
  1. 42
      .config/nvim/after/ftplugin/c.lua

42
.config/nvim/after/ftplugin/c.lua

@ -3,7 +3,49 @@
-- 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.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({ "", "}"}),
}),
},
}

Loading…
Cancel
Save