diff options
author | mattn <mattn.jp@gmail.com> | 2020-02-15 23:12:50 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-15 23:12:50 +0900 |
commit | 01f3c1a5d919f0ab772a7485aa5c0e5f41f3341f (patch) | |
tree | 6d306e15a8b0ff3ae1c59ab4892b9b07eb4e53db | |
parent | aed10b6de257492b25c44bfb282c704444d6365d (diff) | |
parent | a68b31af77f247d8360dd67c23296c9bc45961d7 (diff) | |
download | vim-lsp-settings-01f3c1a5d919f0ab772a7485aa5c0e5f41f3341f.tar.gz vim-lsp-settings-01f3c1a5d919f0ab772a7485aa5c0e5f41f3341f.tar.bz2 vim-lsp-settings-01f3c1a5d919f0ab772a7485aa5c0e5f41f3341f.zip |
Merge pull request #161 from mattn/local-config
Load project related local .vim-lsp-settings/config.json
-rw-r--r-- | autoload/lsp_settings.vim | 13 | ||||
-rw-r--r-- | autoload/lsp_settings/utils.vim | 8 |
2 files changed, 17 insertions, 4 deletions
diff --git a/autoload/lsp_settings.vim b/autoload/lsp_settings.vim index 7fee88f..df2a60f 100644 --- a/autoload/lsp_settings.vim +++ b/autoload/lsp_settings.vim @@ -358,6 +358,19 @@ function! s:vim_lsp_load_or_suggest(ft) abort return endif + try + let l:root = lsp#utils#find_nearest_parent_directory('.', '.vim-lsp-settings') + if !empty(l:root) && filereadable(l:root . '/config.json') + let l:config = json_decode(join(readfile(l:root . '/config.json'), "\n")) + if has_key(g:, 'lsp_settings') + call lsp_settings#utils#merge(g:lsp_settings, l:config) + else + let g:lsp_settings = l:config + endif + endif + catch + endtry + if get(g:, 'lsp_loaded', 0) for l:server in s:settings[a:ft] let l:config = lsp_settings#server_config(l:server.command) diff --git a/autoload/lsp_settings/utils.vim b/autoload/lsp_settings/utils.vim index a39851f..3a48d7c 100644 --- a/autoload/lsp_settings/utils.vim +++ b/autoload/lsp_settings/utils.vim @@ -31,7 +31,7 @@ function! lsp_settings#utils#first_one(lines) abort return l:path endfunction -function! s:merge(lhs, rhs) abort +function! lsp_settings#utils#merge(lhs, rhs) abort let [l:lhs, l:rhs] = [a:lhs, a:rhs] if type(l:lhs) ==# 3 if type(l:rhs) ==# 3 @@ -70,7 +70,7 @@ function! s:merge(lhs, rhs) abort endif elseif type(l:rhs[l:key]) ==# 4 if has_key(l:lhs, l:key) - call s:merge(l:lhs[l:key], l:rhs[l:key]) + call lsp_settings#utils#merge(l:lhs[l:key], l:rhs[l:key]) else let l:lhs[l:key] = l:rhs[l:key] endif @@ -82,7 +82,7 @@ function! s:merge(lhs, rhs) abort endif endfunction -function! lsp_settings#utils#merge(d) abort +function! lsp_settings#utils#dotmerge(d) abort let l:ret = {} let l:keys = keys(a:d) for l:k in sort(keys(a:d)) @@ -101,7 +101,7 @@ function! lsp_settings#utils#merge(d) abort endif let l:cur = l:cur[l:kk] endfor - call s:merge(l:ret, l:new) + call lsp_settings#utils#merge(l:ret, l:new) endfor return l:ret endfunction |