nvrim/
buffer.rs

1//! Buffer text extraction helpers exposed to Lua.
2//!
3//! Provides a dictionary with functions to obtain visual selection lines and classify the word under
4//! cursor (see `token_under_cursor`).
5
6use nvim_oxi::Dictionary;
7
8pub mod token_under_cursor;
9
10/// [`Dictionary`] of buffer text helpers.
11///
12/// Entries:
13/// - `"get_visual_selection"`: wraps [`ytil_noxi::visual_selection::get_lines`] and returns the current visual
14///   selection (inclusive) as lines.
15/// - `"get_token_under_cursor"`: wraps [`crate::buffer::token_under_cursor::get`] and returns a classified token under
16///   the cursor.
17///
18/// Intended for exposure to Lua.
19pub fn dict() -> Dictionary {
20    dict! {
21        "get_visual_selection_lines": fn_from!(ytil_noxi::visual_selection::get_lines),
22        "get_token_under_cursor": fn_from!(token_under_cursor::get),
23    }
24}