astrolsp API documentation
AstroNvim LSP Utilities
Various utility functions to use within AstroNvim for the LSP engine
This module can be loaded with local astro = require "astrolsp"
copyright 2023 license GNU General Public License v3.0
function astrolsp.add_on_attach(on_attach: fun(client: vim.lsp.Client, bufnr: integer), opts?: { client_name: string?, autocmd: (vim.api.keyset.create_autocmd)? })
-> autocmd_id: integerSet up a given on_attach function to run when language servers are attached
param on_attach — the on_attach function to run
param opts — options for configuring the on_attach
return autocmd_id — The id for the created LspAttach autocommand
tableA table of LSP clients that have been attached with AstroLSP
AstroLSPOptsThe configuration as set by the user through the setup() function
unknownFormat options that are passed into the vim.lsp.buf.format (:h vim.lsp.buf.format())
tableA table of lsp progress messages that can be used to display LSP progress in a statusline
function astrolsp.lsp_setup(server: string)Helper function to set up a given server with the Neovim LSP client
param server — The name of the server to be setup
function astrolsp.on_attach(client: vim.lsp.Client, bufnr: integer)The on_attach function used by AstroNvim
param client — The LSP client details when attaching
param bufnr — The buffer that the LSP client is attaching to
function astrolsp.progress(data: { client_id: integer, params: lsp.ProgressParams })Add a new LSP progress message to the message queue
function astrolsp.setup(opts: AstroLSPOpts)Setup and configure AstroLSP
param opts — options passed by the user to configure AstroLSP
AstroNvim LSP File Operation Utilities
Utilities for working with LSP based file operations
This module is heavily inspired by nvim-lsp-file-operations https://github.com/antosha417/nvim-lsp-file-operations/tree/master
This module can be loaded with local astrolsp_fileops = require "astrolsp.file_operations"
copyright 2025 license GNU General Public License v3.0
function astrolsp.file_operations.didCreateFiles(fnames: string|string[])Notify LSP clients that file(s) were created
param fnames — a file or list of files that were created
function astrolsp.file_operations.didDeleteFiles(fnames: string|string[])Notify LSP clients that file(s) were deleted
param fnames — a file or list of files that were deleted
function astrolsp.file_operations.didRenameFiles(renames: AstroLSPFileOperationsRename|AstroLSPFileOperationsRename[])Notify LSP clients that file(s) were renamed
param renames — a table or list of tables of files that were renamed
function astrolsp.file_operations.willCreateFiles(fnames: string|string[])Notify LSP clients that file(s) are going to be created
param fnames — a file or list of files that will be created
function astrolsp.file_operations.willDeleteFiles(fnames: string|string[])Notify LSP clients that file(s) are going to be deleted
param fnames — a file or list of files that will be deleted
function astrolsp.file_operations.willRenameFiles(renames: AstroLSPFileOperationsRename|AstroLSPFileOperationsRename[])Notify LSP clients that file(s) are going to be renamed
param renames — a table or list of tables of files that will be renamed
AstroNvim LSP Toggles
Utility functions for easy LSP toggles
This module can be loaded with local ui = require("astrolsp.toggles")
copyright 2023 license GNU General Public License v3.0
function astrolsp.toggles.autoformat(silent?: boolean)Toggle auto format
param silent — if true then don't sent a notification
function astrolsp.toggles.buffer_autoformat(bufnr?: integer, silent?: boolean)Toggle buffer local auto format
param bufnr — The buffer to toggle the autoformatting of, default the current buffer
param silent — if true then don't sent a notification
function astrolsp.toggles.buffer_codelens(bufnr?: integer, silent?: boolean)Toggle buffer codelens
param bufnr — the buffer to toggle the clients on
param silent — if true then don't sent a notification
function astrolsp.toggles.buffer_inlay_hints(bufnr?: integer, silent?: boolean)Toggle buffer LSP inlay hints
param bufnr — the buffer to toggle the clients on
param silent — if true then don't sent a notification
function astrolsp.toggles.buffer_semantic_tokens(bufnr?: integer, silent?: boolean)Toggle buffer semantic token highlighting for all language servers that support it
param bufnr — the buffer to toggle the clients on
param silent — if true then don't sent a notification
function astrolsp.toggles.buffer_signature_help(bufnr?: integer, silent?: boolean)Toggle buffer local automatic signature help
param bufnr — The buffer to toggle the auto signature help of, default the current buffer
param silent — if true then don't sent a notification
function astrolsp.toggles.codelens(silent?: boolean)Toggle global codelens
param silent — if true then don't sent a notification
function astrolsp.toggles.inlay_hints(silent?: boolean)Toggle global LSP inlay hints
param silent — if true then don't sent a notification
function astrolsp.toggles.semantic_tokens(silent?: boolean)Toggle global semantic token highlighting for all language servers that support it
param silent — if true then don't sent a notification
function astrolsp.toggles.signature_help(silent?: boolean)Toggle automatic signature help
param silent — if true then don't sent a notification