add MIT license snippet
This commit is contained in:
parent
b5f23572d9
commit
637bdfc93b
@ -53,9 +53,9 @@ cmp.setup{
|
||||
{ name = 'nvim_lua' },
|
||||
|
||||
{ name = 'nvim_lsp', max_item_count = 20 },
|
||||
{ name = 'luasnip' },
|
||||
{ name = 'cmp_tabnine' },
|
||||
{ name = 'path' },
|
||||
{ name = 'luasnip' },
|
||||
{ name = 'buffer', max_item_count = 10, keyword_length = 5 },
|
||||
},
|
||||
formatting = {
|
||||
@ -92,5 +92,3 @@ cmp.setup.cmdline('/', {
|
||||
-- { name = 'cmdline' }
|
||||
-- })
|
||||
-- })
|
||||
|
||||
|
||||
|
55
lua/config/luasnip.lua
Normal file
55
lua/config/luasnip.lua
Normal file
@ -0,0 +1,55 @@
|
||||
local ls = require("luasnip")
|
||||
local capture = require("utils.capture")
|
||||
local s = ls.snippet
|
||||
local sn = ls.snippet_node
|
||||
local t = ls.text_node
|
||||
local i = ls.insert_node
|
||||
local f = ls.function_node
|
||||
local choice = ls.choice_node
|
||||
local d = ls.dynamic_node
|
||||
|
||||
local function getCurrentYear()
|
||||
return os.date("%Y")
|
||||
end
|
||||
|
||||
local function getGitUsername()
|
||||
local stdout = capture("git config user.name")
|
||||
if stdout == "" then
|
||||
return nil
|
||||
end
|
||||
return stdout
|
||||
end
|
||||
|
||||
ls.add_snippets("all", {
|
||||
s("MIT", {
|
||||
t({"The MIT License (MIT)", "Copyright © "}),
|
||||
f(getCurrentYear, {}),
|
||||
t(" "),
|
||||
d(1, function()
|
||||
return sn(nil, {
|
||||
i(1, getGitUsername() or "<copyright holders>")
|
||||
})
|
||||
end, {}),
|
||||
t{
|
||||
"",
|
||||
"",
|
||||
"Permission is hereby granted, free of charge, to any person obtaining a copy of",
|
||||
"this software and associated documentation files (the “Software”), to deal in",
|
||||
"the Software without restriction, including without limitation the rights to",
|
||||
"use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies",
|
||||
"of the Software, and to permit persons to whom the Software is furnished to do",
|
||||
"so, subject to the following conditions:",
|
||||
"",
|
||||
"The above copyright notice and this permission notice shall be included in all",
|
||||
"copies or substantial portions of the Software.",
|
||||
"",
|
||||
"THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR",
|
||||
"IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,",
|
||||
"FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE",
|
||||
"AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER",
|
||||
"LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,",
|
||||
"OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE",
|
||||
"SOFTWARE.",
|
||||
}
|
||||
})
|
||||
})
|
@ -128,7 +128,7 @@ local function usePlugins(use, use_rocks)
|
||||
use 'tpope/vim-eunuch'
|
||||
|
||||
-- Snippets
|
||||
use 'L3MON4D3/LuaSnip'
|
||||
use { 'L3MON4D3/LuaSnip', after = 'nvim-cmp', config = [[require 'config.luasnip']] }
|
||||
|
||||
-- Movement utilities
|
||||
use 'tpope/vim-unimpaired'
|
||||
|
10
lua/utils/capture.lua
Normal file
10
lua/utils/capture.lua
Normal file
@ -0,0 +1,10 @@
|
||||
return function (cmd, raw)
|
||||
local f = assert(io.popen(cmd, 'r'))
|
||||
local s = assert(f:read('*a'))
|
||||
f:close()
|
||||
if raw then return s end
|
||||
s = string.gsub(s, '^%s+', '')
|
||||
s = string.gsub(s, '%s+$', '')
|
||||
s = string.gsub(s, '[\n\r]+', ' ')
|
||||
return s
|
||||
end
|
Loading…
Reference in New Issue
Block a user