Visual Studio Editor-like formatting


#1

In visual studio there’re options to automatically format your code according to your standards (such as spaces between mathematical operators, spaces before parenthesis and etc.) I searched for many packages but did not find any, is there any package like this available (since I don’t know the exact term I should search for)? I’m currently using Lua.

More detailed description: the Visual Studio Editor has an utility that whenever you put a “;” or save the file, it will modify all the code according to your configuration, so it can put spaces around math operators, spaces before parenthesis in functions calls, put elses in separate lines and etc.


#2

I’m not entirely sure but you may be looking for something like the package ‘atom-beautify’. Give it a shot.


#3

Sorry, but I forgot to mention that the language I’m using is Lua (which probably makes it way harder to find)


#4

Perhaps the atom-format-lua package?


#5

This isn’t exactly what I’m looking for, the Visual Studio Editor has an utility that whenever you put a “;” or save the file, it will modify all the code according to your configuration, so it can put spaces around math operators, spaces before parenthesis in functions calls, put elses in separate lines and etc.


#6

In fact, I just realized, what that package does is basically auto-indending and I already have a pcakage for that


#7

Sorry bud, I am not entirely sure. I feel as though there may not be a package yet. Maybe you can make your own! Always a cool time to try something new.


#8

But that would require lua parsing and I don’t know how to parse the ASTs outputted by luaparse and I have no idea how this would work as I never made a package before. I’m also currently busy with many other projects and don’t really have the time to do this…


#9

To get the behavior you want isn’t the AST enough? It already knows about operators, etc.

Edit: I meant to say the token list already knows about operators, functions, etc. No parsing to an AST is needed. This is based on my experience with coffeescript tokens. Lua tokens may be different.


#10

But putting spaces inside parenthesis of function calls and etc. I really have no idea how to use ASTs and that would require a lot of learning, which I currently don’t have enough time to (and to do that with all the languages I use atom for, would require way too many packages).


#11

I didn’t mean to say you should do anything. (grin)

I just realized I got tokens and the AST confused. One would actually only need the token list. It would be pretty easy if one had the time.


#12

Well, I’ll give it a try when I have time (together with the lua obfuscator in node.js in my list).


#13

Hi, I just don’t use a single plugin.

I hope this helps you to find your way.

Cheers


#14

Hello, editor config doesn’t has the functionality I’m searching for as it only helps to maintain a certain tab length and some other simple settings, what I wanted was a package that could do exactly what jscs-fixer but for lua instead.
As lua is not so popular (yet, I hope) I don’t think there’s any package that could be used with the same functionality as jscs-fixer.