mirror of
https://github.com/dense-analysis/ale.git
synced 2026-01-01 00:53:29 +08:00
Add ALEGoToImplementation (#4160)
* Add go to implementation * Add test cases for GoToImplementation * Add documentation for GoToImplementation
This commit is contained in:
@@ -121,6 +121,12 @@ function! s:OnReady(line, column, options, capability, linter, lsp_details) abor
|
||||
\ a:line,
|
||||
\ a:column
|
||||
\)
|
||||
elseif a:capability is# 'implementation'
|
||||
let l:message = ale#lsp#tsserver_message#Implementation(
|
||||
\ l:buffer,
|
||||
\ a:line,
|
||||
\ a:column
|
||||
\)
|
||||
endif
|
||||
else
|
||||
" Send a message saying the buffer has changed first, or the
|
||||
@@ -134,6 +140,8 @@ function! s:OnReady(line, column, options, capability, linter, lsp_details) abor
|
||||
let l:message = ale#lsp#message#Definition(l:buffer, a:line, a:column)
|
||||
elseif a:capability is# 'typeDefinition'
|
||||
let l:message = ale#lsp#message#TypeDefinition(l:buffer, a:line, a:column)
|
||||
elseif a:capability is# 'implementation'
|
||||
let l:message = ale#lsp#message#Implementation(l:buffer, a:line, a:column)
|
||||
else
|
||||
" XXX: log here?
|
||||
return
|
||||
@@ -175,6 +183,14 @@ function! ale#definition#GoToType(options) abort
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
function! ale#definition#GoToImpl(options) abort
|
||||
for l:linter in ale#linter#Get(&filetype)
|
||||
if !empty(l:linter.lsp)
|
||||
call s:GoToLSPDefinition(l:linter, a:options, 'implementation')
|
||||
endif
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
function! ale#definition#GoToCommandHandler(command, ...) abort
|
||||
let l:options = {}
|
||||
|
||||
@@ -200,6 +216,8 @@ function! ale#definition#GoToCommandHandler(command, ...) abort
|
||||
|
||||
if a:command is# 'type'
|
||||
call ale#definition#GoToType(l:options)
|
||||
elseif a:command is# 'implementation'
|
||||
call ale#definition#GoToImpl(l:options)
|
||||
else
|
||||
call ale#definition#GoTo(l:options)
|
||||
endif
|
||||
|
||||
@@ -44,6 +44,7 @@ function! ale#lsp#Register(executable_or_address, project, init_options) abort
|
||||
\ 'completion_trigger_characters': [],
|
||||
\ 'definition': 0,
|
||||
\ 'typeDefinition': 0,
|
||||
\ 'implementation': 0,
|
||||
\ 'symbol_search': 0,
|
||||
\ 'code_actions': 0,
|
||||
\ 'did_save': 0,
|
||||
@@ -259,6 +260,14 @@ function! s:UpdateCapabilities(conn, capabilities) abort
|
||||
let a:conn.capabilities.typeDefinition = 1
|
||||
endif
|
||||
|
||||
if get(a:capabilities, 'implementationProvider') is v:true
|
||||
let a:conn.capabilities.implementation = 1
|
||||
endif
|
||||
|
||||
if type(get(a:capabilities, 'implementationProvider')) is v:t_dict
|
||||
let a:conn.capabilities.implementation = 1
|
||||
endif
|
||||
|
||||
if get(a:capabilities, 'workspaceSymbolProvider') is v:true
|
||||
let a:conn.capabilities.symbol_search = 1
|
||||
endif
|
||||
@@ -379,6 +388,7 @@ function! ale#lsp#MarkConnectionAsTsserver(conn_id) abort
|
||||
let l:conn.capabilities.completion_trigger_characters = ['.']
|
||||
let l:conn.capabilities.definition = 1
|
||||
let l:conn.capabilities.typeDefinition = 1
|
||||
let l:conn.capabilities.implementation = 1
|
||||
let l:conn.capabilities.symbol_search = 1
|
||||
let l:conn.capabilities.rename = 1
|
||||
let l:conn.capabilities.filerename = 1
|
||||
@@ -438,6 +448,10 @@ function! s:SendInitMessage(conn) abort
|
||||
\ 'typeDefinition': {
|
||||
\ 'dynamicRegistration': v:false,
|
||||
\ },
|
||||
\ 'implementation': {
|
||||
\ 'dynamicRegistration': v:false,
|
||||
\ 'linkSupport': v:false,
|
||||
\ },
|
||||
\ 'publishDiagnostics': {
|
||||
\ 'relatedInformation': v:true,
|
||||
\ },
|
||||
|
||||
@@ -139,6 +139,15 @@ function! ale#lsp#message#TypeDefinition(buffer, line, column) abort
|
||||
\}]
|
||||
endfunction
|
||||
|
||||
function! ale#lsp#message#Implementation(buffer, line, column) abort
|
||||
return [0, 'textDocument/implementation', {
|
||||
\ 'textDocument': {
|
||||
\ 'uri': ale#util#ToURI(expand('#' . a:buffer . ':p')),
|
||||
\ },
|
||||
\ 'position': {'line': a:line - 1, 'character': a:column - 1},
|
||||
\}]
|
||||
endfunction
|
||||
|
||||
function! ale#lsp#message#References(buffer, line, column) abort
|
||||
return [0, 'textDocument/references', {
|
||||
\ 'textDocument': {
|
||||
|
||||
@@ -72,6 +72,14 @@ function! ale#lsp#tsserver_message#TypeDefinition(buffer, line, column) abort
|
||||
\}]
|
||||
endfunction
|
||||
|
||||
function! ale#lsp#tsserver_message#Implementation(buffer, line, column) abort
|
||||
return [0, 'ts@implementation', {
|
||||
\ 'line': a:line,
|
||||
\ 'offset': a:column,
|
||||
\ 'file': expand('#' . a:buffer . ':p'),
|
||||
\}]
|
||||
endfunction
|
||||
|
||||
function! ale#lsp#tsserver_message#References(buffer, line, column) abort
|
||||
return [0, 'ts@references', {
|
||||
\ 'line': a:line,
|
||||
|
||||
Reference in New Issue
Block a user