Add python support

At the moment, only supports params for function definitions.
I added more options to configure the default generator (please see the
templates field in configuration/python.lua)
This commit is contained in:
Daniel Mathiot
2021-08-23 12:53:27 +02:00
parent df48fe0a38
commit 40616b25d7
4 changed files with 70 additions and 3 deletions

View File

@@ -0,0 +1,39 @@
local ts_utils = require("nvim-treesitter.ts_utils")
return {
-- Search for these nodes
parent = { "function_definition" },
-- Traverse down these nodes and extract the information as necessary
data = {
["function_definition"] = {
["2"] = {
match = "parameters",
extract = function(node)
local regular_params = neogen.utility:extract_children("identifier")(node)
return {
parameters = regular_params,
}
end,
},
},
},
-- Use default granulator and generator
locator = nil,
granulator = nil,
generator = nil,
template = {
annotation_convention = "google_docstrings", -- required: Which annotation convention to use (default_generator)
append = { position = "after", offset = 4 }, -- optional: where to append the text (default_generator)
use_default_comment = false, -- If you want to prefix the template with the default comment for the language (default_generator)
google_docstrings = {
{ nil, '"""' },
{ "parameters", "\t%s: ", { before_first_item = "Args: " } },
{ nil, '"""' },
},
},
}