diff --git a/README.md b/README.md index d03ad5b..ff2402b 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,20 @@ Use your favorite package manager to install Neogen, e.g: +### Lazy + +```lua +{ + "danymat/neogen", + dependencies = "nvim-treesitter/nvim-treesitter", + config = true, + -- Uncomment next line if you want to follow only stable versions + -- version = "*" +} +``` + +### Packer + ```lua use { "danymat/neogen", diff --git a/doc/neogen.txt b/doc/neogen.txt index f616fa3..bb45925 100644 --- a/doc/neogen.txt +++ b/doc/neogen.txt @@ -183,7 +183,7 @@ Feel free to submit a PR, I will be happy to help you ! We use semantic versioning ! (https://semver.org) Here is the current Neogen version: > - neogen.version = "2.10.3" + neogen.version = "2.10.4" < # Changelog~ diff --git a/lua/neogen/configurations/python.lua b/lua/neogen/configurations/python.lua index 95603b8..c42caaf 100644 --- a/lua/neogen/configurations/python.lua +++ b/lua/neogen/configurations/python.lua @@ -49,15 +49,8 @@ return { { retrieve = "all", node_type = "typed_default_parameter", - extract = true, - subtree = { - { - retrieve = "all", - node_type = "identifier", - extract = true, - as = i.Tparam, - }, - }, + as = i.Tparam, + extract = true }, { retrieve = "first", @@ -153,14 +146,14 @@ return { local results = helpers.copy({ [i.HasParameter] = function(t) - return t[i.Parameter] and { true } or nil + return (t[i.Parameter] or t[i.Tparam]) and { true } + end, + [i.HasReturn] = function(t) + return (t[i.ReturnTypeHint] or t[i.Return]) and { true } end, [i.Type] = true, - [i.Parameter] = function(t) - return t[i.Parameter] - end, + [i.Parameter] = true, [i.Return] = true, - [i.HasReturn] = true, [i.ReturnTypeHint] = true, [i.ArbitraryArgs] = true, [i.Kwargs] = true, @@ -168,9 +161,6 @@ return { [i.Tparam] = true, }, res) or {} - -- Generates a "flag" return - results[i.HasReturn] = (results[i.ReturnTypeHint] or results[i.Return]) and { true } or nil - -- Removes generation for returns that are not typed if results[i.ReturnTypeHint] then results[i.Return] = nil diff --git a/lua/neogen/utilities/helpers.lua b/lua/neogen/utilities/helpers.lua index 2ca188c..713200e 100644 --- a/lua/neogen/utilities/helpers.lua +++ b/lua/neogen/utilities/helpers.lua @@ -43,17 +43,14 @@ return { local copy = {} for parameter, rule in pairs(rules) do - local parameter_value = table[parameter] - if parameter_value then - if type(rule) == "function" then - copy[parameter] = vim.tbl_deep_extend("error", rule(table), copy[parameter] or {}) - elseif rule == true and parameter_value ~= nil then - copy[parameter] = parameter_value - else - vim.notify("Incorrect rule format for parameter " .. parameter, vim.log.levels.ERROR) - return - end + if type(rule) == "function" then + copy[parameter] = rule(table) + elseif rule == true then + copy[parameter] = table[parameter] + else + vim.notify("Incorrect rule format for parameter " .. parameter, vim.log.levels.ERROR) + return end end