feat: Allow custom placement to be disabled for certain types

This commit is contained in:
danymat
2022-02-01 15:16:00 +01:00
parent 985baa1380
commit 1e8fccb924
2 changed files with 2 additions and 1 deletions

View File

@@ -73,7 +73,7 @@ return function(parent, data, template, required_type)
local append = template.append or {}
if append.position == "after" then
if append.position == "after" and not vim.tbl_contains(append.disabled or {}, required_type) then
local child_node = nodes:matching_child_nodes(parent, append.child_name)[1]
if not child_node and append.fallback then
local fallback = nodes:matching_child_nodes(parent, append.fallback)[1]

View File

@@ -29,6 +29,7 @@ local template_configuration = {
---@field child_name string Which child node to use for appending the annotation
---@field fallback string Node to fallback if `child_name` is not found
---@field position "'after'"|"'before'" Place the annotation relative to position with `child_name` or `fallback`
---@field disabled table|nil Disable custom placement for provided types
---
--- For example, to customize the placement for a python annotation, we can use `append`, like so:
---