autoload/lsp/lspserver.vim | 14 ++++++++++++-- doc/lsp.txt | 6 ++++-- diff --git a/autoload/lsp/lspserver.vim b/autoload/lsp/lspserver.vim index 2d71cd9a0479c7d04ce7141dedd776b499f85e40..e652d015fe53dd40fe3de92869e667109ea99818 100644 --- a/autoload/lsp/lspserver.vim +++ b/autoload/lsp/lspserver.vim @@ -155,12 +155,22 @@ # Compute the rootpath (based on the directory of the buffer) var rootPath = '' var rootSearchFiles = lspserver.rootSearchFiles + var bufDir = bnr->bufname()->fnamemodify(':p:h') if !rootSearchFiles->empty() - var bufDir = bnr->bufname()->fnamemodify(':p:h') rootPath = util.FindNearestRootDir(bufDir, rootSearchFiles) endif if rootPath == '' - rootPath = getcwd() + var cwd = getcwd() + + # bufDir is within cwd + var bufDirPrefix = bufDir[0 : cwd->strcharlen() - 1] + if &fileignorecase + ? bufDirPrefix ==? cwd + : bufDirPrefix ==# cwd + rootPath = cwd + else + rootPath = bufDir + endif endif lspserver.workspaceFolders = [rootPath] diff --git a/doc/lsp.txt b/doc/lsp.txt index 6ea8a030e78675cd64120a333672c528ab63eb06..56e58022a6d80ce627e20b83912b81664d09207a 100644 --- a/doc/lsp.txt +++ b/doc/lsp.txt @@ -270,8 +270,10 @@ searched upwards in all the parent directories. If multiple directories are found, then the directory closest to the directory of the current buffer is used as the workspace root. If this parameter is not - specified or the files are not found, then the - current working directory is used as the workspace root. + specified or the files are not found, then the current + working directory is used as the workspace root for + decendent files, for any other files the parent + directory of the file is used. Aditionally the following configurations can be made: