Is there a Sublime Text Syntax for Flex and Bison? - sublimetext2

I'm looking for a syntax in Sublime Text that highlights my Flex and Bison files (or lex/yacc) in a way that makes them readable... Sublime Text automatically chooses Lisp for Flex files, but that doesn't do the trick all that well. Any suggestions to try another syntax? Or is there a plugin somewhere that's useful (haven't found anything so far)?.

I haven't found one built specifically for Sublime, but I've found one for TextMate, which Sublime is compatible with.
Therefore, for Flex highlight, all you need to do is git clone the TextMate's syntax files to your Packages folder.
Regarding Bison, I've found a syntax for TextMate, but it didn't work very well for me. The one Vaklarados posted worked nicer with my source files.

The one thalesmello posted works well for Flex. For Bison, I've found this one - it's pretty minimal but it's a start:
https://github.com/Jackneill/sublime-text-packages/tree/master/Packages/Bison
Please let me know if you find something better!
edit: I take it back - the Flex one highlights start states & C/C++ code in pink and it looks quite terrible. For basic lex files it looks okay, but it needs work. :)
edit again: as sonu kumar pointed out, the project has been removed from github. For an alternative you could try the built-in OCamlyacc highlighting (pretty decent), or another alternative: https://bitbucket.org/artyom_smirnov/sublime-text-bison-highlighter (needs some work)
I'm using Sublime a lot more & do a fair bit of work in Flex/Bison, so I might get around to writing one... one day. :D

Indeed there are:
Flex
Bison
It's not so hard to write your own packages for non-typical languages. Just browse the source of other language syntax files and copy-paste-change what you need. Also raises your regex skills to a better level.

Install Package Control for Sublime Text.
I found this there:
https://sublime.wbond.net/packages/Bison
Do try it, I found it good enough for my use.

https://github.com/m-happy/Packages/blob/master/Flex/Flex.sublime-syntax
You can add this file to your sublime package.

Related

Vim plugs to work with custom HTML tags and SCSS

My Vim level is about intermediate - I've been using it about 10 years, but on "newbie" level - find file, delete something, add something, save and quit.
Now I decided to make Vim my only code editor.
I'm working with Ionic framework (it's Angular + SCSS) and I have a question about some useful things:
Is there a way to add all non-standard HTML tag to Syntastic? It's highlights all of Ionic tags, such as <ion-list>, <ion-button>, <ion-radio> and so on. If my google skills are good enough, there's no full Ionic plugin, which will add snippets, syntastic checkers and so on.
Is there a way to find and add classes from HTML to SCSS and from SCSS to HTML? I mean, if I'll write .my-very-important-class in SCSS file and then go to HTML file (which is in the same directory with same name and differs by .html or .scss) and in class="" attribute start to input "my" I'll get autocomplete suggest for this class. Is it real to make or maybe someone did already?
There is also main file for theming an app, called variables.scss. I need this file to be scanned and match colors (in this file there is an color section, where I can put all colors, I'll need in app, and in .scss file of any page I can get color I need with just color: color($colors, colorname) where colorname is the name of color variable. It's awesome feature, except no color highlighting in code. So it would be great to get color mappings and then highlighting with correct color in .scss file of page.
I didn't found any plugins for this. If there some existing plugins I've missed - I'll be happy to try it. If it's no - I will be glad to made one myself (if it's not very hard). Anyway, I think this are useful things not just for me.
UPD: #1 was fixed - I'm not sure, how exactly, but now it's fine in HTML and I have no errors or warnings from syntastic about wrong tags. I'm feeling newbie, but seems like I forgot to install Vim-ionic2 plugin - just added it to my .vimrc.
And #2 seems to be answered - does what I need.
Syntastic is a frontend to several linters. Find the linter used by Syntastic and look for a way to make it accept those custom tags.
If you have the CSS file opened, <C-n> should let you complete the CSS class.
You might need something like set iskeyword+=- for Vim to complete the whole class name.
I think this would be totally useless. That said, if you didn't find such a thing… write it.
respect to the first point I'll say that vim for itself doesn't highlights all the HTML elements (main, header,etc) because the default html.vim file is a little outdated. However, I've just created a repository in which I added all the remaining elements to be highlighted.
If you encounter that something in the language you're working on doesn't get highlighted you should create a .vim file adding the keywords you want to be highlighted. I share you the repository I've talked about: github repo
It'll be nice that people can contribute so we don't have to create repeated vim files.
You can read more about syntax here: vimdocumentation
First off, I'd really recommend you split this into three separate questions. I feel like they could easily have dedicated answers that are not really connected. And someone might have a good suggestion for one of them, but not for the others. On my side, I can give you suggestions about 2) and 3) only.
For 2), you could use romainl's suggestion for completing keywords. You could also try generating tags for your CSS files using ctags. Here's one possible way to do it: https://github.com/rstacruz/ctags-css. Once you have the tags, you could use tag completion. See :help ins-completion, in particular the "tags" section. It would be a pretty good idea to read up the entire section, though, to get an overview of what's possible.
For 3), there's plugins around for this. Try this one: https://github.com/lilydjwg/colorizer

Contemporary Solution for Formatting HTML in Notepad++

It seems this should be a basic and comomon requirement, but after an hour of searching instead of getting on with the task I want to use it for, I can't find an effective solution for formatting HTML in Notepad++.
I've visited Formatting code in Notepad++ and How To Auto-Format / Indent XML/HTML in Notepad++ but
XML tools plugin - no good because it doesn't even align opening and closing head tags.
TextFX HTML Tidy - no good. Missing dll, link from menu to dll broken and all SO solutions involve putting the dll once found into plugins/config directory which my install doesn't have (Maybe I could create it, but I want an easier solution now)
Tidy2 - won't install
I'm using Windows 10 on a 64-bit machine. I love Notepad++ but this sucks. Please put me out of my misery.

Better Reindent Lines Feature for Sublime Text 3

I have found Sublime Text's Reindent Lines feature to not being very reliable or helpful, especially when dealing with JSON files. Does anyone know of a way to make it work better? I know of plugins like "HTML-CSS-JS Prettify" but they only (and quite correctly, I might add) strive to work with HTML, CSS and JS respectively. I'd love to know if there is better way to indent/reindent all kinds of files.
Bonus points for any hint regarding converting from tabs to spaces (or vice versa) and reindenting correctly in one go.
pretty JSON package works perfectly for me.
You can specify the style of indentation from the package setting also. (which solves your second problem)

Sublime Text 3 Code autoformatting

I've searched high and low, but I can't seem to find a plugin that makes Sublime work similar to how Visual Studio formats my code as I type it.
For example, when I write a for loop, it looks something like this:
for(int i=0;i<value.length;i++) {
//loop body
}
As soon as I complete the loop body, Visual Studio will format it to be much more readable:
for (int i = 0; i < value.length; i++)
{
//loop body
}
Basically, it's just adding spaces around operators in this case, but it does much more. If I write horribly indented HTML/XML code, it corrects the indentation. Arrays and multiline conditionals become much more readable.
Are there any Sublime Text 3 plugins out there that do something similar to this? Everybody seems to highly recommend the "Reindent" command, which works for the HTML/XML formatting, but it doesn't space everything out in a consistent way. JsParen looks good, but it won't work for any other language that I use, namely PHP, and it's for ST2.
CodeFormatter is one possible option for PHP. It uses the PEAR PHP_Beautifier, which you'll need to install separately. There are a bunch of configuration options detailed in the README, so you should be able to find something that suits your needs.
For C/C++/C#/Java code, you can't go wrong with SublimeAStyleFormatter, a formatter that uses the popular AStyle rules. Again, there are many options available, check the .sublime-settings file for details.
HTML-CSS-JS Prettify is what I'm using currently for those languages. It requires node.js to work, so make sure you read through the instructions carefully.
Finally, you may think I'm being facetious, but I'm really not: pay attention to style when you're coding. I work a lot in Python, where the visual presentation of the code is actually part of the syntax. Code is meant to be read, by other developers as well as by machines, and it does no one any good to try and pound out poorly-formatted, unindented code while thinking "I'll just prettify it later." Maybe your formatter doesn't fix all your mistakes, or maybe you forget, or get lazy. If you focus on the look and structure of the code, you can more easily see how the different parts fit together, and perhaps catch some bugs before they can do any harm. Set a clear style guide for yourself, and stick with it. You'll be glad you did.
Open Sublime Text editor.
Press Ctrl + Shift + P.
In the menu select Package Control : install Package
Now select SublimeAStyleFormatter.
After installing the above extension, you may press Ctrl + Alt + F to format your current file.

track and display changes in html

I am looking for a tool to display/track changes in text a little bit like it is done on stackoverflow when a question is edited. Does anybody know of a tool to achieve that?
You may want to use diff for that.
If you can use PHP on your server there's a handy pear package to perform the task you require. Here's an example :
https://web.archive.org/web/1/http://articles.techrepublic%2ecom%2ecom/5100-10878_11-6174867.html
There's actually a actually Javascript implementations outhere as well, not tested though:
http://ejohn.org/projects/javascript-diff-algorithm/
http://aignes.net/
Commercial tool though. I have no idea of a F/OSS alternative.
A copy of my own answer from here.
What about DaisyDiff (Java and PHP vesions available).
Following features are really nice:
Works with badly formed HTML that can be found "in the wild".
The diffing is more specialized in HTML than XML tree differs. Changing part of a text node will not cause the entire node to be changed.
In addition to the default visual diff, HTML source can be diffed coherently.
Provides easy to understand descriptions of the changes.
The default GUI allows easy browsing of the modifications through keyboard shortcuts and links.