From e55fa57320b284eb38392a5e57b2edee27d966a5 Mon Sep 17 00:00:00 2001 From: Yasuhiro Matsumoto Date: Thu, 20 Feb 2020 00:14:47 +0900 Subject: root_uri patterns should be configurable --- autoload/lsp_settings.vim | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'autoload/lsp_settings.vim') diff --git a/autoload/lsp_settings.vim b/autoload/lsp_settings.vim index f1b163e..9183069 100644 --- a/autoload/lsp_settings.vim +++ b/autoload/lsp_settings.vim @@ -168,13 +168,22 @@ function! lsp_settings#exec_path(cmd) abort return '' endfunction -function! lsp_settings#root_path(...) abort +function! lsp_settings#root_path(name) abort let l:patterns = get(a:000, 0, []) return lsp#utils#find_nearest_parent_file_directory(lsp#utils#get_buffer_path(), extend(l:patterns, g:lsp_settings_root_markers)) endfunction -function! lsp_settings#root_uri(...) abort - let l:patterns = get(a:000, 0, []) +function! lsp_settings#root_uri(name) abort + let l:patterns = [] + for l:ft in sort(keys(s:settings)) + for l:conf in s:settings[l:ft] + if l:conf.command ==# a:name && has_key(l:conf, 'root_uri_patterns') + let l:patterns = l:conf['root_uri_patterns'] + break + endif + endfor + endfor + let l:dir = lsp#utils#find_nearest_parent_file_directory(lsp#utils#get_buffer_path(), extend(l:patterns, g:lsp_settings_root_markers)) if empty(l:dir) return lsp#utils#get_default_root_uri() -- cgit v1.2.3-54-g00ecf From 0e71903b66fdf01d0386ba1b653174dfcec7f21c Mon Sep 17 00:00:00 2001 From: Yasuhiro Matsumoto Date: Thu, 20 Feb 2020 00:18:27 +0900 Subject: Fix root_uri_patterns --- autoload/lsp_settings.vim | 6 +++--- local-schema.json | 15 ++++++++++++--- schema.json | 11 ++++++++++- 3 files changed, 25 insertions(+), 7 deletions(-) (limited to 'autoload/lsp_settings.vim') diff --git a/autoload/lsp_settings.vim b/autoload/lsp_settings.vim index 9183069..fc6282b 100644 --- a/autoload/lsp_settings.vim +++ b/autoload/lsp_settings.vim @@ -345,15 +345,15 @@ function! s:vim_lsp_suggest_plugin() abort let l:ext = expand('%:e') for l:ft in keys(s:settings) for l:server in s:settings[l:ft] - if !has_key(l:server, 'vim-plugin') + if !has_key(l:server, 'vim_plugin') continue endif - if index(l:server['vim-plugin']['extensions'], l:ext) == -1 + if index(l:server['vim_plugin']['extensions'], l:ext) == -1 continue endif redraw echohl Directory - echomsg printf('Please install vim-plugin "%s" to enable Language Server', l:server['vim-plugin']['name']) + echomsg printf('Please install vim-plugin "%s" to enable Language Server', l:server['vim_plugin']['name']) echohl None return endfor diff --git a/local-schema.json b/local-schema.json index 694a97f..bf49ddd 100644 --- a/local-schema.json +++ b/local-schema.json @@ -4,7 +4,6 @@ "patternProperties": { "^([a-z0-9_-]+)+$": { "description": "define name of language server", - "type": "object", "properties": { "blacklist": { "items": { @@ -26,8 +25,8 @@ "type": "object" }, "disabled": { - "description": "set true if you want to enable server", "default": true, + "description": "set true if you want to enable server", "type": "boolean" }, "initialization_options": { @@ -39,6 +38,15 @@ "pattern": "^file://\\S+$", "type": "string" }, + "root_uri_patterns": { + "default": [], + "description": "define patterns with file or directory names for finding root_uri", + "items": { + "description": "file or directory name", + "type": "string" + }, + "type": "array" + }, "whitelist": { "items": { "description": "define name of whitelisted language server", @@ -50,7 +58,8 @@ "workspace_config": { "type": "object" } - } + }, + "type": "object" } }, "title": "vim-lsp-settings-local", diff --git a/schema.json b/schema.json index ab23b42..fa36bac 100644 --- a/schema.json +++ b/schema.json @@ -32,7 +32,16 @@ }, "type": "array" }, - "vim-plugin": { + "root_uri_patterns": { + "default": [], + "description": "define patterns with file or directory names for finding root_uri", + "items": { + "description": "file or directory name", + "type": "string" + }, + "type": "array" + }, + "vim_plugin": { "additionalProperties": false, "default": {}, "description": "define suggestion for vim-plugin", -- cgit v1.2.3-54-g00ecf From d31db49d279bd2b637743f669f1939ecc9759161 Mon Sep 17 00:00:00 2001 From: Yasuhiro Matsumoto Date: Thu, 20 Feb 2020 00:24:10 +0900 Subject: Prefer user's configuration --- autoload/lsp_settings.vim | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'autoload/lsp_settings.vim') diff --git a/autoload/lsp_settings.vim b/autoload/lsp_settings.vim index fc6282b..e1d8e2b 100644 --- a/autoload/lsp_settings.vim +++ b/autoload/lsp_settings.vim @@ -174,15 +174,17 @@ function! lsp_settings#root_path(name) abort endfunction function! lsp_settings#root_uri(name) abort - let l:patterns = [] - for l:ft in sort(keys(s:settings)) - for l:conf in s:settings[l:ft] - if l:conf.command ==# a:name && has_key(l:conf, 'root_uri_patterns') - let l:patterns = l:conf['root_uri_patterns'] - break - endif + let l:patterns = lsp_settings#get(a:name, 'root_uri_patterns', []) + if empty(l:patterns) + for l:ft in sort(keys(s:settings)) + for l:conf in s:settings[l:ft] + if l:conf.command ==# a:name && has_key(l:conf, 'root_uri_patterns') + let l:patterns = l:conf['root_uri_patterns'] + break + endif + endfor endfor - endfor + endif let l:dir = lsp#utils#find_nearest_parent_file_directory(lsp#utils#get_buffer_path(), extend(l:patterns, g:lsp_settings_root_markers)) if empty(l:dir) -- cgit v1.2.3-54-g00ecf