Painted on the outside wall of Leith Dockers Club is a mural that depicts some of the wizened faces of the men who worked the port amid familiar haunts of this working-class district north of Edinburgh’s gilded city centre. Soon they will be joined by another of Leith’s favourite sons, Irvine Welsh, the writer and poet who, they felt, brought this neglected place to life once more.

It is 23 years since Welsh penned his masterpiece, Trainspotting, the ferocious and poetic depiction of an underclass that generations of the city burgesses had tried to pretend didn’t exist. The film of the book was made three years later and now, on its 20th anniversary, the director Danny Boyle and most of the original cast have come together to begin filming the long-awaited sequel. In locations around Leith, as well as some in Glasgow, Ewan McGregor, Robert Carlyle, Jonny Lee Miller and the boys have been glimpsed playing their former selves with some gusto.

They look as though they are enjoying themselves and Carlyle says that the Trainspotting 2 script is even better than the original. In the Dockers, Rab Mitchell, the manager, is fishing out a photograph of Welsh standing beside the club. “Irvine Welsh is the first and only honorary member of the Leith Dockers Club,” he says proudly. “I’ve been meaning to get an image of him put up on the mural outside. He’s a great lad and often pops in for a pint when he returns home from the States. He’ll always be welcome here and not just because he talked fondly about us in Trainspotting. He gave Leith a voice, a real voice.”

The Dockers Club is one of several places in this little enclave that are stitched forever into the fabric of British cinema and literature. Just across the road is the Central Bar underneath the old Leith Central Station which inspired the name of the book. The pub is a throwback to an earlier age when working-class men, some retired, would spend an afternoon perched beside a big saloon bar sipping ale and making the day’s racing selections. The smoking ban in Scotland’s pubs has been in force for more than a decade but this is one of those bars which, while smoke-free, cannot be pictured in your mind without smoke. Cigarettes ought to be smoked in here.

On Friday afternoon it’s busy and I stop to pick up some of the working- class Edinburgh dialect which Irvine gave voice to. The author and journalist Simon Pia, born and raised here, is another who says that Trainspotting is perhaps the best book that’s ever been written about Scotland. “You have to remember,” he says, that when people think of working-class dialects they immediately think of Glaswegian and people like Billy Connolly and Stanley Baxter. In literature, the authentic Glaswegian dialect has been captured wonderfully by James Kelman.

“What Welsh did in Trainspotting was bring to life a rich and varied authentic Edinburgh working-class dialect that many people outside its natural habitat probably didn’t even know existed, including in the city itself. The book also perfectly captured what was going on in real Edinburgh in the 1980s.”

What was going on then was that Edinburgh, posh, elegant and classical Edinburgh – the Athens of the north – was becoming known as the Aids capital of Europe, mainly brought about by shared needles in filthy tenements in scenes that Welsh faithfully and with no adornment whatsoever brought to grim life. At the beginning of a chapter called The First Day of the Edinburgh Festival, Welsh brutally paints a city of contrasts. “Ay took ma last shot in order tae git us through the horrors ay the shopping trip. Ma final score will be used tae help us sleep, and ease us oaf the skag. Ah’ll try tae take it in small, measured doses. Ah need some quickly. The great decline is setting in. It starts as it generally does, with a slight nausea in the pit ay ma stomach and an irrational panic attack.”

Under Danny Boyle’s cinematic direction, scenes like that were accorded a terrifying beauty, like the first time you watched the 1966 footage of a Buddhist monk serenely setting fire to himself. Unsurprisingly, the book and film were not received well in some parts of an Edinburgh which was trying to promote itself as the go-to cultural destination in the western world. “Trainspotting captured a time and a place in the history of this city perfectly,” says Pia. “Those of us who knew these places and who had lived and worked here in places like Leith, Pilton, the Drylaw and Muirhouse, knew that this was just as real as the Castle and the Palace and the galleries and the old town. Irvine observed all this, and he got it all. It might not be what some others would like to have seen up there on the screen, but the people around here loved it. They didn’t think he had reduced them or disparaged them. They thought he honoured them … and he had.”

The port of Leith was formally merged with Edinburgh in 1920 despite Leithers voting 5-1 against the move in a referendum. But it has never really belonged to the rest of the city. As well as having its own coat of arms and civic hall, it also has a strong sense of its own identity which is palpably distinct from Edinburgh’s.

Glaswegians who have lived and worked in Edinburgh are fond of saying that Leith reminds them of Glasgow’s warmth and edginess. Last week, a local arts festival announced that it plans a rerun of that 1920 referendum.

Morvern Cunningham, festival director of the LeithLate arts programme, wants to mark the centenary of that controversial ballot with a second one. “I’ve always quite fancied the idea of doing another referendum,” he said. “The idea might be to ask people if they still wanted to be part of Edinburgh, even though they voted No back in the day. I would be interested in the answer.”

The answer, though, would never really be in any doubt. Following the 2014 referendum on Scottish independence, Edinburgh voted for the status quo in greater numbers than anywhere else. In Leith, though, the residents backed independence, the only Edinburgh neighbourhood to do so. It wasn’t so much a vote for an independent Scotland as a vote for an independent republic of Leith.

In the Scottish elections this month, Tories in Edinburgh loosened the SNP’s stranglehold on Scottish politics a little. Ruth Davidson, leader of the Scottish Tories, chose to move from Glasgow to stand in Edinburgh, sensing that this city would give her a better chance of winning a seat after two electoral defeats in Glasgow by wide margins. She romped home in Scotland’s capital.

Welsh has been attending some of the filming for Trainspotting 2, fitting these in between watching his beloved Hibernian’s forlorn attempt to return to the Scottish Premiership.

He was delighted that Rab Mitchell at the Leith Dockers Club had passed on his best wishes. “Ah give Rab my best. He’s one of the last of the real old school still involved there. What gave me most pride with Trainspotting was just finishing it. It had been in my head such a long time. To prove to myself I could write and be able to move on was big for me.

“With the film I was so proud that all those incredibly talented people were gathered in this space doing their thing and bringing it to life big time because I’d bothered to write the novel. That was a real buzz.”

In the Central Bar and in the Banana Flats around the corner, also made famous by Trainspotting, history hangs in the air once more and there is tension. On Saturday Hibernian, the pride of Leith, won the Scottish Cup with a late winner against Rangers. They haven’t lifted the trophy since 1902, at a time when many of those who voted in the first Leith independence referendum would have been alive.

In the same year that Trainspotting 2 will bring Leith and its characters and its language to the world once more, the planets have aligned favourably for Leithers and their long-suffering football team.