From 4227f608b29ef575e92e93e165e9893dd10a1210 Mon Sep 17 00:00:00 2001 From: danymat Date: Sun, 9 Jan 2022 16:29:50 +0100 Subject: [PATCH] feat(rust) Add support for rust (`func`, `file`) #34 --- README.md | 2 ++ lua/neogen.lua | 3 +-- lua/neogen/configurations/rust.lua | 36 ++++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 lua/neogen/configurations/rust.lua diff --git a/README.md b/README.md index c470456..fe02181 100644 --- a/README.md +++ b/README.md @@ -194,6 +194,8 @@ There is a list of supported languages and fields, with their annotation style | | [Godoc](https://go.dev/blog/godoc) (`"godoc"`) | | | java | | | `func`, `class` | | | [Javadoc](https://docs.oracle.com/javase/1.5.0/docs/tooldocs/windows/javadoc.html#documentationcomments) (`"javadoc"`) | | +| rust | | | `func`, `file` | +| | [Rustdoc](https://doc.rust-lang.org/rustdoc/what-is-rustdoc.html) (`"rustdoc"`) | | ## Adding Languages diff --git a/lua/neogen.lua b/lua/neogen.lua index 6a8eca5..5f35ae1 100644 --- a/lua/neogen.lua +++ b/lua/neogen.lua @@ -122,8 +122,6 @@ function neogen.jumpable(reverse) return neogen.utilities.cursor.jumpable(reverse) end - - function neogen.generate_command() vim.api.nvim_command('command! -range -bar Neogen lua require("neogen").generate()') end @@ -142,6 +140,7 @@ neogen.setup = function(opts) cpp = require("neogen.configurations.c"), go = require("neogen.configurations.go"), java = require("neogen.configurations.java"), + rust = require("neogen.configurations.rust"), }, }) diff --git a/lua/neogen/configurations/rust.lua b/lua/neogen/configurations/rust.lua new file mode 100644 index 0000000..f32de4f --- /dev/null +++ b/lua/neogen/configurations/rust.lua @@ -0,0 +1,36 @@ +return { + parent = { + func = { "function_item" }, + file = { "source_file" }, + }, + data = { + func = { + ["function_item"] = { + ["0"] = { + extract = function() + return {} + end, + }, + }, + }, + file = { + ["source_file"] = { + ["0"] = { + extract = function() + return {} + end, + }, + }, + }, + }, + + template = { + annotation_convention = "rustdoc", + rustdoc = { + { nil, "! $1", { no_results = true, type = { "file" } } }, + { nil, "", { no_results = true, type = { "file" } } }, + + { nil, "/ $1", { no_results = true, type = { "func" } } }, + }, + }, +}