dotfiles/symlinks/config/nvim/plugin/projectionist.lua

644 lines
14 KiB
Lua
Raw Normal View History

2021-04-07 19:50:46 +00:00
local vim_readme_template = {
2022-04-28 13:53:54 +00:00
"# Name",
"",
"## Requirements",
"",
"## Installation",
"",
"## Usage",
"",
"### Commands",
"",
"### Keymaps",
"",
"## License",
"",
"[LICENSE NAME](LICENSE)",
2021-04-07 19:50:46 +00:00
}
local vim_doc_template = {
2022-04-28 13:53:54 +00:00
"*{}.txt* Description",
"",
"INTRODUCTION *{}*",
"",
"Description",
"",
"CONTENTS *{}-contents*",
"",
" 1. Overview |{}-overview|",
" 2. Requirements |{}-requirements|",
" 3. Installation |{}-installation|",
" 4. Usage |{}-usage|",
" 5. Commands |{}-commands|",
" 6. Functions |{}-functions|",
" 7. Mappings |{}-mappings|",
" 8. Plugs |{}-plugs|",
" 9. Options |{}-options|",
" 10. Issues |{}-issues|",
" 11. Contributing |{}-contributing|",
" 12. Version |{}-version|",
" 13. License |{}-license|",
"",
"OVERVIEW *{}-overview*",
"",
"REQUIREMENTS *{}-requirements*",
"",
"INSTALLATION *{}-installation*",
"",
" 1. Plug <https://github.com/junegunn/vim-plug>",
"",
" Add the following to your vimrc, or something sourced therein: >",
"",
" Plug 'esensar/{}'",
"<",
" Then install via `:PlugInstall`",
"",
" 2. Pathogen <https://github.com/tpope/vim-pathogen> >",
"",
" cd ~/.vim/bundle",
" git clone https://github.com/esensar/{}.git",
"<",
" Then run `:Helptags`",
"",
" 3. Manual",
"",
" Clone this repository and copy the files in plugin/, autoload/, and doc/",
" to their respective directories in your vimfiles, or copy the text from",
" the github repository into new files in those directories. Make sure to",
" run `:helptags`.",
"",
"USAGE *{}-usage*",
"",
"COMMANDS *{}-commands*",
"",
"FUNCTIONS *{}-functions*",
"",
"MAPPINGS *{}-mappings*",
"",
"PLUGS *{}-plugs*",
"",
"OPTIONS *{}-options*",
"",
"ISSUES *{}-issues*",
"",
"If you experience issues using {}, please report them at",
"<https://github.com/esensar/{}/issues>.",
"",
"CONTRIBUTING *{}-contributing*",
"",
"Feel free to look at already reported issues at ",
"<https://github.com/esensar/{}/issues>.",
"If available, check out CONTRIBUTING.md in the repository.",
"Otherwise, feel free to create a new issue or pull request.",
"",
"VERSION *{}-version*",
"",
"Version 1.0.0",
"",
"LICENSE *{}-license*",
"",
"vim:tw=78:ts=2:ft=help:norl:",
2021-04-07 19:50:46 +00:00
}
local flutter_config = {
2022-04-28 13:53:54 +00:00
["*"] = {
start = "flutter run",
2022-05-05 12:03:39 +00:00
dispatch = "flutter test",
2022-04-28 13:53:54 +00:00
},
["lib/*.dart"] = {
alternate = "test/{}_test.dart",
type = "source",
},
["test/*_test.dart"] = {
alternate = "lib/{}.dart",
type = "test",
template = {
"import 'package:flutter_test/flutter_test.dart';",
"",
"import 'package:flutter_template/{}.dart';",
"",
"void main() {",
" testWidgets('', (WidgetTester tester) async {",
" });",
"}",
},
},
2021-04-07 19:50:46 +00:00
}
local python_config = {
2022-04-28 13:53:54 +00:00
["*.py"] = {
alternate = "tests/{dirname}/test_{basename}.py",
type = "source",
},
["tests/**/test_*.py"] = {
alternate = "{dirname}/{basename}.py",
type = "test",
template = {
"import unittest",
"from unittest import mock",
"",
"class {dirname|underscore|camelcase|capitalize}{basename|camelcase|capitalize}Test(unittest.TestCase):",
" pass",
"",
"",
'if __name__ == "__main__":',
" unittest.main()",
},
},
2021-04-07 19:50:46 +00:00
}
local dotnet_solution_config = {
2022-04-28 13:53:54 +00:00
["src/**/Controllers/*.cs"] = {
type = "controller",
alternate = {
"tests/{dirname}.Tests/Controllers/{basename}Tests.cs",
"tests/{dirname}.IntegrationTests/Controllers/{basename}Tests.cs",
},
},
["src/**/Models/*.cs"] = {
type = "model",
alternate = "tests/{dirname}.Tests/Models/{basename}Tests.cs",
},
["src/**/Views/*.cshtml"] = {
type = "view",
alternate = "tests/{dirname}.Tests/Views/{basename}Tests.cs",
},
["src/**/Services/*.cs"] = {
type = "service",
alternate = "tests/{dirname}.Tests/Services/{basename}Tests.cs",
},
["src/**/Extensions/*.cs"] = {
type = "extension",
alternate = "tests/{dirname}.Tests/Extensions/{basename}Tests.cs",
},
["*.csproj"] = {
type = "project",
},
["src/**/appsettings*json"] = {
type = "appsettings",
},
["src/*.cs"] = {
type = "source",
alternate = "tests/{dirname}.Tests/{basename}Tests.cs",
template = {
"using System;",
"",
"namespace {dirname|dot}",
"{",
" public class {basename}",
" {",
" }",
"}",
},
},
["tests/**.IntegrationTests/Controllers/*Tests.cs"] = {
type = "test",
alternate = "src/{dirname}/Controllers/{basename}.cs",
},
["tests/**.Tests/Controllers/*Tests.cs"] = {
type = "test",
alternate = "src/{dirname}/Controllers/{basename}.cs",
},
["tests/**.Tests/Views/*Tests.cs"] = {
type = "test",
alternate = "src/{dirname}/Views/{basename}.cs",
},
["tests/**.Tests/Models/*Tests.cs"] = {
type = "test",
alternate = "src/{dirname}/Models/{basename}.cs",
},
["tests/**.Tests/Services/*Tests.cs"] = {
type = "test",
alternate = "src/{dirname}/Services/{basename}.cs",
},
["tests/**.Tests/Extensions/*Tests.cs"] = {
type = "test",
alternate = "src/{dirname}/Extensions/{basename}.cs",
},
["tests/*Tests.cs"] = {
type = "test",
alternate = "src/{dirname}/{basename}.cs",
template = {
"using System;",
"",
"namespace {dirname|dot}",
"{",
" public class {basename}Tests",
" {",
" }",
"}",
},
},
2021-04-08 14:50:20 +00:00
}
2021-04-07 19:50:46 +00:00
local vim_plugin_config = {
2022-04-28 13:53:54 +00:00
["doc/*.txt"] = {
type = "help",
template = vim_doc_template,
},
["autoload/*.vim"] = {
type = "autoload",
alternate = "test/{}.vader",
},
["test/*.vader"] = {
type = "test",
altername = "autoload/{}.vim",
},
["plugin/*.vim"] = {
type = "plugin",
template = {
'if exists("g:loaded_{}") || &cp | finish | endif',
"",
"let g:loaded_{} = 1",
},
},
["README.md"] = {
template = vim_readme_template,
},
2021-04-07 19:50:46 +00:00
}
local lua_vim_plugin_config = {
2022-04-28 13:53:54 +00:00
["doc/*.txt"] = {
type = "help",
template = vim_doc_template,
},
["plugin/*.vim"] = {
type = "plugin",
template = {
'if exists("g:loaded_{}") || &cp | finish | endif',
"",
"let g:loaded_{} = 1",
},
},
["lua/*.lua"] = {
type = "source",
2022-05-07 16:10:27 +00:00
alternate = "tests/{}_spec.lua",
2022-04-28 13:53:54 +00:00
},
2022-05-07 16:10:27 +00:00
["tests/*_spec.lua"] = {
2022-04-28 13:53:54 +00:00
type = "test",
alternate = "lua/{}.lua",
template = {
'local subject = require("{dot}")',
"",
2022-05-08 15:33:41 +00:00
'describe("{dot}:", function()',
"end)",
},
2022-04-28 13:53:54 +00:00
},
["README.md"] = {
template = vim_readme_template,
},
2021-04-07 19:50:46 +00:00
}
local csharp_project_config = {
2022-04-28 13:53:54 +00:00
["*"] = {
start = "dotnet run",
console = "dotnet fsi",
},
}
2021-06-11 10:20:00 +00:00
local java_project_config = {
2022-04-28 13:53:54 +00:00
["src/main/java/*.java"] = {
type = "source",
template = {
"package {dirname|dot};",
"",
"public class {basename} {open}",
"{close}",
},
alternate = "src/test/java/{}Test.java",
},
["src/test/java/*Test.java"] = {
type = "test",
template = {
"package {dirname|dot};",
"",
"public class {basename}Test {open}",
"{close}",
},
alternate = "src/main/java/{}.java",
},
["src/main/java/module-info.java"] = {
type = "moduleinfo",
},
["src/main/java/**/package-info.java"] = {
type = "packageinfo",
},
["src/main/resources/*"] = {
type = "resource",
},
["src/test/resources/*"] = {
type = "testresource",
},
2021-06-11 10:20:00 +00:00
}
2021-12-01 12:28:50 +00:00
local kotlin_project_config = {
2022-04-28 13:53:54 +00:00
["src/main/kotlin/*.kt"] = {
type = "source",
template = {
"package {dirname|dot}",
"",
"class {basename} {open}",
"{close}",
},
alternate = "src/test/kotlin/{}Test.kt",
},
["src/main/java/*.kt"] = {
type = "source",
template = {
"package {dirname|dot}",
"",
"class {basename} {open}",
"{close}",
},
alternate = "src/test/java/{}Test.kt",
},
["src/test/kotlin/*Test.kt"] = {
type = "test",
template = {
"package {dirname|dot}",
"",
"class {basename}Test {open}",
"{close}",
},
alternate = "src/main/kotlin/{}.kt",
},
["src/test/java/*Test.kt"] = {
type = "test",
template = {
"package {dirname|dot}",
"",
"class {basename}Test {open}",
"{close}",
},
alternate = "src/main/java/{}.kt",
},
["src/main/resources/*"] = {
type = "resource",
},
["src/test/resources/*"] = {
type = "testresource",
},
2021-12-01 12:28:50 +00:00
}
local mint_config = {
2022-04-28 13:53:54 +00:00
["*"] = {
start = "mint start",
2022-05-05 12:03:39 +00:00
dispatch = "mint test",
2022-04-28 13:53:54 +00:00
},
["source/*.mint"] = {
type = "source",
template = {
"component {basename} {open}",
" style {basename|camelcase} {open}",
" {close}",
"",
" fun render : Html {open}",
" {close}",
"{close}",
},
alternate = "tests/{}.mint",
},
["tests/*.mint"] = {
type = "test",
template = {
'suite "{basename}" {open}',
' test "A test" {open}',
" with Test.Html {open}",
" {close}",
" {close}",
"{close}",
},
alternate = "source/{}.mint",
},
}
local crystal_config = {
2022-04-28 13:53:54 +00:00
["*"] = {
start = "crystal run",
2022-05-05 12:03:39 +00:00
dispatch = "crystal spec",
console = "crystal eval",
2022-04-28 13:53:54 +00:00
},
["src/*.cr"] = {
type = "source",
template = {
"module {capitalize|colons}",
"end",
},
alternate = "spec/{}_spec.cr",
},
["spec/*_spec.cr"] = {
type = "spec",
template = {
"describe {capitalize|colons} do",
" # TODO Write tests",
"",
' it "works" do',
" false.should eq(true)",
" end",
"end",
},
alternate = "src/{}.cr",
},
}
2021-05-29 16:43:07 +00:00
local function c_project_config(source_extension, header_extension)
2022-04-28 13:53:54 +00:00
return {
["*"] = {
start = "make run",
2022-05-05 12:03:39 +00:00
dispatch = "make test",
2022-04-28 13:53:54 +00:00
},
["src/*." .. source_extension] = {
type = "source",
alternate = {
"src/{}." .. header_extension,
"test/{}." .. source_extension,
"include/{project|basename}/{}." .. header_extension,
},
},
["test/*." .. source_extension] = {
type = "test",
alternate = {
"src/{}." .. header_extension,
},
},
["src/*." .. header_extension] = {
type = "header",
alternate = {
"src/{}." .. source_extension,
},
},
["include/{project|basename}/*." .. header_extension] = {
type = "header",
alternate = {
"src/{}." .. header_extension,
},
},
}
2021-05-29 16:43:07 +00:00
end
2022-05-05 12:03:39 +00:00
local rust_config = {
["*"] = {
start = "cargo run",
dispatch = "cargo test",
},
2023-05-23 15:42:13 +00:00
["Cargo.toml"] = {
type = "crate",
},
2022-05-05 12:03:39 +00:00
["src/*.rs"] = {
type = "source",
},
2023-07-24 06:19:15 +00:00
["tests/*.rs"] = {
type = "test",
},
2022-05-05 12:03:39 +00:00
}
local zig_config = {
["*"] = {
start = "zig build run",
dispatch = "zig test",
},
["src/*.zig"] = {
type = "source",
},
}
local lein_config = {
["*"] = {
start = "lein run",
dispatch = "lein test",
console = "lein repl",
},
["src/*.clj"] = {
type = "source",
alternate = {
"test/{}_test.clj",
},
},
["src/*.cljs"] = {
type = "source",
alternate = {
"test/{}_test.cljs",
},
},
["src/*.cljc"] = {
type = "source",
alternate = {
"test/{}_test.cljc",
},
},
["test/*_test.clj"] = {
type = "test",
alternate = {
"src/{}.clj",
},
},
["test/*_test.cljs"] = {
type = "test",
alternate = {
"src/{}.cljs",
},
},
["test/*_test.cljc"] = {
type = "test",
alternate = {
"src/{}.cljc",
},
},
}
2022-07-18 14:12:36 +00:00
local clojure_config = {
["*"] = {
dispatch = "clj -M:test",
console = "clj -M:dev",
},
["src/clj/*.clj"] = {
type = "source",
alternate = {
"test/clj/{}_test.clj",
},
},
["src/clj/*.cljs"] = {
type = "source",
alternate = {
"test/clj/{}_test.cljs",
},
},
["src/clj/*.cljc"] = {
type = "source",
alternate = {
"test/clj/{}_test.cljc",
},
},
["test/clj/*_test.clj"] = {
type = "test",
alternate = {
"src/clj/{}.clj",
},
},
["test/clj/*_test.cljs"] = {
type = "test",
alternate = {
"src/clj/{}.cljs",
},
},
["test/clj/*_test.cljc"] = {
type = "test",
alternate = {
"src/clj/{}.cljc",
},
},
}
2022-08-01 13:25:40 +00:00
local golang_config = {
["*"] = {
start = "go run .",
dispatch = "go test ./...",
},
["*.go"] = {
type = "source",
alternate = {
"{}_test.go",
},
},
["*_test.go"] = {
type = "test",
alternate = {
"{}.go",
},
},
}
2023-08-19 19:02:32 +00:00
local playdate_config = {
["*"] = {
start = "pdc Source output.pdx && PlaydateSimulator output.pdx",
dispatch = "pdc Source output.pdx && PlaydateSimulator.debug output.pdx",
},
["Source/pdxinfo"] = {
type = "metadata",
},
["Source/*.lua"] = {
type = "source",
},
}
2021-04-07 19:50:46 +00:00
vim.g.projectionist_heuristics = {
2022-04-28 13:53:54 +00:00
["pubspec.yaml"] = flutter_config,
["requirements.txt|pyproject.toml"] = python_config,
["*.sln"] = dotnet_solution_config,
["*.csproj"] = csharp_project_config,
["plugin/|autoload/"] = vim_plugin_config,
["src/*.cpp|test/*.cpp"] = c_project_config("cpp", "hpp"),
["src/*.c|test/*.c"] = c_project_config("c", "h"),
["lua/"] = lua_vim_plugin_config,
["build.gradle|pom.xml"] = java_project_config,
["build.gradle|build.gradle.kts"] = kotlin_project_config,
["mint.json"] = mint_config,
["shard.yml"] = crystal_config,
2022-05-05 12:03:39 +00:00
["Cargo.toml"] = rust_config,
2022-08-01 13:25:40 +00:00
["go.mod"] = golang_config,
2022-05-05 12:03:39 +00:00
["build.zig"] = zig_config,
["project.clj"] = lein_config,
2022-07-18 14:12:36 +00:00
["deps.edn"] = clojure_config,
2023-08-19 19:02:32 +00:00
["Source/main.lua|Source/pdxinfo"] = playdate_config,
2021-04-07 19:50:46 +00:00
}