Josh Ritter has been at it for nearly two decades, but the central pillars of his style remain unchanged. Ritter’s exquisite lyricism has always been at the core of his appeal and now, 40 years old and a little gray at the edges, Ritter is an even more accomplished raconteur than he was in his teenage years. The Idahoan singer-songwriter’s tunes are often Bob Dylan-esque in their narrative complexity, built around delicate stories and subtle characters. Ritter is such an enthusiastic storyteller that in 2011 he wrote a novel — the tale of a West Virginian farm boy turned into a World War I soldier who occasionally hears supernatural voices. Stephen King called it “a lot of fun.” On Thursday, Ritter debuted “Thunderbolt’s Goodnight,” the second of two singles building up to the release of his ninth studio album “Gathering.” The new track is exceptional because of Ritter’s lyrical savoir faire, but it never breaks away from the muted meditativeness — which is expected from the stereotypical heartsick singer-songwriter. Ritter’s clever imagery keeps the track from feeling stale, but “Thunderbolt’s Goodnight” never feels like anything more than a very good indie-folk number. Ritter morphs into something more important when he picks up the pace, as evidenced on this summer’s first song “Showboat.” His livelier numbers revel in the joy and energy of a catchy, windows-down country ode while retaining the literary merit of his more introspective tracks. It’s this energy that sets Ritter apart. Folk-rock and indie-rock very often feel lugubrious and self-pitying, and Ritter — when he’s in the mood — can provide a breathtaking, genre-bending antidote. “Thunderbolt’s Goodnight” is not genre-bending. It’s a longing, desperate love song, delivered in the most intimate version of Ritter’s midwestern croon. In Ritter’s hands, one of the most exhausted images in all of music — the sunset — becomes something slightly more original, reflecting ambiguity and growth. Ritter peppers the song with other arresting images, as he sings about his previous lovers’ “eyes of polished stone,” for example. The music traffics in melancholy but narrowly avoids melancholy’s associated clichés, and, as a result, manages to feel intimate and vulnerable without losing too much impetus. This is a talent Ritter has always displayed. In the bare-bones, piano-driven “The Curse” from 2010’s “So the World Runs Away,” Ritter’s lyrical inventiveness and ability to create narrative tension prevents his music from feeling feeble, despite a slower tempo and whispery sensibility. The song is a rambling, surreal ballad, taking us “under miles of stone…under scarab and bone,” to watching the ocean through “a porthole in stowage,” to a “sandstorm of flashbulbs and rowdy reporters.” Ritter’s ability to craft compelling images and characters allows him to operate in musically familiar territory without sounding pretentious. This is what good singer-songwriters have been doing for generations, but it’s a difficult art and Ritter is better at it than most. Ritter’s other song from this summer, “Showboat,” displays a much rarer treat — an ability and a willingness to combine complex, introspective lyrics with vital and confident music. Again, Ritter takes a familiar image — the rain — and imbues it this time with not only shrewd meaning but also earnest mirth. The track’s refrain is self-deprecating and genuine — presenting a narrator who is stoic yet honest, broken yet hopeful. Ritter shapes this character in a dynamic voice, assuredly and often breathlessly yelping without ever quite leaving behind the underlying insecurity that the lyrics require. The music is an electrifying mixture of bluesy guitar riffs and bright horn interjections — this song is as emotionally raw and nuanced as anything Sufjan Stevens, Father John Misty, Connor Oberst or any other contemporary songwriter has recently produced — and it’s danceable. No one else provides that combination. This outstanding mixture isn’t new for Ritter. “Getting Ready to Get Down,” from 2015’s “Sermon on the Rocks,” is a particularly salient example. Ritter tells a winding tale of adolescence saturated with the contradictions and uncertainty of a religious, midwestern upbringing. The lyrics reference the Bible and Tom Petty with equal fluency before reaching an explosive conclusion. “Jesus hates your high school dances,” the narrator declares. “If you want to see a miracle watch me get down!” the song’s protagonist replies. Ritter’s earthy voice is at home in this up-tempo modem and his twanging guitar amplifies the narrative’s cathartic electricity. The song is as fun and catchy as any bland pop tune and as detailed and emotional as any moody coffee shop number. If Dylan’s “Tangled up in Blue” and Sam Hunt’s “Body Like a Back Road” had a baby, it might sound a little bit like “Getting Ready to Get Down.” The singer-songwriter scene often lacks this flair. The best folk album of the year is Mount Eerie’s “A Crow Looks at Me” — a stupefying, transcendent and overwhelmingly depressing album. The genre needs some twinkle to keep the melancholy from becoming repetitive, and Ritter has a knack for providing exactly that. Though he is comfortable — and often excellent — in woebegone numbers such as this week’s “Thunderbolt’s Goodnight,” Ritter is at his best when he eschews the forlorn tones of modern indie-folk and lets a little more country spark shine through. Ritter’s best is simultaneously ebullient and introspective, energetic and intellectual. “Gathering,” featuring this summer’s two singles, will be released in September, and with any luck it will sound more like “Showboat” than “Thunderbolt’s Goodnight.” Ritter is an exceptionally gifted songwriter, but when he gets ready to get down, he becomes a unique musician.