Skip to content

Instantly share code, notes, and snippets.

@sogaiu
Last active February 28, 2024 09:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sogaiu/1542a94b626c70c034477f08fb670322 to your computer and use it in GitHub Desktop.
Save sogaiu/1542a94b626c70c034477f08fb670322 to your computer and use it in GitHub Desktop.
~/.ctags.d/janet.ctags -- for indexing top-level things in janet code -- usage: `ctags -R <dir>` or for emacs, `ctags -e -R <dir>` -- sorry, no destructuring support
--exclude=.git
--langdef=Janet
--langmap=Janet:.janet
--regex-janet=/^\([ \t]*def[ \t]+([^0-9:#][^ \t\[{(]+)/\1/D/
--regex-janet=/^\([ \t]*def-[ \t]+([^0-9:#][^ \t\[{(]+)/\1/d/
--regex-janet=/^\([ \t]*defglobal[ \t]+([^0-9:#][^ \t\[{(]+)/\1/g/
--regex-janet=/^\([ \t]*defmacro[ \t]+([^0-9:#][^ \t\[{(]+)/\1/M/
--regex-janet=/^\([ \t]*defmacro-[ \t]+([^0-9:#][^ \t\[{(]+)/\1/m/
--regex-janet=/^\([ \t]*defn[ \t]+([^0-9:#][^ \t\[{(]+)/\1/N/
--regex-janet=/^\([ \t]*defn-[ \t]+([^0-9:#][^ \t\[{(]+)/\1/n/
--regex-janet=/^\([ \t]*var[ \t]+([^0-9:#][^ \t\[{(]+)/\1/V/
--regex-janet=/^\([ \t]*var-[ \t]+([^0-9:#][^ \t\[{(]+)/\1/v/
--regex-janet=/^\([ \t]*varfn[ \t]+([^0-9:#][^ \t\[{(]+)/\1/R/
--regex-janet=/^\([ \t]*varglobal[ \t]+([^0-9:#][^ \t\[{(]+)/\1/G/
@MaxGyver83
Copy link

Hi @sogaiu,

I just found this gist when I searched for Janet support in ctags. I have created ~/.ctags.d/janet.ctags.

I get this error:

$ ctags -R .
ctags: Non-alphanumeric char is used in kind name: 'private def' in "--regex-Janet" option

Do you know why? Do I use the wrong ctags version? I use Universal Ctags 6.1.0.

@MaxGyver83
Copy link

Replacing all private xxx with privatexxx fixes it for me.

@sogaiu
Copy link
Author

sogaiu commented Feb 28, 2024

Thanks for the investigation and sharing your results.

I am no longer using ctags directly.

Perhaps you'll find the following to be of interest though they are specific to the case of indexing Janet's source code:

@sogaiu
Copy link
Author

sogaiu commented Feb 28, 2024

I investigated a bit regarding the error you mentioned.

I found this issue.

One of the maintainers mentioned this.

Looking through there I came across:

<kind-spec> has two forms: one-letter form and full form.

The one-letter form in the form of <letter>. It just refers a kind <letter> 
defined with --kinddef-<LANG>. This form is recommended in Universal Ctags.

The full form of <kind-spec> is in the form of <letter>,<name>,<description>. 
Either the kind <name> and/or the <description> can be omitted. See the 
description of --kinddef-<LANG>=<letter>,<name>,<description> option about 
the elements.

The full form is supported only for keeping the compatibility with Exuberant 
Ctags which does not have --kinddef-<LANG> option. Supporting the form will 
be removed from Universal Ctags in the future.

So my take is that removing the bits that look like ,private def might be
a better approach and have updated the gist content.

Thanks for the investigation and report :)

@MaxGyver83
Copy link

Perhaps you'll find the following to be of interest though they are specific to the case of indexing Janet's source code:

Thank you for sharing! This looks interesting. Actually, I use ludovicchabant/vim-gutentags: A Vim plugin that manages your tag files which calls ctags for me. That's why I'm happy with your ctags configuration for now. But maybe it's even possible to configure vim-gutentags to call idk-janet instead of ctags.

So my take is that removing the bits that look like ,private def might be
a better approach and have updated the gist content.

Thanks for investigating. This approach sounds reasonable!

@sogaiu
Copy link
Author

sogaiu commented Feb 28, 2024

Thanks for mentioning vim-gutentags. I'd seen it before but not set it up.

FWIW, idk-janet currently works only with Janet's source code (so only this repository). It's not likely to be useful for any other repository.

I tried but didn't make much progress on something that works for typical janet projects (like those that are meant to be installed with jpm). There are limits to what one can pull off statically with a reasonable amount of effort when there is stuff like this. The flexibility of Janet doesn't make creating tooling for it any easier (^^;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment