Skip to content

Latest commit

 

History

History
325 lines (176 loc) · 6.38 KB

File metadata and controls

325 lines (176 loc) · 6.38 KB

Lua API

astrolsp API documentation

astrolsp

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

add_on_attach

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: integer

Set 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

attached_clients

table

A table of LSP clients that have been attached with AstroLSP

config

AstroLSPOpts

The configuration as set by the user through the setup() function

format_opts

unknown

Format options that are passed into the vim.lsp.buf.format (:h vim.lsp.buf.format())

lsp_progress

table

A table of lsp progress messages that can be used to display LSP progress in a statusline

lsp_setup

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

on_attach

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

progress

function astrolsp.progress(data: { client_id: integer, params: lsp.ProgressParams })

Add a new LSP progress message to the message queue

setup

function astrolsp.setup(opts: AstroLSPOpts)

Setup and configure AstroLSP

param opts — options passed by the user to configure AstroLSP

astrolsp.file_operations

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

didCreateFiles

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

didDeleteFiles

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

didRenameFiles

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

willCreateFiles

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

willDeleteFiles

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

willRenameFiles

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

astrolsp.toggles

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

autoformat

function astrolsp.toggles.autoformat(silent?: boolean)

Toggle auto format

param silent — if true then don't sent a notification

buffer_autoformat

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

buffer_codelens

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

buffer_inlay_hints

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

buffer_semantic_tokens

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

buffer_signature_help

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

codelens

function astrolsp.toggles.codelens(silent?: boolean)

Toggle global codelens

param silent — if true then don't sent a notification

inlay_hints

function astrolsp.toggles.inlay_hints(silent?: boolean)

Toggle global LSP inlay hints

param silent — if true then don't sent a notification

semantic_tokens

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

signature_help

function astrolsp.toggles.signature_help(silent?: boolean)

Toggle automatic signature help

param silent — if true then don't sent a notification