Skip to content

Commit

Permalink
feat(rust) Add support for rust (func, file) #34
Browse files Browse the repository at this point in the history
  • Loading branch information
danymat committed Jan 9, 2022
1 parent ded4838 commit 4227f60
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions lua/neogen.lua
Expand Up @@ -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
Expand All @@ -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"),
},
})

Expand Down
36 changes: 36 additions & 0 deletions 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" } } },
},
},
}

0 comments on commit 4227f60

Please sign in to comment.