diff options
author | Horacio Sanson <hsanson@gmail.com> | 2021-10-15 08:42:07 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-15 08:42:07 +0900 |
commit | c7e3f1a0dd447eeafcbbd158974860c1918dbdd5 (patch) | |
tree | 54ccfbe683256ae981f0633b084ae4545274229c /autoload | |
parent | 7413dfd3fc386920217fb43e9a517e99d9cf42b8 (diff) | |
download | ale-c7e3f1a0dd447eeafcbbd158974860c1918dbdd5.zip |
Fix 3207 - do not send didSave notification if not supported (#3930)
Diffstat (limited to 'autoload')
-rw-r--r-- | autoload/ale/lsp.vim | 19 | ||||
-rw-r--r-- | autoload/ale/lsp_linter.vim | 1 |
2 files changed, 13 insertions, 7 deletions
diff --git a/autoload/ale/lsp.vim b/autoload/ale/lsp.vim index 510f3e95..75d81525 100644 --- a/autoload/ale/lsp.vim +++ b/autoload/ale/lsp.vim @@ -45,6 +45,7 @@ function! ale#lsp#Register(executable_or_address, project, init_options) abort \ 'typeDefinition': 0, \ 'symbol_search': 0, \ 'code_actions': 0, + \ 'did_save': 0, \ 'includeText': 0, \ }, \} @@ -265,15 +266,19 @@ function! s:UpdateCapabilities(conn, capabilities) abort let a:conn.capabilities.symbol_search = 1 endif - if has_key(a:capabilities, 'textDocumentSync') - if type(a:capabilities.textDocumentSync) is v:t_dict - let l:save = get(a:capabilities.textDocumentSync, 'save', v:false) + if type(get(a:capabilities, 'textDocumentSync')) is v:t_dict + let l:syncOptions = get(a:capabilities, 'textDocumentSync') - if type(l:save) is v:true - let a:conn.capabilities.includeText = 1 - endif + if get(l:syncOptions, 'save') is v:true + let a:conn.capabilities.did_save = 1 + endif + + if type(get(l:syncOptions, 'save')) is v:t_dict + let a:conn.capabilities.did_save = 1 + + let l:saveOptions = get(l:syncOptions, 'save') - if type(l:save) is v:t_dict && get(a:capabilities.textDocumentSync.save, 'includeText', v:false) is v:true + if get(l:saveOptions, 'includeText') is v:true let a:conn.capabilities.includeText = 1 endif endif diff --git a/autoload/ale/lsp_linter.vim b/autoload/ale/lsp_linter.vim index 753fb57b..230b3141 100644 --- a/autoload/ale/lsp_linter.vim +++ b/autoload/ale/lsp_linter.vim @@ -466,6 +466,7 @@ function! s:CheckWithLSP(linter, details) abort " If this was a file save event, also notify the server of that. if a:linter.lsp isnot# 'tsserver' \&& getbufvar(l:buffer, 'ale_save_event_fired', 0) + \&& ale#lsp#HasCapability(l:buffer, 'did_save') let l:include_text = ale#lsp#HasCapability(l:buffer, 'includeText') let l:save_message = ale#lsp#message#DidSave(l:buffer, l:include_text) let l:notified = ale#lsp#Send(l:id, l:save_message) != 0 |