Elm VSCode plugin does not format on save - visual-studio-code

I have copied the following question from the Elm Slack channel for posterity.
I am having trouble getting the Elm VSCode plugin to format on save. I have set the absolute path to my global install of elm-format in settings.json. I have also set format on save for elm:
"[elm]": {
"editor.formatOnSave": true,
},
I am on an Ubuntu machine, and format does not happen on save or with Ctrl-Shift-I. Does anyone see something that I might be missing?

Install elm-format
Install the extension Elm Language Support for VSCode, which includes syntax and error highlighting
Configure VS code settings.json:
"[elm]": {
"editor.formatOnSave": true
},

The format on save timeout should not be an issue with VSCode 1.42 (Q1 2020)
See "Better handling of slow save operations":
VS Code allows extensions to change a file's contents when saving files to disk.
Features like Format on Save and Fix on Save are examples.
However, saving is a critical operation and extensions doing processing during a save must finish quickly so that the actual save operation can proceed.
"Quickly" used to be enforced by VS Code with timeouts that would make VS Code cancel extension save participation.
That enforcement guaranteed speedy saving but could be frustrating because sometimes expected processing would not happen.
With this release, we have given up the timeout-based approach and instead show a progress notification that allows you to cancel extensions participating in save ("Save Participants").
The notification lets you know that save operations are running and you can decide if you want to wait for a save participant to finish or not.

The following are the responses and resolution.
Response from #stoft:
Try installing elm-format locally or globally with npm, that helped me on MacOS.
Response from #razzee:
please check two things:
are you on the latest elm-format version
increase the formatting timeout of vscode, unfortunately elm-format is sometimes too slow "editor.formatOnSaveTimeout" is what the setting is called"
A global install of the latest version of elm-format was enough for format on save to work.
One case where format on save does not work by following these suggestions is in the elm-0.19-workshop. Format on save will not trigger on Elm files in intro/part1/ or any of the other "part" directories.

Not setting the paths to elm-format and elm-tests explicitely worked for me.
I ran
npm install --global elm-test elm-format
and let the extension figure out where it is.
As soon as I specify that /home/a-teammate/npm/lib/node_modules/elm-test/bin/elm-format is the elm-format I want to use, it stops working. Although pointing to the same elm-format.
Tested with elmtooling.elm-ls-vscode in version 0.9.4, elm 0.19.1 and elm-format 0.8.3

I had this issue with Prettier formatter being installed as default. I resolved it by overriding formatter for Elm specifically:
"[elm]": {
"editor.defaultFormatter": "elmTooling.elm-ls-vscode"
},

Related

Extension 'ESLint' cannot format '../../../file.tsx'. How to debug this?

I started a project 3 months ago and since a while my ESLint formatter suddenly stopped working (like 1 week ago). Can't get it to work in any way. I didn't do any package updates. It could be that I have updated the ESLint extension itself and the global yarn version.
The formatter I am using in VSCode is:
"[typescriptreact]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
},
I have tried cleaning my Yarn packages and reinstalling them. I have tried several other ESLint settings but can't get it to work.
This issue occurs in two different projects, so I'm guessing it has to do with the extension itself. In one of my project I am getting this message as well:
When I click it and select a node path, it doesn't do anything unfortunately. Also when I switch to a completely different laptop, I still get the issue. So It probably has to do with my preferred configuration + the updated extension.
I can't seem to find a good way to debug this, and it's rather trial and error right now. Could you help me with some next steps on how to discover the problem and how to get closer to a more focused question?
Note:
If you need any more info, please let me know and I'll update asap.

Can I recover a different version of a file on VSCode after clicking the wrong button on "resolve save conflict"?

I opened VSCode and was presented with a notification that there was a conflict between two versions of a file. I followed the prompts and got a side-by-side comparison of two versions. I clicked the button that accepts the newer version, believing that VSCode had correctly inferred which version was newer. It had not, and I lost a significant number of changes to the file. Is there a cached copy of the other version anywhere?
Thank you!
ps - I seem to have failed to actually commit the changes in git as well. Not sure how that happened.
After searching through the VSCode appdata, I concluded that it wasn't likely that there was a copy. I found a copy of the bytecode (.pyc file) and used uncompyle6 to get an approximate copy of the version of the .py file I needed to recover. Was able to manually merge from there.
I was flummoxed by this one too. The answer is that you can restore the old version by hitting undo until before the change was made.

VSCode Latex-workshop: No AutoBuild for onFileChange

I have a problem with the AutoBuild function in VSCode Latex-Workshop:
Using
"latex-workshop.latex.autoBuild.run": "onFileChange"
the project is not build if I change (and save) my tex-file, even though the Latex Workshop logger tells me:
[10:54:26] File watcher: responding to change in /path/presentation.tex
[10:54:26] Parsing /path/presentation.tex
But nothing more happens.
If I change the settings to
"latex-workshop.latex.autoBuild.run": "onSave"
things work as expected:
[10:59:28] File watcher: responding to change in /path/presentation.tex
[10:59:28] Parsing /path/presentation.tex
[10:59:28] Auto-build /path/presentation.tex upon save.
[10:59:28] BUILD command invoked.
(... building commences ...)
All other settings are kept on default values.
I am using LaTeX-Workshop version 6.0.0
Thank you very much for your help!
Joschua
I experience the same problems with LaTeX Workshop 8.16.1 in vscode 1.54.3.
It is a known problem, see this FAQ.

Duplicate hints while typing expression in Visual Studio Code

Why do I have the same suggestions while typing expression?
Example:
I had exactly the same problem. After a week or so, it get really annoying.
basically, as the comments hint to, there are probably multiple linting or intelisense tools. In my case (for python) i had the pylance extension added.
When i disabled this, the problem went away, but features were missing. So i added it back...
For some reason (i dont know why), this fixed the problem !!!
I can only hypothesise that in some way the extension was corrupted. Nevertheless, it worked.
EDIT:
I can also confirm that unchecking this setting appears to work:
Jupyter: Pylance Handles Notebooks
My current system is Windows 11, with python 3.10.
Final edit (8 Dec 2022):
This is resolved here:
Please could you install VS Code 1.74 and the latest Jupyter, PyLance and Python extension and confirm this still exists.
Visual Studio Code provides an API so third-party extensions and built-in modules can contribute suggestions for auto-completion pop-ups. The system is currently designed so suggestions are merely appended—there's no duplicate detection or removal (perhaps because extensions can also take care of sorting suggestions and such algorithm would get on the way). That means that if you have more than one extension or module for a given language you can easily get duplicate entries.
Having several extensions for PHP is not necessarily a bad idea since they can address different needs (for instance, PHP DocBlocker just creates annotations, it doesn't provide auto-completion suggestions) but you have at least two extensions (PHP Intelephense and PHP Intellisense) that do exactly the same things. That's likely to hurt performance (all your workspace files will be scanned several times) and just adds noise.
I suggest you read the extension descriptions carefully to learn what they do exactly and then figure out which ones you need. Remember that extensions can be enabled/disabled in a per-workspace basis.
The following is just my own totally subjective opinion. Among the PHP extensions that provide code intelligence only two of them seem mature enough:
PHP Intelephense
PHP Intellisense
I've tried both. PHP Intelephense works best for me than PHP Intellisense so that's the one I've kept. I've also disabled php.suggest.basic following the installation instructions because basic suggestions didn't add any value to me (they were blind string matching):
Turn off the php.suggest.basic setting for best results.
... as well as taming builtin Emmet support, which was providing really dumb suggestions:
"emmet.showExpandedAbbreviation": "inMarkupAndStylesheetFilesOnly"
YMMV.
TLDR; Installing pre-release version of Jupyter solves (v2022.11...)
Ok, so after some more extensive experimentation I think I found what's causing this in my case. After looking at the processes I noticed that there were two Pylance processes running, and consistently this would only be a problem if I was working in a session with a jupyter notebook open or one that had been opened.
saun89 17740 37.3 0.3 1008004 199492 ? Sl 20:58 0:22 /home/saun89/.vscode-server-insiders/bin/fef85ea792f6627c83024d1df726ca729d8c9cb3/node /home/saun89/.vscode-server-insiders/extensions/ms-python.vscode-pylance-2022.11.32/dist/server.bundle.js --cancellationReceive=file:9178e897a2b78b36bfd167f79b36c3bdad2931d71b --node-ipc --clientProcessId=17651
saun89 18743 257 0.7 1304584 382288 ? Sl 20:59 0:20 /home/saun89/.vscode-server-insiders/bin/fef85ea792f6627c83024d1df726ca729d8c9cb3/node /home/saun89/.vscode-server-insiders/extensions/ms-python.vscode-pylance-2022.11.32/dist/server.bundle.js --cancellationReceive=file:8744a321767eed92821fd737be4dc7dcfb728284e5 --node-ipc --clientProcessId=17651
Pylance basically spins up a service for the workspace, and then spins up a separate service for the notebook.
Output from "Python Language Server" logs:
Disabling Jupyter removes the duplication, and after installing an earlier version of the extension (v2022.4) this appears to have fully resolved the issue. I'm going to go ahead and log the extension bug once I have something reproducible.
As of 11/30/22, Jupyter Extension Pre-Release version v2022.11.1003281132 is the latest version fixes this issue. Click the gear icon next to the extension and you should see "install another version..." Then you can select version v2022.11.1003281132.

Pylint in Sublime Text 2

So, I've been using Sublime for a while as a simple text editor, but I'm venturing into the land of plugins for work and I've run into an issue getting pylint to work. Specifically I have it installed and have the Sublime package manager working, but I'm not sure how to include paths in my sublime settings.
I haven't found very useful documentation on this point, but if you are willing to point me towards it that would be a perfectly acceptable answer. My basic issue is that currently every time I save a file, the following error message shows up:
"Please define the full path to 'lint.py' in the settings"
I understand this error message which is great, I just have no idea where the sublime settings are or what the standard format for defining a path is. Any help would be appreciated.
There are quite complete directions at the SublimeLinter GitHub page that should describe how to set everything up. Briefly, go to Preferences->Package Settings->SublimeLinter->Settings - Default to see where the different settings are defined. Then, open Preferences->Package Settings->SublimeLinter->Settings - User to change anything, as the main settings will be overwritten when the package is updated. Remember that settings files are in JSON format, so you'll need opening and closing curly brackets to enclose settings, and a comma between them:
{
"sublimelinter_delay": 30,
"sublimelinter_mark_style": "none"
}
I haven't gotten the error you have, are you sure you're using the regular SublimeLinter and not the new beta version? I just installed it fresh on my work machine (I've been using it for a while at home) and after restarting ST2 it's working like a charm with Python.
I had the same problem. I found it to be coming from the package "Pylinter". I removed Pylinter and added SublimeLinter, it covers more than python and is well used. I'm enjoying it quite a bit.
From your command line just run:
sudo easy_install pylint
sudo easy_install pep8
After that restart your sublime.
I encounter the same situation today. In my case, that is because I have not installed the 'pylint' in my system yet. It works fine after I installed the 'pylint' through pip.
Just for other people reference.