Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add vim-lsp for working with LSPs #56

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

santiagorodriguez96
Copy link
Collaborator

@santiagorodriguez96 santiagorodriguez96 commented Nov 29, 2024

Motivation

It's been a while since we wanted to enable seamless navigation through classes and definitions across the working directory and the different Ruby gems. We kinda had the first one with ctags – even though you'd have to re-generate the ctags from time to time to pick up the new definitions – but we couldn't get to make an approach for navigating through the definitions in the gems work properly.

Therefore, after quite some time, we got to give Language Server Protocols a try and managed to accomplish this goal.

Details

This pull request includes the addition of new submodules for vim-lsp and vim-lsp-settings which allows for installing Language Server Protocols. It also sets custom configurations such as:

  • Disable typeprof for now as it was throwing some errors – let's re-consider enabling back in a follow up PR.
  • Disable highlighting of the references to the symbol under the cursor – we feel that it bothers more than the value it gives.
  • Disable signs for code actions – for the moment we don't know what this functionality provides so we will reconsider adding it as a follow up as it shows an A> string at the left of the numbers on the line where the cursos is placed.
  • Custom mappings for some of the functions provided by vim-lsp:
    • gd for navigating to the definition of the word under the cursor
    • gpd for peek at the definition of the word under the cursor
    • gs to take a look and navigate across the document symbols
    • gS to search through the workspace symbols

Using with Ruby

vim-lsp-settings – which is used to easily install and configure LSPs – supports installing Ruby LSP:

https://shopify.github.io/ruby-lsp/

In order to install it we just have to do: :LspInstallServer ruby-lsp. Note that this will clone the repo for ruby-lsp gem into the vim-lsp-settings default dir and install it dependencies in vendor/bundle meaning that the ruby-lsp gem won't be available globally for your ruby versions, so you might have to install the gem using gem install.

After that, it should work properly!

  • gd for navigating to the definition of the Class or method under the cursor
  • gpd for peek at the definition of the Class or method under the cursor
  • gs to take a look and navigate across the classes, modules, methods, etc.
  • gS to search for classes, modules, methods, etc, for the workspace – including gems!
Screen.Recording.2024-11-29.at.15.04.55.mov

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants