-
Notifications
You must be signed in to change notification settings - Fork 171
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
Support for Neovim #188
Comments
Hey! Based on my understanding, we'd need to add a file similar to this one for the sorbet LSP, correct? In terms of basic configuration, I believe all that'd be needed is
Here is where we send the initializationOptions in VS Code. It's just an array of strings like enabledFeatures: ["documentSymbols", "foldingRanges", ...] And here are all of the feature names. I'm not super familiar with Neovim. Could we test this out and make sure it works before contributing to nvim-lspconfigs? |
I just wanted to hop in and drop my
I hope this helps! |
@alexwu Thanks! Isn't bundle exec required in the cmd tho? |
If you use it without bundler and your app has We are going to explore allowing the Ruby LSP to be executed without bundler, but then it'll probably fall back to formatting files using SyntaxTree and disable all RuboCop functionality. |
Nice catch -- I've updated the snippet it to use bundler. |
To try this, I just need to install the |
@alexventuraio, after you install ruby-lsp via your Gemfile and the nvim-lspconfig plugin, you can put @alexwu instruction anywhere in your Vim configuration. You'll probably want to create some keymaps for jumping around. Look at the nvim-lspconfig README for a good starting setup. If your vim configuration is not in Lua, then you insert Lua code with:
|
While our team's focus is on supporting VS Code, we'd gladly add an Would that be helpful? We could get started with neovim. |
@vinistock yes, I think that would be helpful. I have a branch adding ruby-lsp to the nvim-lspconfig project. Once that goes through I'll be happy to write some Neovim instructions. |
@wassimk thanks for sharing your solution, I'm looking forward to go through your PR and read your instructions to get it done. |
@alexwu thank you for your config, it worked great. I did notice one issue, diagnostics errors do not show. |
Does the Neovim LSP support the specification version 3.17? It should work if it does. |
neovim does not support from matrix:
here's a snippet nvim lsp users can incorporate into their configs to request on_attach = function(client, bufnr)
vim.api.nvim_create_autocmd({ 'BufEnter', 'BufWritePre', 'CursorHold' }, {
buffer = bufnr,
callback = function()
local params = vim.lsp.util.make_text_document_params(bufnr)
client.request(
'textDocument/diagnostic',
{ textDocument = params },
function(err, result)
if err then return end
if not result then return end
vim.lsp.diagnostic.on_publish_diagnostics(
nil,
vim.tbl_extend('keep', params, { diagnostics = result.items }),
{ client_id = client.id }
)
end
)
end,
})
end |
It looks like lspconfig now ships with support directly: https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#ruby_ls The only thing you may need to change the local lspconfig = require("lspconfig")
lspconfig.ruby_ls.setup({
cmd = { "bundle", "exec", "ruby-lsp" }
}) edit added a note about what you may need to change |
I have tried this snippet, and one problem I'm seeing is that you don't get diagnostics when I first load a file. I have to make a change and save. I tried addding like |
One downside I'm seeing for using the lsp is that you'll see an error about connecting to the LSP when the |
This worked fine for me. on_attach = function(client, buffer)
local callback = function()
local params = vim.lsp.util.make_text_document_params(buffer)
client.request(
'textDocument/diagnostic',
{ textDocument = params },
function(err, result)
if err then return end
vim.lsp.diagnostic.on_publish_diagnostics(
nil,
vim.tbl_extend('keep', params, { diagnostics = result.items }),
{ client_id = client.id }
)
end
)
end
callback() -- call on attach
vim.api.nvim_create_autocmd({ 'BufEnter', 'BufWritePre', 'BufReadPost', 'InsertLeave', 'TextChanged' }, {
buffer = buffer,
callback = callback,
})
end |
I found a way to do this 🎉 I was looking at adding |
coc.nvim also kinda supports it https://github.com/neoclide/coc.nvim/wiki/Language-servers#using-shopifyruby-lsp |
Folks, I added an editors file to aggregate configurations for the Ruby LSP in editors other than VS Code. If somebody wants to contribute instructions for NeoVim, we can put it there and close this issue. We can also include multiple alternatives if there's not a single way of doing it. |
Link to related neovim and nvim-lspconfig issues: |
Another thing that might help: since #562, we switched features from being opt-in to being opt-out so that configuration is easier for editors (everything is enabled by default if no config is passed). |
any help?
local status_ok, lspconfig = pcall(require, 'lspconfig')
if not status_ok then
return
end
local servers = require("junior.lsp.servers")
for _, server in pairs(servers) do
local opts = {}
local handler = require("junior.lsp.handlers")
opts = {
on_attach = handler.on_attach,
capabilities = handler.capabilities,
}
if server == 'lua_ls' then
opts = vim.tbl_deep_extend("force", {
settings = {
Lua = {
diagnostics = {
globals = { "vim" },
},
},
},
}, opts)
end
lspconfig[server].setup(opts)
end
local servers = {
'lua_ls',
'tsserver',
'ruby_ls'
}
return servers When i open a buffer with ruby file, i can see the the ruby_ls has attached to the buffer but i dont get any completion or diagnostic. I already tried the suggestions on this issue and nothing happens. Im have the gem installed btw. on the LspLog i have this [ERROR] but i dont know what this means |
@b-sep We can not see the handler where you customize the on-attach. |
my handlers file is just a bunch of mappings and visual stuff, you can see here i'll try the workaround that u link, ty :) |
I'm not sure if this is neovim specific, or a broader ruby-lsp question: if you use sorbet, is there any guidance/recommendations for using the sorbet LSP and ruby-lsp together? There is definitely some overlap as noted in #206 I'm still learning and understanding nvim + lsp, but I get the impression only one ruby LSP ends up being attached. |
The default behaviour for language servers is to allow for more than one and merge responses. If both the Ruby LSP and Sorbet implement the same request, you'd just get the results duplicated in the editor. We use both Sorbet and the Ruby LSP on our projects (even on the Ruby LSP project itself, we use both). This works out of the box on VS Code, but I have no idea how NeoVim handles it. |
This is also my experience using both together.
@technicalpickles Looking at your committed configuration here sorbet is |
I stand corrected, thanks for the info! I'll need to look more closely how things behave when both ruby-lsp and sorbet are enabled to see if there is actually any duplicates.
Thanks for checking that out. I was in a interim stage while debugging some other LSP related things 😅 |
I posted this over on @cefigueiredo's neovim/nvim-lspconfig#2498 , but figured would share here too:
I'm just trying to work out what the easiest way to enable vim folks to use ruby-lsp without needing much extra configuration. I think it's moving the workaround into nvim-lspconfig, or maybe another package? Is there anything that can be implemented within ruby-lsp? |
I'm trying to set ruby-lsp up in my neovim config. The gem is installed correctly and it seems to start fine. When I enter any ruby file, though, I get this error in the
I don't think I have anything fancy set up, just the usual I tried searching online but I have literally no clue about where to start to address this issue. Any clue about what I might be missing / doing wrong? My dot files are here: https://github.com/metalelf0/dot-files/tree/master/.config/nvim Thanks in advance! |
ProblemI am using NvChad with the following lspconfig.ruby_ls.setup {
on_attach = function(client, buffer)
local callback = function()
local params = vim.lsp.util.make_text_document_params(buffer)
client.request(
'textDocument/diagnostic',
{ textDocument = params },
function(err, result)
if err then return end
vim.lsp.diagnostic.on_publish_diagnostics(
nil,
vim.tbl_extend('keep', params, { diagnostics = result.items }),
{ client_id = client.id }
)
end
)
end
callback() -- call on attach
vim.api.nvim_create_autocmd({ 'BufEnter', 'BufWritePre', 'BufReadPost', 'InsertLeave', 'TextChanged' }, {
buffer = buffer,
callback = callback,
})
end,
capabilities = capabilities,
} I added the workaround to make diagnostics work in neovim but there is an error when i make a change in a
|
Closing this since instructions were added in #830. If there are other instructions for different NeoVim plugins that can connect to the LSP, please feel free to put up a PR adding the configuration to a new section in that file. |
How would I lazy load this using return { } ? |
…ypescript-eslint/eslint-plugin-5.33.1 Bump @typescript-eslint/eslint-plugin from 5.33.0 to 5.33.1
I need help understanding the question. The LSP will only start in Ruby files. That should be the required lazy loading. |
Let me start by saying I am so excited that ruby tooling has gotten some love lately.
Are there a plans to add support for other editors (most notably) Neovim?
Neovim since version 0.5 natively supports Language Server Protocol and there is a significant subset of already supported LSP.
The text was updated successfully, but these errors were encountered: