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

C/C++: replace dot operator with arrow operator intelligently #9738

Closed
GeekZJJ opened this issue Feb 27, 2024 Discussed in #9685 · 3 comments
Closed

C/C++: replace dot operator with arrow operator intelligently #9738

GeekZJJ opened this issue Feb 27, 2024 Discussed in #9685 · 3 comments

Comments

@GeekZJJ
Copy link

GeekZJJ commented Feb 27, 2024

I try to use helix to replace vscode to write C/C++ code recently. But I notice that helix can't show the struct member suggestions when I type a . after a struct pointer automatically. I use the same clangd args in vscode, everything works fine. So I'm guessing this is a feature we haven't being implemented currently.
In order to troubleshoot this, I turn on clangd --log=verbose flag and find out helix doesn't send context.triggerCharacter and context.triggerKind to clangd. Maybe it's the root cause of this problem. But I didn't find out how to modify this behavior.

  • helix's clangd output
I[12:28:28.089] <-- textDocument/didChange
V[12:28:28.089] <<< {
  "id": 4,
  "jsonrpc": "2.0",
  "method": "textDocument/completion",
  "params": {
    "position": {
      "character": 8,
      "line": 9
    },
    "textDocument": {
      "uri": "file://******/main.c"
    }
  }
}
  • vscode's clangd output
I[12:29:34.626] <-- textDocument/didChange
V[12:29:34.652] <<< {
  "id": 24,
  "jsonrpc": "2.0",
  "method": "textDocument/completion",
  "params": {
    "context": {
      "triggerCharacter": ".",
      "triggerKind": 2
    },
    "position": {
      "character": 8,
      "line": 9
    },
    "textDocument": {
      "uri": "file://******/main.c"
    }
  }
}

Originally posted by @GeekZJJ in #9685 (reply in thread)

Discussed in #9685

Originally posted by GeekZJJ February 21, 2024
Hi! I try to use helix to replace vscode to write C/C++ code recently. Everything is good, but I notice that helix can't show the struct member suggestions when I type a . after a struct pointer automatically. I use the same clangd args in vscode, everything works fine. So I'm guessing this is a feature we haven't being implemented currently. Am I right?
My language.toml file is as below:

[language-servers.clangd]
command = "/usr/bin/clangd"
args = ["--pretty", "--background-index", "-j=2", "--clang-tidy", "--clang-tidy-checks=performance-*,bugprone-*", "--all-scopes-completion", "--completion-style=detailed", "--header-insertion=iwyu", "--pch-storage=disk"]

[[language]]
name = "c"
language-servers = ["clangd"]
auto-format = false

Edited:
I found that in the language.toml file I make some mistake, which make clangd's args I configured don't make any sense. The [language-servers.clangd] should be [language-server.clangd]. Correct file is as below.

[language-server.clangd]
command = "/usr/bin/clangd"
args = ["--pretty", "--background-index", "-j=2", "--clang-tidy", "--clang-tidy-checks=performance-*,bugprone-*", "--all-scopes-completion", "--completion-style=detailed", "--header-insertion=iwyu", "--pch-storage=disk"]

[[language]]
name = "c"
language-servers = ["clangd"]
auto-format = false
@the-mikedavis
Copy link
Member

No need to duplicate the discussion. If we can narrow down the exact cause of the difference between vscode and helix then we can make an issue focusing on that but this is just fragmenting the debugging discussion

@the-mikedavis the-mikedavis closed this as not planned Won't fix, can't repro, duplicate, stale Feb 27, 2024
@pascalkuthe
Copy link
Member

@GeekZJJ
Copy link
Author

GeekZJJ commented Feb 28, 2024

@the-mikedavis Got that. So sorry for my duplicate post.
@pascalkuthe Maybe that is because of my out of date helix version. I will try it when ppa:maveonair/helix-editor have an update version with the commit mentioned above. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants