Sublime Forum

VHDL Mode for Sublime Text 3

#1

I am happy to announce successful publication of my language package for VHDL. The goal was to emulate the vhdl-mode Emacs capabilities and I’ve been able to come close, and work continues.

Major features

  • Copying a full port design from an entity or component and instantiating it as entity/component/signal list/instantiation/testbench
  • Code beautification (indentation and alignment)
  • A mimicry of stutter-typing shortcuts with snippets.
  • A set of snippets for language constructs
  • Header insertion (somewhat more involved than a snippet)
  • A new syntax definition file with fine grained lexical scoping

Thanks to everyone in Plugin Development who put up with my running commentary and questions. You all deserve massive credit for making the development process successful.

If anyone actually is simultaneously a hardware developer, Sublime Text user, and VHDL coder I hope this helps you out.

(Actually I guess it’s not yet completely merged into Package Control channel, so might not be on the website just yet.)

4 Likes

#2

Well after many moons I believe this is pretty close to feature complete. I’ve got the bits of VHDL Mode constructed that I think are most useful (and a few of lesser usefulness), have emulated what I cannot handle directly, and so forth. VHDL-2008 refinement I think is just an ongoing process.

If HDL designers come up with a “man I really wish I could do X” with the language, please let me know as I would be happy to consider the ideas for extending the package further.

1 Like

#3

Hi,

I just discovered your pluing. It is amazing.
Howver, i’ve some questions but first of all, i don’t know where to ask my questions. Here or on your github page ?

0 Likes

#4

You can ask here if you like. Glad it’s helpful for you.

0 Likes

#5

Hi

Thanks for your help.
Well, for now, i still test your plugin, but i’ve 2 questions:
1/ I don’t really understand how keyboard shortcut are handle with the plugin. I understood that plugin add new shortcut, with a “Emacs” style, but why some standard shortcuts don’t work anymore when VHDL-Mode is enable?

2/ Header template is a great feature, how is it possible to set the length of line used in this template? For example, i mostly write HDL files with a line limit to 110, so i’ll want to use this length when i add a header.

Thanks for your answers.

0 Likes

#6

Well, the package was designed to be familiar to folks who were used to Emacs vhdl-mode which provided a lot of utility for coding in the language. The base set of keybinds are similar but not exactly like Emacs vhdl-mode. They should not interfere with any standard Sublime Text keybinds. However, there do exist a second set of keybinds that are activated with a specific user setting that will use the actual old-style Emacs keybinds. Those will most likely conflict with Sublime Text base keybinds, however if you’re using the Emacs Pro Essentials package they won’t. Unless you are an old hand at Emacs I would just stick with the base keybinds (ones that start with Alt-K). If you have a problem with a specific keybind, just let me know, I should be able to shed some light on the command.

The shortcuts for comment box and comment line do pay attention to your personal settings for line length, but the template won’t – it’s implemented as a snippet. If you want to change the format of the snippet, you’ll probably need to get another package called “Package Resource Viewer”. With that tool you can look into mine (and anyone elses – and the default) packages. You can also edit those files and the tool will create an override for that file for you personally.

Hope that helps. Let me know if you have more questions!

0 Likes

#7

Hi

Thank you for your answers.

1/ I let the defI’ve let the default configuration of the package. But in sublime text i’ve configured the command “toggle block comment” with the keyboard shortcut “ctrl-+/”.
It works fine for my python or tcl files, but not anymore in my VHDL files. In those files i have to used ‘M-k c c’. I can do it obviously, but for me it is quicker to do use my previous configuration.

2/ I’m going to look the package you’ve mentionned. If i well understand it means that if for a project i need to have a line length of 110 characteres i change the package configuration, and if for another project i need to have a line length of 90 characters i need to change the package configuration one more time.
I dont’t know the limitations or the complexity to create a package but why it is not possible to have a line length option in the settings file?

0 Likes

#8

Okay, I got a chance to look into this. The answer is oddly simple. Sublime Text does not by default know how to comment VHDL. The toggle comment command simply does not work at all, no matter what it’s bound to. So I’m trying to figure out how Sublime Text knows how to comment anything! Maybe there’s a file containing a language attribute that needs to be set that I never set (because I wrote my own command.) Anyway, I’m looking into this.

Final edit: I have a fix for this in development branch. You’ll probably see a package update in a few hours after I make sure everything is clean and push a release.

In short, currently the header is generated with a sublime snippet. The lines you see in the header are not dynamically generated for your chosen line length. It could be possible to dynamically generate the header without using a snippet, however it would take some time to write that and I’m behind on my bug list as it is. I can add it as an open issue and consider it, but I don’t see that getting implemented in the near future.

The line and box stutter typing shortcuts do pay attention to your chosen line length because those are dynamically generated.

0 Likes

#9

Been also ruminating on the header box issue. It is not really a simple thing to create this so that it is simultaneously customizeable and dynamic. The Emacs vhdl-mode solution was that it was possible to create a custom header for every project you defined. I do have some of this capability in that I permit the user to create the custom fields for version control and export control notices. However this is simply some substitution text and not creating the ‘lines’ out of comment characters.

I suspect if you have wildly varying project requirements, the best solution would be to create a header snippet per project and manually insert that. Sadly this will not work with the insert header command but Sublime Text will recognize a unique name as you start to type it and that’s not a bad solution either. If you keep the -- Last update : field the same, you should get the automatic time stamping when you save the file still though because that’s only looking for that string (and if you need to change the string, there’s a setting for that.)

Sorry that the header functionality isn’t as customizable as you desire and/or need. I don’t see a quick way to bake that into the package right now.

0 Likes

#10

Hi

Thanks for your answers.
I understand the problem for the header. And yes, maybe you’re wright it will be easyier to create header for the needed project in order to adjust line lenth and, if needed other things.

0 Likes

#11

Sure. Doing a little more investigating (because some of this was written quite awhile ago and I simply don’t remember what I did) it does look like the line generation stutter typing command is also hard coded to an 80 character line limit. There might be a way to alter this but I’ll have to see what Sublime Text’s settings are for line lengths. I’ll add the issue to the project in any event.

(Clearly my own personal preferences for an 80 character limit influenced these features greatly :smiley: )

0 Likes

#12

Actually, while writing up the issue on this, a way of handling this that isn’t too painful came to mind. I’ll see if I can’t figure out a way to give you project determined line lengths. It won’t be today, but keep an eye out for a package update in the future (maybe – depends on competing demands on my time.)

0 Likes

#13

Speaking about stutter typing, it seems some of them doesn’t work on my computer:

— : Produces a comment line extending to column 80 starting where the cursor is, and accounting for tabs. This one pays attention to the tab_size Preference if you use tabs.
–= : Produces a three-sided comment box extending to column 80 starting whree the cursor is, and accounting for tabs. (See notes.)

When i type these two stutter nothing happens.

0 Likes

#14

Huh. Interesting and weird. The only thing this checks is the source scope. Are you definitely in a VHDL file (down in the lower right corner, it says VHDL?). It will not do anything in any other source, like plain text or other code.

0 Likes

#15

Ok, i understood my mistake.
Stutter sems to not working when you use the numeric keypad characters.
if i use the ‘standard’ character it works…( with 80 characters :wink: )

0 Likes

#16

Huh. Yes the numpad produces the keypad_minus character event. I could consider adding that in, though there is no = on the keypad. The entire intent of this (and other Emacs philosophy keystrokes) is that you don’t really ever take your fingers off the home row, so the characters intended for use was dash and equals on the top row of keys.

I do have a line length setting working for inserting line and box. There are appropriate error messages if your character position is in a spot where it can’t actually obey this (e.g. you set the line length to 40 characters and try to insert a line at character position 60). The header insertion will insert SOME lines dynamically, though I have a spot where there is optional text. I can’t seem to get optional text lines to be dynamic but I think that may be a limitation of the snippet engine. Checking with the experts on this one. So might be able to get something that suits a multiproject, multilinestandard scenario pretty soon.

0 Likes

#17

Okay. Think I’ve got what you want there. Was an interesting addition and I do like making things more customizeable. Package Control will update before too long and ST should catch up. This is probably all the time I can devote to this today though (and for a little while).

0 Likes

#18

Once again, thank you for all your explanations, and for your quick answers to my questions.

0 Likes

#20

Sure, no trouble at all.

0 Likes

#21

Hi,

I’ve found a weird behavior of the plugin this morning (when i came back from holydays). When i use the header snippet, the header generated is not as expected, for example there is no comment lines, no creation date, no company name and so on.

First i’ve though that i’ve made an error, so i use a fresh new install of ST3 and install only the VHDL-Mode package, but the problem still exist.

0 Likes