added snippets for csharp

This commit is contained in:
Sebastian 2024-09-29 21:56:55 +02:00
parent 0485d332d2
commit c372e473d2
2 changed files with 183 additions and 6 deletions

View File

@ -802,7 +802,12 @@ require('lazy').setup({
end end
return 'make install_jsregexp' return 'make install_jsregexp'
end)(), end)(),
config = function()
require('luasnip.loaders.from_lua').load { paths = { '~/.config/nvim/snippets/' } }
end,
dependencies = { dependencies = {
-- `friendly-snippets` contains a variety of premade snippets. -- `friendly-snippets` contains a variety of premade snippets.
-- See the README about individual language/framework/plugin snippets: -- See the README about individual language/framework/plugin snippets:
-- https://github.com/rafamadriz/friendly-snippets -- https://github.com/rafamadriz/friendly-snippets

172
snippets/cs.lua Normal file
View File

@ -0,0 +1,172 @@
local ls = require 'luasnip'
local s = ls.snippet
local t = ls.text_node
local i = ls.insert_node
local f = ls.function_node
local c = ls.choice_node
local d = ls.dynamic_node
local r = ls.restore_node
local fmt = require('luasnip.extras.fmt').fmt
return {
s(
'cww',
fmt('Console.WriteLine({});{}', {
i(1, ''),
i(0),
})
),
s(
'cw',
fmt('Console.Write({});{}', {
i(1, ''),
i(0),
})
),
s(
'do',
fmt(
[[
do
{{
{}}} while ({});
{}]],
{
i(2),
i(1),
i(0),
}
)
),
s(
'while',
fmt(
[[
while ({})
{{
{}}}
{}]],
{
i(1),
i(2),
i(0),
}
)
),
s(
'fo',
fmt(
[[
for (int {} = 0; {} < {}; {}++)
{{
{}}}
{}]],
{
i(2, 'i'),
f(function(args)
return args[1][1]
end, { 2 }),
i(1, '1'),
f(function(args)
return args[1][1]
end, { 2 }),
i(3),
i(0),
}
)
),
s(
'forr',
fmt(
[[
for (int {} = {} - 1; {} >= 0; {}--)
{{
{}}}
{}]],
{
i(2, 'i'),
i(1, 'length'),
f(function(args)
return args[1][1]
end, { 2 }),
f(function(args)
return args[1][1]
end, { 2 }),
i(3),
i(0),
}
)
),
s('cc', t 'Console.Clear();'),
s('crk', t 'Console.ReadKey(true);'),
s('crl', t 'Console.ReadLine();'),
s(
'foreach',
fmt(
[[
foreach ({})
{{
{}}}{}]],
{
i(1),
i(2),
i(0),
}
)
),
s(
'cla',
fmt(
[[
class {}
{{
{}}}
]],
{
i(1, 'ClassName'),
i(0),
}
)
),
s(
'inter',
fmt(
[[
interface {}
{{
{}}}
]],
{
i(1, 'IInterfaceName'),
i(0),
}
)
),
s(
'enu',
fmt(
[[
enum {}
{{
{}}}
]],
{
i(1, 'EnumName'),
i(0),
}
)
),
}