Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: enable non-error logs #3

Merged
merged 1 commit into from
Nov 18, 2024
Merged

fix: enable non-error logs #3

merged 1 commit into from
Nov 18, 2024

Conversation

WillLillis
Copy link
Contributor

It's not entirely clear to me what was causing the previous logging implementation to have issues. Only logs with MessageType::ERROR would be logged (at least in neovim). This could be partially addressed by using a tracing_subscriber logger (as suggested here: ebkalderon/tower-lsp#423). The server's logs would show up if the level was set to TRACE, but then so would every single message exchanged between the lsp client and server. Swapping out the calls to self.client.log_message() with the log crate's macros, as well as to the tracing_subscriber changes seems to remedy things. Log file after start up:

[START][2024-11-17 23:44:15] LSP logging initiated
[ERROR][2024-11-17 23:44:15] .../vim/lsp/rpc.lua:764	"rpc"	"/home/lillis/projects/ts_query_ls/target/debug/ts_query_ls"	"stderr"	'2024-11-18T04:44:15.478760Z  INFO ts_query_ls: ts_query_ls initialize: InitializeParams { process_id: Some(240085), root_path: Some("/home/lillis/projects/grammars/tree-sitter-c"), root_uri: Some(Url { scheme: "file", cannot_be_a_base: false, username: "", password: None, host: None, port: None, path: "/home/lillis/projects/grammars/tree-sitter-c", query: None, fragment: None }), initialization_options: None, capabilities: ClientCapabilities { workspace: Some(WorkspaceClientCapabilities { apply_edit: Some(true), workspace_edit: Some(WorkspaceEditClientCapabilities { document_changes: None, resource_operations: Some([Rename, Create, Delete]), failure_handling: None, normalizes_line_endings: None, change_annotation_support: None }), did_change_configuration: Some(DynamicRegistrationClientCapabilities { dynamic_registration: Some(false) }), did_change_watched_files: Some(DidChangeWatchedFilesClientCapabilities { dynamic_registration: Some(false), relative_pattern_support: Some(true) }), symbol: Some(WorkspaceSymbolClientCapabilities { dynamic_registration: Some(false), symbol_kind: Some(SymbolKindCapability { value_set: Some([File, Module, Namespace, Package, Class, Method, Property, Field, Constructor, Enum, Interface, Function, Variable, Constant, String, Number, Boolean, Array, Object, Key, Null, EnumMember, Struct, Event, Operator, TypeParameter]) }), tag_support: None, resolve_support: None }), execute_command: None, workspace_folders: Some(true), configuration: Some(true), semantic_tokens: Some(SemanticTokensWorkspaceClientCapabilities { refresh_support: Some(true) }), code_lens: None, file_operations: None, inline_value: None, inlay_hint: Some(InlayHintWorkspaceClientCapabilities { refresh_support: Some(true) }), diagnostic: None }), text_document: Some(TextDocumentClientCapabilities { synchronization: Some(TextDocumentSyncClientCapabilities { dynamic_registration: Some(false), will_save: Some(true), will_save_wait_until: Some(true), did_save: Some(true) }), completion: Some(CompletionClientCapabilities { dynamic_registration: Some(false), completion_item: Some(CompletionItemCapability { snippet_support: Some(true), commit_characters_support: Some(false), documentation_format: Some([Markdown, PlainText]), deprecated_support: Some(true), preselect_support: Some(false), tag_support: Some(TagSupport { value_set: [Deprecated] }), insert_replace_support: None, resolve_support: Some(CompletionItemCapabilityResolveSupport { properties: ["additionalTextEdits"] }), insert_text_mode_support: None, label_details_support: None }), completion_item_kind: Some(CompletionItemKindCapability { value_set: Some([Text, Method, Function, Constructor, Field, Variable, Class, Interface, Module, Property, Unit, Value, Enum, Keyword, Snippet, Color, File, Reference, Folder, EnumMember, Constant, Struct, Event, Operator, TypeParameter]) }), context_support: Some(false), insert_text_mode: None, completion_list: Some(CompletionListCapability { item_defaults: Some(["editRange", "insertTextFormat", "insertTextMode", "data"]) }) }), hover: Some(HoverClientCapabilities { dynamic_registration: Some(true), content_format: Some([Markdown, PlainText]) }), signature_help: Some(SignatureHelpClientCapabilities { dynamic_registration: Some(false), signature_information: Some(SignatureInformationSettings { documentation_format: Some([Markdown, PlainText]), parameter_information: Some(ParameterInformationSettings { label_offset_support: Some(true) }), active_parameter_support: Some(true) }), context_support: None }), references: Some(DynamicRegistrationClientCapabilities { dynamic_registration: Some(false) }), document_highlight: Some(DynamicRegistrationClientCapabilities { dynamic_registration: Some(false) }), document_symbol: Some(DocumentSymbolClientCapabilities { dynamic_registration: Some(false), symbol_kind: Some(SymbolKindCapability { value_set: Some([File, Module, Namespace, Package, Class, Method, Property, Field, Constructor, Enum, Interface, Function, Variable, Constant, String, Number, Boolean, Array, Object, Key, Null, EnumMember, Struct, Event, Operator, TypeParameter]) }), hierarchical_document_symbol_support: Some(true), tag_support: None }), formatting: Some(DynamicRegistrationClientCapabilities { dynamic_registration: Some(true) }), range_formatting: Some(DynamicRegistrationClientCapabilities { dynamic_registration: Some(true) }), on_type_formatting: None, declaration: Some(GotoCapability { dynamic_registration: None, link_support: Some(true) }), definition: Some(GotoCapability { dynamic_registration: Some(true), link_support: Some(true) }), type_definition: Some(GotoCapability { dynamic_registration: None, link_support: Some(true) }), implementation: Some(GotoCapability { dynamic_registration: None, link_support: Some(true) }), code_action: Some(CodeActionClientCapabilities { dynamic_registration: Some(true), code_action_literal_support: Some(CodeActionLiteralSupport { code_action_kind: CodeActionKindLiteralSupport { value_set: ["", "quickfix", "refactor", "refactor.extract", "refactor.inline", "refactor.rewrite", "source", "source.organizeImports"] } }), is_preferred_support: Some(true), disabled_support: None, data_support: Some(true), resolve_support: Some(CodeActionCapabilityResolveSupport { properties: ["edit"] }), honors_change_annotations: None }), code_lens: Some(DynamicRegistrationClientCapabilities { dynamic_registration: Some(false) }), document_link: None, color_provider: None, rename: Some(RenameClientCapabilities { dynamic_registration: Some(true), prepare_support: Some(true), prepare_support_default_behavior: None, honors_change_annotations: None }), publish_diagnostics: Some(PublishDiagnosticsClientCapabilities { related_information: Some(true), tag_support: Some(TagSupport { value_set: [Unnecessary, Deprecated] }), version_support: None, code_description_support: None, data_support: Some(true) }), folding_range: None, selection_range: None, linked_editing_range: None, call_hierarchy: Some(DynamicRegistrationClientCapabilities { dynamic_registration: Some(false) }), semantic_tokens: Some(SemanticTokensClientCapabilities { dynamic_registration: Some(false), requests: SemanticTokensClientCapabilitiesRequests { range: Some(false), full: Some(Delta { delta: Some(true) }) }, token_types: [SemanticTokenType("namespace"), SemanticTokenType("type"), SemanticTokenType("class"), SemanticTokenType("enum"), SemanticTokenType("interface"), SemanticTokenType("struct"), SemanticTokenType("typeParameter"), SemanticTokenType("parameter"), SemanticTokenType("variable"), SemanticTokenType("property"), SemanticTokenType("enumMember"), SemanticTokenType("event"), SemanticTokenType("function"), SemanticTokenType("method"), SemanticTokenType("macro"), SemanticTokenType("keyword"), SemanticTokenType("modifier"), SemanticTokenType("comment"), SemanticTokenType("string"), SemanticTokenType("number"), SemanticTokenType("regexp"), SemanticTokenType("operator"), SemanticTokenType("decorator")], token_modifiers: [SemanticTokenModifier("declaration"), SemanticTokenModifier("definition"), SemanticTokenModifier("readonly"), SemanticTokenModifier("static"), SemanticTokenModifier("deprecated"), SemanticTokenModifier("abstract"), SemanticTokenModifier("async"), SemanticTokenModifier("modification"), SemanticTokenModifier("documentation"), SemanticTokenModifier("defaultLibrary")], formats: [TokenFormat("relative")], overlapping_token_support: Some(true), multiline_token_support: Some(false), server_cancel_support: Some(false), augments_syntax_tokens: Some(true) }), moniker: None, type_hierarchy: None, inline_value: None, inlay_hint: Some(InlayHintClientCapabilities { dynamic_registration: Some(true), resolve_support: Some(InlayHintResolveClientCapabilities { properties: ["textEdits", "tooltip", "location", "command"] }) }), diagnostic: Some(DiagnosticClientCapabilities { dynamic_registration: Some(false), related_document_support: None }) }), window: Some(WindowClientCapabilities { work_done_progress: Some(true), show_message: Some(ShowMessageRequestClientCapabilities { message_action_item: Some(MessageActionItemCapabilities { additional_properties_support: Some(true) }) }), show_document: Some(ShowDocumentClientCapabilities { support: true }) }), general: Some(GeneralClientCapabilities { regular_expressions: None, markdown: None, stale_request_support: None, position_encodings: Some([PositionEncodingKind("utf-16")]) }), experimental: None }, trace: Some(Off), workspace_folders: Some([WorkspaceFolder { uri: Url { scheme: "file", cannot_be_a_base: false, username: "", password: None, host: None, port: None, path: "/home/lillis/projects/grammars/tree-sitter-c", query: None, fragment: None }, name: "/home/lillis/projects/grammars/tree-sitter-c" }]), client_info: Some(ClientInfo { name: "Neovim", version: Some("0.11.0-dev+g72a1df6065") }), locale: None }    \n'
[ERROR][2024-11-17 23:44:15] .../vim/lsp/rpc.lua:764	"rpc"	"/home/lillis/projects/ts_query_ls/target/debug/ts_query_ls"	"stderr"	'2024-11-18T04:44:15.491524Z  INFO ts_query_ls: ts_query_ls did_ops: DidOpenTextDocumentParams { text_document: TextDocumentItem { uri: Url { scheme: "file", cannot_be_a_base: false, username: "", password: None, host: None, port: None, path: "/home/lillis/projects/grammars/tree-sitter-c/queries/highlights.scm", query: None, fragment: None }, language_id: "query", version: 0, text: "(identifier) @variable\\n\\n((identifier) @constant\\n (#match? @constant \\"^[A-Z][A-Z\\\\\\\\d_]*$\\"))\\n\\n\\"break\\" @keyword\\n\\"case\\" @keyword\\n\\"const\\" @keyword\\n\\"continue\\" @keyword\\n\\"default\\" @keyword\\n\\"do\\" @keyword\\n\\"else\\" @keyword\\n\\"enum\\" @keyword\\n\\"extern\\" @keyword\\n\\"for\\" @keyword\\n\\"if\\" @keyword\\n\\"inline\\" @keyword\\n\\"return\\" @keyword\\n\\"sizeof\\" @keyword\\n\\"static\\" @keyword\\n\\"struct\\" @keyword\\n\\"switch\\" @keyword\\n\\"typedef\\" @keyword\\n\\"union\\" @keyword\\n\\"volatile\\" @keyword\\n\\"while\\" @keyword\\n\\n\\"#define\\" @keyword\\n\\"#elif\\" @keyword\\n\\"#else\\" @keyword\\n\\"#endif\\" @keyword\\n\\"#if\\" @keyword\\n\\"#ifdef\\" @keyword\\n\\"#ifndef\\" @keyword\\n\\"#include\\" @keyword\\n(preproc_directive) @keyword\\n\\n\\"--\\" @operator\\n\\"-\\" @operator\\n\\"-=\\" @operator\\n\\"->\\" @operator\\n\\"=\\" @operator\\n\\"!=\\" @operator\\n\\"*\\" @operator\\n\\"&\\" @operator\\n\\"&&\\" @operator\\n\\"+\\" @operator\\n\\"++\\" @operator\\n\\"+=\\" @operator\\n\\"<\\" @operator\\n\\"==\\" @operator\\n\\">\\" @operator\\n\\"||\\" @operator\\n\\n\\".\\" @delimiter\\n\\";\\" @delimiter\\n\\n(string_literal) @string\\n(system_lib_string) @string\\n\\n(null) @constant\\n(number_literal) @number\\n(char_literal) @number\\n\\n(field_identifier) @property\\n(statement_identifier) @label\\n(type_identifier) @type\\n(primitive_type) @type\\n(sized_type_specifier) @type\\n\\n(call_expression\\n  function: (identifier) @function)\\n(call_expression\\n  function: (field_expression\\n    field: (field_identifier) @function))\\n(function_declarator\\n  declarator: (identifier) @function)\\n(preproc_function_def\\n  name: (identifier) @function.special)\\n\\n(comment) @comment\\n" } }    \n'

@ribru17 ribru17 merged commit f8ec7a3 into ribru17:master Nov 18, 2024
@WillLillis WillLillis deleted the logging branch November 18, 2024 17:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants