Geany syntax highlighting questions - templates

1) Are there any Geany users here who have gotten good syntax highlighting for Scala?
2) What should I do about syntax highlighting when I'm editing (Mako) templates that are generating things other than HTML/CSS/JS? (say, C/C++ code, or w/e) Is good syntax highlighting too much to ask out of Geany in this case (or any other editor, for that matter)?

I just wanted to chime in to note that the latest version of geany (1.22) does have syntax highlighting for Scala - it's rudimentary, but it will at least highlight comments and a few keywords. Annoyingly, the support is initially only activated for files named Foo.scl, rather than using the standard convention of Foo.scala, but this can be changed by modifying /usr/share/geany/filetype_extensions.conf (the format is pretty obvious).

Related

Vim isnt highlighting basic types in c/c++

I have recently started using vim and i see my syntax files are located in /usr/share/vim/vim74 (I'm on linux Mint) and my c.vim seems to make the basic things like int and double keywords however when I edit any c or c++ files none of the types are highlighted however some things like const are highlighted. I am not sure why this is happening. Can anyone help me out?
To check whether the syntax parsing works as expected, check (when editing a C / C++ file) with
:syntax list
that those keywords (like int) are defined. You'll also get a preview of the highlight coloring there. Alternatively, the colors are shown via
:highlight
To change those, you have to switch to another :colorscheme or edit / augment the current one.
For advanced troubleshooting, I recommend the SyntaxAttr.vim - Show syntax highlighting attributes of character under cursor plugin.

How can I configure Emacs to highlight C++ that violate a detailed code style?

I've been researching existing C++ code style tools and have yet to find any packages which will allow me to highlight sections of a file which break a detailed code style configuration. While there seem to be several options for basic code style settings (what should/shouldn't be indented, line length > some threshold, etc), other issues do not seem to be addressed. For context, I'm hoping to be able to recognize when I do the following:
{ on same line as function definition (should be next line)
{ on next line after if statement (should be same line)
no space between ) and {
no space between comparisons (should be a == b instead of a== b,a==b, etc)
consecutive new lines
type *var_name or type * var_name instead of type* var_name
and so on...
This style is heavily enforced on my team, and I am having difficulty minimizing inconsistencies. I'm looking for either an existing emacs tool which allow me to customize these settings extensively, or suggestions on how to create an emacs package myself identifies these errors.
As Noufal suggests, Flymake is one option.
Another is Flycheck. I switched from Flymake to Flycheck a few years ago and haven't looked back. Flycheck supports a large number of languages and tools, and seems to require less hand-holding than Flymake.
From its GitHub README:
Features
Supports over 30 programming and markup languages with more than 60 different syntax checking tools
Fully automatic, fail-safe, on-the-fly syntax checking in background
Nice error indication and highlighting
Optional error list popup
Many customization options
A comprehensive manual
A simple interface to define new syntax checkers
A “doesn't get in your way” guarantee
Many 3rd party extensions
For C and C++ code, Flycheck supports Clang and Cppcheck out of the box, and there is a plugin for Google's C++ style guide as well.
And of course you can add your own checkers if you wish.
If you can configure your tool to emit output in the format that can be understood by flymake, it should be able to do it.
Many tools such as gcc itself and others do this so that flymake works.

vim ctag leading to the wrong definition of fun

I'm using vim's ctag to navigate through c++ codes.
in many cases it's working all right.
but there're some errors when:
vector<int> v;
v.push_back(10);
when i'm navigating from the "push_back" here, it brings me to /usr/include/c++/4.4.7/bits/basic_string.h 's push_back()
I'm wondering if it's a bug of or drawback of vim/ctags ?
thansk!
Vim's tag navigation is not syntax-tree-aware. By default it jumps to the first matching tag from the tags file.
ctags just jumps to first to first matching tag: "push_back()". It does not know that type of "v" is "std::vector". The only way to fix this problem is not to use ctags.
I tried different vim plugins, but most of them are not working correctly or not working at all for c++.
There are plugins clang_complete and YouCompleteMe, that use clang C++ compiler to generate syntax tree. They are for autocompletion, but they also provide functionality to navigate in c++ code.
YouCompleteMe is much faster then clang_complete, but I think it is more difficult to install and configure it.
https://github.com/Valloric/YouCompleteMe
https://github.com/Rip-Rip/clang_complete

Eclipse copy code with syntax highlighting

I'm writing a document of programming guidelines for my developers team. I use MS Word. We work with Eclipse CDT (C++). I need to copy-paste C++ code with syntax highlighting from Eclipse to Word. I've tried Notepad++ and it can export text with syntax highlighting, but it's highlighting is limited to basic syntax (it doesn't know about defined class, enum etc...).
Eclipse syntax highlighting is very powerful and I wish to export directly from Eclipse to Word using it's syntax highlighting.
Is there any Eclipse plugin that achieve this purpose? Or some trick to do it (without taking a screen snapshot)?
When you copy the code to word document, you can choose the option "keep source formatting" and the highlighting will be the same as the one in eclipse.
EDIT:
As mentioned in the comments below, this won't work on folded code, so you can right click on the line numbers and select Folding > Expand All
EDIT 2:
Also mentioned in the comments, as of eclipse oxygen, the code is automatically copied with syntax highlighting
When I copy from Eclipse straight to PowerPoint some of the formatting is messed up. Bold and color seems to "keep going". But if I copy from Eclipse to Word -- and then from Word to PowerPoint (with the keep source formatting CNTRL-K) -- the formatting is correct. I recently upgraded Eclipse to Mars and Office to 2013. I still have to go through Word first.
I was trying it too and for some reason not every compile unit would keep the formating.
After a while I've seen that you also won't get the formating kept if there are parts of the code hidden, so for the ones that cannot make it work with the answers above, just make sure that there are no "+" signs on the left of your code (mine were where the imports at the beggining).
Copying of formatting is supported since version 3.2
Note that everything is copied: highlighting of spelling errors, marked variables/types/etc and underscoring of warnings/errors.
To avoid that, turn off spell checking, "Mark Occurrences" and "Report problems as you type" respectively.

Customized C++ Syntax Highlighting in Eclipse CDT? (e.g. highlight all asserts)

i just wanted to know if there is an easy way to tell Eclipse (Helios Service Release 1) that every line in my code which is part of an assertion should be highlighted in a chosen color.
I'm aware of the fact, that assertions could be arbitrarily complex, so that parsing is needed. But maybe Eclipse supports something like "highlight all occurences of this function" out of the box.
Thanks.
Sascha