Yes, there is such a connection. I will give just one example and I invite others to share their examples and opinions on this topic.
The example I would like to consider is the novel “The Life and Opinions of Tristram Shandy, Gentleman”. Many historians of European literature consider this particular novel to be the great masterpiece of 18th century English-language literature. The author of the novel is an Irish writer named Laurence Sterne. He published this nine-volume novel as a series over the course of several years, from 1759 to 1767. Below I will try to summarise the novel, then I'll connect it with the philosophy of that time.
Even though the novel is extremely long, nothing really happens in it. The narrator, Tristram Shandy himself, tells the story of his life, yet a very peculiar one, not because is full of events, but, quite the contrary, because it is devoid of any events but is full of his thoughts. It is a novel about Tristram’s opinions really, and his life is nothing but their succession. These opinions flow and take each other's place, sometimes slowly, sometimes moving swiftly, and most often they digress by association and become opinions about opinions. There are characters in the novel besides Tristram, but all of them look like completely weird, strange, whimsy people with inexplicable sympathises and idiosyncrasies. The novel reads as a modernist oeuvre, very similar to works by James Joyce or Virginia Woolf. Yet, those authors wrote in the 20th century, while Sterne lived in the first half of the 18th century. How had his work become possible at all?
Many scholars argue that his literary technique as well as the content of his novel are the products of his fascination with John Locke’s theory of mind. Locke died 9 years prior to Sterne’s birth, yet Locke’s popularity in Europe left a lasting legacy. Sterne was a big fan of Locke and used to give Locke’s books to his friends as presents. Locke argued that a fundamental principle of the mind is the association of ideas. The only way we can think is by connecting ideas together, in a line or chain of thoughts. If we do it carefully, we think clearly and efficiently. If some factors disturb the connection, we basically become mad. Scholars who study the intellectual history of the 18th century recognise that the influence of this theory went far beyond pure philosophy, and that Sterne became one of the carriers of this theory. The answer to the question of why his novel is so peculiar is that it was inspired by Locke and is an illustration of Locke’s theory of association. Tristram and other characters are so strange because their associations of ideas are damaged.
This explanation, however, does not fully explain why Trisram actually openly disagrees with some of Locke’s positions. Perhaps, as some scholars suggest, a more accurate explanation of what “The Life and Opinions” is, should include another important philosopher of Sterne’s time, the one whom Sterne knew personally, and this philosopher is David Hume. Hume developed another theory of mind. While according to Locke ideas could be connected in the right and in the wrong way, for Hume ideas are always connected arbitrarily. They are in a constant flux, and there is no right or wrong way they can go, as there is no right or wrong way for the river to flow. The water runs as it pleases to run, and so do ideas. Moreover, according to Hume, there is no such a thing as “I”. It is a mere illusion created by fast change of separate ideas. They move too fast and because of their speed they create an illusion of an entity - a thing which we call “I”.
Tristram’s flux of ideas does not fully represent Hume’s theory, for there is a very distinct “I” in the novel, yet Sterne seems to prefer the idea of a flux to the idea of a strong chain of ideas. That is the reason why some scholars call “The Life and Opinion” the first stream of consciousness novel in modern European literature, which appeared well before novels of the same genre of the beginning of the 20th century.
Scholars who study the case of Laurence Strene and the philosophy of his mind often try to answer the question of causality: who influenced whom? This approach is certainly a valid and an interesting one: it is fascinating to learn about the exact books that Sterne had in his library, or about what exactly he and Hume said to each other when they met in Paris. However, there could be another approach, the one which is not so much concerned with causality, but rather looks for different things (objects, architectural shapes, novels, etc) within one historical period that look similar to each other - i.e. they follow similar "templates". The Russian philosopher and historian of culture Alexander Dobrokhotov has developed a theory which allows us to interpret cases like the case of Sterne. He searches precisely for this "isomorphism amongst heterogeneous artefacts" - which means artefacts such as novels or genres, paintings or art styles, buildings or architectural movements, musical compositions of styles, in one given period that display a lot of the same characteristics.
This theory does not discourage us from looking for empirical influences, yet it emphasises not empirical material, but rather the very foundations which made influence possible at all. Sterne might have read and liked Locke, but he could have written a novel without any reference to the philosopher or his philosophy. But he wrote a novel about how the mind works. Most importantly, Sterne was not the only one who wrote about it. A small group of far less famous writers and poets of the 18th century wrote a novel “Memoirs of Martinus Scriblerus”, which also is concerned with the work of consciousness. There were other less well known reflexive novels at that time, where the functioning of the mind was in the front. Why was this isomorphism (similarity) possible? How did it work beyond the actual empirical influences we can trace? Dobrokhotov believes that if we reconstruct the ontological wholeness from the individual artefact, and thus answer the question of how the world should look like so that the artefact could be a part of it, we can fit the novel into the greater philosophical context of the time. Furthermore, if the wholeness is the same for all its artefacts (i.e. if the feel and the shape of the era is the same for all the cultural products that were produced in it), an "isomorphism of heterogeneous artefacts" can be discovered.
If we answer the question of how isomorphism is possible, we will be able to understand what we mean when we look for a connection between literature and philosophy. Perhaps if we develop a conceptual answer to this question regarding any given era, we will be able to discover some other connections which are not so obvious to us now, or we will be able to explain why there are no connections at all in some other cases.