ShiroTakeda/gams-mode

auto-completion

Closed this issue · 11 comments

Hi,

I would like for gams-mode to have a standard emacs auto-completion. I am aware of your gams-ac package, but the auto-complete package is de facto no longer maintained and company-mode is the new standard.

I have started something that seems to work:

  • I have imported the full list of GAMS commands (the people from GAMS gave me the location).
  • Enabled a standard completion-at-point using this list.
  • And for those who wants to use company, I have defined the proper backends. But this is optional, it can works with other completion frameworks since it relies on the emacs standard completion functions.

I barely know elisp, so I did it with a big help from ChatGPT.

Are you interested by a PR?

Here is a GIF of the auto-completion with company-mode:
company-gams

As you can see, it takes care of auto-completion of filenames that was in your TODO list.

And here is another using the basic auto-completion functions of emacs:
capf-gams

Thank you.

I am interested in the code for supporting company-mode , so please send me a pull request.

However, it is generally preferable to have the code for company-mode support in a separate package, rather than directly in gams-mode, which is why I have the code for auto-completion mode in a separate package (gams-ac package).

Therefore, it is better to provide the code for company-mode support in a separate repository on github. Any thoughts on this point? I can create a repository for this purpose.

It is not necessarily the case that a company-specific package is better. This is what I thought too at the beginning, but I changed my mind. The way I implemented it is inspired from ess, which keeps all the code for auto-complete and company in the package. Then it is transparent for the user: if you use company, it works automatically in ess, and the same for auto-complete. No need to install another package.

But the main reason for not creating a company-gams package is that there is only one line of code related to company in what I have done.

The key idea is that I have not implemented a GAMS auto-completion with company, I have implemented a GAMS auto-completion using the built-in completion-at-point function of emacs. It means that the completion works even if you don't use any completion package. Once you have completion-at-point working, there is nothing to do for company: company relies on completion-at-point for providing completion.

I don't know how auto-complete works, but it is likely that what I have done could also be used with auto-complete without gams-ac.

I will send you the PR this week.

Thanks for merging the PR.

From this, are you interested in my suggestion of replacing the existing list of strings used for font-lock by the complete lists present in the txt files to have a more complete font-lock?

After merging your PR, I have modified gams-mode.el slightly. In addition, I moved script file for creating gams_commands.txt to command_files directory. If you find a problem in the program, please let me know.

I am interested in expanding the scope of the font-lock feature.

In addition, I moved script file for creating gams_commands.txt to command_files directory.

Good move.

I have seen that you have also added the MPSGE commands, which is good too. I wanted to do it next.

I am interested in expanding the scope of the font-lock feature.

When I will have time, I will look a bit at this. Likely over the coming weeks.

Thanks for all your work.

I have just tested the package released on MELPA and the auto-completion does not work because the package does not include the gams_commands.txt file.

Thank you.

I forgot to update the setting for MELPA.

I updated GAMS mode distributed on MELPA.

It works perfectly now. Thanks.

Hi @ShiroTakeda,

I have just tested auto-complete with the recent version of gams. Since we have enable emacs capf, it is enough to use the package ac-capf to enable the auto-completion based on all the keywords that have been included.

With this, I am not sure about the added value of gams-ac with what is already built-in.