antonk52 / basics-language-server

Buffer, path, and snippet completions
MIT License
53 stars 0 forks source link

FR: Expose snippet reloading function #1

Closed chrisgrieser closed 1 week ago

chrisgrieser commented 1 week ago

I am the maintainer of nvim-scissors, and would like to implement a hot-reload-support for the basics lsp. To be able to do that, the LSP needs to expose some sort of function that reloads a snippet file inside settings.snippets.sources

snippet engines usually expose such functionality, so other plugins can properly integrate with them, e.g. require("luasnip.loaders").reload_file(path) for luasnip: https://github.com/L3MON4D3/LuaSnip/blob/master/DOC.md#loaders

It would be great for the basics LSP to also expose such a function, though I am not sure how this would work with an LSP as opposed to a lua plugin.

antonk52 commented 1 week ago

Hi, since this is a language server and not a plugin it is tricky. I can see a couple of ways how this can be achieved:

Since the first option requires no additional effort and can work already I think it should be preferred. What do you think?

chrisgrieser commented 1 week ago

Yeah, simply restarting the LSP sounds like a reasonable solution. Since I am not super familiar with LSPs, what would the code be to restart a specific language server?

I only know :LspRestart, which iirc is provided by nvim-lspconfig, and I'd like to avoid adding a dependency just for restarting the LSP

antonk52 commented 1 week ago

Never done this myself. I know that with lspconfig you can restart a specific server with :LSPRestart <server-name>. you can also get completion for the available servers with :LSPRestart <tab>. You can follow to the code where the command is defined to see how it is implemented.

chrisgrieser commented 1 week ago

Hmm yeah, the code looks like there is no builtin method in nvim, it's rather manually detaching, stopping, timing etc. Adding a dependency to nvim-lspconfig for hot-reloading is not ideal, but probably preferable implementing a reload function myself…

Implemented on my end then via https://github.com/chrisgrieser/nvim-scissors/commit/6fd7a0c232ab74c886f57af128b95ab4a81308f3