Updated vimtex and snippets

This commit is contained in:
Minhazul Haque 2024-03-02 19:25:49 +06:00
parent 84a6b218fe
commit 10bf23a6ec
44 changed files with 4209 additions and 69 deletions

88
LuaSnip/c/c.lua Normal file
View file

@ -0,0 +1,88 @@
local helpers = require('personal.luasnip-helper-funcs')
local get_visual = helpers.get_visual
local line_begin = require("luasnip.extras.expand_conditions").line_begin
return
{
-- MAIN FUNCTION
s({trig = "main", snippetType="autosnippet"},
fmta(
[[
int main()
{
<>
return 0;
}
]],
{ i(1) }
),
{condition = line_begin}
),
-- GENRIC FUNCTION
s({trig = "ff", snippetType="autosnippet"},
fmta(
[[
/*
<>
*/
<>(<>)
{
<>
}
]],
{
i(3),
i(1),
i(2),
d(4, get_visual)
}
),
{condition = line_begin}
),
-- BLOCK COMMENT
s({trig = "cc", snippetType="autosnippet"},
fmta(
[[
/*
<>
*/
]],
{ i(1) }
),
{condition = line_begin}
),
-- DATA STRUCTURE
s({trig = "ss", snippetType="autosnippet"},
fmta(
[[
struct <> {
<>
};
]],
{
i(1),
i(0)
}
)
),
-- -> DEREFERENCE STRUCTURE PROPERTY
s({trig = "--", snippetType="autosnippet", wordTrig=false},
{
t("->")
}
),
-- NULL POINTER SYMBOLIC CONSTANT
s({trig = "00", snippetType="autosnippet", wordTrig=false},
{
t("NULL")
}
),
-- RETURN
s({trig = "rr", snippetType="autosnippet", wordTrig=false},
{
t("return")
},
{ condition = line_begin }
),
}

91
LuaSnip/c/controlflow.lua Normal file
View file

@ -0,0 +1,91 @@
local helpers = require('personal.luasnip-helper-funcs')
local get_visual = helpers.get_visual
local line_begin = require("luasnip.extras.expand_conditions").line_begin
return
{
-- IF STATEMENT
s({trig = "iff", snippetType="autosnippet"},
fmta(
[[
if (<>) {
<>
}
]],
{
i(1),
d(2, get_visual)
}
),
{condition = line_begin}
),
-- FOR LOOP
s({trig = "fll", snippetType="autosnippet"},
fmta(
[[
for (<>) {
<>
}
]],
{
i(1),
d(2, get_visual)
}
),
{condition = line_begin}
),
-- WHILE LOOP
s({trig = "wll", snippetType="autosnippet"},
fmta(
[[
while (<>) {
<>
}
]],
{
i(1),
d(2, get_visual)
}
),
{condition = line_begin}
),
-- SWITCH STATEMENT
s({trig = "sc", snippetType="autosnippet"},
fmta(
[[
switch (<>) {
case <>: {
<>
}<>
default: {
<>
}
}
]],
{
i(1),
i(2),
i(3),
i(4),
i(5),
}
),
{condition = line_begin}
),
-- SWITCH CASE
s({trig = "cs", snippetType="autosnippet"},
fmta(
[[
case <>: {
<>
}
]],
{
i(1),
d(2, get_visual),
}
),
{condition = line_begin}
),
}

33
LuaSnip/c/headers.lua Normal file
View file

@ -0,0 +1,33 @@
local helpers = require('personal.luasnip-helper-funcs')
local get_visual = helpers.get_visual
local line_begin = require("luasnip.extras.expand_conditions").line_begin
return
{
-- GENERIC HEADER INCLUDE
s({trig = "hh", snippetType="autosnippet"},
fmt(
[[#include <{}.h>]],
{
d(1, get_visual)
}
),
{condition = line_begin}
),
-- STDIO HEADER
s({trig = "hio", snippetType="autosnippet"},
{ t('#include <stdio.h>') },
{condition = line_begin}
),
-- STDLIB HEADER
s({trig = "hlib", snippetType="autosnippet"},
{ t('#include <stdlib.h>') },
{condition = line_begin}
),
-- STRING HEADER
s({trig = "hstr", snippetType="autosnippet"},
{ t('#include <string.h>') },
{condition = line_begin}
),
}

33
LuaSnip/c/io.lua Normal file
View file

@ -0,0 +1,33 @@
local helpers = require('personal.luasnip-helper-funcs')
local get_visual = helpers.get_visual
local line_begin = require("luasnip.extras.expand_conditions").line_begin
return
{
-- PRINTF
s({trig = "pp", snippetType="autosnippet"},
fmta(
[[printf("<>"<>);]],
{
i(1),
i(2)
}
),
{ condition = line_begin }
),
-- GETLINE BOILERPLATE
s({trig = "gll", snippetType="autosnippet"},
fmta(
[[
char *line = NULL;
size_t len = 0;
ssize_t nread;
nread = getline(&line, &len, stdin);
<>
free(line);
]],
{ i(0) }
)
),
}