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

Cquery highlight support? #299

Closed
cossonleo opened this issue Jan 27, 2018 · 7 comments
Closed

Cquery highlight support? #299

cossonleo opened this issue Jan 27, 2018 · 7 comments

Comments

@cossonleo
Copy link
Contributor

Is there a plan for supporting cquery highlight?

@autozimu
Copy link
Owner

autozimu commented Jan 27, 2018 via email

@cossonleo
Copy link
Contributor Author

cossonleo commented Jan 27, 2018

@autozimu
Cquery implement feature of semantic highlighting
Is there a plan to support it?

screenshot_20180127_160142

@autozimu
Copy link
Owner

@MaskRay Were you able to point to some docs detailing this API?

@MaskRay
Copy link
Contributor

MaskRay commented Jan 30, 2018

Here the issue is that aside from generic language client framework (e.g. LanguageClient-neovim lsp-mode), there should be language server-specific plugins for different language servers, because servers may provide extensions or need adaptation.

See https://github.com/emacs-lsp for a list of language-specific plugins in the Emacs land.

I learned that Vim/Neovim matchaddpos() is very limited and only supports a small number of overlays (8).

If someone decides to implement it, the response messages is defined in https://github.com/cquery-project/cquery/blob/master/src/message_handler.h#L27 and here is an example:

  • stableId: identifier
  • SymbolKind parentKind: the client may use it to differentiate global variables with local variables. No clients has exploited this information yet.
  • ClangSymbolKind kind: similar with LSP namespace SymbolKind, but Clang specific. This is used to differentiate methods/functions/variables/namespaces/... I didn't use LSP SymbolKind because it misses: ClassMethod,StaticMethod, InstanceProperty, ClassProperty, StaticProperty, Destructor, ConversionFunction.
  • StorageClass storage: static / auto / none. Can be used to differentiate static variables vs global variables.
{
  "jsonrpc": "2.0",
  "method": "$cquery/publishSemanticHighlighting",
  "params": {
    "uri": "file:///tmp/c/a.cc",
    "symbols": [
      {
        "stableId": 6,
        "parentKind": 3,
        "kind": 13,
        "storage": 1,
        "ranges": [
          {
            "start": {
              "line": 10,
              "character": 18
            },
            "end": {
              "line": 10,
              "character": 21
            }
          }
        ]
      },
      {
        "stableId": 5,
        "parentKind": 3,
        "kind": 25,
        "storage": 1,
        "ranges": [
          {
            "start": {
              "line": 8,
              "character": 25
            },
            "end": {
              "line": 8,
              "character": 26
            }
          },
          {
            "start": {
              "line": 9,
              "character": 4
            },
            "end": {
              "line": 9,
              "character": 5
            }
          }
        ]
      },
      {
        "stableId": 4,
        "parentKind": 0,
        "kind": 16,
        "storage": 0,
        "ranges": [
          {
            "start": {
              "line": 8,
              "character": 7
            },
            "end": {
              "line": 8,
              "character": 10
            }
          }
        ]
      },
      {
        "stableId": 0,
        "parentKind": 0,
        "kind": 7,
        "storage": 0,
        "ranges": [
          {
            "start": {
              "line": 1,
              "character": 7
            },
            "end": {
              "line": 1,
              "character": 17
            }
          },
          {
            "start": {
              "line": 2,
              "character": 2
            },
            "end": {
              "line": 2,
              "character": 12
            }
          },
          {
            "start": {
              "line": 8,
              "character": 11
            },
            "end": {
              "line": 8,
              "character": 21
            }
          },
          {
            "start": {
              "line": 10,
              "character": 4
            },
            "end": {
              "line": 10,
              "character": 14
            }
          }
        ]
      }
    ]
  }
}

@autozimu
Copy link
Owner

For nvim, the API nvim_buf_add_highlight might be a good fit in this case. And for vim, there isn't a proper way to do it as far as I know.

@MagBad
Copy link

MagBad commented Jul 6, 2018

For C++ on Neovim it's possible to use chromatica which basically does the requesting task. The issue is also related to #383 respectively.

@martskins
Copy link
Collaborator

I'll close this one as semantic highlighting is now supported.

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

5 participants