this is a stretch goal, i know it's a bunch of work and i don't expect you to do a bunch of free labour. just jotting my thoughts down so i don't lose them.
racket is a meta-language for building programming languages. each language in the racket ecosystem identifies itself through a #lang my-lang at the top of the file (docs1). furthermore, each language may possibly have a different file extension. in an ideal world, a racket plugin would support all languages built on top of racket, not just racket itself and some hand-coded extensions.
there are three main ways to detect whether a given file is built on top of racket.
- sniff the shebang.
- sniff the
#lang attribute.
info.rkt files record the file extension used by a given language. @jackfirth tells me the recommended interface to this is get-module-suffixes, which we could call with e.g. racket -e '(require compiler/module-suffix) (print (get-module-suffixes))'
this plugin already partly does 1 and 2. but it only does so for a hard-coded list of file extensions. part of this work would be to do it for any racket file; probably by caching the racket -e output. we could avoid unnecessary work by only running if we see a #lang header.
once we discover the filetype, there are 4 main things we want to support:
commentstring
- autoindent through
indentexpr
- indent/detent
- LSP (which gets us syntax highlighting for free)
we can get commentstring by calling racket like so (see Comments):
$ racket -e "((read-language (open-input-string \"#lang rhombus\")) 'drracket:comment-delimiters #f)"
Indentation is harder.
This returns a racket function. Technically we could use a racket library that drives Neovim via the RPC API,
but this seems complicated and also slow. Not sure what to do here.
for LSP, things are actually not too tricky. the hard part is just integrating with the editor's LSP extension.
the main ones are nvim + lspconfig, coc, and ALE. for neovim we can also just call the LSP APIs directly.
to start, i only plan to work with lspconfig and tell people using other plugins to configure them manually; but it shouldn't be too hard to extend this.
note that we do need to inform lspconfig where the workspace root is. i think in practice this is "the closest info.rkt upward from this directory".
this is a stretch goal, i know it's a bunch of work and i don't expect you to do a bunch of free labour. just jotting my thoughts down so i don't lose them.
racket is a meta-language for building programming languages. each language in the racket ecosystem identifies itself through a
#lang my-langat the top of the file (docs1). furthermore, each language may possibly have a different file extension. in an ideal world, a racket plugin would support all languages built on top of racket, not just racket itself and some hand-coded extensions.there are three main ways to detect whether a given file is built on top of racket.
#langattribute.info.rktfiles record the file extension used by a given language. @jackfirth tells me the recommended interface to this isget-module-suffixes, which we could call with e.g.racket -e '(require compiler/module-suffix) (print (get-module-suffixes))'this plugin already partly does 1 and 2. but it only does so for a hard-coded list of file extensions. part of this work would be to do it for any racket file; probably by caching the
racket -eoutput. we could avoid unnecessary work by only running if we see a#langheader.once we discover the filetype, there are 4 main things we want to support:
commentstringindentexprwe can get
commentstringby calling racket like so (see Comments):Indentation is harder.
This returns a racket function. Technically we could use a racket library that drives Neovim via the RPC API,
but this seems complicated and also slow. Not sure what to do here.
for LSP, things are actually not too tricky. the hard part is just integrating with the editor's LSP extension.
the main ones are nvim +
lspconfig,coc, and ALE. for neovim we can also just call the LSP APIs directly.to start, i only plan to work with
lspconfigand tell people using other plugins to configure them manually; but it shouldn't be too hard to extend this.note that we do need to inform lspconfig where the workspace root is. i think in practice this is "the closest
info.rktupward from this directory".Footnotes
actually even this syntax is extensible; see https://docs.racket-lang.org/choose-lang/index.html ↩