nvim: add C++ include guard snippet, remove license snippets
This commit is contained in:
parent
a1152ca15d
commit
bbaef102ca
@ -5,91 +5,8 @@ local i = require("luasnip.nodes.insertNode").I
|
|||||||
local fmt = require("luasnip.extras.fmt").fmt
|
local fmt = require("luasnip.extras.fmt").fmt
|
||||||
local t = require("luasnip.nodes.textNode").T
|
local t = require("luasnip.nodes.textNode").T
|
||||||
|
|
||||||
local agpl =
|
|
||||||
[[/* This file is part of {project}.
|
|
||||||
* Copyright © {year} {name} <{email}>
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Affero General Public License as published by
|
|
||||||
* the Free Software Foundation, version 3.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
{cursor}]]
|
|
||||||
|
|
||||||
local bsd0 =
|
|
||||||
[[/* This file is part of {project}.
|
|
||||||
* Copyright © {year} {name} <{email}>
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and/or distribute this software for any
|
|
||||||
* purpose with or without fee is hereby granted.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
|
||||||
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
|
||||||
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
|
||||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
{cursor}]]
|
|
||||||
|
|
||||||
local my = require('my.functions')
|
local my = require('my.functions')
|
||||||
return {
|
return {
|
||||||
s({ trig = 'AGPL',
|
|
||||||
name = 'AGPL-3.0-only',
|
|
||||||
dscr = 'Inserts the GNU Affero General Public License, version 3'
|
|
||||||
},
|
|
||||||
fmt(agpl, {
|
|
||||||
project = f(function()
|
|
||||||
local root = my.get_project_root()
|
|
||||||
if root then return root:gsub('.*/', '') end
|
|
||||||
return 'INSERT_PROJECT'
|
|
||||||
end),
|
|
||||||
year = f(function()
|
|
||||||
return os.date('%Y')
|
|
||||||
end),
|
|
||||||
name = f(function()
|
|
||||||
return my.shell_capture('git config user.name')
|
|
||||||
or 'INSERT_NAME'
|
|
||||||
end),
|
|
||||||
email = f(function()
|
|
||||||
return my.shell_capture('git config user.email')
|
|
||||||
or 'INSERT_EMAIL'
|
|
||||||
end),
|
|
||||||
cursor = i(0)
|
|
||||||
})),
|
|
||||||
s({ trig = '0BSD',
|
|
||||||
name = '0BSD',
|
|
||||||
dscr = 'Inserts the BSD Zero Clause License'
|
|
||||||
},
|
|
||||||
fmt(bsd0, {
|
|
||||||
project = f(function()
|
|
||||||
local root = my.get_project_root()
|
|
||||||
if root then return root:gsub('.*/', '') end
|
|
||||||
return 'INSERT_PROJECT'
|
|
||||||
end),
|
|
||||||
year = f(function()
|
|
||||||
return os.date('%Y')
|
|
||||||
end),
|
|
||||||
name = f(function()
|
|
||||||
return my.shell_capture('git config user.name')
|
|
||||||
or 'INSERT_NAME'
|
|
||||||
end),
|
|
||||||
email = f(function()
|
|
||||||
return my.shell_capture('git config user.email')
|
|
||||||
or 'INSERT_EMAIL'
|
|
||||||
end),
|
|
||||||
cursor = i(0)
|
|
||||||
})),
|
|
||||||
s({ trig = 'main',
|
s({ trig = 'main',
|
||||||
name = 'main',
|
name = 'main',
|
||||||
dscr = 'main function'
|
dscr = 'main function'
|
||||||
@ -97,5 +14,26 @@ return {
|
|||||||
t({ 'int main(int argc, char *argv[]) {' }),
|
t({ 'int main(int argc, char *argv[]) {' }),
|
||||||
i(0),
|
i(0),
|
||||||
t({ '', '}' })
|
t({ '', '}' })
|
||||||
})
|
}),
|
||||||
|
s({ trig = 'includeguard',
|
||||||
|
name = 'includeguard',
|
||||||
|
dscr = 'add include guard'
|
||||||
|
},
|
||||||
|
fmt([[#ifndef {project}_{basename}
|
||||||
|
#define {project}_{basename}
|
||||||
|
|
||||||
|
{cursor}
|
||||||
|
|
||||||
|
#endif // {project}_{basename}]], {
|
||||||
|
project = f(function()
|
||||||
|
local root = my.get_project_root()
|
||||||
|
if root then return root:gsub('.*/', ''):upper() end
|
||||||
|
return 'INSERT_PROJECT'
|
||||||
|
end),
|
||||||
|
basename = f(function()
|
||||||
|
return vim.fs.basename(vim.api.nvim_buf_get_name(0)):upper()
|
||||||
|
:gsub('%.', '_')
|
||||||
|
end),
|
||||||
|
cursor = i(0)
|
||||||
|
}))
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user