Skip to main content

LuaLanguage

Struct LuaLanguage 

Source
pub struct LuaLanguage { /* private fields */ }
Expand description

A language defined by a Lua configuration file.

Build with LuaLanguage::from_path and hand it to increparse_lsp::serve:

fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
    let language = increparse_lua::LuaLanguage::from_path("minilang.lua")?;
    increparse_lsp::serve(language)
}

Implementations§

Source§

impl LuaLanguage

Source

pub fn from_path( path: impl AsRef<Path>, ) -> Result<Self, Box<dyn Error + Send + Sync>>

Loads a language definition from a Lua file.

Source

pub fn from_config( lua: Lua, config: Value, ) -> Result<Self, Box<dyn Error + Send + Sync>>

Builds a language from an already-evaluated configuration table.

Source

pub fn name(&self) -> &str

The language’s name from the config.

Source

pub fn lua(&self) -> &Lua

The embedded Lua state (contexts live here).

Trait Implementations§

Source§

impl Language<LuaCtx> for LuaLanguage

Source§

fn supports_symbols(&self) -> bool

Runtime hook for symbol support; defaults to SUPPORTS_SYMBOLS.
Source§

fn engine(&self) -> &Engine<LuaCtx>

The pass schedule run over every document.
Source§

fn root_ctx(&self) -> LuaCtx

Context for a freshly opened document’s root region.
Source§

fn diagnostic( &self, doc: &Document<LuaCtx>, node: FailedNode<'_, LuaCtx>, ) -> Option<Diagnostic>

Renders the diagnostic for a failing region, or None to stay silent (e.g. for contexts whose failure is expected). Read more
Source§

fn symbols(&self, doc: &Document<LuaCtx>) -> Vec<DocumentSymbol>

The document symbols for the outline view. Only consulted when supports_symbols is true.
Source§

const SUPPORTS_SYMBOLS: bool = false

Whether to advertise and answer textDocument/documentSymbol. Defaults to false; flip to true and override symbols. Read more
Source§

fn encoding(&self) -> PositionEncoding

The position encoding to negotiate with the client. Defaults to UTF-16, the LSP default and what most clients use.
Source§

fn extra_diagnostics(&self, doc: &Document<C>) -> Vec<Diagnostic>

Diagnostics that do not come from parse failures — lint-rule violations, style warnings, anything computed from the settled document rather than a failing tree node. Merged into the same publishDiagnostics notification, after the parse diagnostics.
Source§

fn supports_hover(&self) -> bool

Runtime hook for hover support; defaults to false.
Source§

fn supports_definition(&self) -> bool

Runtime hook for go-to-definition support; defaults to false.
Source§

fn supports_completion(&self) -> bool

Runtime hook for completion support; defaults to false.
Source§

fn supports_code_actions(&self) -> bool

Runtime hook for code-action support (the editor’s quickfix lightbulb); defaults to false.
Source§

fn code_action(&self, doc: &Document<C>, range: Range) -> Vec<CodeAction>

Code actions for the given range — typically quickfixes for the diagnostics published there. The skeleton dispatches textDocument/codeAction when supports_code_actions is true.
Source§

fn hover(&self, doc: &Document<C>, offset: usize) -> Option<Hover>

Hover contents for the byte offset in doc, or None. Read more
Source§

fn definition(&self, doc: &Document<C>, offset: usize) -> Option<Vec<Location>>

Definition locations for the byte offset in doc, or None.
Source§

fn completion( &self, doc: &Document<C>, offset: usize, ) -> Option<CompletionResponse>

Completions for the byte offset in doc, or None.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> MaybeSend for T
where T: Send,

Source§

impl<T> MaybeSync for T
where T: Sync,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.