]> Sergey Matveev's repositories - vim-lsp.git/commitdiff
Make servers with a non matching 'rootSearch' score below servers without 'rootSearch'
authorAndreas Louv <andreas@louv.dk>
Thu, 13 Apr 2023 18:59:08 +0000 (20:59 +0200)
committerAndreas Louv <andreas@louv.dk>
Thu, 13 Apr 2023 18:59:10 +0000 (20:59 +0200)
This makes it possible to configure a server to run within a given
repository, while having another one run for everything else.

autoload/lsp/lsp.vim

index 88e0b086038627ecf674a7754ca5cc6304b12cba..1e3c93c5da6725c591477af6b5e8a773065d83cc 100644 (file)
@@ -55,7 +55,7 @@ def LspGetServers(bnr: number, ftype: string): list<dict<any>>
 
   # All the langauge servers with the same score are being used
   var bestMatches: list<dict<any>> = []
-  var bestScore: number = 0
+  var bestScore: number = -2
 
   var bufDir = bnr->bufname()->fnamemodify(':p:h')
 
@@ -66,7 +66,9 @@ def LspGetServers(bnr: number, ftype: string): list<dict<any>>
       # The score is calculated by how deep the workspace root dir is, the
       # deeper the better.
       var path = util.FindNearestRootDir(bufDir, lspserver.rootSearchFiles)
-      score = path->strcharlen()
+      # subtract one to make servers with a non matching 'rootSearch' rank below
+      # servers without a 'rootSearch'.
+      score = path->strcharlen() - 1
     endif
 
     if score > bestScore