wakatime / zed-wakatime

A WakaTime extension for Zed.
https://wakatime.com/zed
MIT License
49 stars 4 forks source link

It doesn't work with C++ files? #4

Closed rakim-0 closed 1 month ago

rakim-0 commented 1 month ago

Wakatime doesn't show up in lsp debug. I can only logs for clang

stderr: I[02:29:59.578] PID: 188986
stderr: I[02:29:59.578] Working directory: /home/rakim/programming-stuff/cp+dsa
stderr: I[02:29:59.578] argv[0]: /usr/bin/clangd
stderr: I[02:29:59.578] Starting LSP over stdin/stdout
stderr: I[02:29:59.578] <-- initialize(0)
stderr: I[02:29:59.579] --> reply:initialize(0) 0 ms
stderr: I[02:29:59.581] <-- initialized
stderr: I[02:29:59.581] <-- workspace/didChangeConfiguration
stderr: I[02:29:59.581] <-- textDocument/didOpen
stderr: I[02:29:59.581] <-- textDocument/didOpen
stderr: I[02:29:59.581] Failed to find compilation database for /home/rakim/programming-stuff/cp+dsa/leetcode/lc-1671.cpp
stderr: I[02:29:59.581] ASTWorker building file /home/rakim/programming-stuff/cp+dsa/leetcode/lc-1671.cpp version 0 with command clangd fallback
stderr: [/home/rakim/programming-stuff/cp+dsa/leetcode]
stderr: /usr/bin/clang -resource-dir=/usr/lib64/clang/18 -- /home/rakim/programming-stuff/cp+dsa/leetcode/lc-1671.cpp
stderr: I[02:29:59.581] Failed to find compilation database for /home/rakim/programming-stuff/cp+dsa/interesting_stuff/dp-1-get-all-interesting-substrings.cpp
stderr: I[02:29:59.581] ASTWorker building file /home/rakim/programming-stuff/cp+dsa/interesting_stuff/dp-1-get-all-interesting-substrings.cpp version 0 with command clangd fallback
stderr: [/home/rakim/programming-stuff/cp+dsa/interesting_stuff]
stderr: /usr/bin/clang -resource-dir=/usr/lib64/clang/18 -- /home/rakim/programming-stuff/cp+dsa/interesting_stuff/dp-1-get-all-interesting-substrings.cpp
stderr: I[02:29:59.853] Built preamble of size 2282016 for file /home/rakim/programming-stuff/cp+dsa/leetcode/lc-1671.cpp version 0 in 0.27 seconds
stderr: I[02:29:59.854] Indexing c++17 standard library in the context of /home/rakim/programming-stuff/cp+dsa/leetcode/lc-1671.cpp
stderr: I[02:29:59.880] --> textDocument/publishDiagnostics
stderr: I[02:30:00.022] Built preamble of size 3619304 for file /home/rakim/programming-stuff/cp+dsa/interesting_stuff/dp-1-get-all-interesting-substrings.cpp version 0 in 0.44 seconds
stderr: I[02:30:00.050] --> textDocument/publishDiagnostics
stderr: I[02:30:00.132] <-- workspace/didChangeConfiguration
stderr: I[02:30:01.393] Indexed c++17 standard library (incomplete due to errors): 14161 symbols, 1810 filtered

my config:

{
    "vim_mode": true,
    "ui_font_size": 16,
    "ui_font_family": "Zed Plex Mono",
    "buffer_font_family": "Iosevka Nerd Font",
    "buffer_font_size": 20,
    "tab_size": 4,
    "theme": {
        "mode": "system",
        "light": "One Light",
        "dark": "Ayu Mirage"
    },
    "lsp": {
        "wakatime": {
            "settings": {
                "api-key":"<key>"
            }
        },
        "biome": {
            "settings": {
                "config_path": "/home/rakim/biome.json"
            }
        }
    },
    "languages": {
        "json": {
            "formatter": {
                "language_server": {
                    "name": "biome"
                }
            }
        },
        "jsonc": {
            "formatter": {
                "language_server": {
                    "name": "biome"
                }
            }
        },
        "cpp": {
            "formatter": {
                "external": {
                    "command": "/usr/bin/clang-format",
                    "arguments": [
                        "--style=file",
                        "--assume-filename={buffer_path}"
                    ]
                }
            },
            "lsp": {
                "wakatime": {
                    "settings": {
                        "api-key": "<key>"
                    }
                }
            }
        }
    },
    "buffer_font_features": {
        "calt": false
    },
    "format_on_save": "on",
    "code_actions_on_format": {
        "source.fixAll.biome": true,
        "source.organizeImports.biome": true
    }
}
rakim-0 commented 1 month ago

It works fine with json or python files though so I'm just confused on how to fix it

bestgopher commented 1 month ago

Hi, it is working fine on my pc. image

rakim-0 commented 1 month ago

I've been going through the logs. C++ files sometimes shows up, sometimes doesn't.
Anything else I can check to debug this?

Also could it be that it's conflicting with another LSP like clang? nvm adding C++ to extension.toml and loading it as a dev extension seemed to fix it.

LOGS: ``` Wakatime language server initialized Wakatime command: "/home/rakim/.local/bin/wakatime-cli" "--time" "1730396537" "--write" "false" "--entity" "/home/rakim/programming-stuff/cp+dsa/leetcode/hello.c" "--plugin" "Zed/0.159.6 Zed-wakatime/0.1.4" "--language" "c" Wakatime command: "/home/rakim/.local/bin/wakatime-cli" "--time" "1730396565" "--write" "false" "--entity" "/home/rakim/programming-stuff/cp+dsa/leetcode/hello.py" "--plugin" "Zed/0.159.6 Zed-wakatime/0.1.4" "--language" "python" Wakatime command: "/home/rakim/.local/bin/wakatime-cli" "--time" "1730396565" "--write" "false" "--entity" "/home/rakim/programming-stuff/cp+dsa/leetcode/hello.py" "--plugin" "Zed/0.159.6 Zed-wakatime/0.1.4" "--language" "python" Wakatime command: "/home/rakim/.local/bin/wakatime-cli" "--time" "1730396582" "--write" "false" "--entity" "/home/rakim/programming-stuff/cp+dsa/leetcode/hello.py" "--plugin" "Zed/0.159.6 Zed-wakatime/0.1.4" "--guess-language" "--lineno" "0" "--cursorpos" "0" Wakatime command: "/home/rakim/.local/bin/wakatime-cli" "--time" "1730396608" "--write" "false" "--entity" "/home/rakim/programming-stuff/cp+dsa/leetcode/hello.py" "--plugin" "Zed/0.159.6 Zed-wakatime/0.1.4" "--language" "python" Wakatime command: "/home/rakim/.local/bin/wakatime-cli" "--time" "1730396774" "--write" "true" "--entity" "/home/rakim/programming-stuff/cp+dsa/leetcode/hello.cpp" "--plugin" "Zed/0.159.6 Zed-wakatime/0.1.4" "--guess-language" ```
bestgopher commented 1 month ago

@rakim-0 I have released v0.1.5. You will be able to update to the new version once the PR is merged.

rakim-0 commented 1 month ago

Thank you!