gediminasz / ctags-companion

A Visual Studio Code symbols provider based on Ctags
https://marketplace.visualstudio.com/items?itemName=gediminaszlatkus.ctags-companion
MIT License
25 stars 7 forks source link

Allow absolute paths in the tags file #5

Closed crawler closed 3 years ago

crawler commented 3 years ago

Hi, @gediminasz First of all, thank you for your work on this extension. It is pretty useful. My pull request allows the tags file to refer to external libs using absolute paths. Because currently, reindexScope joins path with the scope.uri, despite its type, resulting in the wrong address. The solution comes with a test assertion.

gediminasz commented 3 years ago

Thank you for contributing! I'm glad you find it useful.

By the way, how do you end up having absolute paths in your tags file?

crawler commented 3 years ago

I write in Ruby using a bundler dependencies manager. And I want to be able to navigate not only by my source code but also to the definitions in external libs. So I came up with the following configuration:

"ctags-companion.command": "/usr/local/bin/ctags -R --languages=Ruby --fields=+nKz -f .vscode/.tags ./ $(bundle list --paths)"

The bundle list --paths command generates the list of absolute paths to each library I use. In combination with "./" arg, tags file includes both, my source code and the external libs.

And the file looks like:

....
Adapter ./app/models/spree/ebay/offer/adapter.rb        /^      class Adapter < Synchronizable::Base$/;"        kind:class      line:6  class:Spree.Ebay.Offer
Adapter /Users/player1/Src/bundle/ruby/2.7.0/gems/faraday-1.0.1/lib/faraday/adapter.rb /^  class Adapter$/;"   kind:class      line:6  module:Faraday  mixin:extend:MiddlewareRegistry,extend:DependencyLoader,extend:Parallelism
...