LSP should be able to attach to unnamed buffer
Language server
all (yamlls in the example)
Requested feature
Currently, the lsp server won't attach to an unnamed buffer because of this: https://github.com/neovim/nvim-lspconfig/blob/932164a3cc87eafdd20c7d271037bea913b31c7b/lua/lspconfig/configs.lua#L89-L90
I want the language server to do formatting linting and diagnostics on unnamed buffers when the language server or the user doesn't care about a workspace to be passed.
jsonls:
mkdir /tmp/unnamed-buffer-test
cd /tmp/unnamed-buffer-test
curl -sLO https://gist.githubusercontent.com/mosheavni/20c60ea4fe7d63554b6fbbd21a5fd59e/raw/3e001e4607664df0fa168f80d1bae138449a579d/minimal_init.lua
curl -s https://gist.githubusercontent.com/mosheavni/ef05c2c3aef46c9a14b2a63316a5c0a1/raw/313fd484f6b94727ccf1dc3d6b469659a9bdb5ca/myfile.json | nvim -nu minimal_init.lua
Now set the filetype to json:
:setf json
Should output `client jsonls is attached" does not.
:LspInfo
Other clients which have this feature
No response
No idea why this feature is not out of the box. can anyone please help? Any way to bypass this behaviour in my local config?
This is truly a real pain in using neovim.
I open a lot of kubectl get .. -oyaml | vim and I want formatting and diagnostics right away.
Same for curl -Ls https://......json | vim
There are so many cases where I'd want lsp to attach to an unnamed buffer.
More than that, I even introduced a PR which for even weirder reason isn't approved since there's a workflow that doesn't allow the use of vim.fn.getcwd()
it should be support I will take a look at this when i have time. thanks for report :)
@mosheavni sorry for late . currently I can make it works fine. but I just want to know do we want only support with the
single_file_support ? I think it can be support for any server ?
@glepnir I don't want to assume about any language server I don't know / not using, but this is an expected behaviour. If someone copies a code from stackoverflow, opens a new buffer and wants completion and diagnostics without having to save the file first, this is a desired behaviour.
yep also think so. then I need do some works to make it more compete . also I need to check what the vscode do in this situation