From: Andreas Louv Date: Thu, 13 Apr 2023 18:59:08 +0000 (+0200) Subject: Make servers with a non matching 'rootSearch' score below servers without 'rootSearch' X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=2692228d6412b3951f2f92e6d40fb685ad062658;p=vim-lsp.git Make servers with a non matching 'rootSearch' score below servers without 'rootSearch' This makes it possible to configure a server to run within a given repository, while having another one run for everything else. --- diff --git a/autoload/lsp/lsp.vim b/autoload/lsp/lsp.vim index 88e0b08..1e3c93c 100644 --- a/autoload/lsp/lsp.vim +++ b/autoload/lsp/lsp.vim @@ -55,7 +55,7 @@ def LspGetServers(bnr: number, ftype: string): list> # All the langauge servers with the same score are being used var bestMatches: list> = [] - 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> # 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