.. _`lsp_attach`: ********* LspAttach ********* ``LspAttach`` ``event`` ======================= When we create an ``autocommand`` for ``LspAttach`` .. code-block:: vim.api.nvim_create_autocmd("LspAttach", { group = vim.api.nvim_create_augroup("vvnraman.lsp.config", { clear = true }), callback = function(event) -- some code end }) This is the event which comes in .. code-block:: [INFO Tue Nov 18 07:06:50 2025] /home/vvnraman/.config/nvim/lua/plugins/lsp/lsp.lua:43: { buf = 1, data = { client_id = 1 }, event = "LspAttach", file = "/home/vvnraman/my/code/cppcon-2022-cpp-neovim-toy-calc/src/app/app_main.cpp", group = 32, id = 63, match = "/home/vvnraman/my/code/cppcon-2022-cpp-neovim-toy-calc/src/app/app_main.cpp" } ``vim.lsp.get_client_by_id(event.data.client_id)`` ================================================== .. code-block:: [INFO Tue Nov 18 07:06:50 2025] /home/vvnraman/.config/nvim/lua/plugins/lsp/lsp.lua:46: { _is_stopping = false, _log_prefix = "LSP[clangd]", _on_attach_cbs = { }, _on_exit_cbs = { }, _on_init_cbs = { }, _trace = "off", attached_buffers = { true }, cancel_request = , capabilities = { general = { positionEncodings = { "utf-8", "utf-16", "utf-32" } }, offsetEncoding = <1>{ "utf-8", "utf-16" }, textDocument = { callHierarchy = { dynamicRegistration = false }, codeAction = { codeActionLiteralSupport = { codeActionKind = { valueSet = { "", "quickfix", "refactor", "refactor.extract", "refactor.inline", "refactor.rewrite", "source", "source.organizeImports" } } }, dataSupport = true, dynamicRegistration = true, isPreferredSupport = true, resolveSupport = { properties = { "edit", "command" } } }, codeLens = { dynamicRegistration = false, resolveSupport = { properties = { "command" } } }, completion = { completionItem = { commitCharactersSupport = true, deprecatedSupport = true, documentationFormat = { "markdown", "plaintext" }, insertReplaceSupport = true, insertTextModeSupport = <2>{ valueSet = { 1, 2 } }, labelDetailsSupport = true, preselectSupport = true, resolveSupport = { properties = <3>{ "documentation", "additionalTextEdits", "insertTextFormat", "insertTextMode", "command" } }, snippetSupport = true, tagSupport = { valueSet = <4>{ 1 } } }, completionItemKind = { valueSet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25 } }, completionList = { itemDefaults = <5>{ "commitCharacters", "editRange", "insertTextFormat", "insertTextMode", "data" } }, contextSupport = true, dynamicRegistration = false, editsNearCursor = true, insertTextMode = 1 }, declaration = { linkSupport = true }, definition = { dynamicRegistration = true, linkSupport = true }, diagnostic = { dynamicRegistration = false, tagSupport = { valueSet = { 1, 2 } } }, documentHighlight = { dynamicRegistration = false }, documentSymbol = { dynamicRegistration = false, hierarchicalDocumentSymbolSupport = true, symbolKind = { valueSet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 } } }, foldingRange = { dynamicRegistration = false, foldingRange = { collapsedText = true }, foldingRangeKind = { valueSet = { "comment", "imports", "region" } }, lineFoldingOnly = true }, formatting = { dynamicRegistration = true }, hover = { contentFormat = { "markdown", "plaintext" }, dynamicRegistration = true }, implementation = { linkSupport = true }, inlayHint = { dynamicRegistration = true, resolveSupport = { properties = { "textEdits", "tooltip", "location", "command" } } }, publishDiagnostics = { dataSupport = true, relatedInformation = true, tagSupport = { valueSet = { 1, 2 } } }, rangeFormatting = { dynamicRegistration = true, rangesSupport = true }, references = { dynamicRegistration = false }, rename = { dynamicRegistration = true, prepareSupport = true }, semanticTokens = { augmentsSyntaxTokens = true, dynamicRegistration = false, formats = { "relative" }, multilineTokenSupport = false, overlappingTokenSupport = true, requests = { full = { delta = true }, range = false }, serverCancelSupport = false, tokenModifiers = { "declaration", "definition", "readonly", "static", "deprecated", "abstract", "async", "modification", "documentation", "defaultLibrary" }, tokenTypes = { "namespace", "type", "class", "enum", "interface", "struct", "typeParameter", "parameter", "variable", "property", "enumMember", "event", "function", "method", "macro", "keyword", "modifier", "comment", "string", "number", "regexp", "operator", "decorator" } }, signatureHelp = { dynamicRegistration = false, signatureInformation = { activeParameterSupport = true, documentationFormat = { "markdown", "plaintext" }, parameterInformation = { labelOffsetSupport = true } } }, synchronization = { didSave = true, dynamicRegistration = false, willSave = true, willSaveWaitUntil = true }, typeDefinition = { linkSupport = true } }, window = { showDocument = { support = true }, showMessage = { messageActionItem = { additionalPropertiesSupport = true } }, workDoneProgress = true }, workspace = { applyEdit = true, configuration = true, didChangeConfiguration = { dynamicRegistration = false }, didChangeWatchedFiles = { dynamicRegistration = false, relativePatternSupport = true }, inlayHint = { refreshSupport = true }, semanticTokens = { refreshSupport = true }, symbol = { dynamicRegistration = false, symbolKind = { valueSet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 } } }, workspaceEdit = { resourceOperations = { "rename", "create", "delete" } }, workspaceFolders = true } }, commands = {}, config = { capabilities = { offsetEncoding = , textDocument = { completion = { completionItem = { commitCharactersSupport = true, deprecatedSupport = true, insertReplaceSupport = true, insertTextModeSupport =
, labelDetailsSupport = true, preselectSupport = true, resolveSupport = { properties =
}, snippetSupport = true, tagSupport = { valueSet =
} }, completionList = { itemDefaults =
}, contextSupport = true, dynamicRegistration = false, editsNearCursor = true, insertTextMode = 1 } } }, cmd = { "clangd" }, filetypes = { "c", "cpp", "objc", "objcpp", "cuda" }, name = "clangd", on_attach = , on_init = , root_dir = "/home/vvnraman/my/code/cppcon-2022-cpp-neovim-toy-calc", root_markers = { "compile_commands.json" }, single_file_support = false }, dynamic_capabilities = { capabilities = <6>{}, client_id = 1, get = , register = , supports = , supports_registration = , unregister = }, flags = {}, get_language_id = , handlers = {}, id = 1, initialized = true, is_stopped = , messages = { messages = {}, name = "clangd", progress = {}, status = {} }, name = "clangd", notify = , offset_encoding = "utf-8", on_attach = , progress = { _idx_read = 0, _idx_write = 0, _items = {}, _size = 51, pending = {}, = { __call = , __index = { clear = , peek = , pop = , push = } } }, registrations =
, request = , request_sync = , requests = {}, root_dir = "/home/vvnraman/my/code/cppcon-2022-cpp-neovim-toy-calc", rpc = { is_closing = , notify = , request = , terminate = }, server_capabilities = { astProvider = true, callHierarchyProvider = true, clangdInlayHintsProvider = true, codeActionProvider = { codeActionKinds = { "quickfix", "refactor", "info" } }, compilationDatabase = { automaticReload = true }, completionProvider = { resolveProvider = false, triggerCharacters = { ".", "<", ">", ":", '"', "/", "*" } }, declarationProvider = true, definitionProvider = true, documentFormattingProvider = true, documentHighlightProvider = true, documentLinkProvider = { resolveProvider = false }, documentOnTypeFormattingProvider = { firstTriggerCharacter = "\n", moreTriggerCharacter = {} }, documentRangeFormattingProvider = true, documentSymbolProvider = true, executeCommandProvider = { commands = { "clangd.applyFix", "clangd.applyRename", "clangd.applyTweak" } }, foldingRangeProvider = true, hoverProvider = true, implementationProvider = true, inactiveRegionsProvider = true, inlayHintProvider = true, memoryUsageProvider = true, referencesProvider = true, renameProvider = { prepareProvider = true }, selectionRangeProvider = true, semanticTokensProvider = { full = { delta = true }, legend = { tokenModifiers = { "declaration", "definition", "deprecated", "deduced", "readonly", "static", "abstract", "virtual", "dependentName", "defaultLibrary", "usedAsMutableReference", "usedAsMutablePointer", "constructorOrDestructor", "userDefined", "functionScope", "classScope", "fileScope", "globalScope" }, tokenTypes = { "variable", "variable", "parameter", "function", "method", "function", "property", "variable", "class", "interface", "enum", "enumMember", "type", "type", "unknown", "namespace", "typeParameter", "concept", "type", "macro", "modifier", "operator", "bracket", "label", "comment" } }, range = false }, signatureHelpProvider = { triggerCharacters = { "(", ")", "{", "}", "<", ">", "," } }, standardTypeHierarchyProvider = true, textDocumentSync = { change = 2, openClose = true, save = true }, typeDefinitionProvider = true, typeHierarchyProvider = true, workspaceSymbolProvider = true }, server_info = { name = "clangd", version = "clangd version 20.1.0 (https://github.com/llvm/llvm-project 24a30daaa559829ad079f2ff7f73eb4e18095f88) linux+grpc x86_64-unknown-linux-gnu" }, settings = {}, stop = , supports_method = , workspace_folders = { { name = "/home/vvnraman/my/code/cppcon-2022-cpp-neovim-toy-calc", uri = "file:///home/vvnraman/my/code/cppcon-2022-cpp-neovim-toy-calc" } }, = <7>{ __index =
, _add_workspace_folder = , _get_language_id = , _get_registration = , _get_registration_options = , _notification = , _on_error = , _on_exit = , _process_request = , _register = , _register_dynamic = , _remove_workspace_folder = , _resolve_handler = , _run_callbacks = , _server_request = , _supports_registration = , _text_document_did_open_handler = , _unregister = , _unregister_dynamic = , cancel_request = , create = , exec_cmd = , initialize = , is_stopped = , notify = , on_attach = , request = , request_sync = , stop = , supports_method = , write_error = } }