mirror of
				https://github.com/neovim/neovim.git
				synced 2025-11-04 01:34:25 +00:00 
			
		
		
		
	lsp: Resolve codeLense server capabilities (#14056)
This commit is contained in:
		@@ -42,6 +42,8 @@ lsp._request_name_to_capability = {
 | 
			
		||||
  ['textDocument/prepareCallHierarchy'] = 'call_hierarchy';
 | 
			
		||||
  ['textDocument/rename'] = 'rename';
 | 
			
		||||
  ['textDocument/codeAction'] = 'code_action';
 | 
			
		||||
  ['textDocument/codeLens'] = 'code_lens';
 | 
			
		||||
  ['codeLens/resolve'] = 'code_lens_resolve';
 | 
			
		||||
  ['workspace/executeCommand'] = 'execute_command';
 | 
			
		||||
  ['textDocument/references'] = 'find_references';
 | 
			
		||||
  ['textDocument/rangeFormatting'] = 'document_range_formatting';
 | 
			
		||||
 
 | 
			
		||||
@@ -975,6 +975,16 @@ function protocol.resolve_capabilities(server_capabilities)
 | 
			
		||||
    general_properties.rename = true
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  if server_capabilities.codeLensProvider == nil then
 | 
			
		||||
    general_properties.code_lens = false
 | 
			
		||||
    general_properties.code_lens_resolve = false
 | 
			
		||||
  elseif type(server_capabilities.codeLensProvider) == 'table' then
 | 
			
		||||
    general_properties.code_lens = true
 | 
			
		||||
    general_properties.code_lens_resolve = server_capabilities.codeLensProvider.resolveProvider or false
 | 
			
		||||
  else
 | 
			
		||||
    error("The server sent invalid codeLensProvider")
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  if server_capabilities.codeActionProvider == nil then
 | 
			
		||||
    general_properties.code_action = false
 | 
			
		||||
  elseif type(server_capabilities.codeActionProvider) == 'boolean'
 | 
			
		||||
 
 | 
			
		||||
@@ -154,6 +154,7 @@ function tests.capabilities_for_client_supports_method()
 | 
			
		||||
          hoverProvider = true;
 | 
			
		||||
          definitionProvider = false;
 | 
			
		||||
          referencesProvider = false;
 | 
			
		||||
          codeLensProvider = { resolveProvider = true; };
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    end;
 | 
			
		||||
 
 | 
			
		||||
@@ -336,6 +336,8 @@ describe('LSP', function()
 | 
			
		||||
          local full_kind = exec_lua("return require'vim.lsp.protocol'.TextDocumentSyncKind.Full")
 | 
			
		||||
          eq(full_kind, client.resolved_capabilities().text_document_did_change)
 | 
			
		||||
          eq(true, client.resolved_capabilities().text_document_save)
 | 
			
		||||
          eq(false, client.resolved_capabilities().code_lens)
 | 
			
		||||
          eq(false, client.resolved_capabilities().code_lens_resolve)
 | 
			
		||||
        end;
 | 
			
		||||
        on_exit = function(code, signal)
 | 
			
		||||
          eq(0, code, "exit code", fake_lsp_logfile)
 | 
			
		||||
@@ -361,6 +363,8 @@ describe('LSP', function()
 | 
			
		||||
          eq(true, client.resolved_capabilities().hover)
 | 
			
		||||
          eq(false, client.resolved_capabilities().goto_definition)
 | 
			
		||||
          eq(false, client.resolved_capabilities().rename)
 | 
			
		||||
          eq(true, client.resolved_capabilities().code_lens)
 | 
			
		||||
          eq(true, client.resolved_capabilities().code_lens_resolve)
 | 
			
		||||
 | 
			
		||||
          -- known methods for resolved capabilities
 | 
			
		||||
          eq(true, client.supports_method("textDocument/hover"))
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user