texstudio-org / texstudio

TeXstudio is a fully featured LaTeX editor. Our goal is to make writing LaTeX documents as easy and comfortable as possible.
http://www.texstudio.org/
GNU General Public License v3.0
2.83k stars 345 forks source link

tkz-euclide/pgfplots macros/commands are not recognized #752

Closed LoganDark closed 3 years ago

LoganDark commented 5 years ago

Environment

Expected behavior

Things like tkz-euclide macros/commands are recognized

Actual behavior

image

This happens with tkz-euclide, pgfplots, and some other libraries

How to reproduce

\documentclass[12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{helvet,parskip,amsmath}
\usepackage[a4paper, margin=1in]{geometry}

\title{Minimal Working Example}
\author{LoganDark}
\date{October 2019}

\renewcommand{\familydefault}{\sfdefault}
\renewcommand{\baselinestretch}{1.25}

\usepackage{tikz,tkz-euclide}
\usetkzobj{all}

\begin{document}
    \begin{tikzpicture}[scale=1]
        \tkzInit[xmax=7,ymax=7]
        %\tkzAxeXY
        %\tkzGrid

        \begin{pgfinterruptboundingbox}
            \tkzDefPoints{3/3/C,6/3/R,4/6/sA,6/2/sB}
            \tkzInterLC(sA,sB)(C,R)
            \tkzGetPoints{A}{B}
            \tkzDefPointBy[homothety=center B ratio 1.25](A)
            \tkzGetPoint{Ae}
            \tkzDefPointBy[homothety=center A ratio 1.25](B)
            \tkzGetPoint{Be}
        \end{pgfinterruptboundingbox}

        \tkzDrawSegment(A,B)
        \tkzDrawSegments[style=dashed](Ae,A B,Be)
        \tkzDrawCircle(C,R)
        \tkzDrawPoints(A,B)
        \tkzLabelPoints[right](B)
        \tkzLabelPoints[above right](A)
    \end{tikzpicture}
\end{document}

image

dca00 commented 5 years ago

Texstudio probably should not strive to recognize all macros of all packages.

LoganDark commented 5 years ago

Then why does it have to mark them wrong?

muzimuzhi commented 5 years ago

They are just marked as "unrecognized command/environment" (when cursor is hover on the commands/environment).

Texstudio uses cwl files to highlight the predefined commands from loaded packages. It is welcome to to contribute to texstudio project by "adding missing cwl files". The related documentation can be found in Sec. 4.13 of texstudio's user manual. You can open the manual from texstudio's menu item "Help > User Manual", or here is a litter bit outdated online verion.

sunderme commented 5 years ago

usually txs can parse unknown styles automatically to generate a provisional cwl in .config/texstudio/completion/autogenerated This fails occasionally as .sty files are notoriously hard to parse. You can generate a user file (see manual) which lists the commands, possibly just by extending whatever cwl txs has managed to generate.

timhoffm commented 5 years ago

See also FAQ: Why does TeXstudio mark a command as missing and the links therein.

We welcome if you want to contribute a .cwl with the command definitions of tkz-euclide.

LoganDark commented 5 years ago

@timhoffm this is still an issue until the cwl files are added. I'm not sure if I can add them myself but I think closing the issue is a bit drastic. This feels kinda like a "we don't care and you can do it yourself" so far

timhoffm commented 5 years ago

@LoganDark I'm sorry if this feels a bit drastic. We do have a .sty file parser that can automatically create basic cwl files, but it is not possible to identify all ways a command can be defined in .sty files. Additionally that parser cannot attach semantic information to the commands.

There are edge cases which require manual work. Given the limited bandwidth of core developers, we cannot promise to support these as a core feature of TeXstudio. We have to rely on community contributed .cwl files here, and we welcome these very much. But on the other hand, I don't see it as a bug of TeXstudio if they are not available. This part of language detection is inherently incomplete.

dbitouze commented 5 years ago

But on the other hand, I don't see it as a bug of TeXstudio if they are not available

Indeed, but could be considered as "enhancement".

timhoffm commented 5 years ago

I've introduced a new label "cwl" and reopened.

This will not be targeted by core developers, but everybody from the community is very welcome to contribute a hand-crafted cwl file.

LoganDark commented 5 years ago

Indeed, but could be considered as "enhancement".

At this point it would probably be better to create a new issue about the missing cwl files. From what I can see the devs don't feel like it would be worth the effort for TeXstudio to automatically look for commands, so an issue about the editor not discovering commands is basically a 'works as intended wontfix'.

timhoffm commented 5 years ago

From what I can see the devs don't feel like it would be worth the effort for TeXstudio to automatically look for commands, so an issue about the editor not discovering commands is basically a 'works as intendeed wontfix'.

I'm sorry, but that's absolutely not true. We do have put quite some effort in that automatism and it's working well, but TeX is too complex to make it work for all edge cases.

LoganDark commented 5 years ago

TeX is too complex to make it work for all cases.

Would you be willing to look into the specific method tkz-euclide uses to define its commands then? I understand it might not be possible to solve the issue for every package but the packages included in the distribution should work and be recognized, right?

timhoffm commented 5 years ago

Would you be willing to look into the specific method tkz-euclide uses to define its commands then?

I'm sorry, but no. Further improving the .sty parser this is a rabbit hole I won't dive into. I have too little time for this.

I understand it might not be possible to solve the issue for every package but the packages included in the distribution should work and be recognized, right?

Even that is a goal too high, unfortunately.

mbertucci47 commented 3 years ago

There are now cwl files for each of the tkz-* packages in the completion folder. I imagine this issue should be closed now.

LoganDark commented 3 years ago

@mbertucci47 If the tkz-euclide commands provided in the example code are recognized, then the issue can be closed.

mbertucci47 commented 3 years ago

With the small fix in pull request #1674, the commands in the example are all recognized. However, the various pgf completion files are still very much incomplete.

LoganDark commented 3 years ago

With the small fix in pull request #1674, the commands in the example are all recognized. However, the various pgf completion files are still very much incomplete.

Feel free to include the magic words closes #752 in your PR description to link that PR to this issue