return []
endif
- var lspservers = ftypeServerMap[ftype]
-
- # All the langauge servers with the same score are being used
- var bestMatches: list<dict<any>> = []
- var bestScore: number = -2
-
var bufDir = bnr->bufname()->fnamemodify(':p:h')
- for lspserver in lspservers
- var score: number = 0
-
- if !lspserver.rootSearchFiles->empty()
- # The score is calculated by how deep the workspace root dir is, the
- # deeper the better.
- var path = util.FindNearestRootDir(bufDir, lspserver.rootSearchFiles)
- # subtract one to make servers with a non matching 'rootSearch' rank below
- # servers without a 'rootSearch'.
- score = path->strcharlen() - 1
+ return ftypeServerMap[ftype]->filter((key, lspserver) => {
+ if lspserver.runIfSearchFiles->empty()
+ return true
endif
- if score > bestScore
- bestMatches = [lspserver]
- bestScore = score
- elseif score == bestScore
- bestMatches->add(lspserver)
- endif
- endfor
+ var path = util.FindNearestRootDir(bufDir, lspserver.runIfSearchFiles)
- return bestMatches
+ # Run the server if the path is found
+ return !path->empty()
+ })
enddef
# Add a LSP server for a filetype
server.rootSearch = []
endif
+ if !server->has_key('runIfSearch') || server.runIfSearch->type() != v:t_list
+ server.runIfSearch = []
+ endif
+
var lspserver: dict<any> = lserver.NewLspServer(server.name, server.path,
args, server.syncInit,
initializationOptions,
server.workspaceConfig,
server.rootSearch,
+ server.runIfSearch,
customNotificationHandlers,
features, server.debug)
isSync: bool, initializationOptions: any,
workspaceConfig: dict<any>,
rootSearchFiles: list<any>,
+ runIfSearchFiles: list<any>,
customNotificationHandlers: dict<func>,
features: dict<bool>, debug_arg: bool): dict<any>
var lspserver: dict<any> = {
caps: {},
requests: {},
rootSearchFiles: rootSearchFiles,
+ runIfSearchFiles: runIfSearchFiles,
omniCompletePending: false,
completionTriggerChars: [],
signaturePopup: -1,
closest to the directory of the current buffer is used
as the workspace root.
- This option is also used to decide which server to run
- when multiple servers are defined for a filetype. The
- servers that share the longest found workspace root will
- be selected as the relevant language servers for a given
- file.
-
If this parameter is not 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:
+ *lsp-cfg-runIfSearch*
+ runIfSearch (Optional) a List of file and directory names used to
+ determinate if a server should run or not. The directory
+ names in "runIfSearch" must end in "/" or "\". Each
+ file and directory name in "runIfSearch" is searched
+ upwards in all the parent directories. Exactly like
+ |lsp-cfg-rootSearch|.
+
+ If a file or directory is found then the server will be
+ started, otherwise it will not.
+
+ If this parameter is not specified or is an empty list,
+ then the server will always be started.
+
+Additionally the following configurations can be made:
*lsp-cfg-customNotificationHandlers*
customNotificationHandlers