Attempting to setup tsserver following the instructions in the nvim-lspconfig docs.
Everything works great except that when I call vim.lsp.buf.workspace_symbol("whatever") I get symbols from my node_modules in addition to those in my own code.
I use a jsconfig.json file as suggested in the docs:
Experimenting with adding different folders to “exclude” I do get the expected results, so I know that the jsconfig.json is being read and processed. My suspicion is then that tsserver gets symbols from all packages that I import, in this case e.g. React (and all it’s imports?).
Could this be what’s happening and if so how do I stop it? I want to get a list of all the symbols in my code, like vim.lsp.buf.document_symbol() but for all the files in my workspace (excluding node_modules).
Huh that is weird, I’m trying this on my repo which has a jsconfig (poker-game-app) and I’m not getting any workspace symbols from node_modules at all.
What I did: opened src/App.jsx and performed a workspace symbol search for useStyles with :lua vim.lsp.buf.workspace_symbol('useStyles')
I’m not sure what else could be an issue, but take a look at the jsconfig there and see if there is anything missing or something different.
Ok, so in poker-game-app when I do :lua vim.lsp.buf.workspace_symbol('useStyles') I indeed get only symbols from the project.
But if I try :lua vim.lsp.buf.workspace_symbol('render') I get node_modules symbols, e.g:
node_modules/react-dom/cjs/react-dom.production.min.js|282 col 220| [Method] render
Grepping I find that both useStyles and render are present in node_modules, so this might support my theory that workspace symbols are being polluted (from my point of view) by imports.
Would be interesting to see if you get the same results as I do with ‘render’ as search string, if you have the time. If i use the empty string (should return all symbols), I get no results at all - my suspicion is that this is because some maximum is reached.
Hey, so I tried it and you’re right I also see node_modules when I do render. Looking further into the workspace/symbol lsp protocol it seems like it doesn’t have the ability to ignore files/folders? I’m not too sure so probably want to ask this in the typescript-language-server issues page.
Thanks for the help. I figured I should ask in typescript-language-server, but thought this seemed like such a common use case that I assumed I had configured something wrong.
In my use case filtering the quickfix list doesn’t really cut it, since I am most interested in using workspace/symbol with an empty search string to get all symbols. But this returns nothing, as I said. What I am after is for this to replace ctags, letting me quickly jump to any symbol in my code.