Title says it all.
This obsoletes #1328 and #715. You can view, comment on, or merge this pull request online at:
https://github.com/geany/geany/pull/1339
-- Commit Summary --
* Add Arduino custom filetype
-- File Changes --
M data/Makefile.am (1) A data/filedefs/filetypes.Arduino.conf (56) M data/filetype_extensions.conf (3)
-- Patch Links --
https://github.com/geany/geany/pull/1339.patch https://github.com/geany/geany/pull/1339.diff
Isn't Arduino just using C/C++? According to their [FAQ it is](https://www.arduino.cc/en/Main/FAQ):
Q: Can I program the Arduino board in C?
A: In fact, you already are; the Arduino language is merely a set of C/C++ functions that can be called from your code.
It sounds akin to having a custom C++ filetype for Qt or something, not that I'm strictly opposed to either, I just wonder how many special purpose custom filetypes we want to add for languages which are already supported. For example, I've been doing programming on several classic microcontrollers lately, would we want to have a `filetypes.6502.conf`, `filetypes.8051.conf`, `filetypes.8086.conf`, `filetypes.68k.conf`, `filetypes.AVR.conf`, `filetypes.PIC.conf`, etc.? I suppose the alternative would be to put all of these specialized filetypes on the wiki.
Adding the Arduino-specific extensions as in [SFBUG 597](https://sourceforge.net/p/geany/feature-requests/597/) and #1328 seems completely reasonable since they don't clash with existing extensions (despite the fact that users could easily add those extensions themselves and indeed that is the entire purpose of that config file).
Yes, Arduino's language is standard C/C++ used with a framework (which is called Wiring).
This filetype also adds highlighting for all Wiring keywords and menu commands for building and uploading sketches straight from Geany, so I think it has some extra value.
I don't doubt it has extra value, much like a Qt filetype which would have "keywords" like `slots`, `signals`, `emit` and build commands for `moc` and `uic`. I'm really only questioning where we draw the line on adding custom filetypes. Like the assembly examples I gave above, each would have its own set of mnemonics and assemblers, but IMO in that case it is too much to ship by default.
@codebrainz its a good question worth asking, since custom filetypes only cost a menu slot (on a menu that isn't used much usually) I would be happy for lots of specific filetypes, so long as they don't clash with one another. At some time in the future the menu may need re-arranging if its gets too big, but thats a future worry.
In this case the filetype may be based on C/C++, but it has extra features and completely different build commands, so it does seem reasonable for it to be provided as a separate language. And it won't clash with "normal" C++, unlike things like Qt files which still use the normal C++ extensions so they are harder detect, whereas Arduino is using different filetypes, so it will be detected automatically.
The problem with the wiki, is that its a wiki, and its not controlled, remember when your (JSON was it?) filetype was overwritten by one that worked worse. Also I'm afraid many users don't notice whats on the wiki.
@SukkoPera since you have a copyright notice in the filetype file you probably need to provide a license otherwise technically nobody can copy your work. Referring to the GPL v2 as used by the rest of Geany would be best.
@elextr That was not meant to be a copyright notice, but only a "send comments and issues straight to me" type of thing. I omitted the "copyright" word for that purpose. GPLv2 is fine anyway, I'll add that ASAP.
b4n requested changes on this pull request.
Apart from the comments, LGTM
@@ -0,0 +1,56 @@
+# Arduino custom filetype +# +# By SukkoPera software@sukkology.net +# 2016/12/14
timestamp is recorded in Git, no need to add it here IMO, esp. as it'll get forgotten and then out of date in no time :)
+#
+# By SukkoPera software@sukkology.net +# 2016/12/14 +# + +[styling=C] + + +[keywords] +primary=and and_eq asm auto bitand bitor bool boolean break byte case catch char class compl const const_cast constexpr continue decltype default delete do double dynamic_cast else enum explicit extern false final float for friend goto if inline int int8_t int16_t int32_t int64_t long mutable namespace new noexcept not not_eq nullptr operator or or_eq override private protected ptrdiff_t public register reinterpret_cast return short signed sizeof size_t static static_assert static_cast struct switch template this throw true try typedef typeid typename uint8_t uint16_t uint32_t uint64_t union unsigned using virtual void volatile while xor xor_eq +secondary=abs analogRead analogReadResolution analogReference analogWrite analogWriteResolution attachInterrupt bit bitClear bitRead bitSet bitWrite constrain cos delay delayMicroseconds detachInterrupt digitalRead digitalWrite EEPROM Ethernet F highByte interrupts isAlpha isAlphaNumeric isAscii isControl isDigit isGraph isHexadecimalDigit isLowerCase isPrintable isPunct isSpace isUpperCase isWhitespace Keyboard LiquidCrystal loop lowByte map max micros millis min Mouse noInterrupts noTone pinMode pow PROGMEM pulseIn random randomSeed SD Serial Servo setup shiftIn shiftOut sin SoftwareSerial SPI sqrt Stepper tan tone Wire word yield + + +[lexer_properties] +styling.within.preprocessor=1 +lexer.cpp.track.preprocessor=0
IMO it should inherit C's properties: you use the same ones, and if it's plain C++ do as C++ does
+[styling=C] + + +[keywords] +primary=and and_eq asm auto bitand bitor bool boolean break byte case catch char class compl const const_cast constexpr continue decltype default delete do double dynamic_cast else enum explicit extern false final float for friend goto if inline int int8_t int16_t int32_t int64_t long mutable namespace new noexcept not not_eq nullptr operator or or_eq override private protected ptrdiff_t public register reinterpret_cast return short signed sizeof size_t static static_assert static_cast struct switch template this throw true try typedef typeid typename uint8_t uint16_t uint32_t uint64_t union unsigned using virtual void volatile while xor xor_eq +secondary=abs analogRead analogReadResolution analogReference analogWrite analogWriteResolution attachInterrupt bit bitClear bitRead bitSet bitWrite constrain cos delay delayMicroseconds detachInterrupt digitalRead digitalWrite EEPROM Ethernet F highByte interrupts isAlpha isAlphaNumeric isAscii isControl isDigit isGraph isHexadecimalDigit isLowerCase isPrintable isPunct isSpace isUpperCase isWhitespace Keyboard LiquidCrystal loop lowByte map max micros millis min Mouse noInterrupts noTone pinMode pow PROGMEM pulseIn random randomSeed SD Serial Servo setup shiftIn shiftOut sin SoftwareSerial SPI sqrt Stepper tan tone Wire word yield + + +[lexer_properties] +styling.within.preprocessor=1 +lexer.cpp.track.preprocessor=0 +preprocessor.symbol.$(file.patterns.cpp)=# +preprocessor.start.$(file.patterns.cpp)=if ifdef ifndef +preprocessor.middle.$(file.patterns.cpp)=else elif +preprocessor.end.$(file.patterns.cpp)=endif
Those 4 should be removed, they never did anything in Geany and were removed in 09796ef727aa430588ee12fa6c83223acd1794a2
+preprocessor.end.$(file.patterns.cpp)=endif
+ + +[settings] +lexer_filetype=C +tag_parser=C +extension=ino + +# context action command (please see Geany's main documentation for details) +context_action_cmd=xdg-open "https://www.arduino.cc/en/Reference/%s" + + +[indentation] +width=2 +# 0 is spaces, 1 is tabs, 2 is tab & spaces +type=0
`width` and `type` should always be commented out by default, unless it's a strict requirement of the language. This is because it'll override the global user setting, so should be used with extreme caution.
@codebrainz I here your concerns, but the fact it doesn't conflict and has had 3 reports (now 4) about it seem a reasonable enough reason to distribute it to me. Especially as it's fairly trivial to support.
@SukkoPera pushed 1 commit.
705b36e Remove header
@SukkoPera pushed 1 commit.
0805873 Remove useless lines
@SukkoPera pushed 1 commit.
cc1e1d4 Update filetypes.Arduino.conf
SukkoPera commented on this pull request.
@@ -0,0 +1,56 @@
+# Arduino custom filetype +# +# By SukkoPera software@sukkology.net +# 2016/12/14
I put the date there as I plan to maintain the filetype on my own and submit it upstream from time to time. This way I can see immediately if I did any updates but well, I'll just remove this header, as it seems to cause more concerns than benefits :).
SukkoPera commented on this pull request.
+#
+# By SukkoPera software@sukkology.net +# 2016/12/14 +# + +[styling=C] + + +[keywords] +primary=and and_eq asm auto bitand bitor bool boolean break byte case catch char class compl const const_cast constexpr continue decltype default delete do double dynamic_cast else enum explicit extern false final float for friend goto if inline int int8_t int16_t int32_t int64_t long mutable namespace new noexcept not not_eq nullptr operator or or_eq override private protected ptrdiff_t public register reinterpret_cast return short signed sizeof size_t static static_assert static_cast struct switch template this throw true try typedef typeid typename uint8_t uint16_t uint32_t uint64_t union unsigned using virtual void volatile while xor xor_eq +secondary=abs analogRead analogReadResolution analogReference analogWrite analogWriteResolution attachInterrupt bit bitClear bitRead bitSet bitWrite constrain cos delay delayMicroseconds detachInterrupt digitalRead digitalWrite EEPROM Ethernet F highByte interrupts isAlpha isAlphaNumeric isAscii isControl isDigit isGraph isHexadecimalDigit isLowerCase isPrintable isPunct isSpace isUpperCase isWhitespace Keyboard LiquidCrystal loop lowByte map max micros millis min Mouse noInterrupts noTone pinMode pow PROGMEM pulseIn random randomSeed SD Serial Servo setup shiftIn shiftOut sin SoftwareSerial SPI sqrt Stepper tan tone Wire word yield + + +[lexer_properties] +styling.within.preprocessor=1 +lexer.cpp.track.preprocessor=0
Well, I got those (and the 4 in the next change) exactly from filetypes.cpp (from Geany 1.22, I can't really update on this machine). I wanted to inherit as many settings as possible and keep the filetype to a minimum, but without these lines preprocessor directives weren't colored correctly. If these are redundant in newer versions of Geany I'll happily remove them.
SukkoPera commented on this pull request.
+[styling=C] + + +[keywords] +primary=and and_eq asm auto bitand bitor bool boolean break byte case catch char class compl const const_cast constexpr continue decltype default delete do double dynamic_cast else enum explicit extern false final float for friend goto if inline int int8_t int16_t int32_t int64_t long mutable namespace new noexcept not not_eq nullptr operator or or_eq override private protected ptrdiff_t public register reinterpret_cast return short signed sizeof size_t static static_assert static_cast struct switch template this throw true try typedef typeid typename uint8_t uint16_t uint32_t uint64_t union unsigned using virtual void volatile while xor xor_eq +secondary=abs analogRead analogReadResolution analogReference analogWrite analogWriteResolution attachInterrupt bit bitClear bitRead bitSet bitWrite constrain cos delay delayMicroseconds detachInterrupt digitalRead digitalWrite EEPROM Ethernet F highByte interrupts isAlpha isAlphaNumeric isAscii isControl isDigit isGraph isHexadecimalDigit isLowerCase isPrintable isPunct isSpace isUpperCase isWhitespace Keyboard LiquidCrystal loop lowByte map max micros millis min Mouse noInterrupts noTone pinMode pow PROGMEM pulseIn random randomSeed SD Serial Servo setup shiftIn shiftOut sin SoftwareSerial SPI sqrt Stepper tan tone Wire word yield + + +[lexer_properties] +styling.within.preprocessor=1 +lexer.cpp.track.preprocessor=0 +preprocessor.symbol.$(file.patterns.cpp)=# +preprocessor.start.$(file.patterns.cpp)=if ifdef ifndef +preprocessor.middle.$(file.patterns.cpp)=else elif +preprocessor.end.$(file.patterns.cpp)=endif
Done.
SukkoPera commented on this pull request.
+preprocessor.end.$(file.patterns.cpp)=endif
+ + +[settings] +lexer_filetype=C +tag_parser=C +extension=ino + +# context action command (please see Geany's main documentation for details) +context_action_cmd=xdg-open "https://www.arduino.cc/en/Reference/%s" + + +[indentation] +width=2 +# 0 is spaces, 1 is tabs, 2 is tab & spaces +type=0
Not really a strict requirement of course, just the indentation settings recommended by the Arduino guys. I actually don't even use these settings myself, so I'll comment them out.
@SukkoPera pushed 1 commit.
946e3bc Inherit lexer_properties from C
SukkoPera commented on this pull request.
+#
+# By SukkoPera software@sukkology.net +# 2016/12/14 +# + +[styling=C] + + +[keywords] +primary=and and_eq asm auto bitand bitor bool boolean break byte case catch char class compl const const_cast constexpr continue decltype default delete do double dynamic_cast else enum explicit extern false final float for friend goto if inline int int8_t int16_t int32_t int64_t long mutable namespace new noexcept not not_eq nullptr operator or or_eq override private protected ptrdiff_t public register reinterpret_cast return short signed sizeof size_t static static_assert static_cast struct switch template this throw true try typedef typeid typename uint8_t uint16_t uint32_t uint64_t union unsigned using virtual void volatile while xor xor_eq +secondary=abs analogRead analogReadResolution analogReference analogWrite analogWriteResolution attachInterrupt bit bitClear bitRead bitSet bitWrite constrain cos delay delayMicroseconds detachInterrupt digitalRead digitalWrite EEPROM Ethernet F highByte interrupts isAlpha isAlphaNumeric isAscii isControl isDigit isGraph isHexadecimalDigit isLowerCase isPrintable isPunct isSpace isUpperCase isWhitespace Keyboard LiquidCrystal loop lowByte map max micros millis min Mouse noInterrupts noTone pinMode pow PROGMEM pulseIn random randomSeed SD Serial Servo setup shiftIn shiftOut sin SoftwareSerial SPI sqrt Stepper tan tone Wire word yield + + +[lexer_properties] +styling.within.preprocessor=1 +lexer.cpp.track.preprocessor=0
Well, I had a look at the current filetypes.cpp and committed a change. I'll maintain my own separate version for this machine with 1.22.
b4n commented on this pull request.
@@ -0,0 +1,56 @@
+# Arduino custom filetype +# +# By SukkoPera software@sukkology.net +# 2016/12/14
I put the date there as I plan to maintain the filetype on my own and submit it upstream from time to time.
That's great :)
This way I can see immediately if I did any updates but well, I'll just remove this header, as it seems to cause more concerns than benefits :).
Well I don't really mind, it's comments after all, but I know from experience that this will get out of date at some point, and don't see much use for it.
b4n commented on this pull request.
+#
+# By SukkoPera software@sukkology.net +# 2016/12/14 +# + +[styling=C] + + +[keywords] +primary=and and_eq asm auto bitand bitor bool boolean break byte case catch char class compl const const_cast constexpr continue decltype default delete do double dynamic_cast else enum explicit extern false final float for friend goto if inline int int8_t int16_t int32_t int64_t long mutable namespace new noexcept not not_eq nullptr operator or or_eq override private protected ptrdiff_t public register reinterpret_cast return short signed sizeof size_t static static_assert static_cast struct switch template this throw true try typedef typeid typename uint8_t uint16_t uint32_t uint64_t union unsigned using virtual void volatile while xor xor_eq +secondary=abs analogRead analogReadResolution analogReference analogWrite analogWriteResolution attachInterrupt bit bitClear bitRead bitSet bitWrite constrain cos delay delayMicroseconds detachInterrupt digitalRead digitalWrite EEPROM Ethernet F highByte interrupts isAlpha isAlphaNumeric isAscii isControl isDigit isGraph isHexadecimalDigit isLowerCase isPrintable isPunct isSpace isUpperCase isWhitespace Keyboard LiquidCrystal loop lowByte map max micros millis min Mouse noInterrupts noTone pinMode pow PROGMEM pulseIn random randomSeed SD Serial Servo setup shiftIn shiftOut sin SoftwareSerial SPI sqrt Stepper tan tone Wire word yield + + +[lexer_properties] +styling.within.preprocessor=1 +lexer.cpp.track.preprocessor=0
Yeah inheritance of something else than style came up in a newer version than 1.22.
On a side note, this way of inheriting lexer_properties settings is not mentioned in the [docs](http://geany.org/manual/index.html#lexer-properties-section).
Good point, thanks. Well I think all sections can be inherited actually, but yeah we need to update the docs. @elextr will be happy to ~~do it~~ remind us :)
b4n commented on this pull request.
LGTM
b4n approved this pull request.
@codebrainz I here your concerns, but the fact it doesn't conflict and has had 3 reports (now 4) about it seem a reasonable enough reason to distribute it to me. Especially as it's fairly trivial to support.
The previous reports were just about adding the extensions to `filetype_extensions.conf` so the files would get detected as the proper C/C++ filetype that they are. It wasn't until @elextr [suggested a custom filetype](https://github.com/geany/geany/pull/1328#issuecomment-264328288) in passing that this became about adding a 2nd C/C++ filetype.
LGBI
codebrainz requested changes on this pull request.
Other than hardcoding one of many boards, everything else looks good to me.
+[indentation] +#width=2 +# 0 is spaces, 1 is tabs, 2 is tab & spaces +#type=0 + + +# Use this reference for making up Arduino command lines: +# https://github.com/arduino/Arduino/blob/master/build/shared/manpage.adoc +[build-menu] +FT_00_LB=_Build +FT_00_CM=arduino --verify "%d/%f" --board arduino:avr:uno +FT_00_WD= + +FT_01_LB=Build (_Verbose) +FT_01_CM=arduino --verify --verbose-build "%d/%f" --board arduino:avr:uno
Is the UNO a really common board and/or compatible with other boards? Like if I had a LilyPad with an ATmega168V, is this default going give me a bad time?
codebrainz commented on this pull request.
+[indentation] +#width=2 +# 0 is spaces, 1 is tabs, 2 is tab & spaces +#type=0 + + +# Use this reference for making up Arduino command lines: +# https://github.com/arduino/Arduino/blob/master/build/shared/manpage.adoc +[build-menu] +FT_00_LB=_Build +FT_00_CM=arduino --verify "%d/%f" --board arduino:avr:uno +FT_00_WD= + +FT_01_LB=Build (_Verbose) +FT_01_CM=arduino --verify --verbose-build "%d/%f" --board arduino:avr:uno
According to [the docs](https://github.com/arduino/Arduino/blob/master/build/shared/manpage.adoc) this could be left out.
SukkoPera commented on this pull request.
+[indentation] +#width=2 +# 0 is spaces, 1 is tabs, 2 is tab & spaces +#type=0 + + +# Use this reference for making up Arduino command lines: +# https://github.com/arduino/Arduino/blob/master/build/shared/manpage.adoc +[build-menu] +FT_00_LB=_Build +FT_00_CM=arduino --verify "%d/%f" --board arduino:avr:uno +FT_00_WD= + +FT_01_LB=Build (_Verbose) +FT_01_CM=arduino --verify --verbose-build "%d/%f" --board arduino:avr:uno
The Uno is the "standard" Arduino nowadays, definitely the most common one. Of course I would love to have a board selection menu, but I guess we need a plugin rather than a filetype, for that. In fact, I am actually considering the possibility of writing an Arduino plugin.
That option can only be left out if you want to compile for the latest board that you selected in the Arduino IDE, but I think it is more practical to override it by customizing the command line in the project settings, rather than having to open the Arduino IDE and change the board there. If I have to do that, at that point I can just hit the Compile button in the IDE to do the build.
codebrainz commented on this pull request.
+[indentation] +#width=2 +# 0 is spaces, 1 is tabs, 2 is tab & spaces +#type=0 + + +# Use this reference for making up Arduino command lines: +# https://github.com/arduino/Arduino/blob/master/build/shared/manpage.adoc +[build-menu] +FT_00_LB=_Build +FT_00_CM=arduino --verify "%d/%f" --board arduino:avr:uno +FT_00_WD= + +FT_01_LB=Build (_Verbose) +FT_01_CM=arduino --verify --verbose-build "%d/%f" --board arduino:avr:uno
Of course I would love to have a board selection menu, but I guess we need a plugin rather than a filetype, for that. In fact, I am actually considering the possibility of writing an Arduino plugin.
That would be cool.
but I think it is more practical to override it by customizing the command line in the project settings in Geany
Sounds reasonable.
codebrainz approved this pull request.
Closed #1339 via 21b37f553fdcaa37463465bd24d9ca5537800f0a.
@codebrainz thanks!
github-comments@lists.geany.org