zanoni-mbdyn / language-mbdyn

Syntax highlighting plugin for MBDyn (https://www.mbdyn.org/) input files
GNU General Public License v3.0
2 stars 1 forks source link

Installation guide and automatic highlighting #1

Closed nebluda closed 7 years ago

nebluda commented 7 years ago

Hi Mr. Zanoni, I am currently using MBDyn for a project and I found really useful the package for Atom editor. Still I found not that obvious the "apm link" command in the folder to be able to use the source files directly without the package manager built-in in the editor. Moreover I searched a bit online how to modify the config.cson file in order to automatically highlight the desired extensions ('mbd','elm,'nod','ref','set') without having to select it manually. Do you think that would be useful to add a simple explanatory file to the repository with these small steps? I'd be really happy to contribute but I don't have that much experience using github and I don't know if it's the correct/useful way.

zanoni-mbdyn commented 7 years ago

Hi shydot76,

this Atom package is still very much in development, that's why it still lacks a lot of useful features at the moment, and it is still not even advertised in the MBDyn website :)

I think that the correct procedure to work with the development files is the one described here: https://discuss.atom.io/t/load-developing-package/2554/2 using "apm develop" and not "apm link", but I could be wrong about this.

Yours is actually a very good suggestion and I'll add the extensions you have cited in the next release of the package (I'm slowly working toward a thorough recognition of the input syntax in autocompletion).

As to contribute, if you want to help write the snippets and grammars file, great! I admit that I myself do not have a lot of experience with managing collaborative projects trough github: If you confirm your interest in collaborating, I'll dig through the documentation in the next few days and let you know how we can proceed.

Cheers Andrea

nebluda commented 7 years ago

You are absolutely right, using "apm develop" is the correct way of dealing with developer packages since it links the GitHub folder in ~/.atom/dev/packages/, instead of the usual ~/.atom/packages/ and it deals with dependencies. I just tried to make it work and "apm link" seems to be sufficient in order to make Atom load it but not very robust.

For the automatic extension recognition a just added in the config.cson the following lines under the "core" key

   customFileTypes:
        'source.mbdyn': [
            'mbd'
            'set'
            'ref'
            'nod'
            'elm'
          ]

It can be included by default in the package without editing the configuration file? I followed the steps in this page. http://stackoverflow.com/questions/24653727/github-atom-how-to-apply-a-particular-syntax-highlighting-to-some-files-based-o

I don't have experience with managing collaborative projects with GitHub either but I really like the tool and I would like to contribute since I will work with MBDyn in the following months.

Cheers

zanoni-mbdyn commented 7 years ago

I added the extensions in the grammars/mbdyn.cson file, they will be included in the next release of the package. Thank you.

I think that to contribute you just have to clone the repository, make a branch, do your modifications and then make a pull request: see the github doc page here

Cloning the repository is something that maybe is done automatically by the apm develop command, you can check that by issuing a git status in the ~/.atom/dev/packages/language-mbdyn/ folder and see if anyone responds.

I'll have more time to guide you though what can be done specifially starting from next week, please bear with me!

For the moment, thank you very much for your interest and willingness to help. It is much appreciated :)

Cheers Andrea

nebluda commented 7 years ago

I will try to learn a bit more about GitHub workflow in these days. Thanks to you for developing this tool.

In the meantime, have a nice Christmas. Cheers.

zanoni-mbdyn commented 7 years ago

Thank you, a nice Christmas to you too. Cheers

zanoni-mbdyn commented 7 years ago

Hi shydot76,

If you're still interested in contributing to this project, I can provide you some guidance on how to proceed.

Basically what is left to do is to go through the input syntax of MBDyn, in the input manual of the latest version, and create the snippets in the snippets/mbdyn-snippets.cson file.

In doing so, the best practice is, in my opinion, to create scopes in the grammars/mbdyn.cson so that the snippets are as much context-specific as they can.

See for example the scope .source.mbdyn.definition.strategy created at line 218 of the file grammars/mbdyn.cson, to which the snippets defined from line 80 of snippets/mbdyn-snippets.cson apply.

Hope to hear from you, Cheers Andrea

zanoni-mbdyn commented 7 years ago

I forgot to mention that the next big chunks of snippets are the one referring to elements (Chapter 8 of the Input Manual), MBDyn drives (Section 2.5) and constitutive laws (Section 2.9). You can pick the one that you like the most, if you want to contribute :)

nebluda commented 7 years ago

Hi Mr Zanoni,

Sorry but it was a busy week. I still want to contribute and I should be able to start working on it this weekend. I will go over the suggestion you gave me. Maybe I could start from the constitutive laws?

Thanks for the guidance. I will inform you (hopefully not) if I encounter some big problems.

Have a nice weekend!

zanoni-mbdyn commented 7 years ago

That would be perfect, I've completed the drivers and begun dealing with elements.

Thank you again. Andrea

nebluda commented 7 years ago

Good morning Mr. Zanoni,

I started working on the constitutive laws, but I was wondering which should be the right scope for those snippets. Constitutive laws could be defined alone or at the end of deformable elements. Should I take into account both cases? Because for the second one I would say that source.mbdyn.section.elements should be the correct one, but I am not totally sure.

Thanks for the help. Have a good week.

zanoni-mbdyn commented 7 years ago

Hi shidot76,

yes I think that the correct way should be to accont for both cases:

Thank you for taking your time to work on the project. Cheers Andrea

nebluda commented 7 years ago

Hi Mr Zanoni, I implemented all the constitutive laws for what concerns the first case. For the second one, I am having trouble defining the scope correctly. Starting from the strategy definition I wrote something like

`           {
                begin: '\\b(constitutive law)\\b\:'
                beginCaptures:
                    '1':
                        name: 'keyword.control.mbdyn'
                    '2':
                        name: 'punctuation.definition.mbdyn'
                end: '\;'
                endCaptures:
                    '1':
                        name: 'punctuation.terminator.mbdyn'
                contentName: 'source.mbdyn.definition.constituivelaw'
                patterns: [
                    {
                        include: '$self'
                    }
                ]
            }`

But that does not work. Can you give me some advice?

P.S. I wanted to create a new branch for pushing the updated snippets and create a pull request but I was not able to do that. Should I be authorized by the owner of the repository?

Thanks! Have a nice weekend.

zanoni-mbdyn commented 7 years ago

Hi shidot76,

the code that you have posted seems correct to me, where have tried to put that snippet? Check that the resulting scoping is correct: for example like it's described here

I've added you as a collaborator, that should make things easier. Anyway, I think that the correct procedure is making a fork, do your own modifications and then make a pull request from there.

Cheers Andrea

nebluda commented 7 years ago

I put that in the mbdyn.cson file, just next to strategy. After some trials, I found out that it works if I remove the second word at the beginning of the scope definition. So that would be

begin: '\\b(constitutive)\\b\:' Could blank spaces be a problem? I really don't understand why it works for other scope definition and not for this case (for instance 'initial value'). When I try with the complete 'constitutive law' string in begin: the scope is not recognized. ( I check with ctrl+alt+shift+p)

I tried to create a new branch locally and push it to origin so that's why I got the error. Now I pushed to my repository (I suppose that is how you call that). Thanks

Cheers.

zanoni-mbdyn commented 7 years ago

The problem was that the costitutive law keyword was already included into another set of keywords (in repository -> keywords) that was superseding (being defined before it) the scoping that you were trying to set up.

I've modified the mbdyn.cson file to fix the issue, please pull it before making other modificiations. I've also added a specific pattern matching inside the constitutive law scoping definition, to highlight the names of the constitutive laws in their definition, see lines 250-251 of mbdyn.cson. Another pattern matching could be added to account for special keywords used by constitutive laws as, for example, the proportional keyword used in linear viscoelastic constlaws. I generally put them under keyword.other.mbdyn.

I've also added a couple of snippets in the file mbdyn-snippets.cson:

It would be even better to limit the scope to the specific elements that make use of constitutive laws, giving them a specific scope in the process... But that would maybe be a bit overzealous :)

Cheers Andrea

nebluda commented 7 years ago

Thank you for the help! How would you like to account for the special keywords (for instance proportional)? By having them of a special color?

Sorry it was a bit lazy of me to copy paste for different scopes but I did not know that you could make rules for multiple scopes at the time. I think is definitely better that way. I think I still should finish something in the indentation of the snippets though, it's not correct. Should I enter also the type of entities that the parser should expect? I thought it was more readable this way.

You would like to define a scope for all the elements that can have a constitutive law? Do you have other ideas in mind that you would like to add?

Cheers

zanoni-mbdyn commented 7 years ago

As for the special keywords, you can define a match pattern in the constitutive law scoping pattern:

{
        begin: '\\b(constitutive law)\\b\:'
        beginCaptures:
           '1':
               name: 'keyword.control.mbdyn'
           '2':
               name: 'punctuation.definition.mbdyn'
        end: '\;' 
        endCaptures:
           '1':
               name: 'punctuation.terminator.mbdyn'
        contentName: 'source.mbdyn.definition.constlaw'
        patterns  [
                     {
                        match: '\\b(proportional|[...])\\b'
                        name: 'keyword.other.mbdyn'
                     }
                     {
                         match: '\\b(linear elastic isotropic|linear elastic generic|[...])\\b'
                         name: 'entity.name.type.mbdyn.constlaw'
                      }
                     {
                         include: '$self'
                     }
        ]
}

And then also under the joint scoping pattern, further down in the mbdyn.cson file.

That should suffice, for now. I think that we can let the user be a little bit autonomous and trust him to not define a constitutive law where it is not supposed to be! So no, I'll discard the idea of making a specific scope for elements to which a constlaw can be attached. Scoping the constitutive law snippets in the above quoted scope and the joints scope will do just fine.

Finally, yes, I try to put the type of the entities expected by the parser in each snippet. There might be some of the older ones in which the feature is missing and I'll have to re-check them when I have time, but definetely yes go ahead and place type tags to all the variables in the new snippets.

Again, thanks for the collaboration :) Cheers

zanoni-mbdyn commented 7 years ago

Hi shydot76,

are you still working on the constitutive laws snippets? Now they are the only part of the MBDyn syntax not covered by the addon and I would really like to complete it by the end of the month.

If you dropped the issue, no problem, I'll deal with it.

Cheers Andrea

nebluda commented 7 years ago

Hi Andrea,

I am really sorry but I was overwhelmed by a lot of things in these weeks and I had to stop. I will cover that as soon as possible. Maybe finishing them mid next week maximum? Is that okay?

Sorry but I am really bad at managing time.

Cheers

On 13 March 2017 at 15:24, Andrea Zanoni notifications@github.com wrote:

Hi shydot76,

are you still working on the constitutive laws snippets? Now they are the only part of the MBDyn syntax not covered by the addon and I would really like to complete it by the end of the month.

If you dropped the issue, no problem, I'll deal with it.

Cheers Andrea

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/zanoni-mbdyn/language-mbdyn/issues/1#issuecomment-286122157, or mute the thread https://github.com/notifications/unsubscribe-auth/AS5iom7OmwspK6ezHatFuURb-A9O7CxHks5rlVGmgaJpZM4LRuGN .

-- Antonino Sidoti

zanoni-mbdyn commented 7 years ago

Don't worry, I wasn't trying to stress you on this matter!

If you think you'll have the time to do it in the near future, great, I would very much appreciate it. If not, no worries not bad feelings, I'll manage it. :)

This is free software, everyone contributes at his own pace.

Cheers Andrea

zanoni-mbdyn commented 7 years ago

@shydot76 I've managed to complete the snippets for the constitutive laws today. Now the autocompletion is complete (no pun intended!) and the package has reached version 1.0.

Thanks for the collaboration anyway, I hope that you keep in touch with the MBDyn community.

Cheers Andrea