Skip to content

QUESTION: i cant add a new language #4127

@amtoine

Description

@amtoine

hello there 👋

it's my first issue here and i have to admit i've been enjoying this new (to me) editor for a few days now and it's really cool 😋

my situation

currently, i'm an intern and i work on the Oberon programming language
it is one of the successors of pascal and modula 2 and shares a syntax very similar to pascal

however, neither modula and oberon are known to helix, which is quite expected 😉 😏

what works

i've been able to

sudo helix --grammar fetch
sudo helix --grammar build

which both now give me

Fetching 107 grammars
107 up to date git grammars

and

Building 107 grammars
107 grammars already built

respectively 👌

my problem

i tried, thanks to the Adding Languages and the Language sections of the documentation, to add a new language to my ~/.config/helix/languages.toml

[[language]]
name = "oberon"
scope = "source.oberon"
injection-regex = "oberon"
file-types = ["obn", "Mod", "mod"]
roots = []
comment-token = "(*"
indent = { tab-width = 4, unit = "  " }

[[grammar]]
name = "oberon"
source = { git = "https://github.com/Isopod/tree-sitter-pascal", rev = "2fd40f477d3e2794af152618ccfac8d92eb72a66" }

you can see the special extensions, the special comment token and i'm using the same grammar as pascal 👍

but now, when i run

sudo helix --grammar fetch
sudo helix --grammar build

i get the same 107 as before, and not 108 with oberon 😕

and when i try to build without sudo, it recognizes the new language

> hx --grammar build
Building 108 grammars
107 grammars already built
1 grammars failed to build
	Failure 0/1: Failed to read directory "/var/lib/helix/runtime/grammars/sources/oberon". Did you use 'hx --grammar fetch'?

but then, does not have the permissions to do anything...

> hx --grammar fetch
...
Failure 100/108: Could not create grammar directory "/var/lib/helix/runtime/grammars/sources/oberon"
...

what is happening? 😱

additional information

i'm using:

  • ArchLinux version 5.19.10-arch1-1
  • alacritty version 0.10.1
  • nushell version 0.67.0
  • helix version 22.08.1 (which is the latest i believe)

temporary workaround

i can simply extend the types of the pascal language with a simpler languages.toml file

[[language]]
name = "pascal"
file-types = ["pas", "pp", "inc", "lpr", "lfm", "obn", "mod", "Mod"]

it works fine but the oberon files are recognized as pascal source files and it's not very satisfying right? 😉

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions