cssmodules-language-server icon indicating copy to clipboard operation
cssmodules-language-server copied to clipboard

‌‌[help] not working properly

Open Daydreamer-riri opened this issue 1 year ago • 8 comments

‌‌‌I have configured cssmodule-ls in lazyvim, and it can be displayed in LspInfo, but neither completion nor navigation is working.

image image image

Daydreamer-riri avatar Aug 15 '24 03:08 Daydreamer-riri

Please provide a repository to repro the issue, installed version and configuration without a distribution. Otherwise the issue is too vague to guess what could be wrong.

antonk52 avatar Aug 15 '24 08:08 antonk52

‌‌‌‌Sorry. My configuration repository is here: https://github.com/Daydreamer-riri/LazyVimConfig The lsp configuration is here: https://github.com/Daydreamer-riri/LazyVimConfig/blob/main/lua/plugins/lsp.lua

Additionally, my nvim version is 0.10.1.

If you need any information, please let me know!

Daydreamer-riri avatar Aug 15 '24 08:08 Daydreamer-riri

I do not have the time to set up your neovim configuration. This goes outside of the scope of this project.

You can create a test_cssm_ls.lua file with the following content

vim.api.nvim_create_autocmd('FileType', {
    pattern = { 'typescript', 'typescriptreact', 'javascript', 'javascriptreact' },
    callback = function()
        vim.lsp.start({
            name = 'cssmodules_ls',
            cmd = { 'cssmodules-language-server' },
            root_dir = vim.uv.cwd(),
        })
    end,
})

And file.js and style.css files

file.js content

import css from './style.css';

css.button;

style.css content

.button {
  color: red;
}

You can start neovim with nvim -u path/to/test_cssm_ls.lua ./path/to/file.js

I've just verified that go to definition and hover both work. If this works then the language server works as expected. If this works but the LazyVim setup doesn't than the issue with the LazyVim setup.

antonk52 avatar Aug 15 '24 14:08 antonk52

Hi @antonk52 , thank you so much for your patience! I understand that you don't need to do anything for me.

I just used my personal computer, using the config from my repo in WSL and everything is working fine.

I'm not sure if it's a system problem (the computer I'm having trouble with is Windows), but I'll try something tomorrow with what you said.

Thanks again for your reply!

Daydreamer-riri avatar Aug 15 '24 14:08 Daydreamer-riri

No worries, if the issue with the LazyVim itself I can suggest opening an issue in LazyVim. I know that there are users of cssmodules-lanague-server on windows so it should be working fine. If you can verify that the example I provided above is working than the issue is with the LazyVim or lspconfig setup and should be reported in the respected repository.

Happy to help if we can narrow the problem down to this project!

antonk52 avatar Aug 15 '24 16:08 antonk52

Hi, I've encountered some issues, and I've recorded them in a video.

https://github.com/user-attachments/assets/4553f02e-9d75-45ff-820a-2e31df77fae0

What should I do next?

Daydreamer-riri avatar Aug 16 '24 04:08 Daydreamer-riri

A few things stood out from the video

  • There was an error saying that the server did not start as it was not available from the $PATH. You try replacing the language server name with an absolute path to the executable
  • When running nvim -u ./test_cssm_ls.lua you tried to see if completion would work. While the language server supports completing the classnames, it won't work as neovim does not support lsp completion out of the box without additional configuration. You can verify that the server works correctly by calling go-to-defintion or hover over the classname in a javascript file

antonk52 avatar Aug 16 '24 09:08 antonk52

‌‌‌‌‌The first reason is that the default language server's executable file is in PS1(powershell) format. After using the absolute path of the CMD format, it no longer prompts that the server has not started.

After the language server started normally, both hover and go-to-definition worked properly. I will continue to experiment next week to see if it is due to my configuration.

Enjoy your weekend~

Daydreamer-riri avatar Aug 16 '24 10:08 Daydreamer-riri

Hi @antonk52, sorry I was a little busy a while back. In the meantime I replaced a work computer. The same problem exists in this new computer.

image {5A859B06-C55D-405D-B1BA-9DFA9B0BF62C}

Daydreamer-riri avatar Sep 03 '24 09:09 Daydreamer-riri

Can you please provide share the output of these two commands?

node --version
cssmodules-language-server --version

antonk52 avatar Sep 03 '24 14:09 antonk52

{71857AB1-4918-46B9-A1F1-0C5DC677E17F} {19C63CB5-FA28-4F9C-B843-94FAB6F7114D}

Daydreamer-riri avatar Sep 04 '24 02:09 Daydreamer-riri

Odd, I am not too sure why this is the case and I don't have a windows machine to troubleshoot this. Can you build the server from source and debug if the server receives a request for hover/go-to-definition?

git clone https://github.com/antonk52/cssmodules-language-server.git
cd cssmodules-language-server
npm install
npm run build

This creates a lib directory. lib/cli.js file is what is being run for a language server. You can add log statements and see them in LspLog output. You can also add vim.lsp.log.set_level(vim.lsp.log.DEBUG) to you init.lua for a more verbose output. I suggest disabling other language servers to only see the logs from the cssmosules' one

antonk52 avatar Sep 04 '24 10:09 antonk52

I haven't added new log yet:

[DEBUG][2024-09-04 19:50:24] ...m/lsp/client.lua:678	"LSP[cssmodules_ls]"	"client.request"	1	"textDocument/hover"	{  position = {    character = 10,    line = 2  },  textDocument = {    uri = "file:///E:/person/demos/main.js"  }}	<function 1>	1
[DEBUG][2024-09-04 19:50:24] .../vim/lsp/rpc.lua:286	"rpc.send"	{  id = 3,  jsonrpc = "2.0",  method = "textDocument/hover",  params = {    position = {      character = 10,      line = 2    },    textDocument = {      uri = "file:///E:/person/demos/main.js"    }  }}
[DEBUG][2024-09-04 19:50:24] .../vim/lsp/rpc.lua:408	"rpc.receive"	{  id = 3,  jsonrpc = "2.0"}
[DEBUG][2024-09-04 19:50:29] ...m/lsp/client.lua:678	"LSP[cssmodules_ls]"	"client.request"	1	"textDocument/hover"	{  position = {    character = 9,    line = 2  },  textDocument = {    uri = "file:///E:/person/demos/main.js"  }}	<function 1>	1
[DEBUG][2024-09-04 19:50:29] .../vim/lsp/rpc.lua:286	"rpc.send"	{  id = 4,  jsonrpc = "2.0",  method = "textDocument/hover",  params = {    position = {      character = 9,      line = 2    },    textDocument = {      uri = "file:///E:/person/demos/main.js"    }  }}
[DEBUG][2024-09-04 19:50:29] .../vim/lsp/rpc.lua:408	"rpc.receive"	{  id = 4,  jsonrpc = "2.0"}
[DEBUG][2024-09-04 19:50:57] ...m/lsp/client.lua:678	"LSP[cssmodules_ls]"	"client.request"	1	"textDocument/hover"	{  position = {    character = 9,    line = 2  },  textDocument = {    uri = "file:///E:/person/demos/main.js"  }}	<function 1>	1
[DEBUG][2024-09-04 19:50:57] .../vim/lsp/rpc.lua:286	"rpc.send"	{  id = 5,  jsonrpc = "2.0",  method = "textDocument/hover",  params = {    position = {      character = 9,      line = 2    },    textDocument = {      uri = "file:///E:/person/demos/main.js"    }  }}
[DEBUG][2024-09-04 19:50:57] .../vim/lsp/rpc.lua:408	"rpc.receive"	{  id = 5,  jsonrpc = "2.0"}
[DEBUG][2024-09-04 19:50:57] ...m/lsp/client.lua:678	"LSP[cssmodules_ls]"	"client.request"	1	"textDocument/hover"	{  position = {    character = 9,    line = 2  },  textDocument = {    uri = "file:///E:/person/demos/main.js"  }}	<function 1>	1
[DEBUG][2024-09-04 19:50:57] .../vim/lsp/rpc.lua:286	"rpc.send"	{  id = 6,  jsonrpc = "2.0",  method = "textDocument/hover",  params = {    position = {      character = 9,      line = 2    },    textDocument = {      uri = "file:///E:/person/demos/main.js"    }  }}
[DEBUG][2024-09-04 19:50:57] .../vim/lsp/rpc.lua:408	"rpc.receive"	{  id = 6,  jsonrpc = "2.0"}
[DEBUG][2024-09-04 19:50:58] ...m/lsp/client.lua:678	"LSP[cssmodules_ls]"	"client.request"	1	"textDocument/hover"	{  position = {    character = 9,    line = 2  },  textDocument = {    uri = "file:///E:/person/demos/main.js"  }}	<function 1>	1
[DEBUG][2024-09-04 19:50:58] .../vim/lsp/rpc.lua:286	"rpc.send"	{  id = 7,  jsonrpc = "2.0",  method = "textDocument/hover",  params = {    position = {      character = 9,      line = 2    },    textDocument = {      uri = "file:///E:/person/demos/main.js"    }  }}
[DEBUG][2024-09-04 19:50:58] .../vim/lsp/rpc.lua:408	"rpc.receive"	{  id = 7,  jsonrpc = "2.0"}
[DEBUG][2024-09-04 19:51:01] ...m/lsp/client.lua:678	"LSP[cssmodules_ls]"	"client.request"	1	"textDocument/implementation"	{  position = {    character = 9,    line = 2  },  textDocument = {    uri = "file:///E:/person/demos/main.js"  }}	<function 1>	1
[DEBUG][2024-09-04 19:51:01] .../vim/lsp/rpc.lua:286	"rpc.send"	{  id = 8,  jsonrpc = "2.0",  method = "textDocument/implementation",  params = {    position = {      character = 9,      line = 2    },    textDocument = {      uri = "file:///E:/person/demos/main.js"    }  }}
[DEBUG][2024-09-04 19:51:01] .../vim/lsp/rpc.lua:408	"rpc.receive"	{  id = 8,  jsonrpc = "2.0"}
[DEBUG][2024-09-04 19:51:07] ...m/lsp/client.lua:678	"LSP[cssmodules_ls]"	"client.request"	1	"textDocument/hover"	{  position = {    character = 9,    line = 2  },  textDocument = {    uri = "file:///E:/person/demos/main.js"  }}	<function 1>	1
[DEBUG][2024-09-04 19:51:07] .../vim/lsp/rpc.lua:286	"rpc.send"	{  id = 9,  jsonrpc = "2.0",  method = "textDocument/hover",  params = {    position = {      character = 9,      line = 2    },    textDocument = {      uri = "file:///E:/person/demos/main.js"    }  }}
[DEBUG][2024-09-04 19:51:07] .../vim/lsp/rpc.lua:408	"rpc.receive"	{  id = 9,  jsonrpc = "2.0"}
[DEBUG][2024-09-04 19:51:10] .../vim/lsp/rpc.lua:286	"rpc.send"	{  jsonrpc = "2.0",  method = "textDocument/didChange",  params = {    contentChanges = { {        range = {          ["end"] = {            character = 13,            line = 2          },          start = {            character = 6,            line = 2          }        },        rangeLength = 7,        text = ""      } },    textDocument = {      uri = "file:///E:/person/demos/main.js",      version = 4    }  }}
[DEBUG][2024-09-04 19:51:10] .../vim/lsp/rpc.lua:286	"rpc.send"	{  jsonrpc = "2.0",  method = "textDocument/didChange",  params = {    contentChanges = { {        range = {          ["end"] = {            character = 6,            line = 2          },          start = {            character = 6,            line = 2          }        },        rangeLength = 0,        text = "."      } },    textDocument = {      uri = "file:///E:/person/demos/main.js",      version = 5    }  }}
[DEBUG][2024-09-04 19:51:10] ...m/lsp/client.lua:678	"LSP[cssmodules_ls]"	"client.request"	1	"textDocument/completion"	{  context = {    triggerCharacter = ".",    triggerKind = 2  },  position = {    character = 7,    line = 2  },  textDocument = {    uri = "file:///E:/person/demos/main.js"  }}	<function 1>	1
[DEBUG][2024-09-04 19:51:10] .../vim/lsp/rpc.lua:286	"rpc.send"	{  id = 10,  jsonrpc = "2.0",  method = "textDocument/completion",  params = {    context = {      triggerCharacter = ".",      triggerKind = 2    },    position = {      character = 7,      line = 2    },    textDocument = {      uri = "file:///E:/person/demos/main.js"    }  }}
[DEBUG][2024-09-04 19:51:10] .../vim/lsp/rpc.lua:408	"rpc.receive"	{  id = 10,  jsonrpc = "2.0"}
[DEBUG][2024-09-04 19:51:12] .../vim/lsp/rpc.lua:286	"rpc.send"	{  jsonrpc = "2.0",  method = "textDocument/didChange",  params = {    contentChanges = { {        range = {          ["end"] = {            character = 7,            line = 2          },          start = {            character = 7,            line = 2          }        },        rangeLength = 0,        text = "b"      } },    textDocument = {      uri = "file:///E:/person/demos/main.js",      version = 6    }  }}
[DEBUG][2024-09-04 19:51:12] ...m/lsp/client.lua:678	"LSP[cssmodules_ls]"	"client.request"	1	"textDocument/completion"	{  context = {    triggerKind = 1  },  position = {    character = 8,    line = 2  },  textDocument = {    uri = "file:///E:/person/demos/main.js"  }}	<function 1>	1
[DEBUG][2024-09-04 19:51:12] .../vim/lsp/rpc.lua:286	"rpc.send"	{  id = 11,  jsonrpc = "2.0",  method = "textDocument/completion",  params = {    context = {      triggerKind = 1    },    position = {      character = 8,      line = 2    },    textDocument = {      uri = "file:///E:/person/demos/main.js"    }  }}
[DEBUG][2024-09-04 19:51:12] .../vim/lsp/rpc.lua:408	"rpc.receive"	{  id = 11,  jsonrpc = "2.0"}
[DEBUG][2024-09-04 19:51:12] .../vim/lsp/rpc.lua:286	"rpc.send"	{  jsonrpc = "2.0",  method = "textDocument/didChange",  params = {    contentChanges = { {        range = {          ["end"] = {            character = 8,            line = 2          },          start = {            character = 8,            line = 2          }        },        rangeLength = 0,        text = "u"      } },    textDocument = {      uri = "file:///E:/person/demos/main.js",      version = 7    }  }}
[DEBUG][2024-09-04 19:51:12] .../vim/lsp/rpc.lua:286	"rpc.send"	{  jsonrpc = "2.0",  method = "textDocument/didChange",  params = {    contentChanges = { {        range = {          ["end"] = {            character = 9,            line = 2          },          start = {            character = 9,            line = 2          }        },        rangeLength = 0,        text = "t"      } },    textDocument = {      uri = "file:///E:/person/demos/main.js",      version = 8    }  }}
[DEBUG][2024-09-04 19:51:12] .../vim/lsp/rpc.lua:286	"rpc.send"	{  jsonrpc = "2.0",  method = "textDocument/didChange",  params = {    contentChanges = { {        range = {          ["end"] = {            character = 10,            line = 2          },          start = {            character = 10,            line = 2          }        },        rangeLength = 0,        text = "t"      } },    textDocument = {      uri = "file:///E:/person/demos/main.js",      version = 9    }  }}
[DEBUG][2024-09-04 19:51:12] .../vim/lsp/rpc.lua:286	"rpc.send"	{  jsonrpc = "2.0",  method = "textDocument/didChange",  params = {    contentChanges = { {        range = {          ["end"] = {            character = 11,            line = 2          },          start = {            character = 11,            line = 2          }        },        rangeLength = 0,        text = "o"      } },    textDocument = {      uri = "file:///E:/person/demos/main.js",      version = 10    }  }}
[DEBUG][2024-09-04 19:51:13] .../vim/lsp/rpc.lua:286	"rpc.send"	{  jsonrpc = "2.0",  method = "textDocument/didChange",  params = {    contentChanges = { {        range = {          ["end"] = {            character = 12,            line = 2          },          start = {            character = 12,            line = 2          }        },        rangeLength = 0,        text = "n"      } },    textDocument = {      uri = "file:///E:/person/demos/main.js",      version = 11    }  }}
[DEBUG][2024-09-04 19:51:15] .../vim/lsp/rpc.lua:286	"rpc.send"	{  jsonrpc = "2.0",  method = "textDocument/didSave",  params = {    textDocument = {      uri = "file:///E:/person/demos/main.js"    }  }}

Added part log: image

Daydreamer-riri avatar Sep 04 '24 11:09 Daydreamer-riri

I think I found out why. I use '\n' as EOL (to ensure consistency with other colleagues, as well as consistency between local builds and servers). So the 'os.EOL' you used to split the line doesn't apply to me.

My nvim config:

vim.api.nvim_create_autocmd({ "BufNewFile", "BufRead" }, {
  pattern = "*",
  callback = function()
    vim.bo.fileformat = "unix"
  end,
})
{561D92C8-129F-4F90-A2D3-C3A649E85667}

Daydreamer-riri avatar Sep 04 '24 12:09 Daydreamer-riri

Nice job looking into it and spotting the issue!

antonk52 avatar Sep 04 '24 16:09 antonk52

Solved by #30

And released in v1.4.1

Solid job debugging the root issue and contributing a fix for it 💪

antonk52 avatar Sep 04 '24 21:09 antonk52