SciTE with Golang gofmt

405 views
Skip to first unread message

Andreas Klauer

unread,
Mar 29, 2017, 12:02:09 PM3/29/17
to scite-interest
Hi there,

I'm new to SciTE, using version 3.7.4 on Linux.

Is anyone using this editor for Go (golang.org)?

Google turned up this http://go-lang.cat-v.org/text-editors/scite/ and from what I understand it kinda retrofits the CPP syntax highlighter for Go.

Syntax highlighting aside, Golang has another peculiarity... it likes to run any and all code through its indenter, gofmt. This is an external program similar to HTML Tidy that produces properly formatted code, and it'll either print to stdout or change the file directly.

Only problem is, I can't get it to work. The SciTE FAQ has an example for HTML Tidy here http://www.scintilla.org/SciTEFAQ.html but that doesn't work for me, either.

I ended up with this is in my SciTEUser.properties:

command.name.0.*.go=gofmt
command
.0.*.go=gofmt -w $(FilePath)
command
.mode.0.*.go=filter:yes,savebefore:yes

command
.name.1.*.html=HTML Tidy
command
.1.*.html=tidy -i -wrap 0 -m $(FilePath)
command
.is.filter.1.*.html=1

The command shows up in the menu, the program actually runs and successfully changes the file. And scite shows it ran gofmt, exit code 0. Okay.

But I still have to manually select File -> Revert to make those changes show up in the editor. Ideally I would like this to happen automatically and for gofmt to run whenever I save the file and if undo history could be preserved somehow that'd be really great.

I thought the "filter" would be the flag responsible for that but there does not seem to be any change no matter how I set it.

Is it possible?

Kind regards
Andreas Klauer

Neil Hodgson

unread,
Mar 29, 2017, 3:54:32 PM3/29/17
to scite-i...@googlegroups.com
Andreas Klauer:

> But I still have to manually select File -> Revert to make those changes show up in the editor.

Also needs load.on.activate=1 .

Neil

Andreas Klauer

unread,
Mar 29, 2017, 4:32:00 PM3/29/17
to scite-interest, nyama...@me.com
Am Mittwoch, 29. März 2017 21:54:32 UTC+2 schrieb Neil Hodgson:

   Also needs load.on.activate=1 .


That did it. (Wasn't mentioned in the HTML Tidy example or I missed it?)

Also set reload.preserves.undo=1, I guess these go together (in my case).

So many settings, takes a while to see through them. :)

Thanks,
Andreas

Csaba Raduly

unread,
Mar 30, 2017, 3:47:58 AM3/30/17
to scite-i...@googlegroups.com, Neil Hodgson
On Wed, Mar 29, 2017 at 10:31 PM, Andreas Klauer wrote:
> Am Mittwoch, 29. März 2017 21:54:32 UTC+2 schrieb Neil Hodgson:
>>
>>
>> Also needs load.on.activate=1 .
>>
>
> That did it. (Wasn't mentioned in the HTML Tidy example or I missed it?)

load.on.activate does not appear in the FAQ

Csaba
--
GCS a+ e++ d- C++ ULS$ L+$ !E- W++ P+++$ w++$ tv+ b++ DI D++ 5++
The Tao of math: The numbers you can count are not the real numbers.
Life is complex, with real and imaginary parts.
"Ok, it boots. Which means it must be bug-free and perfect. " -- Linus Torvalds
"People disagree with me. I just ignore them." -- Linus Torvalds

Neil Hodgson

unread,
Mar 31, 2017, 9:33:52 PM3/31/17
to scite-i...@googlegroups.com
Csaba Raduly:

> load.on.activate does not appear in the FAQ

FAQ updated.

Neil

George Hummet

unread,
Apr 22, 2017, 2:25:31 PM4/22/17
to scite-interest, nyama...@me.com
a few times ago, i grepped a more complete set for go to ue within cpp.properties  - just pasting here for reference.

keywordclass.go=\
bool byte rune float string int int8 int16 int32 int64 float32 float64 struct uint uintptr uint8 uint16 uint32 \
uint64 complex complex64 complex128 const string real continue defer go continue default else for func goto fallthrough \
falseif import interface len map nil package return select switch case chan true false type var range func \
fallthough break append cap copy delete error imag range type for import return make new panic print println real recover nil break
keywords.$(file.patterns.go)=$(keywordclass.go)

Neil Hodgson

unread,
Apr 23, 2017, 6:00:04 PM4/23/17
to scite-interest
George:

> keywordclass.go=\
> bool byte rune float string int int8 int16 int32 int64 float32 float64 struct uint uintptr uint8 uint16 uint32 \
> uint64 complex complex64 complex128 const string real continue defer go continue default else for func goto fallthrough \
> falseif import interface len map nil package return select switch case chan true false type var range func \
> fallthough break append cap copy delete error imag range type for import return make new panic print println real recover nil break

That looks wrong as it will not highlight the common keyword “if” since it has been jammed up against “false”.

The go specification defines a set of keywords at https://golang.org/ref/spec#Keywords and the current keywordclass.go setting includes the predefined numeric types (https://golang.org/ref/spec#Numeric_types), boolean constants (https://golang.org/ref/spec#Boolean_types), and pointer literals along with some but not all predefined functions.

“float” does not appear in the specification without a numeric suffix.

A reasonable value for keywordclass.go may be the union of https://golang.org/ref/spec#Keywords and https://golang.org/ref/spec#Predeclared_identifiers. Sorting the value of keywordclass.go like the current setting makes it easier to check.

Neil

George Hummet

unread,
Apr 23, 2017, 8:18:21 PM4/23/17
to scite-interest, nyama...@me.com
thanks Neal, ill have a look at go in the next times. so its likely to see some more here.
Reply all
Reply to author
Forward
0 new messages