Mastering Ruby Code Navigation: Ruby LSP Enhancements in the First Half of 2024
In early 2024, the Ruby Language Server Protocol improved code navigation, enhancing features like hover and go-to-definition. Rails addon updates facilitate navigation in models, views, and controllers, with ongoing experimental features.
Read original articleIn the first half of 2024, significant enhancements have been made to the Ruby Language Server Protocol (LSP), particularly in code navigation features. These improvements stem from advancements in the Ruby LSP indexer, which enhances developer productivity by facilitating key navigation functionalities such as hover, go-to-definition, completion, and signature help. Notable enhancements include better support for singleton methods, local variables, and the inheritance hierarchy, allowing developers to trace method calls and understand variable scopes more effectively. The Ruby LSP now also supports navigation within Ruby core classes and modules, providing documentation and completion candidates.
The Rails addon has seen substantial improvements, enabling seamless navigation between models, views, and controllers, including features like go-to-definition for ActiveRecord callbacks and associations. Additionally, code navigation support has been extended to .erb files, enhancing the overall Rails development experience.
Experimental features are also in development, such as the ancestors hierarchy request, which aims to clarify the inheritance structure, and guessed types, which attempts to infer variable types based on their names. These features are designed to further enhance code navigation capabilities.
The Ruby LSP project, primarily driven by the Ruby Developer Experience team at Shopify, remains an open-source initiative, welcoming contributions from the community. The ongoing enhancements reflect a commitment to improving the Ruby development experience and fostering collaboration within the Ruby community.
Related
JRuby funding at Red Hat stopped – call for sponsors
JRuby gains independence post Red Hat sponsorship end. Updates 9.3.15.0 and 9.4.8.0 released, with plans for JRuby 10 supporting Ruby 3.4 and Rails 7.1. Community urged for GitHub sponsorship or commercial support for continued development.
Modern Emacs TypeScript Web Config
Setting up modern Emacs config for TypeScript web dev includes lsp-mode, Treesitter, Tailwind, TSX support, multiple LSP servers, Corfu completion, flycheck linter, eslint, Tailwind LSP, lsp-doctor, and Emacs LSP Booster.
Gleam v1.3.0 – Auto-imports and tolerant expressions
Gleam v1.3.0 update includes auto-imports, tolerant expressions, enhanced completions, import cycles diagnostics, syntax warnings, arithmetic support, and JavaScript bundler hints. Contributors improved functionality and user experience significantly.
- Many commenters express frustration with Ruby's dynamic typing and the limitations it imposes on code navigation and debugging.
- Some users highlight the effectiveness of RubyMine for code navigation, contrasting it with the new Ruby Language Server Protocol features.
- There is a sentiment that Ruby is falling behind other languages in terms of development experience and tooling maturity.
- Several commenters note the historical significance of Ruby and Rails but express concern over its declining market relevance.
- Some users are experimenting with type-checking solutions like Sorbet to improve Ruby's usability.
Sorbet may fix things, but at that point, just use a language with more mature tooling around types, like Python or TypeScript.
Dynamic types offer dubious marginal benefits but bring tons of downsides. The demonstrations in this article reflect that.
I think it works well, is stable, and I would still reach for it over Shopify's LSP personally. Feel free to use it! Though as a heads up, I don't work in Ruby much anymore unfortunately so I'm not actively working on it or accepting issues.
On the other hand, the Ruby community seems stuck in the 2000s, with some of the self inflicted Ruby pains and attitude being fairly similar to what some Python devs were doing in the late Python 2 era.
These days, I still like Ruby and I would enjoy building some little project with it, but I would rather make a living using other stuff.
For everyone commenting about those and who haven't, I suggest trying RubyMine to set expectations on what is possible first.
Excited to try this to see if it measures up.
"Look up the source" in 2024 is a symptom of a wider problem. Ruby was innovative in the 1990s but it is starting to fall behind the times.
Those of us who are old enough to remember the euphoria that greeted the release of Ruby on Rails in 2004 are mostly surprised to see Ruby's current, limited market share. There was a moment when it seemed like Ruby was going to sweep the whole world of software. But that didn't happen. The mutability that made Ruby so fun also makes it difficult to maintain Ruby codebases over the long-term.
For awhile Ruby seemed relevant in fields beyond Web development, such as devops. I recall 12 years ago a startup tried to recruit me, they were going to revolutionize devops by building automations for Chef. But the metaprogramming in Ruby made it less than ideal for devops work. That startup failed. In most places I now work, a combination of Ansible and Terraform dominate, save where the company uses the constellation of tools surrounding Kubernetes to manage everything. The places that use Chef have been using Chef for 15 years, no new company chooses Chef today.
There was a stretch after 2004 when Ruby was trying to break into new areas. GTK bindings for Ruby were developed and some people experimented with desktop Ruby. But that never took off.
Many of us who loved the metaprogramming in Ruby, but wanted a better structure for that metaprogramming, moved on to other languages such as Clojure.
Some of us loved Ruby because it allowed easier polymorphism than Java did -- after all, you could use higher order functions to produce functions, but without having all the ceremony of building a Factory. But folks who just wanted the polymorphism of functions returning functions eventually moved to NodeJS.
Ruby always felt fluid and magical in a way that made it seem vaguely unsuitable for data science, and eventually Python came to dominate data science.
The Ruby community witnessed the conflict between Rails and Merb, and their eventual union, and eventually Rails became a comfortable framework for quickly generating an API. But for anything that needs high levels of write throughput, no one would chose Ruby, and so other languages have taken some of the market share.
Even on the Web, some big companies (Twitter, AirBnB) either gave up on it completely, or now only use it for templating the frontend, or offering an API to support the frontend. For backend processing, many companies have moved away from it.
In short, Ruby has been losing market share for awhile. In some fields, such as devops, where it used to be competitive, it has almost completely disappeared. It survives only in Web development, and only because of Rails.
None of this can be very inspiring for Ruby developers.
Related
JRuby funding at Red Hat stopped – call for sponsors
JRuby gains independence post Red Hat sponsorship end. Updates 9.3.15.0 and 9.4.8.0 released, with plans for JRuby 10 supporting Ruby 3.4 and Rails 7.1. Community urged for GitHub sponsorship or commercial support for continued development.
Modern Emacs TypeScript Web Config
Setting up modern Emacs config for TypeScript web dev includes lsp-mode, Treesitter, Tailwind, TSX support, multiple LSP servers, Corfu completion, flycheck linter, eslint, Tailwind LSP, lsp-doctor, and Emacs LSP Booster.
Gleam v1.3.0 – Auto-imports and tolerant expressions
Gleam v1.3.0 update includes auto-imports, tolerant expressions, enhanced completions, import cycles diagnostics, syntax warnings, arithmetic support, and JavaScript bundler hints. Contributors improved functionality and user experience significantly.