Alkynes and nitriles participate as electrophiles in numerous heterocycle synthesis reactions, being attacked by a wide variety of nucleophiles.

A) The nucleophilic-electrophilic character of propanedinitrile and alpha-aminoketones allows the preparation of pyrroles , let's see an example.

pyrrole cyclization sp synthesis

Mechanism:

pyrrole synthesis cyclization sp mechanism

B) In this second example we put into play thiourea, which reacts with alphabromonitrile yielding thiazole.

synthesis thiazole cyclization sp

Mechanism:
thiazole synthesis sp cyclization mechanism

C) Intramolecular cyclization in which the alcohol acts as a nucleophile and the alkyne as an electrophile.

furan synthesis sp cyclization

Mechanism:

furan synthesis sp cyclization mechanism