reddit / emacs

Flycheck 32 released

alternateved · 2022-03-30 15:19
https://www.flycheck.org/en/latest/changes.html#frozen-on-may-3rd-2020-released-mar-28-2022
PreferredBadger672 · 2022-03-30 15:39
Oh awesome, I remember seeing posts saying flycheck was unmaintained so it’s a relief to see a new release
[deleted] · 2022-03-30 16:20
Sweet! Now if only eglot played nice with it...
1419538 · 2022-03-30 16:54
The link isn’t working
alternateved · 2022-03-30 17:10
This is a link redirecting to Changes page if the posted one doesn't work: https://www.flycheck.org/en/latest/changes.html
holgerschurig · 2022-03-30 17:19
Does eglot even need it? When I code in C or C++ than clangd does the implicit flycheck, and spell-fu checks my strings. Why would I then need flycheck?
super-linux-nerd · 2022-03-30 17:57
Since Flymake got some TLC I haven't missed Flycheck at all. Eglot + Flymake work great.
andreyorst · 2022-03-30 19:02
well, Eglot provides communication between `clangd` and ~~flycheck~~ flymake, so yeah, eglot and ~~flycheck~~ flymake is needed to work with `clangd`. Edit: Eglot uses flymake, not flycheck. I Always confuse these two for some reason.
holgerschurig · 2022-03-30 19:52
Since when? To my best knowledge eglot doesn't need or use flycheck. But maybe this changed recently? There are external things that try to integrate it, like this https://gist.github.com/eyal0/8f58d4209dc8cdb5d9c474b61c49b2dc but I honestly don't know why I would need them. When I type, eglot sends my code to clangd, which due to the compilation database (and a .clang-tidy file) checks my source code as-i-type. Without flycheck (which I disabled in my Doom configuration).
andreyorst · 2022-03-30 20:01
sorry, got confused with `flymake`, which is what eglot uses as a frontend for diagnostics
Fearless_Process · 2022-03-30 20:56
This is one of the reasons I use lsp-mode over eglot. Flycheck allows you to show more than just lsp diagnostics by chaining "checkers", for example with rust I show the lsp errors first and then show clippy lints after all lsp errors have been resolved. This is not possible to do with flymake afaict.
Fearless_Process · 2022-03-30 21:01
What if you wanted to show clang-tidy lints inside of emacs alongside clangd diagnostics? Afaik you can't do this with eglot and flymake, and I would say it's a non-niche use case. Maybe you specifically don't need this function but flycheck does provide real benefits over flymake still.
[deleted] · 2022-03-30 21:43
Wow. I didn't know you can chain checkers like that. Will have to set aside an hour or two for this on the weekend!
[deleted] · 2022-03-30 21:46
[deleted]
[deleted] · 2022-03-30 21:51
I'll need to visit flymake again then. Tbh it was so long ago that I am not even sure why I switched to flycheck.
emax-gomax · 2022-03-30 22:54
I mean nothings stopping you from doing this. Install or write a clang-tidy backend for flymake. Disable automatic flymake setup with eglot (this would replace the existing hooks with eglot specific ones) and then setup a custom hook to setup the flymake backends with eglot including your clang tidy one. Although all things considered the correct way to do something like this is have your language server integrate with clang-tidy. For example pylsp has a bunch of plugins to integrate with mypy, pylint, etc.
emax-gomax · 2022-03-30 22:57
You're kinda thinking of it backwards. This isn't an lsp-mode feature, it's a flycheck feature. Flycheck has a list of checkers associated with each buffer and with lsp-mode the lsp checker is also included. Flymake has the same. It's just eglot by default overrides all of them with eglot own ones. If you really want lsp and clippy at the same time... you can quite easily do it. Just setup the flymake hook yourself instead of relying on eglot.
holgerschurig · 2022-03-31 04:58
I can do it and I do it. Because clangd has clang-tidy built in. As I said, the .clang-tidy config file controls what clangd flags me out as errors. It even has scan-built guilt in, as I can make it display me info from the static checker. I'm sure there cases where an actual make-based checker is more versatile or needed. But this is not the case here. flymake could be helpful in projects using lex, yacc, peg or similar, for example. But for these few cases I just rely on the normal compilation mode from Emacs. Also, because compilation/clang-tidy/scan-build is just all inside clangd, there is no forking happening. And no parsing/executing of the rather inefficient make system. So it is much, much faster.
PuercoPop · 2022-03-31 07:16
Flymake \_can\_ do that. Flymake allows you to enable multiple backends.
ImpendingNothingness · 2022-03-31 13:04
Frozen in May of 2020 and released until this month, damn, I’m not familiar with the developer/s so I wonder why it took so long.
Fearless_Process · 2022-03-31 15:42
It's technically possible sure, but doing it with flycheck is a line or two of elisp because it supports chaining together of different checking back ends OOTB. I have looked into writing my own flymake back ends but I haven't really wrapped my head around it yet. I am also curious if flymake is smart enough to only show the second layer of diagnostics after all errors from the first have been resolved. I'm sure I could implement this as well but if flycheck does it already I see no reason to bother.
emax-gomax · 2022-03-31 16:58
You might not be reading what I've said correctly... flymake already does this. The checkers that are run by flymake are regular functions. Each of the ones run in the current buffer on a change are kept in a hook variable. If you wanted to run mypy as well as pylint then all you have to do is `(add-hook 'flymake-diagnostic-functions 'flymake-mypy nil t)` assuming pylint is already in the list (if it's not, do this exact same thing but with flymake-pylint). The issue here isn't making flymake run multiple checkers, it's having those checker functions written and available. There are some projects trying to provide a collection of these such as flymake-rest. Hell it even provides a use-package helper so you can hook multiple checkers into the same mode in an easy way. I've used it to hook proselint and markdownlint both into markdown buffers.
emax-gomax · 2022-03-31 17:06
I agree with most of your points but have no idea what you mean by make-based checker. I still defer to language servers whenever I can. They integrate better with projects and build tools. However standalone linters still have their uses. Language servers are rich editing supports but that also makes them bloated and slow (in some cases, other times their insanely fast like clangd). I've had mixed experiences for stuff like this, and honestly the ability to fallback to a standalone linter is great for this. I just want to edit a Python file and get complaints when my typing or syntax is wrong. This is incidentally also why I like how eglot does things. When I've already got a more powerful (and frankly better) language server up and running then it takes over. When not my linters are still there for me. It's a good compromise IMO.
Fearless_Process · 2022-03-31 20:44
Oh I see what you mean now. I did not realize it was that easy to add an extra hook in there. I will have to try this out later!
holgerschurig · 2022-04-01 06:33
> but have no idea what you mean by make-based checker Flymake calls "make" repeatedly and automatically when while you edit. Or scons, meson, ninja, whatever you configure it. And the build tool can then call any compilation tool, even tools that a language server doesn't know. Like moc, lex, yacc. And therefore you can check against errors that those tools report, not just against what the language server implements. To my best knowledge, no language server implements Qt's moc, for example. You can do the same by running `M-x compile`, and can jump from error to error. Flymake just does this in the background, automatically, while you type. So, as you said, you can run a linter that via flymake. And therefore you have a possibly greater amount errors you can catch, compared to some language servers. But it's much, much slower. I personally run these slower things either via my normal compilation, with my equivalent of `M-x compile` (I added a bit of code so that this uses completing-read to find my compile command, with history and so). Or as an automatic task in my continuous integration pipeline.
emax-gomax · 2022-04-01 06:54
I see what you mean, but I've never heard of anyone hooking a build tool into flymake... mostly because flymake works on a buffer by buffer basis and build tools are designed to build projects, not lint files. Even with gcc or clang linters you're not actually compiling. You pass a flag to make them just output messages and leave the build directory clean.
holgerschurig · 2022-04-01 06:59
> but I've never heard of anyone hooking a build tool into flymake Well, https://www.emacswiki.org/emacs/FlyMake is full of how to hook things into it, like Ada build system, scons, whatever. Really, you should stop arguing. You asked about what you don't know, you got an explanation, and now you STILL act like you didn't get this explanation, or that you somehow don't accept it. I have the feeling you argue for argue's sake.
emax-gomax · 2022-04-01 06:59
> Much of this page is probably obsolete after the Emacs 26 revival?
holgerschurig · 2022-04-01 07:13
So, flymake in current Emacs doesn't use make? I mean, it's called fly**make** ??? The chapter in the Info manual about flymake as a chapter "Backend functions" (from Emacs 28.0.92, so quite recent) that tells how you write this very functions to add other diagnostics. It then continues to explain in the chapter "The legacy Proc backend" the old backend. But if you use the new way, or the old way, Flymake will always spawn external tools, e.g. via makefile, or directly. This makes it more versatile, but also slower as a language server, that just stays in memory and don't need no spawning. And really, you're getting obnoxious by now.
emax-gomax · 2022-04-01 07:23
I don't know why you're being so hostile. You're describing a workflow I've never heard of before so I'm asking you to elaborate on it. I never denied flymake runs a checker/linter process and generates diagnostics from it, I also never denied you could use make or another build tool for this purpose. All I said is that doesn't seem to be the conventional approach for checkers anymore and to ask you to explain why you'd prefer or choose this over dedicated checkers like pylint, mypy, mdl, etc. build tools build projects. Why you'd want that overhead just to lint something confuses me, and sure I've got `make lint` setup to lint my entire project but that's likely not what you want to run just to lint a specific file (or buffer that has no file) so how do you do that? Do you have a pattern task setup like lint-/path/to/file in your makefile and configure it like that? Also, you seriously think the name justifies your point? People can name their projects anything. The approach you describe doesn't seem to have been a thing since 2018. If you're going to share out of date answers or information then at least present it as such instead of getting all defensive and hostile when questioned on it.
holgerschurig · 2022-04-01 07:30
> I don't know why you're being so hostile. Well, I see that. And you continue ... I stop it here. I said already that you're obnoxious, and I meant that.