basedpyright icon indicating copy to clipboard operation
basedpyright copied to clipboard

Add `--version` command to basedpyright-langserver binary

Open ashb opened this issue 10 months ago • 9 comments

This is not important or affecting anything at all really, but, if you use this in neovim and run the :checkhealth command it shows this:

LSP configs active in this buffer (bufnr: 505) ~
- Language client log: ~/.local/state/nvim/lsp.log
- Detected filetype: `python`
- 2 client(s) attached to this buffer
- Client: `basedpyright` (id: 1, bufnr: [483, 45, 198, 39, 505, 458, 50, 48, 46, 42, 40, 165])
  root directory:    ~/code/airflow/airflow/providers/celery/
  filetypes:         python
  cmd:               ~/.local/share/nvim/mason/bin/basedpyright-langserver --stdio
  version:           `?` (Failed to get version) Tried:
  `/Users/ash/.local/share/nvim/mason/bin/basedpyright-langserver --version`
  `/Users/ash/.local/share/nvim/mason/bin/basedpyright-langserver -version`
  `/Users/ash/.local/share/nvim/mason/bin/basedpyright-langserver version`
  `/Users/ash/.local/share/nvim/mason/bin/basedpyright-langserver --help`
  
  executable:        true
  autostart:         true

Running the command manually I see this error:

/Users/ash/.local/share/nvim/mason/packages/basedpyright/venv/lib/python3.12/site-packages/basedpyright/dist/pyright-langserver.js:34880
    throw new Error("Connection input stream is not set. " + commandLineMessage);
          ^

Error: Connection input stream is not set. Use arguments of createConnection or set command line parameters: '--node-ipc', '--stdio' or '--socket={number}'
    at _createConnection (/Users/ash/.local/share/nvim/mason/packages/basedpyright/venv/lib/python3.12/site-packages/basedpyright/dist/pyright-langserver.js:34880:11)
    at createConnection (/Users/ash/.local/share/nvim/mason/packages/basedpyright/venv/lib/python3.12/site-packages/basedpyright/dist/pyright-langserver.js:34831:10)
    at run (/Users/ash/.local/share/nvim/mason/packages/basedpyright/venv/lib/python3.12/site-packages/basedpyright/dist/pyright-langserver.js:124324:47)
    at async main (/Users/ash/.local/share/nvim/mason/packages/basedpyright/venv/lib/python3.12/site-packages/basedpyright/dist/pyright-langserver.js:124288:5)

Node.js v22.13.1

Having --help or --version work would be nice, but everything is working perfectly fine without this, it's just a nice to have

ashb avatar Jan 30 '25 09:01 ashb

does neovim just try various different arguments to the language server command assuming one of them will work? as far as i know the language server spec doesn't mandate that servers support --help or --version cli arguments. i think returning serverInfo in InitializeResult would probably be a better option than the client guessing different commands (#1022)

DetachHead avatar Jan 30 '25 10:01 DetachHead

Yeah it's just nvim trying it and hoping.

That said, having a --help option that prints something is no bad thing, no?

ashb avatar Feb 12 '25 18:02 ashb

i think returning serverInfo in InitializeResult would probably be a better option than the client guessing different commands (#1022)

that's true! Neovim already reads InitializeResult.serverInfo https://github.com/neovim/neovim/pull/31611, I believe the CLI approach is just a fallback in case the server doesn't provide serverInfo

disrupted avatar Feb 13 '25 16:02 disrupted

since #1077 has been merged i think this issue can be closed

DetachHead avatar Feb 14 '25 09:02 DetachHead

That said, having a --help option that prints something is no bad thing, no?

I agree with this. It would be nice to have a very minimal help menu. Perhaps we could open a separate issue for it?

disrupted avatar Feb 14 '25 09:02 disrupted

i'll leave this issue open then but curious as to what the use case is if it's already covered by the lsp spec. i think it's only worth doing if there's a client that doesn't read serverInfo for some reason

DetachHead avatar Feb 14 '25 09:02 DetachHead

i'll leave this issue open then but curious as to what the use case is if it's already covered by the lsp spec. i think it's only worth doing if there's a client that doesn't read serverInfo for some reason

The use is if you try to invoke it directly in a shell by mistake etc.

ashb avatar Feb 28 '25 06:02 ashb

currently it crashes with a stack trace if you do that, which i guess should be fixed

DetachHead avatar Feb 28 '25 07:02 DetachHead

+1, trying to add this as a kakoune LSP integration, but a) it took a bit to realize basedpyright != basedpyright-langserver and b) I don't have a great way of figuring out how to pipe input into the LSP.

khoover avatar Oct 01 '25 23:10 khoover