Can you add custom functionality for goto definition for lsp to use multiple langauges?

This page summarizes the projects mentioned and recommended in the original post on /r/neovim

Our great sponsors
  • WorkOS - The modern identity platform for B2B SaaS
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • SaaSHub - Software Alternatives and Reviews
  • vim-ripgrep

    Use RipGrep in Vim and display results in a quickfix list

  • If the symbol has a fairly unique name you can do something like 'grep word under cursor', there are many ways to do this, I tend to use https://github.com/jremmen/vim-ripgrep, also just :h vimgrep. For more complicated cases maybe write some minimal vimscript/lua code to for example use a more specialized grep pattern in a specific directory and make a keymap for that or something.

  • ctags

    A maintained ctags implementation

  • Not sure if it will help in this case, but I also depend on ctags for when the lsp fails (e.g. code it doesn't compile for some reason). Here you let a program create a tags file, e.g. I use https://github.com/universal-ctags/ctags (it seems it can parse json files, though I'm not sure what kind of tags are generated from this and if they will be useful to you) with https://github.com/ludovicchabant/vim-gutentags to update the tags file. The tags file just contains symbol names with locations where they are defined, and vim has builtin functionality to use these tags files :h tag and they (can) work filetype independent. For example if I mention a C type in a markdown document I can just use ctrl-[ to jump to its definition in the C source file. Possibly you can generate tags files yourself from the json files to help with this, the tags file format is not very complicated. Tags also are not very intelligent and depend on unique names for them to work well, there is the :h g_CTRL-] that can help, but for symbols that are very common (e.g. init or something that potentially has like 20+ definitions) it doesn't really work.

  • WorkOS

    The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.

    WorkOS logo
  • vim-gutentags

    A Vim plugin that manages your tag files

  • Not sure if it will help in this case, but I also depend on ctags for when the lsp fails (e.g. code it doesn't compile for some reason). Here you let a program create a tags file, e.g. I use https://github.com/universal-ctags/ctags (it seems it can parse json files, though I'm not sure what kind of tags are generated from this and if they will be useful to you) with https://github.com/ludovicchabant/vim-gutentags to update the tags file. The tags file just contains symbol names with locations where they are defined, and vim has builtin functionality to use these tags files :h tag and they (can) work filetype independent. For example if I mention a C type in a markdown document I can just use ctrl-[ to jump to its definition in the C source file. Possibly you can generate tags files yourself from the json files to help with this, the tags file format is not very complicated. Tags also are not very intelligent and depend on unique names for them to work well, there is the :h g_CTRL-] that can help, but for symbols that are very common (e.g. init or something that potentially has like 20+ definitions) it doesn't really work.

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts