-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
Closed
Labels
Description
Problem
When I purposely create an error in a simple Ruby file (puts "Hello, World!
), I notice that Neovim will initially report a diagnostic error message. If I fix the error, I notice the diagnostic message is still present.
The Ruby-LSP is somewhat unique in that it only supports pull diagnostics and not PublishDiagnostics. Although I'm aware the former was implemented in #24128.
Steps to reproduce using "nvim -u minimal_init.lua"
Steps to reproduce:
- Ensure you have Ruby 3.0 or greater installed
- Install Ruby-LSP with
gem install ruby-lsp
(current version 0.13.2) - Open Neovim with the following command:
nvim -u [path to minimal_init.lua file] example.rb
- Once in the file, invalidate the code in the
example.rb
file by removing one of the quotation marks fromputs "Hello, World"
. You'll see a diagnostic error - Put the quotation mark back. You'll still see the error.
Files outlined below:
minimal_init.lua file:
local on_windows = vim.loop.os_uname().version:match("Windows")
local function join_paths(...)
local path_sep = on_windows and "\\" or "/"
local result = table.concat({ ... }, path_sep)
return result
end
vim.cmd([[set runtimepath=$VIMRUNTIME]])
local temp_dir = vim.loop.os_getenv("TEMP") or "/tmp"
vim.cmd("set packpath=" .. join_paths(temp_dir, "nvim", "site"))
local package_root = join_paths(temp_dir, "nvim", "site", "pack")
local lspconfig_path = join_paths(package_root, "test", "start", "nvim-lspconfig")
if vim.fn.isdirectory(lspconfig_path) ~= 1 then
vim.fn.system({ "git", "clone", "https://github.com/neovim/nvim-lspconfig", lspconfig_path })
end
vim.lsp.set_log_level("debug")
require("vim.lsp.log").set_format_func(vim.inspect)
local nvim_lsp = require("lspconfig")
local on_attach = function(_, bufnr)
local function buf_set_option(...)
vim.api.nvim_buf_set_option(bufnr, ...)
end
buf_set_option("omnifunc", "v:lua.vim.lsp.omnifunc")
-- Mappings.
local opts = { buffer = bufnr, noremap = true, silent = true }
vim.keymap.set("n", "gD", vim.lsp.buf.declaration, opts)
vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts)
vim.keymap.set("n", "K", vim.lsp.buf.hover, opts)
vim.keymap.set("n", "gi", vim.lsp.buf.implementation, opts)
vim.keymap.set("n", "<C-k>", vim.lsp.buf.signature_help, opts)
vim.keymap.set("n", "<space>wa", vim.lsp.buf.add_workspace_folder, opts)
vim.keymap.set("n", "<space>wr", vim.lsp.buf.remove_workspace_folder, opts)
vim.keymap.set("n", "<space>wl", function()
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end, opts)
vim.keymap.set("n", "<space>D", vim.lsp.buf.type_definition, opts)
vim.keymap.set("n", "<space>rn", vim.lsp.buf.rename, opts)
vim.keymap.set("n", "gr", vim.lsp.buf.references, opts)
vim.keymap.set("n", "<space>e", vim.diagnostic.open_float, opts)
vim.keymap.set("n", "[d", vim.diagnostic.goto_prev, opts)
vim.keymap.set("n", "]d", vim.diagnostic.goto_next, opts)
vim.keymap.set("n", "<space>q", vim.diagnostic.setloclist, opts)
end
-- Add the server that troubles you here
local name = "ruby_ls"
local cmd = { "ruby-lsp" } -- needed for elixirls, lua_ls, omnisharp
if not name then
print("You have not defined a server name, please edit minimal_init.lua")
end
if not nvim_lsp[name].document_config.default_config.cmd and not cmd then
print([[You have not defined a server default cmd for a server
that requires it please edit minimal_init.lua]])
end
nvim_lsp[name].setup({
cmd = cmd,
on_attach = on_attach,
})
example.rb file:
puts "Hello, World!"
Expected behavior
Diagnostic messages to be continually updated when the Ruby file is edited.
Neovim version (nvim -v)
0.10.0-dev-7d279a0
Language server name/version
ruby-lsp 0.13.2
Operating system/version
macOS 14.1 (23B74)
Log file
https://gist.github.com/olimorris/dc262e730c720824701d34c9e01e3748