mirror of
				https://github.com/neovim/neovim.git
				synced 2025-11-04 09:44:31 +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/prepareCallHierarchy'] = 'call_hierarchy';
 | 
				
			||||||
  ['textDocument/rename'] = 'rename';
 | 
					  ['textDocument/rename'] = 'rename';
 | 
				
			||||||
  ['textDocument/codeAction'] = 'code_action';
 | 
					  ['textDocument/codeAction'] = 'code_action';
 | 
				
			||||||
 | 
					  ['textDocument/codeLens'] = 'code_lens';
 | 
				
			||||||
 | 
					  ['codeLens/resolve'] = 'code_lens_resolve';
 | 
				
			||||||
  ['workspace/executeCommand'] = 'execute_command';
 | 
					  ['workspace/executeCommand'] = 'execute_command';
 | 
				
			||||||
  ['textDocument/references'] = 'find_references';
 | 
					  ['textDocument/references'] = 'find_references';
 | 
				
			||||||
  ['textDocument/rangeFormatting'] = 'document_range_formatting';
 | 
					  ['textDocument/rangeFormatting'] = 'document_range_formatting';
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -975,6 +975,16 @@ function protocol.resolve_capabilities(server_capabilities)
 | 
				
			|||||||
    general_properties.rename = true
 | 
					    general_properties.rename = true
 | 
				
			||||||
  end
 | 
					  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
 | 
					  if server_capabilities.codeActionProvider == nil then
 | 
				
			||||||
    general_properties.code_action = false
 | 
					    general_properties.code_action = false
 | 
				
			||||||
  elseif type(server_capabilities.codeActionProvider) == 'boolean'
 | 
					  elseif type(server_capabilities.codeActionProvider) == 'boolean'
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -154,6 +154,7 @@ function tests.capabilities_for_client_supports_method()
 | 
				
			|||||||
          hoverProvider = true;
 | 
					          hoverProvider = true;
 | 
				
			||||||
          definitionProvider = false;
 | 
					          definitionProvider = false;
 | 
				
			||||||
          referencesProvider = false;
 | 
					          referencesProvider = false;
 | 
				
			||||||
 | 
					          codeLensProvider = { resolveProvider = true; };
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    end;
 | 
					    end;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -336,6 +336,8 @@ describe('LSP', function()
 | 
				
			|||||||
          local full_kind = exec_lua("return require'vim.lsp.protocol'.TextDocumentSyncKind.Full")
 | 
					          local full_kind = exec_lua("return require'vim.lsp.protocol'.TextDocumentSyncKind.Full")
 | 
				
			||||||
          eq(full_kind, client.resolved_capabilities().text_document_did_change)
 | 
					          eq(full_kind, client.resolved_capabilities().text_document_did_change)
 | 
				
			||||||
          eq(true, client.resolved_capabilities().text_document_save)
 | 
					          eq(true, client.resolved_capabilities().text_document_save)
 | 
				
			||||||
 | 
					          eq(false, client.resolved_capabilities().code_lens)
 | 
				
			||||||
 | 
					          eq(false, client.resolved_capabilities().code_lens_resolve)
 | 
				
			||||||
        end;
 | 
					        end;
 | 
				
			||||||
        on_exit = function(code, signal)
 | 
					        on_exit = function(code, signal)
 | 
				
			||||||
          eq(0, code, "exit code", fake_lsp_logfile)
 | 
					          eq(0, code, "exit code", fake_lsp_logfile)
 | 
				
			||||||
@@ -361,6 +363,8 @@ describe('LSP', function()
 | 
				
			|||||||
          eq(true, client.resolved_capabilities().hover)
 | 
					          eq(true, client.resolved_capabilities().hover)
 | 
				
			||||||
          eq(false, client.resolved_capabilities().goto_definition)
 | 
					          eq(false, client.resolved_capabilities().goto_definition)
 | 
				
			||||||
          eq(false, client.resolved_capabilities().rename)
 | 
					          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
 | 
					          -- known methods for resolved capabilities
 | 
				
			||||||
          eq(true, client.supports_method("textDocument/hover"))
 | 
					          eq(true, client.supports_method("textDocument/hover"))
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user