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

LspInfo reports Running in single file mode when current buffer is not in root_dir #3167

Closed
stasjok opened this issue May 21, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@stasjok
Copy link
Contributor

stasjok commented May 21, 2024

Description

When active buffer is outside of root_dir LspInfo reports root directory as Running in single file mode.

Steps to reproduce

minimal_init.lua:

local lspconfig = require("lspconfig")

lspconfig.lua_ls.setup({
  -- Use dirname as root_dir
  root_dir = vim.fs.dirname,
})

-- Set up lspconfig commands
vim.cmd.runtime("plugin/lspconfig.lua")

-- Make tmpdir
local tmpdir = assert(vim.uv.fs_mkdtemp(vim.fs.joinpath(vim.uv.os_tmpdir(), "lspinfo_repro.XXXXXX")))

-- Open file in tmpdir
vim.schedule(function()
  vim.cmd.edit(vim.fs.joinpath(tmpdir, "file.lua"))
end)

-- Remove tmpdir after vim exit. It won't work if test files were saved there
vim.api.nvim_create_autocmd("VimLeave", {
  callback = function()
    vim.uv.fs_rmdir(tmpdir)
  end,
})
  1. Run neovim: nvim --clean --noplugin -u minimal_init.lua. One buffer is active.
  2. Run command: :LspInfo. Root directory: /tmp/lspinfo_repro.9qkBbS.
  3. Edit any file outside of root dir: :edit /tmp/lspinfo_repro.
  4. :LspInfo. Root directory: Running in single file mode.
  5. Switch buffer back: :buffer #.
  6. :LspInfo. Root directory: /tmp/lspinfo_repro.9qkBbS.
  7. Edit any file inside of root dir (change 9qkBbS to your case): :e /tmp/lspinfo_repro.9qkBbS/1234.
  8. :LspInfo. Root directory: /tmp/lspinfo_repro.9qkBbS.
  9. When switching to buffer created in 3. LspInfo again reports root directory as single file.
@stasjok stasjok added the bug Something isn't working label May 21, 2024
@glepnir
Copy link
Member

glepnir commented May 21, 2024

it outside of the root then it run in single file mode what's the problem ?

@glepnir glepnir closed this as completed May 21, 2024
@stasjok
Copy link
Contributor Author

stasjok commented May 21, 2024

it outside of the root then it run in single file mode what's the problem ?

Client itself is not outside of the root dir, but it's wrongly reported as such. The problem is wrong info reported by LspInfo. Maybe a screenshot would help to understand what's the problem?

image

All those servers are not running in single file mode. They all have its own root_dir. So it's strange to report it like this.

Compare it to this:

image

I just switched buffer, nothing else changed. Now lua_ls is reported as single file mode, but for nil_ls root directory is displayed correctly.

Checkhealth (all clients has root_dir):

vim.lsp: Active Clients ~
- nil_ls (id=1, root_dir=/nix/store/dpplx09mq0jpkm8b149xjc1brpky7503-source, attached_to=[1,280])
- nil_ls (id=2, root_dir=/nix/store/7v74bj8chscad3xcb03bvi474q9mv2g0-source, attached_to=[297,540,569,324,266,37])
- null-ls (id=4, root_dir=/nix/store/lqdsr7qjrzm1q20zxiwlv5nhv2ap4a0s-vimplugin-nvim-lspconfig-2024-05-16, attached_to=[783,586,211,806,640,637])
- nil_ls (id=6, root_dir=/nix/store/zyzhqfys86byv201frlpiyipzzw38p02-source/lib, attached_to=[554])
- lua_ls (id=7, root_dir=/nix/store/mv069f2y146dpijxgnwd5nddjv9qkcci-neovim-patched-0.10.1-dev/share/nvim/runtime, attached_to=[783,586,211,806,640,637])

@glepnir
Copy link
Member

glepnir commented May 21, 2024

I remeber there has a problem after i add workspace relate stuff see #2648 I will check it later.

@stasjok
Copy link
Contributor Author

stasjok commented May 21, 2024

Could you reopen for the time being? It's not urgent, but so that it's not forgotten completely.

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

No branches or pull requests

2 participants