Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate operators for all editors #1950

Merged
merged 5 commits into from
Jun 18, 2024
Merged

Generate operators for all editors #1950

merged 5 commits into from
Jun 18, 2024

Conversation

nitinprakash96
Copy link
Collaborator

@nitinprakash96 nitinprakash96 commented Jun 17, 2024

Currently, operator names are generated only for vscode only using the command cabal run swarm:swarm-docs -- editors --code.
With this PR, I intend to bring that behaviour to all the editors.

Changes include:

  • cabal run swarm:swarm-docs -- editors command now supports vim as well.
  • operatorNames can generate operator list catering to all the editors supporting Swarm.
  • Update operator list in swarm-mode.el, swarm.vim and swarm.tmLanguage.yaml.

How to test emacs syntax:

  • Open editors/emacs/swarm-mode.el in emacs.
  • Then M-x eval-buffer
  • Open up any of the .sw file under examples.
  • Then M-x swarm-mode

How to test vim syntax:

  • Copy swarm.vim to vim directory using cp editors/vim/swarm.vim ~/.vim/syntax/sw.vim
  • Setup auto detect in vim. echo 'autocmd BufRead,BufNewFile *.sw set filetype=sw' > ~/.vim/ftdetect/sw.vim
  • Open up any of the .sw files under examples. (Also ensure that you have syntax on in vim. ESC :syntax on)

Comment on lines 30 to 51
"-"
"=="
"!="
"<"
">"
"<="
">="
"||"
"&&"
"+"
"-"
"*"
"/"
"\\"
":"
"^"
"++"
"$"
"->"
"<-"
"=")
t)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that the list of operators are not in sync across editors. I'd like a second pair of eyes to check if this covers all or not.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • What is \\? Is that lambda?
  • There is duplicate - because one is unary, but that is OK.
  • ++ will not matter I think, because + will be parsed twice instead. Should not be noticeable though.

It's probably best idea to test in emacs, but it looks good to me. 👍

Copy link
Collaborator Author

@nitinprakash96 nitinprakash96 Jun 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right. + gets parsed twice and covers for ++ as well! Thanks for catching that 😄

What is \ ? Is that lambda?

Yes. Should this not be there? It's quite possible I might've added something extra.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why add it manually when you can copy the output of cabal run swarm:swarm-docs -- editors --emacs?

Copy link
Collaborator Author

@nitinprakash96 nitinprakash96 Jun 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I needed to get some input on what the operators are for now.
The list generated by operatorNames in it's current implementation does not cater to emacs (and possibly vim). Emacs fails to parse the generated list because of escaping where it does not need it.

But ultimately I'll be using that command once I figure out the requirements by emacs and vim.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xsebek My recent commit ensures that there's no manual labour involved. All the operators can now simply be copied to respective config files by running the cabal run command.

@nitinprakash96 nitinprakash96 marked this pull request as ready for review June 18, 2024 06:54
Copy link
Member

@byorgey byorgey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link
Member

@xsebek xsebek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for bringing even Vim up-to-date. 🙂

@nitinprakash96 nitinprakash96 added the merge me Trigger the merge process of the Pull request. label Jun 18, 2024
@mergify mergify bot merged commit 4dc0976 into main Jun 18, 2024
12 checks passed
@mergify mergify bot deleted the nitin/keyword-gen branch June 18, 2024 17:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge me Trigger the merge process of the Pull request.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants