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

bug: lua-language-server not working with LSP file operations #279

Closed
3 tasks done
mehalter opened this issue Jan 10, 2024 · 1 comment
Closed
3 tasks done

bug: lua-language-server not working with LSP file operations #279

mehalter opened this issue Jan 10, 2024 · 1 comment
Labels
bug Something isn't working P0 Highest priority, will receive attention

Comments

@mehalter
Copy link
Contributor

mehalter commented Jan 10, 2024

Did you check the docs and existing issues?

  • I have read the docs
  • I have searched the existing issues

Neovim version (nvim -v)

v0.10.0-dev-2051+gee3d4f6b9

Operating system/version

Arch Linux

Describe the bug

Lua language server LSP module renaming doesn't work in Oil. It doesn't prompt for modifications so something is going on with the LSP integration. I did testing on the latest stable neovim release and nightly. It seems related to nightly, on 0.9.5 it is working. It seems to work with both vtsls and tssserver. vtsls working and the lua language server not working is definitely a strange once since they both rely on didRenameFiles. So I'm not sure what is going on.

In depth demonstration with the repro.lua below comparing the operation from my own fork that I had opened a PR with and the current master branch: https://asciinema.org/a/kfPxsdk1wEtwhJKp8JCo3plt2

What is the severity of this bug?

breaking (some functionality is broken)

Steps To Reproduce

  1. nvim -u repro.lua lua_sample/init.lua
  2. :LspInfo, make sure lua language server is attached
  3. :Oil, open the oil file manager and rename test.lua to hello.lua, save the buffer, and see that you don't get prompted to modify the requires

Expected Behavior

LSP integration should work.

Directory structure

lua_sample/init.lua:

local test = require("test")

test.test()

lua_sample/test.lua:

local M = {}

function M.test()
  print("Hello")
end

return M

Repro

-- save as repro.lua
-- run with nvim -u repro.lua
-- DO NOT change the paths
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs { "config", "data", "state", "runtime", "cache" } do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system {
    "git",
    "clone",
    "--filter=blob:none",
    "--single-branch",
    "https://github.com/folke/lazy.nvim.git",
    lazypath,
  }
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  {
    "stevearc/oil.nvim",
    config = function()
      require("oil").setup {
        -- add any needed settings here
      }
    end,
  },
  { -- basic configuration of lua language server
    "neovim/nvim-lspconfig",
    config = function()
      local lspconfig = require "lspconfig"
      lspconfig.lua_ls.setup {}
    end,
  },
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

Did you check the bug with a clean config?

  • I have confirmed that the bug reproduces with nvim -u repro.lua using the repro.lua file above.
@mehalter mehalter added the bug Something isn't working label Jan 10, 2024
@stevearc stevearc added the P0 Highest priority, will receive attention label Jan 14, 2024
@stevearc
Copy link
Owner

One thing I immediately ran into was that LuaLS was running in single-file mode. This was because lua_sample/ didn't have any of the lspconfig-defined root files:
https://github.com/neovim/nvim-lspconfig/blob/7eed8b2150192e5ad05e1886fdf133493ddf2928/lua/lspconfig/server_configurations/lua_ls.lua#L3-L11

After adding one, nvim 0.9.5 started working. The issue with nightly was because of the filter glob matching. I thought that the paths were always relative to the workspace, and only matched against the absolute path on nvim <0.10 because it was covering a case that glob2reg couldn't handle. I thought that would be unnecessary on nvim 0.10 since we have real glob support, but turns out some LSP servers use absolute paths for their filter definitions, so we have to keep it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working P0 Highest priority, will receive attention
Projects
None yet
Development

No branches or pull requests

2 participants