MattDMo/Neon-color-scheme

C++ Ambiguous Colours

kgizdov opened this issue · 6 comments

I'm not sure if it's intended or not, but I get this after the recent major update:
syntax

I checked (as per the README) with the online theme editor and it seems function arguments should be italic and functions should have different colours, but they don't. The above is just an example, my code is basically a lot of the same green now. I wonder if this is a SublimeText issue or not. Any tips to resolve this?

Thanks.

EDIT: I'm on Build 3114 if that matters

Can you give me some plain text I can plug into Sublime and test? Preferably a full function, so I can see all the relevant scopes. Also, are you using the builtin C++ syntax, or a third-party one?

Here's a quick fix, while I push out a new version:

Select Preferences -> Browse Packages..., browse to the Neon Color Scheme folder, and open Neon.tmTheme in Sublime with XML syntax. Replace lines 2075 through 2089 with the following:

        <dict>
            <key>name</key>
            <string>C++ Function arguments</string>
            <key>scope</key>
            <string>meta.function-call.c++ meta.group.c++</string>
            <key>settings</key>
            <dict>
                <key>fontStyle</key>
                <string>italic</string>
                <key>foreground</key>
                <string>#2BB71D</string>
            </dict>
        </dict>

This will now make the function arguments appear the same as in any other language, a slightly darker green and italicized. Please let me know if this messes up something else!

I'm using the built-in syntax for C++. Should I be using something else?
Example main.c

int main(int argc, char const *argv[]) {
    if (argc <= 2 || argc > 3) {
        std::cerr << "ERROR: Wrong number of arguments" << std::endl;
        std::cerr << "USAGE: status <IP> <PORT>" << std::endl;
        writeToParent("er");
        exit(-1);
    }
    std::string prefix, ip, port;
    prefix = "ws://";
    ip = std::string(argv[1]);
    port = std::string(argv[2]);
    ws = WS::from_url(prefix + ip +":" + port);
    assert(ws);
    pthread_mutex_lock(&wait_);
    ws->send("Status?");
    ws->poll();
    pthread_mutex_unlock(&wait_);
    if (ws->getReadyState() != WS::CLOSED) {
        ws->poll(1000);
        ws->dispatch(handle_status);
    }

    bool comm_ok = true;
    bool debug = true;
    char * commBuf = new char[1024];
    while (ws->getReadyState() != WS::CLOSED && ws->getReadyState() != WS::CLOSING) {
        for (unsigned received = 0; received < sizeof(msg_t); ) {
    ...

Example class

#ifndef __CLASS_HPP__
#define __CLASS_HPP__

#include <string>

#include "./custom.hpp"

// headers
// #undef WIN32
#include "./some.h"
#include "./thing.h"
#include "./omg.h"
// #define WIN32 1

class Hello {
 public:
    Hello();
    ~Hello();
    explicit Hello(std::string name);
    std::string getHello(int idx);
    int open(std::string String);
    int close();
    int getSet(byte addr[], size_t addr_size, byte data[], size_t data_size);
    void putSet(byte buf[], size_t buf_size);
 protected:
    bool OK();
    void connect();
 private:
    TYPE _fif;
    bool _isOK;
    std::string _name;
};

#endif  // __CLASS_HPP__

Example header

#define getVarName(var) #var

typedef uint8_t byte;
typedef uint16_t byte16_t;

const uint32_t kBufSendSize = 388;
const uint32_t kMsgSize = 1024;

struct aStruct {
    bool enable;
    std::string fff;
};

union __int {
    byte b[sizeof(int32_t)];
    int32_t i;
};

Hello::Hello() : _fif(fifInvalid), _isOK(false), _name("Hello") {}

Hello::~Hello() {}

Forgot to mention:
IN HEADER:
head
IN C FILE:
not_head
Why the inconsistency of std:: or other :: for classes, etc?

Also, I noticed that unions are not highlighted properly.
union

I'm going to mark this as resolved after these many years. A lot of improvements have been made to the default C/C++ syntaxes (and to Neon), and the example code in this issue just looks a lot better overall than it did in 2016.