From 7090563294dd303944d3a40c8351c088a1419457 Mon Sep 17 00:00:00 2001 From: blob42 Date: Thu, 1 Jun 2023 16:09:31 +0200 Subject: [PATCH] project configs and template plugins for licensing --- lua/custom/plugins/configs/projectconfig.lua | 18 ++++++++++++++++ lua/custom/plugins/init.lua | 21 ++++++++++++++++--- my_packages/perproject/lua/perproject.lua | 22 +++++++++++++++++--- mysnippets/lua.lua | 2 +- templates/COPYRIGHT.NOTICE | 1 + templates/LICENSE.MAIN.AGPL3 | 14 +++++++++++++ templates/LICENSE.PERFILE.AGPL3 | 15 +++++++++++++ templates/myawesome.target | 2 ++ 8 files changed, 88 insertions(+), 7 deletions(-) create mode 100644 lua/custom/plugins/configs/projectconfig.lua create mode 100644 templates/COPYRIGHT.NOTICE create mode 100644 templates/LICENSE.MAIN.AGPL3 create mode 100644 templates/LICENSE.PERFILE.AGPL3 create mode 100644 templates/myawesome.target diff --git a/lua/custom/plugins/configs/projectconfig.lua b/lua/custom/plugins/configs/projectconfig.lua new file mode 100644 index 0000000..1b8bab1 --- /dev/null +++ b/lua/custom/plugins/configs/projectconfig.lua @@ -0,0 +1,18 @@ +local ok, pconfig = pcall(require, "nvim-projectconfig") +if not ok then + vim.notify("missing module nvim-projectconfig", vim.log.levels.WARN) + return false +end + +local M = {} + +local config = { + project_dir = "~/.config/nvim-project-confs/", -- trailing slash important + selint = false, +} + +M.setup = function() + pconfig.setup(config) +end + +return M diff --git a/lua/custom/plugins/init.lua b/lua/custom/plugins/init.lua index 33be804..dce6918 100644 --- a/lua/custom/plugins/init.lua +++ b/lua/custom/plugins/init.lua @@ -229,7 +229,17 @@ return { override_priority = 2000, -- highest priority for my luasnips } end - }, -- }}} + }, + + + -- vim templates + ["https://codeberg.org/jgoguen/tmpl.vim"] = { + setup = function() + + end + }, + + -- }}} -- text formatting -- @@ -482,7 +492,7 @@ return { end }, - -- session and view + -- sessions, projects and views ["vim-scripts/restore_view.vim"] = {}, -- TODO: check if still needed @@ -496,6 +506,11 @@ return { -- end -- }, + ["windwp/nvim-projectconfig"] = { + config = function() + require("custom.plugins.configs.projectconfig").setup() + end, + }, -- -- Misc / General plugins @@ -662,7 +677,7 @@ return { -- ['stevearc/aerial.nvim'] = { - lock = true, + -- lock = true, after = { "base46" }, keys = { "" }, cmd = { "Aerial*" }, diff --git a/my_packages/perproject/lua/perproject.lua b/my_packages/perproject/lua/perproject.lua index 37be7f4..2cee89d 100644 --- a/my_packages/perproject/lua/perproject.lua +++ b/my_packages/perproject/lua/perproject.lua @@ -27,9 +27,14 @@ local _PP_CONF = { callbacks = pp_callbacks, } +-- these are the custom callbacks that can be enabled from perproject files +-- setting manually the callbacks here is a safety measure from auto running +-- untrusted code from perproject files +-- TODO: load callbacks from a `callbacks_file` under `runtimepath` local pp_callbacks = { -- @enabled: bool + -- auto start lsp for this project lsp_autostart = function(enabled) if enabled then local other_matching_configs = require('lspconfig.util').get_other_matching_providers(vim.bo.filetype) @@ -37,6 +42,15 @@ local pp_callbacks = { config.launch() end end + end, + + -- used for testing + -- create a `.pnvim.json` file with this content: + -- { + -- "test_callback": true + -- } + test_callback = function(enabled) + P("test callback") end } @@ -59,7 +73,8 @@ end -- local scandir = require("plenary.scandir") -local function per_project_file() +--TODO: +local function per_project_dir() local cwd = Path.new(vim.fn.getcwd()) local pp_dir = cwd:joinpath(_PP_CONF_.basename) @@ -82,8 +97,8 @@ local function per_project_file() print("no " .. _PP_CONF.basename) end - -- TODO: - -- check if there is a custom .nvim-lsp dir in working dir + -- TODO: handle directoryies + -- check if there is a custom .pnvim.json dir in working dir -- each file inside .nvim-lsp represent a active option if -- it is present -- example @@ -95,6 +110,7 @@ end M.per_project_jsonfile = function() local cwd = Path.new(vim.fn.getcwd()) local pp_file = cwd:joinpath(_PP_CONF.basename) + -- if is file then load the file if pp_file:is_file() then local ok, decoded = pcall(vim.json.decode, (pp_file:read())) if not ok then diff --git a/mysnippets/lua.lua b/mysnippets/lua.lua index 99b9eb9..b18595d 100644 --- a/mysnippets/lua.lua +++ b/mysnippets/lua.lua @@ -23,7 +23,7 @@ return M -- if require s("ifreq", fmt([[ local ok, {} = pcall(require, "{}") - if not ok then + if not ok then vim.notify("missing module {}", vim.log.levels.WARN) return end diff --git a/templates/COPYRIGHT.NOTICE b/templates/COPYRIGHT.NOTICE new file mode 100644 index 0000000..4284401 --- /dev/null +++ b/templates/COPYRIGHT.NOTICE @@ -0,0 +1 @@ +Copyright (c) <# YEAR #> <# AUTHOR #> diff --git a/templates/LICENSE.MAIN.AGPL3 b/templates/LICENSE.MAIN.AGPL3 new file mode 100644 index 0000000..605cce8 --- /dev/null +++ b/templates/LICENSE.MAIN.AGPL3 @@ -0,0 +1,14 @@ +<$ COPYRIGHT.NOTICE $> + +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, either version 3 of the +License, or (at your option) any later version. + +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 . diff --git a/templates/LICENSE.PERFILE.AGPL3 b/templates/LICENSE.PERFILE.AGPL3 new file mode 100644 index 0000000..55358cb --- /dev/null +++ b/templates/LICENSE.PERFILE.AGPL3 @@ -0,0 +1,15 @@ +<$ COPYRIGHT.NOTICE $> +This file is part of <# PROGRAM #>. + +<# 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, either version 3 of the +License, or (at your option) any later version. + +<# 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 <# PROGRAM #>. If not, see . diff --git a/templates/myawesome.target b/templates/myawesome.target new file mode 100644 index 0000000..a6e579b --- /dev/null +++ b/templates/myawesome.target @@ -0,0 +1,2 @@ +<$ LICENSE.PERFILE.AGPL3 $> +