From: Samir Benmendil Date: Fri, 17 Apr 2015 00:44:41 +0000 (+0100) Subject: vim: use git config for copyright name/email X-Git-Url: https://git.rmz.io/dotfiles.git/commitdiff_plain/7cac28796fc7098bed64c9f4ffe0d516b9ce99e3?ds=sidebyside vim: use git config for copyright name/email also fixes some issues with the import to ultisnips --- diff --git a/vim/ultisnips/all.snippets b/vim/ultisnips/all.snippets index f832e0b..7bb39c6 100644 --- a/vim/ultisnips/all.snippets +++ b/vim/ultisnips/all.snippets @@ -1,6 +1,22 @@ +global !p +import subprocess, vim + +def _git_user_name(): + try: + snip.rv = subprocess.check_output(["git", "config", "user.name"]).strip() + except CalledProcessError: + snip.rv = "John Doe" + +def _git_user_email(): + try: + snip.rv = subprocess.check_output(["git", "config", "user.email"]).strip() + except CalledProcessError: + snip.rv = "jdoe@example.com" +endglobal + snippet GPL2 "GPL2 License" b ${1:One line to give the program's name and a brief description.} - Copyright `&enc[:2] == "utf" ? "©" : "(c)"` `strftime("%Y")` ${2:`g:snips_author`} + Copyright `!v &enc[:2] == "utf" ? "©" : "(c)"` `!v strftime("%Y")` ${2:`!p _git_user_name()`} <${3:`!p _git_user_email()`}> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -19,7 +35,7 @@ endsnippet snippet LGPL2 "LGPL2 License" b ${1:One line to give the program's name and a brief description.} - Copyright `&enc[:2] == "utf" ? "©" : "(c)"` `strftime("%Y")` ${2:`g:snips_author`} + Copyright `!v &enc[:2] == "utf" ? "©" : "(c)"` `!v strftime("%Y")` ${2:`!p _git_user_name()`} <${3:`!p _git_user_email()`}> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published @@ -38,7 +54,7 @@ endsnippet snippet GPL3 "GPL3 License" b ${1:one line to give the program's name and a brief description.} - Copyright `&enc[:2] == "utf" ? "©" : "(c)"` `strftime("%Y")` ${2:`g:snips_author`} + Copyright `!v &enc[:2] == "utf" ? "©" : "(c)"` `!v strftime("%Y")` ${2:`!p _git_user_name()`} <${3:`!p _git_user_email()`}> This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -57,7 +73,7 @@ endsnippet snippet LGPL3 "LGPL3 License" b ${1:One line to give the program's name and a brief description.} - Copyright `&enc[:2] == "utf" ? "©" : "(c)"` `strftime("%Y")` ${2:`g:snips_author`} + Copyright `!v &enc[:2] == "utf" ? "©" : "(c)"` `!v strftime("%Y")` ${2:`!p _git_user_name()`} <${3:`!p _git_user_email()`}> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published @@ -76,7 +92,7 @@ endsnippet snippet AGPL3 "AGPL3 License" b ${1:one line to give the program's name and a brief description.} - Copyright `&enc[:2] == "utf" ? "©" : "(c)"` `strftime("%Y")` ${2:`g:snips_author`} + Copyright `!v &enc[:2] == "utf" ? "©" : "(c)"` `!v strftime("%Y")` ${2:`!p _git_user_name()`} <${3:`!p _git_user_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 @@ -106,7 +122,7 @@ endsnippet snippet BSD2 "BSD2 License" b ${1:one line to give the program's name and a brief description} - Copyright `&enc[:2] == "utf" ? "©" : "(c)"` `strftime("%Y")` ${2:`g:snips_author`} + Copyright `!v &enc[:2] == "utf" ? "©" : "(c)"` `!v strftime("%Y")` ${2:`!p _git_user_name()`} <${3:`!p _git_user_email()`}> All rights reserved. Redistribution and use in source and binary forms, with or without @@ -137,7 +153,7 @@ endsnippet snippet BSD3 "BSD3 License" b ${1:one line to give the program's name and a brief description} - Copyright `&enc[:2] == "utf" ? "©" : "(c)"` `strftime("%Y")` ${2:`g:snips_author`} + Copyright `!v &enc[:2] == "utf" ? "©" : "(c)"` `!v strftime("%Y")` ${2:`!p _git_user_name()`} <${3:`!p _git_user_email()`}> All rights reserved. Redistribution and use in source and binary forms, with or without @@ -147,7 +163,7 @@ snippet BSD3 "BSD3 License" b 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - 3. Neither the name of the ${3:organization} nor the + 3. Neither the name of the ${4:organization} nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. @@ -166,7 +182,7 @@ endsnippet snippet BSD4 "BSD4 License" b ${1:one line to give the program's name and a brief description} - Copyright `&enc[:2] == "utf" ? "©" : "(c)"` `strftime("%Y")` ${2:`g:snips_author`} + Copyright `!v &enc[:2] == "utf" ? "©" : "(c)"` `!v strftime("%Y")` ${2:`!p _git_user_name()`} <${3:`!p _git_user_email()`}> All rights reserved. Redistribution and use in source and binary forms, with or without @@ -178,8 +194,8 @@ snippet BSD4 "BSD4 License" b documentation and/or other materials provided with the distribution. 3. All advertising materials mentioning features or use of this software must display the following acknowledgement: - This product includes software developed by the ${3:organization}. - 4. Neither the name of the $3 nor the + This product includes software developed by the ${4:organization}. + 4. Neither the name of the $4 nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. @@ -198,7 +214,7 @@ endsnippet snippet MIT "MIT License" b ${1:one line to give the program's name and a brief description} - Copyright `&enc[:2] == "utf" ? "©" : "(c)"` `strftime("%Y")` ${2:`g:snips_author`} + Copyright `!v &enc[:2] == "utf" ? "©" : "(c)"` `!v strftime("%Y")` ${2:`!p _git_user_name()`} <${3:`!p _git_user_email()`}> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), @@ -222,7 +238,7 @@ endsnippet snippet APACHE "APACHE License" b ${1:one line to give the program's name and a brief description} - Copyright `strftime("%Y")` ${2:`g:snips_author`} + Copyright `!v strftime("%Y")` ${2:`!p _git_user_name()`} <${3:`!p _git_user_email()`}> Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -240,7 +256,7 @@ endsnippet snippet BEERWARE "BEERWARE License" b ${1:one line to give the program's name and a brief description} - Copyright `strftime("%Y")` ${2:`g:snips_author`} + Copyright `!v strftime("%Y")` ${2:`!p _git_user_name()`} <${3:`!p _git_user_email()`}> Licensed under the "THE BEER-WARE LICENSE" (Revision 42): $2 wrote this file. As long as you retain this notice you @@ -253,7 +269,7 @@ snippet WTFPL "WTFPL License" b DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE Version 2, December 2004 - Copyright `strftime("%Y")` ${0:`g:snips_author`} + Copyright `!v strftime("%Y")` ${1:`!p _git_user_name()`} <${2:`!p _git_user_email()`}> Everyone is permitted to copy and distribute verbatim or modified copies of this license document, and changing it is allowed as long @@ -276,7 +292,7 @@ endsnippet snippet AGPL "AGPL License" b ${1:One line to give the program's name and a brief description.} - Copyright `&enc[:2] == "utf" ? "©" : "(c)"` `strftime("%Y")` ${2:`g:snips_author`} + Copyright `!v &enc[:2] == "utf" ? "©" : "(c)"` `!v strftime("%Y")` ${2:`!p _git_user_name()`} <${3:`!p _git_user_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