kawre / leetcode.nvim

A Neovim plugin enabling you to solve LeetCode problems.
MIT License
1.13k stars 48 forks source link

Changing languages doesn't seem to restart LSP #142

Open ReKylee opened 1 week ago

ReKylee commented 1 week ago

My default language is set to Python, but when I use :Leet lang to change to CPP, my LSP, linter and formatter stay on Python.

I've tried opening python and cpp files by themselves and it seems like it works standalone, just not when changing through the command. I've also tried opening a python file, and then switching to a cpp file, and that works too(probably because it opens in a new buffer?)

kawre commented 1 week ago

:Leet lang also opens a new buffer. Could you switch between Python and C++, then paste your LspInfo?

kawre commented 1 week ago

And your neovim version

ReKylee commented 1 week ago

Sure :D

==============================================================================
lspconfig: require("lspconfig.health").check()

LSP configs active in this session (globally) ~
- Configured servers: lua_ls, pyright, ruff, clangd
- OK Deprecated servers: (none)

LSP configs active in this buffer (bufnr: 19) ~
- Language client log: ~\AppData\Local\nvim-data\lsp.log
- Detected filetype: ``
- 0 client(s) attached to this buffer
- 1 active client(s) not attached to this buffer:
- Client: `pyright` (id: 1, bufnr: [7])
  root directory:    Running in single file mode.
  filetypes:         py
  cmd:               ~\AppData\Local\nvim-data\mason\bin\pyright-langserver.CMD --stdio
  version:           `?` (Failed to get version) Tried:
  `C:\Users\ido54\AppData\Local\nvim-data\mason\bin\pyright-langserver.CMD --version`
  `C:\Users\ido54\AppData\Local\nvim-data\mason\bin\pyright-langserver.CMD -version`
  `C:\Users\ido54\AppData\Local\nvim-data\mason\bin\pyright-langserver.CMD version`
  `C:\Users\ido54\AppData\Local\nvim-data\mason\bin\pyright-langserver.CMD --help`

  executable:        true
  autostart:         true

Docs for active configs: ~
- 

from :version NVIM v0.10.2
Build type: Release

kawre commented 1 week ago

when I use :Leet lang to change to CPP, my LSP, linter and formatter stay on Python.

By this, you mean that you are getting python auto completion on a c++ file?

ReKylee commented 1 week ago

{80CBF37D-6087-4684-8A89-2F00C2F9FE1F}

Well actually, it just doesn't do anything and the python linter seems to display python errors on the cpp code

EDIT: Looks like the linter is also dormant, as the warnings remain even if I delete the entire code haha.

kawre commented 1 week ago

How does it behave when you set lang to cpp, then switch to python with :Leet lang?

ReKylee commented 1 week ago

Switching from CPP to Python3 works well, and pyright starts up and I get correct linting, but then switching back to CPP keeps the Python linting for some reason?

kawre commented 1 week ago

Could you add commit = "94c16d8be8d09c0b543782b0323ce6eb1fbc95c5" to leetcode.nvim config? Does it change anything?

ReKylee commented 1 week ago

{4349048C-C834-4AEB-A2F9-C26BA3AFD67E}

With commit = "94c16d8be8d09c0b543782b0323ce6eb1fbc95c5" added, it seems like the previous lint is "stuck"? But the CPP lint and autocomplete work