Closed allan-simon closed 6 months ago
@allan-simon I was thinking a lot before setting it to getcwd()
but could not think of anything better. How would an API for choosing a workspace could look like in your opinion?
would something like
vim.lsp.buf.list_workspace_folders()[1] or getcwd()
work?
exactly , lsp has already all the internal mechanism to determine the workspace root directory so you don't need to reimplement it on your side :)
https://github.com/neovim/nvim-lspconfig/tree/master/lua/lspconfig/server_configurations
https://github.com/neovim/nvim-lspconfig/blob/master/lua/lspconfig/server_configurations/tsserver.lua#L15 for example here it will determine the root directory as any parent directory with a package.json or a .git
If list_workspace_folders is stable API that would be great. BTW - Tabnine knows to index multiple workspaces at once. So no need for [1]. I'm ooo today.. so will issue a PR tomorrow
@amirbilu i believe that list_workspace_folders is stable. btw, it may return an empty table (if no lsp detects a root), so it may be a good idea to check the length and default to the cwd if it's empty
at least it is listed on their documentation https://neovim.io/doc/user/lsp.html#lsp-api
so I've been looking at list_worpskace_folders
and it seems to be working, but only when lsp is ready, which means we need to into to trigger inside the lsp on_attach, this can be done but it means tabnine setup will be a bit more complicated now. What's your perspective on this?
Personally it's ok if tabnine does not start "straight" away (the same as for lsp) as it enhance my workflow and is not a vital part of it (I mean I code if during 3 seconds of my session I don't have LSP or Tabnine )
so what are you suggesting? polling?
https://github.com/rcarriga/nvim-notify/wiki/Usage-Recipes/#lsp-status-updates
does something like this will work ?
vim.lsp.handlers["$/progress"] = function(_, result, ctx)
local client_id = ctx.client_id
local val = result.value
if not val.kind then
return
end
if val.kind == "end" then
your code here
?
(I haven't tested it , just spent some times to see if lsp had already some kind of event handler on which you could attach)
this seems to be working.. i'll issue a PR soon
@allan-simon apologies on the delay.. can you please check if this is working for you?
closing this as solved
Is your feature request related to a problem? Please describe.
Currently Tabnine seems to my current working directory for the "workspace" used by TabnineChat
However my vim settings use "autochdir" , so Tabnine seems to only take as "workspace" the current directory of my current active panel
Describe the solution you'd like
I would like to be able to hardwire it
Describe alternatives you've considered
it can also search for
.git
directory