Helix & Hackatime Setup

Helix

Follow these steps to start tracking your coding in Helix with Hackatime:

1: Log in to Hackatime

hackatime.hackclub.com

Sign in with your Hackatime account (or create one if you don't have one yet)!

2: Set up Hackatime

Follow the instructions on the site, then copy the command into whatever terminal program you use. (The command will be different on Windows - make sure to pick the right one!)

This will set some environment variables and tell Hackatime where to "phone home" when you're working.

💡 Visit our setup page to automatically configure everything!

3: Install Helix

docs.helix-editor.com

Download the Helix binary, or if you know what you're doing, use your distro's package manager for any special builds!

4: Install wakatime-cli

github.com/wakatime/wakatime-cli

This binary is required for Helix to be able to send your time to Hackatime.

You can check that it's installed correctly through your PATH environment variable by running which wakatime-cli or which wakatime (Linux/macOS) or where wakatime-cli or where wakatime (Windows) in your terminal.

5: Install wakatime-ls

github.com/mrnossiom/wakatime-ls

You can either download the binary from GitHub Releases, or if you have cargo installed: cargo install wakatime-ls.

Please note that there are no binaries for Windows available on GitHub releases, if you're on Windows, you will have to use cargo install wakatime-ls

You can check that it's installed correctly through your PATH environment variable by running which wakatime-ls (Linux/MacOS) or where wakatime-ls (Windows) in your terminal.

6: Configure Helix's languages

The way this method works relies on having an LSP tracking your code changes, as Helix does not currently have a plugin system. This means that you have to add this LSP to every language you're planning to use.

Start by creating a languages.toml file in the Helix configuration directory. On Linux/MacOS, this would be ~/.config/helix/languages.toml, and on Windows it would be %AppData%\helix\languages.toml.

Register the LSP

Inside Helix's languages.toml file, add the following content:

[language-server.wakatime]
command = "wakatime-ls"

This registers the Wakatime LSP in Helix, allowing it to be used for other languages.

Add the LSP to your languages

  1. Find the language you want to track in the master languages.toml. For example, the master Rust configuration looks like this:
[[language]]
name = "rust"
scope = "source.rust"
injection-regex = "rs|rust"
file-types = ["rs"]
roots = ["Cargo.toml", "Cargo.lock"]
shebangs = ["rust-script", "cargo"]
auto-format = true
comment-tokens = ["//", "///", "//!"]
block-comment-tokens = [
  { start = "/*", end = "*/" },
  { start = "/**", end = "*/" },
  { start = "/*!", end = "*/" },
]
language-servers = [ "rust-analyzer" ]
indent = { tab-width = 4, unit = "    " }
persistent-diagnostic-sources = ["rustc", "clippy"]
  1. Copy the [[language]] header, the name property, and the language servers property to your own languages.toml:
[[language]]
name = "rust"
language-servers = [ "rust-analyzer" ]
  1. Add "wakatime" to the list of language-servers:
[[language]]
name = "rust"
language-servers = [ "rust-analyzer", "wakatime" ]
  1. Your final languages.toml may look something like this:
[language-server.wakatime]
command = "wakatime-ls"

[[language]]
name = "rust"
language-servers = [ "rust-analyzer", "wakatime" ]
  1. If you want to add more languages, simply repeat these steps! Here's an example with Ruby and Javascript:
[language-server.wakatime]
command = "wakatime-ls"

[[language]]
name = "rust"
language-servers = [ "rust-analyzer", "wakatime" ]

[[language]]
name = "ruby"
language-servers = [ "ruby-lsp", "solargraph", "wakatime" ]

[[language]]
name = "javascript"
language-servers = [ "typescript-language-server", "wakatime" ]

All done!

After you're finished setting everything up, restart Helix, then make sure to check hackatime.hackclub.com after a little while and ensure you're logging progress!

You can also try some wakatime.com/plugins if you'd like to log time spent editing your project in other programs.

Troubleshooting

  • Not seeing your time? Make sure you completed the setup page first.
  • LSP hasn't started? Type :lsp-restart in Helix for it to autocomplete the active LSPs. If wakatime isn't listed, then it's not setup in your languages.toml correctly.
  • Language server exited? This error will show up if you haven't installed everything correctly. Double check that wakatime and wakatime-ls are installed using which (Linux/MacOS) or where (Windows).
  • Still stuck? Ask for help in Hack Club Slack (#hackatime-help channel)
Found an issue with this page? Edit on GitHub

Using Inertia. Build 28fe4739 from 36 minutes ago. 386809 heartbeats (4284 imported) in the past 24 hours. (DB: 2 queries, 0 cached) (CACHE: 0 hits, 0 misses) (0.3 req/sec)