AdaCore / ada_language_server

Server implementing the Microsoft Language Protocol for Ada and SPARK
GNU General Public License v3.0
226 stars 54 forks source link

Highlighting in .ada files does not work in vscode #1127

Closed domeniqo closed 1 year ago

domeniqo commented 1 year ago

Hello, I am not sure if it's vscode issue or it's ada language server's fault, but I experience a different behavior for 2 files with the same content but other file extension. See attached video for short demonstration:

https://user-images.githubusercontent.com/27335718/219699495-86cfecf6-780c-4152-adaa-81bfb6340284.mp4

The problem is, when ada extension is activated and server starts (i.e. using task "Developer: reload window" or simply by opening the vscode for the first time + opening some .ada file), highlighting works fine and all tokens are displayed as expected. If I then edit any *.ada file, tokenization starts to break and I am not sure if the issue is that vscode client does not ask for it correctly or there's issue on the server side. For any other associated file extension (adb, adc, ads) it seems to work fine. Any ideas?

One thing that I have tried so far: I found out that in grammar file (ada.tmLanguage.json), "ada" is not added to file type, so I added it there = no change in behavior. image

reznikmm commented 1 year ago

Ada language server uses GNAT naming for Ada files: specifications are located in .ads and implementation in .adb. Files with .adc extension contain configuration pragmas. GNAT doesn't use .ada files for Ada by default. If, for some reason, you really need to save Ada in .ada then you should modify your project file to specify a custom file naming. We haven't tested ALS/extension with custom namings.

domeniqo commented 1 year ago

Yeah, I am working on some legacy project written in Ada 83 and back then, all specifications/implementations were placed to .ada files. The behavior is strange anyway for me, because when I load the whole project in vscode (only .ada files) and language server starts, all symbols and highlighting works fine up until I modify the file. I will check that custom file naming scheme and hopefully get it resolved. Thank you for your answer!