Make languageId configurable per lsp (#880)

* Make languageId configurable per lsp

* Fix linter warnings

* Use function to define languageId
This commit is contained in:
Jan Damm
2020-08-23 19:25:53 +02:00
committed by GitHub
parent e40e457744
commit e6912a01cd
2 changed files with 16 additions and 1 deletions

View File

@@ -880,9 +880,12 @@ function! s:get_text_document_text(buf, server_name) abort
endfunction
function! s:get_text_document(buf, server_name, buffer_info) abort
let l:server = s:servers[a:server_name]
let l:server_info = l:server['server_info']
let l:language_id = has_key(l:server_info, 'languageId') ? l:server_info['languageId'](l:server_info) : &filetype
return {
\ 'uri': lsp#utils#get_buffer_uri(a:buf),
\ 'languageId': &filetype,
\ 'languageId': l:language_id,
\ 'version': a:buffer_info['version'],
\ 'text': s:get_text_document_text(a:buf, a:server_name),
\ }

View File

@@ -710,6 +710,7 @@ one parameter which is a vim |dict| and is refered to as |vim-lsp-server_info|
\ 'blocklist': ['filetype to blocklist'],
\ 'config': {},
\ 'workspace_config': {'param': {'enabled': v:true}},
\ 'languageId': {server_info->'python'},
\ })
endif
<
@@ -730,6 +731,7 @@ The vim |dict| containing information about the server.
'blocklist': ['filetype'],
'config': {},
'workspace_config': {},
'languageId': {server_info->'filetype'},
}
<
* name:
@@ -807,6 +809,16 @@ The vim |dict| containing information about the server.
Example: >
'workspace_config': {'pyls': {'plugins': \
{'pydocstyle': {'enabled': v:true}}}}
<
* languageId:
optional function returning |string|
By default the languageId is the current filetype. If you're using a sub
filetype like 'ios.swift' your language server may not return anything
because it does not know this language.
In this case you might want to overwrite the languageId with this key.
Example: >
'languageId': {server_info->'typescript'}
<
* config:
optional vim |dict|