Semantic highlighting marking a class usage as a constant
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 2k
- Forks
- 281
- Avg merge
- 2h 14m
- Merged PRs (30d)
- 6
Description
Ruby version
3.2.2
Code snippet
This may not be the most lightweight way to reproduce it, but it's visible.
Dockerfile
# Use Alpine as the base image
FROM alpine:latest
# Set the working directory
WORKDIR /root
# Install necessary packages
RUN apk add --no-cache \
git \
curl \
build-base \
zlib-dev \
openssl-dev \
readline-dev \
linux-headers \
libffi-dev \
cmake \
automake \
autoconf \
libtool \
pkgconf \
gettext-tiny-dev \
ruby \
ruby-dev \
bash \
yaml-dev
# Clone and build Neovim from source
RUN git clone https://github.com/neovim/neovim.git && \
cd neovim && \
make CMAKE_BUILD_TYPE=Release && \
make install
# Clone the LazyVim starter repository
RUN git clone https://github.com/LazyVim/starter ~/.config/nvim
# Copy the content of custom_plugins.lua from an external file
COPY custom_plugins.lua /root/.config/nvim/lua/plugins/custom_plugins.lua
# Create example.rb inline
RUN echo -e "class Foo\n def self.bar\n Foo.new # `Foo` should be the same color in both lines\n end\nend" > ~/example.rb
# Create Gemfile inline
RUN echo "source 'https://rubygems.org'" > ~/Gemfile
# Install bundler and gems specified in the Gemfile
RUN gem install bundler && \
bundle install
# Start Neovim headlessly and install plugins
RUN nvim -es -u ~/.config/nvim/init.lua -i NONE -c "Lazy" -c "qa"
# Start a shell when the Docker container is run
CMD ["sh"]
-- store this in the same folder of the Dockerfile as `custom_plugins.lua`
return {
{
"williamboman/mason.nvim",
opts = function(_, opts)
vim.list_extend(opts.ensure_installed, {
"ruby-lsp",
})
end,
},
{
"neovim/nvim-lspconfig",
opts = {
servers = {
ruby_ls = {},
},
},
},
}
Run:
docker build -t example .
docker run -ti example
# inside
nvim example.rb
Wait a bit and you'll see some notifications like installing ruby_ls, ruby_ls installed, and some seconds later the server will be started automatically. At that point you'll see the color of the second Foo change.
Description
I wanted to replace solargraph with ruby_ls with neovim (and LazyVim). When switching I noticed that the highlighting was different. I've noticed that this is most probably because ruby_ls semantic highlighting.
I'm using https://github.com/maxmx03/solarized.nvim with neo theme, although I can reproduce it with other themes.
After using :Inspect, i've noticed the following
Foo here is highlighted as a a namespace / constant, where on declaration it's as a class:
Expected output
I would expect that in both cases Foo is the same color (orange, as a Type)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with example.rb after ruby_ls starts, using the Dockerfile setup and the :Inspect command to compare the Foo declaration and usage. Trace the semantic-highlighting entry point for Ruby class references; done means both occurrences are classified and rendered consistently as a type, with a regression check for this example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- neovim, ruby
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100