ghdl-language-server icon indicating copy to clipboard operation
ghdl-language-server copied to clipboard

Enhancements to snippets and syntaxes

Open GlenNicholls opened this issue 6 years ago • 11 comments
trafficstars

The snippets and syntaxes are in rough form right now. The following should be added:

Syntaxes

The following keywords are not currently in the syntaxes

  • [ ] rising_edge/falling_edge
  • [ ] event
  • [ ] all types in ieee: real/integer/signed/unsigned/std_logic/etc. (functions too?)
  • [ ] ensure all identifiers are highlighted. Instead of blue, they should be another color
  • [ ] single quotes ' '
    • this might be tough due to the tick ' being valid. Possibly check to make sure there's something between two single quotes. Making this a different color from the double quote would be helpful as well
  • [ ] highlight number in parenthesis or just on their own to make picking out ranges, generics/ports, and addressing a bit easier
  • [ ] block comments (vhdl2008)
  • [ ] time units

Snippets

The following need to be added to snippets

  • ~~entity~~
  • ~~component~~
  • ~~architecture~~
  • [x] all types in ieee: real/integer/signed/unsigned/std_logic/etc. Possibly abbreviations for sl/slv etc.
  • ~~package~~
  • ~~ieee libraries~~
  • [x] function
  • ~~procedure~~
  • [x] context (vhdl2008)
  • [x] process
  • [x] case
  • [x] case generate (vhdl 2008)
  • [x] with select
  • [x] when
  • [x] others
  • [x] while
  • [x] for
  • [x] for generate
  • [x] if/elsif/else
  • [x] if generate
  • [x] if/else generate (vhdl2008)
  • [ ] convert entity/component to instance like this
    • probably needs macro
  • [ ] auto-fill case statement for FSM if select type has FSM states
    • probably needs macro

GlenNicholls avatar Nov 07 '19 16:11 GlenNicholls

@1138-4EB @tgingold feel free to assign this to me and I can start knocking these out as I have time

GlenNicholls avatar Nov 07 '19 16:11 GlenNicholls

@tgingold I am going through the current syntaxes to change the highlight colors for all identifiers. However, vscode doesn't have an easy way of doing this outside creating a new theme which I think is not good since it will force users to use a certain color scheme. I found this example from this blog

Basically, it uses a regexp to determine which scope is used for highlighting. Does this seem reasonable or is there a better way to highlight non-standard repositories while minimizing the manual intervention to support the default themes of VSC? For VHDL syntaxes, there would be no match condition for the capture other than the "keyword", but I would use that to ensure that the highlight color is supported in all default themes (as determined by the *.json under <VSC>/resources/app/extensions/theme-defaults)

GlenNicholls avatar Nov 12 '19 03:11 GlenNicholls

@tgingold can I get permissions? I made a branch and I'm starting to commit my changes/additions to the snippets. It won't let me with the following error:

Glen.Nicholls@CL0285 MINGW64 ~/Desktop/ghdl-language-server (syntax_snippets)
$ git push origin syntax_snippets
remote: Permission to ghdl/ghdl-language-server.git denied to GlenNicholls.
fatal: unable to access 'https://github.com/ghdl/ghdl-language-server.git/': The requested URL returned error: 403

GlenNicholls avatar Nov 12 '19 05:11 GlenNicholls

@GlenNicholls, the regular procedure is to fork this repo to say GlenNicholls/ghdl-language-server, using the 'Fork' button above. Then, you push the branch to your repo. Last, you open a Pull Request, by selecting a branch from your repo.

eine avatar Nov 12 '19 05:11 eine

@1138-4EB Can you check out my commit for the snippets in 4ce89e4? I am adding as much as I can and would like to organize the snippets.vhdl.json to be a bit more readable. Because comments are not supported, I am grouping everything with delimiters in the description. Do you see value in this or should I forego that and just have a short description for each snippet?

Also, what do you think about the above comment I made about the syntax highlighting?

GlenNicholls avatar Nov 12 '19 23:11 GlenNicholls

@1138-4EB @tgingold I am also thinking about adding a snippet for a VHDL file header:

"File Header": {
		"prefix": ["FILE_HEADER"],
		"body": [
			"-----------------------------------------------------------------------------",
			"--",
			"-- Title  : ${1:<Title of File>}",
			"-- Design : ${2:<Title of Design>}",
			"-- Author : ${3:<Your Name>}",
			"-- Date   : $CURRENT_MONTH/$CURRENT_DATE/$CURRENT_YEAR $CURRENT_HOUR:$CURRENT_MINUTE",
			"-- File   : <$TM_FILENAME>",
			"--",
			"-----------------------------------------------------------------------------",
			"--",
			"-- Description",
			"--------------",
			"-- ${4:<Enter Description>}",
			"--",
			"-- Interface",
			"------------",
			"--",
			"-- TODO",
			"-------",
			"--",
			"-----------------------------------------------------------------------------"
		],
		"description": "Standard file header"
	},

Obviously, the format could change, but I use that all the time. Is there value in adding this to the ghdl-ls vscode plugin, or is that too specific?

GlenNicholls avatar Nov 12 '19 23:11 GlenNicholls

Many people want to have an header, but rarely the same. How easily could it be customized by users ?

tgingold avatar Nov 13 '19 06:11 tgingold

I have to investigate. I think the existing identifiers are already highlighted on my setup.

tgingold avatar Nov 13 '19 06:11 tgingold

@tgingold

Many people want to have an header, but rarely the same. How easily could it be customized by users ?

Hmmm, I don't think it would be an easy task. I'm not even sure that it would work with the provided snippet variables. I opened a VSC issue about allowing embedded snippets which would help. At this time, though, I don't think it would be possible for a user to customize the header without a macro or something.

I have to investigate. I think the existing identifiers are already highlighted on my setup.

Okay let me know. I have tried all default themes and turned off all VHDL extensions except ghdl-ls and they aren't highlighted at all for me.

GlenNicholls avatar Nov 13 '19 16:11 GlenNicholls

Here is what I get: Screenshot from 2019-11-14 14-09-57

tgingold avatar Nov 14 '19 17:11 tgingold

@tgingold

Here is what I get: Screenshot from 2019-11-14 14-09-57

Do you have an hdl-proj.json file. In the default theme, I don't see any highlighting for the identifiers at all :/

GlenNicholls avatar Nov 14 '19 18:11 GlenNicholls