aboutsummaryrefslogtreecommitdiff
path: root/autoload/lsp_settings/profile.vim
diff options
context:
space:
mode:
Diffstat (limited to 'autoload/lsp_settings/profile.vim')
-rw-r--r--autoload/lsp_settings/profile.vim31
1 files changed, 31 insertions, 0 deletions
diff --git a/autoload/lsp_settings/profile.vim b/autoload/lsp_settings/profile.vim
new file mode 100644
index 0000000..a035032
--- /dev/null
+++ b/autoload/lsp_settings/profile.vim
@@ -0,0 +1,31 @@
+function! lsp_settings#profile#load_local() abort
+ try
+ let l:root = lsp#utils#find_nearest_parent_directory('.', '.vim-lsp-settings')
+ if !empty(l:root) && filereadable(l:root . '/settings.json')
+ let l:settings = json_decode(join(readfile(l:root . '/settings.json'), "\n"))
+ if has_key(g:, 'lsp_settings')
+ call lsp_settings#utils#merge(g:lsp_settings, l:settings)
+ else
+ let g:lsp_settings = l:settings
+ endif
+ endif
+ catch
+ endtry
+endfunction
+
+function! lsp_settings#profile#edit_local() abort
+ let l:root = lsp_settings#root_path(['.vim-lsp-settings'])
+ if !isdirectory(l:root)
+ return
+ endif
+ let l:root .= '/.vim-lsp-settings'
+ if !isdirectory(l:root)
+ call mkdir(l:root)
+ endif
+ exe 'new' l:root . '/settings.json'
+ if !filereadable(l:root . '/settings.json')
+ call setline(1, ['{', "\t", '}'])
+ call cursor([2, 2])
+ setlocal nomodified
+ endif
+endfunction