sschwarzer
2021-4-16 17:09:29

It seems that the Racket plugin https://github.com/wlangstroth/vim-racket/ doesn’t support gd, “go to definition”. It this feature supported in the language server ( https://github.com/jeapostrophe/racket-langserver ) and if yes, how well?


ben.knoble
2021-4-16 17:10:53

You could quickly add a setlocal define= to get better gd support. (Untested, but something like (define might work as-is)


sschwarzer
2021-4-16 17:10:55

On a related note, is there a web interface to search for definitions, similar to how I can search in the Racket docs for the documentation of a function/form?


ben.knoble
2021-4-16 17:11:23

But that won’t handle let forms


sschwarzer
2021-4-16 17:14:31

> But that won’t handle let forms And it searches only in the buffer?


sschwarzer
2021-4-16 17:14:54

I’m particularly interested in jumping to the code that is part of the Racket installation.


ben.knoble
2021-4-16 17:15:36

Probably correct: for include searches, you’d need to work out setting the options path, include, and includeexpr. You can also use * and # for searching in the buffer for the word under the cursor


sschwarzer
2021-4-16 17:16:48

There’s also https://github.com/universal-ctags/ctags , which supposedly supports Racket. Usually I like Vim’s tag system, but I guess for Racket there are so many definition forms that the text-based tag file creation will miss a lot of definitions.


ben.knoble
2021-4-16 17:17:33

Path might be doable by querying racket about where all the code is; include/includeexpr is a little harder, and you would probably have to use racket in a non-trivial way.

I wonder if @greg’s work on databases and such could be made non-emacs specific to support this?

Yeah, tags are great, but it’s so difficult to keep up with all the ways to define things.


sschwarzer
2021-4-16 17:21:45

Do you have a link to @greg’s work?



sschwarzer
2021-4-16 17:58:20

Thanks, but from reading the thread it’s still totally unclear to me what the scope is, in particular with which tools this is supposed to work. I’ll ask him.


sschwarzer
2021-4-16 18:02:05

For the record, I just installed universal-ctags and the found results from the generated tags are better than I expected. What’s particularly missing, though, are some or all lower-level definitions that are probably somehow built-in. For example, append* is found, but append isn’t.


sschwarzer
2021-4-16 18:03:04

I’ll try this for a bit to see how it goes.


samdphillips
2021-4-16 18:06:22

re: racket-langserver I think within a module go to definition works and someone is working on go to definition out of a module


sschwarzer
2021-4-16 18:08:35

@samdphillips What’s the version of Neovim you use the language server with? Do you use Neovim 0.5.0 with the built-in LSP client or some plugin?


samdphillips
2021-4-16 18:09:02

Neovim 0.5.0 with built-in


samdphillips
2021-4-16 18:10:21

Someone on Discord has reported success using a different plugin, this is how they got it working " plug begin, other plugins Plug 'autozimu/LanguageClient-neovim', { \ 'branch': 'next', \ 'do': 'bash install.sh', \ } " plug end somewhere here set hidden let g:LanguageClient_serverCommands = { \ 'scheme': ['racket', '-l', 'racket-langserver'], " or 'racket' if you have proper filetypes set \ }


sschwarzer
2021-4-16 18:11:28

Interesting. I’m too lazy to install some version that isn’t in Fedora or available as AppImage download. :slightly_smiling_face:

Ok, I take that back, in part. There’s a nightly build for 0.5.0 at https://github.com/neovim/neovim/releases .


sschwarzer
2021-4-16 18:12:26

Yes, I’ve seen autozimu/LanguageClient-neovim several times (in the context of other programming languages).


samdphillips
2021-4-16 18:12:30

yeah I found an ubuntu ppa for 0.5.0, otherwise I wouldn’t have tried


samdphillips
2021-4-16 18:12:40

Also on Mac 0.5.0 is in homebrew


sschwarzer
2021-4-16 18:13:02

I’m running Fedora 33 at the moment.


samdphillips
2021-4-16 18:13:38

So for identifiers defined outside of the module goto definition goes to the require where the name comes from or the lang line if it’s from the language.


sschwarzer
2021-4-16 18:15:54

I installed universal-ctags and ran ctags -R . in the root folder of my Racket installation, then added the generated tags file to the tags option in Neovim. (You can use set tags+=<the_racket_folder> .) Jumping to tags then finds definitions in the source files installed with Racket.


sschwarzer
2021-4-16 18:17:04

I guess I’ll try only the tags approach for now. When I hear that the language server finds definitions outside the current file, I’ll probably give it a try. :slightly_smiling_face:


sschwarzer
2021-4-16 18:18:33

Exuberant ctags might work, too, but this hasn’t been updated for some time and therefore probably is less complete.


greg
2021-4-16 18:20:54

@greg has joined the channel


sschwarzer
2021-4-16 18:21:40

Hi @greg ! :slightly_smiling_face:


greg
2021-4-16 18:22:25

Please don’t tell anyone I’m in this channel instead of #emacs I am so embarrassed!!!


sschwarzer
2021-4-16 18:23:10

At least you can be in both channels. :wink:


greg
2021-4-16 18:23:11

@sschwarzer Hi. You’d pinged me DM so I wanted to share the link. But again, this is just a few weeks old and still very much WIP: https://github.com/greghendershott/pdb


greg
2021-4-16 18:25:22

I don’t know about Vim calling Racket code “directly”, but I imagine some db like this could have a CLI tool, too, that could query a database. e.g. raco pdb find-definition some-file.rkt <pos>, where <pos> is a 1-based index into the file, for the location of a use, and the command outputs some file and location of the definition.


sschwarzer
2021-4-16 18:25:52

It think it would make sense to integrate the database usage (also) into the language server, so that it can be used by all editors/IDEs that can use a LSP server.


greg
2021-4-16 18:26:32

For sure if you can use LSP from Vim easily (I’m totally ignorant about Vim-land), that’s great.


sschwarzer
2021-4-16 18:27:44

Yes, a command line tool also sounds interesting. This approach is used by the Neovim plugin for Nim, where the plugin queries the nimsuggest tool that’s included in the Nim installation. I’d say, nimsuggest is something very similar to a language server in functionality.


greg
2021-4-16 18:28:26

The idea of LSP is neat but there’s bucketloads of marshaling things to and form JSON, so there’s also that. :slightly_smiling_face:


sschwarzer
2021-4-16 18:28:27

> For sure if you can use LSP from Vim easily (I’m totally ignorant about Vim-land), that’s great. Yes, but my point was about using the database from the language server, not using the language server from Vim. :slightly_smiling_face:


greg
2021-4-16 18:28:40

Ah gotcha. Yep.