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

The LSP is not initialized #2

Open
ramfattah opened this issue Jun 28, 2024 · 10 comments
Open

The LSP is not initialized #2

ramfattah opened this issue Jun 28, 2024 · 10 comments

Comments

@ramfattah
Copy link

ramfattah commented Jun 28, 2024

OS: Linux Ubuntu 24.04 LTS
NVIM: v0.10.0-dev-435dee7

After opening a .razor/.cshtml file, no LSP client get attached to the buffer.

Here is my nvm-lspconfig setup:

return { -- LSP Configuration & Plugins
  'neovim/nvim-lspconfig',
  dependencies = {
    -- Automatically install LSPs and related tools to stdpath for Neovim
    { 'williamboman/mason.nvim', config = true }, -- NOTE: Must be loaded before dependants
    'williamboman/mason-lspconfig.nvim',
    'WhoIsSethDaniel/mason-tool-installer.nvim',
    'tris203/rzls.nvim',
.
.
.
.
.


  local capabilities = vim.lsp.protocol.make_client_capabilities()
  capabilities = vim.tbl_deep_extend('force', capabilities, require('cmp_nvim_lsp').default_capabilities())

  require('rzls').setup {
    on_attach = function()
      vim.keymap.set('n', 'gd', vim.lsp.buf.definition, { buffer = 0 })
    end,
    capabilities = capabilities,
    path = '/home/ram/.vscode/extensions/ms-dotnettools.csharp-2.34.12-linux-x64/.razor/rzls',
  }
@tris203
Copy link
Owner

tris203 commented Jun 28, 2024

Do you get any messages @InfinytRam?

I havent tried with the VSCode bundled rzls and instead have used the one built from source in the razor repo

@ramfattah
Copy link
Author

ramfattah commented Jun 29, 2024

Thanks for the quick response @tris203,

This time i provided the path to rzls after cloning and building from dotnet/razor source: https://github.com/dotnet/razor

Steps I took to build dotnet/razor:

  1. Cloned the dotnet/razor repository
  2. cd into razor
  3. run ./build.sh in terminal
  4. Then found the rzls in the following path:
    a. /home/ram/Documents/projects/dotnet/razor/razor/artifacts/LanguageServer/Debug/net8.0/linux-x64/rzls

I provided the rzls path in 'rzls' setup in neovim:

    local capabilities = vim.lsp.protocol.make_client_capabilities()
    capabilities = vim.tbl_deep_extend('force', capabilities, require('cmp_nvim_lsp').default_capabilities())

    require('rzls').setup {
      on_attach = function()
        vim.keymap.set('n', 'gd', vim.lsp.buf.definition, { buffer = 0 })
      end,
      capabilities = capabilities,
      path = '/home/ram/Documents/projects/dotnet/razor/razor/artifacts/LanguageServer/Debug/net8.0/linux-x64/rzls',
    }

and unfortunately i did not get any messages when i opened .cshtml file. I also checked the :messages command in neovim.

Happy to provide additional information.

@tris203
Copy link
Owner

tris203 commented Jun 29, 2024

Can you try and a .razor file?

Ps, this plugin is still very much under development

Only a very small amount of methods work and a lot of debug info is still visible

@nomis51
Copy link

nomis51 commented Jun 30, 2024

I've tried with both VSCode rzls and dotnet/razor rzls, both giving those errors upon opening a razor file

image

It then says "Razor LSP attached" and I can see "rzls" on the task bar, but it's a bit broken. Some warnings show off, but that's pretty much it.

image

And as soon as I input something in the file, it get those two above errors back to back on every keystroke basically.

Had to change the cmd path of the plugin to add .exe at the end for it to works on Windows.

image

And here's my setup

image

@tris203
Copy link
Owner

tris203 commented Jun 30, 2024

I've tried with both VSCode rzls and dotnet/razor rzls, both giving those errors upon opening a razor file

Do you see it open the projected virtual buffers?

@nomis51
Copy link

nomis51 commented Jun 30, 2024

I've tried with both VSCode rzls and dotnet/razor rzls, both giving those errors upon opening a razor file
Do you see it open the projected virtual buffers?

I think so

image

@tris203
Copy link
Owner

tris203 commented Jun 30, 2024

I've tried with both VSCode rzls and dotnet/razor rzls, both giving those errors upon opening a razor file
Do you see it open the projected virtual buffers?

I think so

image

You will also need roslyn.nvim. Which might be the cause of the issue
https://github.com/jmederosalvarado/roslyn.nvim

@ramfattah
Copy link
Author

ramfattah commented Oct 5, 2024

@tris203

Screenshot from 2024-10-04 18-43-41

Getting the same error as @nomis51 when open a .razor file.

Creating virtual buffers for /........../projects/dotnet/IMS/IMS.WebApp/Components/App.razor
Error executing vim.schedule lua callback: ...hare/nvim/lazy/rzls.nvim/lua/rzls/documentstore/init.lua:59: attempt to index a nil value
stack traceback:
	...hare/nvim/lazy/rzls.nvim/lua/rzls/documentstore/init.lua:59: in function 'update_html_vbuf'
	...cal/share/nvim/lazy/rzls.nvim/lua/rzls/handlers/init.lua:38: in function 'handler'
	/usr/local/share/nvim/runtime/lua/vim/lsp/client.lua:1005: in function ''
	vim/_editor.lua: in function <vim/_editor.lua:0>
Error executing vim.schedule lua callback: ...hare/nvim/lazy/rzls.nvim/lua/rzls/documentstore/init.lua:21: attempt to index a nil value
stack traceback:
	...hare/nvim/lazy/rzls.nvim/lua/rzls/documentstore/init.lua:21: in function 'update_csharp_vbuf'
	...cal/share/nvim/lazy/rzls.nvim/lua/rzls/handlers/init.lua:34: in function 'handler'
	/usr/local/share/nvim/runtime/lua/vim/lsp/client.lua:1005: in function ''
	vim/_editor.lua: in function <vim/_editor.lua:0>
Error executing vim.schedule lua callback: ...hare/nvim/lazy/rzls.nvim/lua/rzls/documentstore/init.lua:59: attempt to index a nil value

my config setup:

local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities = vim.tbl_deep_extend('force', capabilities, require('cmp_nvim_lsp').default_capabilities())

local rzls_path = '.........../razor/artifacts/LanguageServer/Debug/net8.0/linux-x64/'

require('rzls').setup {
  on_attach = function() end,
  capabilities = capabilities,
  path = rzls_path,
}

@tris203
Copy link
Owner

tris203 commented Nov 11, 2024

Can you guys try again. There have been a lot of updates to the workings of this

@nomis51
Copy link

nomis51 commented Nov 14, 2024

I finally was able to make it work with your latest work (on native Windows). Can't say it's an easy ride yet, but it's getting there, great work!

I installed roslyn manually (but I believe it would work with mason aswell) and installed rzls with mason.

I had to path manually to the rzls.cmd file located in the nvim-data folder (where neovim packages/data are stored on Windows) for rzls to work. I used your example roslyn config.

And finally it does work, both rzls and roslyn hook up when required. I didn't experience the problem of "open a .cs file first breaks rzls". For me no matter in what other I open files at first, it seems to work (razor then cs, cs then razor, cshtml then cs, etc.)

Although I had one error spamming 5 times as I first open a razor file (but it didn't seem to break anything afaik)

Error executing luv callback:

 ...ocal/nvim-data/lazy/rzls.nvim/lua/rzls/documentstore.lua:38: E5560: Vimscript function must not be called in a lua loop callback stack traceback: 
 
 [C]: in function 'uri_to_bufnr' ...ocal/nvim-data/lazy/rzls.nvim/lua/rzls/documentstore.lua:38: in function 'register_vbufs_by_path' 
 
 ...AppData/Local/nvim-data/lazy/rzls.nvim/lua/rzls/init.lua:180: in function <...AppData/Local/nvim-data/lazy/rzls.nvim/lua/rzls/init.lua:175>

Also, it might simply be WIP as of now, but I'm pointing it out : local @code blocks work, LSP provide completion, but not for code-behind

image

But if I use an explicit code-behind class, it does work

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants