bluz71 / vim-nightfly-colors

A dark midnight theme for modern Neovim & classic Vim
MIT License
828 stars 51 forks source link

Request: Consistent LaTeX Colors Support #60

Closed mafsi closed 5 months ago

mafsi commented 6 months ago

Issue Description: First, I would like to express my gratitude for the incredible work you've done with the Nightfly color scheme for Neovim. The theme is not only visually appealing but also enhances the coding experience significantly.

I am writing to request the addition of consistent color support for LaTeX. Currently, while using Nightfly with LaTeX, I've noticed some inconsistencies in the color highlighting, which can be a bit distracting and affects the overall readability of the code.

Details: Language: LaTeX Current Behavior: Inconsistent color highlighting for various LaTeX elements such as commands, environments, sections, etc. Expected Behavior: Uniform and consistent color scheme that aligns with the rest of the Nightfly theme, improving readability and maintaining the aesthetic integrity of the theme. Example: Here is a snippet of a typical LaTeX document where the inconsistency is noticeable:


\documentclass{article}
\usepackage{amsmath}
\usepackage{csquotes}
\usepackage{natbib}
\title{Sample Document}
\author{Author Name}
\begin{document}
\maketitle
\section{Introduction}
This is a sample document to illustrate the issue. You can use \textit{italic} and \textbf{bold} text. Here is a quote: \enquote{This is an example quote.}

\begin{equation}
E = mc^2
\end{equation}

Here is a citation: \cite[23]{einstein1935can} and an autocite: ~\autocite[23]{einstein1935can}.

\begin{itemize}
    \item First item
    \item Second item
\end{itemize}

\begin{table}[h]
    \centering
    \begin{tabular}{|c|c|}
        \hline
        Column 1 & Column 2 \\
        \hline
        Data 1 & Data 2 \\
        Data 3 & Data 4 \\
        \hline
    \end{tabular}
    \caption{Sample Table}
    \label{tab:sample}
\end{table}

\begin{figure}[h]
    \centering
    \includegraphics[width=0.5\textwidth]{example-image}
    \caption{Sample Figure}
    \label{fig:sample}
\end{figure}

\end{document}

Suggested Solution: Implementing a cohesive color scheme for LaTeX elements that blends seamlessly with the Nightfly colors. This could involve defining specific colors for commands, environments, sections, mathematical expressions, and other LaTeX-specific syntax elements.

Additional Context: Having consistent LaTeX support will greatly enhance the user experience for those of us who frequently work with LaTeX documents in Neovim. It will ensure that the beautiful aesthetics of Nightfly are maintained across different file types and improve the overall usability.

Thank you for considering this request. Your work is greatly appreciated, and I look forward to seeing Nightfly evolve even further.

bluz71 commented 6 months ago

Hello @mafsi,

Are you using Neovim Tree-sitter LaTeX parser?

I can see that the default colors are not ideal in that case, however, is there a particular element in your example document that I must change? I can make some changes, but not being an expert in LaTeX all I can do is choose my own aesthetic to make things nicer. Let me know your main explicit issues, screenshots would be appreciated highlighting the inconsistencies.

Are there other Neovim color-schemes which highlight LaTeX well? If so, can you tell me; I can install and look at their implementation.

Best regards.

mafsi commented 6 months ago

Thank you for your response, @bluz71

To clarify, I am not using the Neovim Tree-sitter LaTeX parser. I am using the default LaTeX syntax highlighting. The main issue I’m experiencing is the inconsistency in color highlighting for different LaTeX elements, which affects readability and aesthetics.

Attached is a screenshot of my current LaTeX document (The document is in Romanian language). Here are the specific issues I noticed:

Ss 2024-06-07 at 12 38 35 PM
  1. Comments (% ...): They are not distinct enough and can blend in with other text, making it hard to differentiate comments from the code.
  2. Commands and Keywords (like \section, \label, \begin, \end): These should stand out more clearly. Currently, they don't have a distinct color that separates them from other text.
  3. Environments (like quote, verse, versewidth): The keywords for beginning and ending environments should be more visually distinct.
  4. Citations and References (\cite{}, \ref{}, \pageref{}, \autocite{}): These should also be highlighted differently to be easily identifiable. Especially the page numbers and the key and the brackets from \autocite[page no. here]{key:here}
  5. \gl{} is a custom command that translates: \newcommand{\gl}[1]{\enquote{#1}} And I would like to see a different color for the brackets and the text inside. There are also complex citation, see the Aristotle example in the image, where it would be nice to see the entire citation:
Ss 2024-06-07 at 12 55 04 PM

I hope this helps, and thanks a lot for your reply!

bluz71 commented 6 months ago
  1. Comment color is fixed for all languages, this will not change, sorry.
  2. \begin should remain as violet since violet indicates keyword, \section should be changed, I will experiment
  3. These look to be textStatement highlight group, so it will not be possible to assign unique colors since the underlying LaTeX syntax highlighter treats them all the same
  4. Can you provide me a LaTeX document which uses all these notations (and all others mentioned), however I think the limitation mentioned for the previous point will also apply here
  5. Looks to be not possible due to limitations of the underlying Vim/Neovim LaTeX syntax highlighter

There is a little bit I can do, but not as much as you expect, there are real limitations with the underlying Vim/Neovim LaTeX syntax highlighter, many elements will be highlighted the same or not at all.

Most important, please provide me a LaTeX document that makes use of everyone one of notations you mention. Also, if know of another colorscheme that highlights LaTeX well, please provide it's name.

From what I have seen, some other Neovim colorschemes seem to have worse LaTeX highlighting.

bluz71 commented 5 months ago

Ok, I have implemented some style tweaks for LaTeX which hopefully improve the situation for you. To my eye, LaTeX documents look better now than before.

Note however, there are real limitations with the default underlying LaTeX syntax highlighter. It is not possible to provide individual colors to the elements you want because they are all highlighted by the same highlight-group.

You may want to also explore the Neovim Tree-sitter LaTeX parser, it seems there is greater disambiguation with that engine than the legacy Vim/Neovim reg-ex syntax highlighter.

Best regards.

mafsi commented 5 months ago

Thank you for implementing the style tweaks for LaTeX! I appreciate your efforts to improve the appearance of LaTeX documents. The changes you made definitely enhance the look.

I understand the limitations with the default LaTeX syntax highlighter regarding individual colors for elements. I'll take your advice and explore the Neovim Tree-sitter LaTeX parser. It sounds promising, especially if it offers better disambiguation compared to the legacy Vim/Neovim regex syntax highlighter.

Thanks again for your help!

Best regards.