From 4f01fd981af20ba998fb591317b56cd94491f628 Mon Sep 17 00:00:00 2001 From: Austin Horstman Date: Sat, 14 Sep 2024 21:53:27 -0500 Subject: [PATCH] plugins/ts-comments-nvim: init --- plugins/by-name/ts-comments/default.nix | 89 +++++++++++++++++++ .../plugins/by-name/ts-comments/default.nix | 81 +++++++++++++++++ 2 files changed, 170 insertions(+) create mode 100644 plugins/by-name/ts-comments/default.nix create mode 100644 tests/test-sources/plugins/by-name/ts-comments/default.nix diff --git a/plugins/by-name/ts-comments/default.nix b/plugins/by-name/ts-comments/default.nix new file mode 100644 index 00000000..29826437 --- /dev/null +++ b/plugins/by-name/ts-comments/default.nix @@ -0,0 +1,89 @@ +{ + lib, + ... +}: +lib.nixvim.neovim-plugin.mkNeovimPlugin { + name = "ts-comments"; + originalName = "ts-comments.nvim"; + package = "ts-comments-nvim"; + + maintainers = [ lib.maintainers.khaneliman ]; + + settingsOptions = { + lang = + lib.nixvim.defaultNullOpts.mkAttrsOf lib.types.anything + { + astro = ""; + axaml = ""; + blueprint = "// %s"; + c = "// %s"; + c_sharp = "// %s"; + clojure = [ + ";; %s" + "; %s" + ]; + cpp = "// %s"; + cs_project = ""; + cue = "// %s"; + fsharp = "// %s"; + fsharp_project = ""; + gleam = "// %s"; + glimmer = "{{! %s }}"; + graphql = "# %s"; + handlebars = "{{! %s }}"; + hcl = "# %s"; + html = ""; + hyprlang = "# %s"; + ini = "; %s"; + ipynb = "# %s"; + javascript = { + __unkeyed-1 = "// %s"; + __unkeyed-2 = "/* %s */"; + call_expression = "// %s"; + jsx_attribute = "// %s"; + jsx_element = "{/* %s */}"; + jsx_fragment = "{/* %s */}"; + spread_element = "// %s"; + statement_block = "// %s"; + }; + kdl = "// %s"; + php = "// %s"; + rego = "# %s"; + rescript = "// %s"; + rust = [ + "// %s" + "/* %s */" + ]; + sql = "-- %s"; + styled = "/* %s */"; + svelte = ""; + templ = { + __default = "// %s"; + component_block = ""; + }; + terraform = "# %s"; + tsx = { + __default = "// %s"; + "/* %s */" = null; + call_expression = "// %s"; + jsx_attribute = "// %s"; + jsx_element = "{/* %s */}"; + jsx_fragment = "{/* %s */}"; + spread_element = "// %s"; + statement_block = "// %s"; + }; + twig = "{# %s #}"; + typescript = [ + "// %s" + "/* %s */" + ]; + vue = ""; + xaml = ""; + } + '' + Configure comment string for each language. + + `ts-comments.nvim` uses the default Neovim `commentstring` as a fallback, so there's no need to configure every language. + ''; + }; +} diff --git a/tests/test-sources/plugins/by-name/ts-comments/default.nix b/tests/test-sources/plugins/by-name/ts-comments/default.nix new file mode 100644 index 00000000..39077c77 --- /dev/null +++ b/tests/test-sources/plugins/by-name/ts-comments/default.nix @@ -0,0 +1,81 @@ +{ + empty = { + plugins.ts-comments.enable = true; + }; + + default = { + plugins.ts-comments = { + enable = true; + settings = { + lang = { + astro = ""; + axaml = ""; + blueprint = "// %s"; + c = "// %s"; + c_sharp = "// %s"; + clojure = [ + ";; %s" + "; %s" + ]; + cpp = "// %s"; + cs_project = ""; + cue = "// %s"; + fsharp = "// %s"; + fsharp_project = ""; + gleam = "// %s"; + glimmer = "{{! %s }}"; + graphql = "# %s"; + handlebars = "{{! %s }}"; + hcl = "# %s"; + html = ""; + hyprlang = "# %s"; + ini = "; %s"; + ipynb = "# %s"; + javascript = { + __default = "// %s"; + "/* %s */" = null; + call_expression = "// %s"; + jsx_attribute = "// %s"; + jsx_element = "{/* %s */}"; + jsx_fragment = "{/* %s */}"; + spread_element = "// %s"; + statement_block = "// %s"; + }; + kdl = "// %s"; + php = "// %s"; + rego = "# %s"; + rescript = "// %s"; + rust = [ + "// %s" + "/* %s */" + ]; + sql = "-- %s"; + styled = "/* %s */"; + svelte = ""; + templ = { + __default = "// %s"; + component_block = ""; + }; + terraform = "# %s"; + tsx = { + __unkeyed-1 = "// %s"; + __unkeyed-2 = "/* %s */"; + call_expression = "// %s"; + jsx_attribute = "// %s"; + jsx_element = "{/* %s */}"; + jsx_fragment = "{/* %s */}"; + spread_element = "// %s"; + statement_block = "// %s"; + }; + twig = "{# %s #}"; + typescript = [ + "// %s" + "/* %s */" + ]; + vue = ""; + xaml = ""; + }; + }; + }; + }; +}