Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syntax Highlighting? #19

Open
escholtz opened this issue Sep 23, 2016 · 26 comments
Open

Syntax Highlighting? #19

escholtz opened this issue Sep 23, 2016 · 26 comments

Comments

@escholtz
Copy link
Contributor

Do you know if anyone has started adding syntax highlighting support for various text editors? My personal interest is for Sublime Text.

@escholtz
Copy link
Contributor Author

escholtz commented Oct 6, 2016

Here is a syntax file I came up with for ST3. Requires GoSublime.

%YAML 1.2
---
# http://www.sublimetext.com/docs/3/syntax.html
name: "QuickTemplate"
file_extensions:
  - qtpl
scope: source.qtpl
contexts:
  main:
    - include: scope:text.html.basic
    - match: "{%"
      push: "Packages/GoSublime/syntax/GoSublime-Go.tmLanguage"
      with_prototype:
        - match: "(?=%})"
          pop: true
        - match: "(code|space|elseif|endif|endfor|endfunc|comment|endcomment|plain|endplain|stripspace|endstripspace|collapsespace|endcollapsespace|endswitch)"
          scope: "keyword.other.go"

I'm a Sublime syntax newbie so probably lots of improvements to be made but the basics seem to work (highlighting html, go, and quicktemplate keywords all in the same file).

@valyala
Copy link
Owner

valyala commented Oct 15, 2016

@escholtz , thanks for the contribution! Just added a link to this issue from the FAQ in the README.md

@tobstarr
Copy link

How about something for vim?

@valyala
Copy link
Owner

valyala commented Oct 24, 2016

@tobstarr , I'm not familiar with vim syntax highlighting, so contributions are welcome :)

@valyala
Copy link
Owner

valyala commented Oct 24, 2016

btw, I use vim, so will be very glad if qtpl syntax highlighting for vim is implemented.

@warbear0129
Copy link

@valyala hi i like quicktemplate so much i made a simple syntax highlighter for vim. https://github.com/warbear0129/vim-qtpl

@codelitt
Copy link

codelitt commented Mar 17, 2017

@valyala, @warbear0129's package wasn't working for me and a couple other people. I've submitted a PR that should get it working for most vim runtimes. Also now it works with Vundle and Pathogen.

Thanks to warbear for the syntax file. It just needed some tweaks. If anyone is having issues they can take a look at my fork (if the PR below is not merged)

warbear0129/vim-qtpl#2

@codelitt
Copy link

@valyala Actually a quick update. The other vim-qtpl package was pretty bare on features and html syntax support. I found it better to take the well written and supported vim-go plugin and add support quicktemplate syntax. I've been testing it out and this is a much better approach.

The PR I submitted to vim-go is here: fatih/vim-go#1241

My fork here (until @fatih) merges it in: https://github.com/codelitt/vim-go

Hopefully this is much more helpful.

@tobstarr
Copy link

@codelitt that looks pretty cool!

@codelitt
Copy link

@tobstarr Thanks! I've been testing it out and it's working very well. Plus it brings all of the awesome things from vim-go to these filetypes (like go fmt)

@valyala valyala reopened this Jun 23, 2017
@valyala
Copy link
Owner

valyala commented Jun 23, 2017

Re-opened the issue in order to make it more prominent (and it is incomplete yet).

@codelitt
Copy link

codelitt commented Jun 23, 2017

@valyala My fork of vim-go provides this very completely: https://github.com/codelitt/vim-go

Unfortunately though, it was not accepted into the main vim-go repo as a PR as the maintainer doesn't want to bother with it feel like it's a good fit for vim-go and needs to be a separate plugin. I'm not sure if anyone has any other ideas.

@fatih
Copy link

fatih commented Jun 23, 2017

Unfortunately though, it was not accepted into the main vim-go repo as a PR as the maintainer doesn't want to bother with it.

I've suggested to you that you can provide it as a separate plugin. You didn't and then say you forked vim-go (which I think is unreliable as well, but that's not my business)

I have limited time,a family, work to do, and many other things. I can't just merge every single feature out there in the universe. it's 5-10 lines. Just create a vim-quicktemplate plugin and there you go. Anyone who uses vim-go can use that as well. It's not hard to create such a plugin. Hope you understand this.

@codelitt
Copy link

codelitt commented Jun 23, 2017

@fatih Perhaps that was poorly worded. I meant unfortunate in the sense of "Now we'll have to sort out something else" and not as a criticism of you. I agree it's a poor choice to try to maintain a separate fork, it's just what I've been doing until I have more time. I completely understand your position as a maintainer and understand you don't feel like this is a good fit for vim-go. Apologies if my original comment made that seem otherwise.

I just went back and re-read the comments on the PR. I'm not sure what it takes to make a plugin that integrates with another plugin like vim-go as I'm not overly familiar with vim plugins, but I'll take a look over the next week or so.

@fatih
Copy link

fatih commented Jun 23, 2017

@codelitt no worries. I apologize if my words were harsh as well. Didn't meant it. Thanks for your understanding.

@codelitt
Copy link

@fatih No worries on my end either. I'd welcome any docs about creating a plugin which integrates with/relies on another plugin (in this case vim-go)

@TuralAsgar
Copy link

TuralAsgar commented Aug 4, 2017

Is there any syntax highlighter for Intellij based IDEs?

@nezorflame
Copy link

Would love to see someone do the VSCode extension.

@atomi
Copy link

atomi commented Oct 31, 2017

I missed this thread when I opened an issue earlier, but here is basic syntax highlighting for vs code:

https://marketplace.visualstudio.com/items?itemName=vsatomi.vscode-quicktemplate

@stereosteve
Copy link
Contributor

@tural-esger for IntelliJ GoLand I created this issue, which you can upvote: https://youtrack.jetbrains.com/issue/GO-4810

@encku
Copy link

encku commented Dec 31, 2017

@stereosteve Can we create our syntax highlighting with this
jetbrains create filetype ?

@b0o
Copy link

b0o commented Jan 14, 2018

Better vim support would be great. The warbear0129/vim-qtpl plugin sorta works, but breaks as soon as I edit the file. It also doesn't have embedded HTML support which is a big letdown.

@b0o
Copy link

b0o commented Jan 15, 2018

I've begun working on my own Vim Quicktemplate syntax plugin: b0o/quicktemplate.vim.

I'm a complete noob when it comes to creating syntax rules for Vim, and the Quicktemplate grammar is rather complex when you take into account the fact that it essentially has 2+ other languages embedded within it (go, html, [js, css]).

It took me quite a while to get anything working at all, but I think at this point my version offers a bit more room for improvement than warbear0129/vim-qtpl. My main issue with vim-qtpl was that it's a 'dumb' syntax highlighting plugin - it doesn't attempt to utilize the existing syntax definitions for Go and HTML, so there's only so much it can do.

I would welcome contributions from anyone who is better with VimL or Vim syntax parsing than me, but I'll be attempting to make this plugin semi-complete over the next few weeks.

2018-01-14-20-41-28


Update 02-11-2018:

I've been working on this plugin quite a bit, and it's now to the point where most things work quite well. Here's an updated screenshot:

Screenshot

@frederikhors
Copy link

Any news for VSCode or Goland?

@m00nyONE
Copy link

m00nyONE commented Oct 1, 2019

Any news for VSCode or Goland?

Yes. take a look inside the README.md file

Is there a syntax highlighting for qtpl files?

Yes - see this issue for details. If you are using JetBrains products (syntax highlighting and autocomplete):

cd JetBrains settings directory
mkdir -p filetypes && cd filetypes
curl https://raw.githubusercontent.com/valyala/quicktemplate/master/QuickTemplate.xml >> QuickTemplate.xml
Restart your IDE

But i have to say it is not very good and no it does not have the type of autocompletion you may expect. its ... lets say .... simple

@SharanSharathi
Copy link

Hello @escholtz, @valyala,
I've added a package in packagecontrol.io for SublimeText - Quick​Template (Go)
It supports syntax highlighting, code completion, and a build system to run qtc with a keyboard shortcut.

please give it a try, and share your feedback.
we can add about this package in README.md - https://github.com/valyala/quicktemplate#faq

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests