Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Utilities
Kate
Commits
0d0e526f
Commit
0d0e526f
authored
Jun 12, 2021
by
Mark Nauwelaerts
Browse files
lspclient: specify null rootUri if no project and empty root config
parent
70763b8a
Changes
1
Hide whitespace changes
Inline
Side-by-side
addons/lspclient/lspclientservermanager.cpp
View file @
0d0e526f
...
...
@@ -536,7 +536,7 @@ private:
// NOTE that also covers a form of environment substitution using %{ENV:XYZ}
auto
editor
=
KTextEditor
::
Editor
::
instance
();
QString
rootpath
;
std
::
optional
<
QString
>
rootpath
;
const
auto
rootv
=
serverConfig
.
value
(
QStringLiteral
(
"root"
));
if
(
rootv
.
isString
())
{
auto
sroot
=
rootv
.
toString
();
...
...
@@ -545,7 +545,11 @@ private:
rootpath
=
sroot
;
}
else
if
(
!
projectBase
.
isEmpty
())
{
rootpath
=
QDir
(
projectBase
).
absoluteFilePath
(
sroot
);
}
else
if
(
sroot
.
isEmpty
())
{
// empty root; so we are convinced the server can handle null rootUri
rootpath
=
QString
();
}
else
if
(
const
auto
url
=
document
->
url
();
url
.
isValid
()
&&
url
.
isLocalFile
())
{
// likewise, but use safer traditional approach and specify rootUri
rootpath
=
QDir
(
QFileInfo
(
url
.
toLocalFile
()).
absolutePath
()).
absoluteFilePath
(
sroot
);
}
}
...
...
@@ -555,15 +559,16 @@ private:
* this is required for some LSP servers like rls that don't handle that on their own like
* clangd does
*/
if
(
rootpath
.
isEmpty
()
)
{
if
(
!
rootpath
)
{
const
auto
fileNamesForDetection
=
serverConfig
.
value
(
QStringLiteral
(
"rootIndicationFileNames"
));
if
(
fileNamesForDetection
.
isArray
())
{
// we try each file name alternative in the listed order
// this allows to have preferences
for
(
auto
name
:
fileNamesForDetection
.
toArray
())
{
if
(
name
.
isString
())
{
rootpath
=
rootForDocumentAndRootIndicationFileName
(
document
,
name
.
toString
());
if
(
!
rootpath
.
isEmpty
())
{
auto
root
=
rootForDocumentAndRootIndicationFileName
(
document
,
name
.
toString
());
if
(
!
root
.
isEmpty
())
{
rootpath
=
root
;
break
;
}
}
...
...
@@ -572,11 +577,11 @@ private:
}
// last fallback: home directory
if
(
rootpath
.
isEmpty
()
)
{
if
(
!
rootpath
)
{
rootpath
=
QDir
::
homePath
();
}
auto
root
=
QUrl
::
fromLocalFile
(
rootpath
);
auto
root
=
rootpath
&&
!
rootpath
->
isEmpty
()
?
QUrl
::
fromLocalFile
(
*
rootpath
)
:
QUrl
()
;
auto
&
serverinfo
=
m_servers
[
root
][
langId
];
auto
&
server
=
serverinfo
.
server
;
if
(
!
server
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment