Context: I want to open throw-away files, usually I create them under /tmp
but can be any other directory. I want to have tsserver
and eslint
(maybe others later) LSP servers attached to that buffer.
Current behaviour: LSP doesn’t start if I open a file under a folder that doesn’t have any matching root pattern (package.json
, .git
, tsconfig.json
, jsconfig.json
).
Even forcing a start once the file is opened with :LspStart tsserver
doesn’t work.
Desired behaviour: I’d like to have tsserver
attached based on filetype.
What have I tried:
-
mkdir /tmp/test && nvim /tmp/test/thingy.js
→ NO Language Server bound - with that file opened tried
:LspStart
→ NO Language Server bound -
touch /tmp/test/package.json & nvim /tmp/test/thingy.js
→tsserver
bound,eslint
not bound - created
~/.config/nvim/after/ftplugin/javascript.lua
an inside I put:
vim.cmd([[LspStart]])
→ NO Language Server bound
- tried with a different command, but same approach:
require('lspconfig.configs').tsserver.launch()
But still NO Language Server bound
So I read the suggested :h lspconfig-root-detection
help, which lead me to :h lspconfig-all
help, but that’s a dead end, because I cannot access the tsserver
help, it seems it’s not properly linked or maybe there’s nothing to link.
I want to have the proper language server bound to my buffer, regardless if it doesn’t belong to any project. What should I change in order to achieve that?
Feel free to check my Neovim configuration if it helps to answer this. I haven’t committed the after ftplugin yet.