diff --git a/README.md b/README.md index 0362ef8..f20e70c 100644 --- a/README.md +++ b/README.md @@ -105,8 +105,6 @@ require("ninetyfive").setup({ -- Key mappings configuration mappings = { - -- When `true`, creates all the mappings set - enabled = true, -- Sets a global mapping to accept a suggestion accept = "", -- Sets a global mapping to accept the next word @@ -142,7 +140,6 @@ use { require("ninetyfive").setup({ enable_on_startup = true, mappings = { - enabled = true, accept = "", accept_word = "", accept_line = "", @@ -169,7 +166,6 @@ lua << EOF require("ninetyfive").setup({ enable_on_startup = true, mappings = { - enabled = true, accept = "", accept_word = "", accept_line = "", @@ -197,7 +193,6 @@ return { debug = false, server = "wss://api.ninetyfive.gg", mappings = { - enabled = true, accept = "", accept_word = "", accept_line = "", diff --git a/doc/ninetyfive.txt b/doc/ninetyfive.txt index dd80e89..f487d0c 100644 --- a/doc/ninetyfive.txt +++ b/doc/ninetyfive.txt @@ -22,6 +22,22 @@ sets Ninetyfive with the provided API Key Parameters ~ {api_key} `(string)`: the api key you want to use. +------------------------------------------------------------------------------ + *Ninetyfive.get_status()* + `Ninetyfive.get_status`() +Returns the current status text for display (e.g., in lualine) +Returns subscription name if connected, "NinetyFive Disconnected" otherwise +Return ~ +`(string)` + +------------------------------------------------------------------------------ + *Ninetyfive.get_status_color()* + `Ninetyfive.get_status_color`() +Returns the color for the current status (for lualine) +Returns nil for paid users (use default), red for disconnected, yellow for unpaid +Return ~ +`(table|nil)` + ============================================================================== ------------------------------------------------------------------------------ @@ -40,9 +56,9 @@ Default values: enable_on_startup = true, -- Update server URI, mostly for debugging server = "wss://api.ninetyfive.gg", + -- When true, indicates Ninetyfive is used exclusively as a cmp source + use_cmp = false, mappings = { - -- When `true`, creates all the mappings set - enabled = true, -- Sets a global mapping to accept a suggestion accept = "", -- Mapping to accept the next word @@ -74,6 +90,82 @@ Usage ~ `require("ninetyfive").setup()` (add `{}` with your |Ninetyfive.options| table) +============================================================================== +------------------------------------------------------------------------------ + *M.compute_delta()* + `M.compute_delta`({old_text}, {new_text}) +the minimal delta between old_text and new_text. +start (byte offset), end (byte offset in old text), and the new text to insert. +Parameters ~ +{old_text} `(string)` +{new_text} `(string)` +Return ~ +`(number)` start byte offset where change begins +Return ~ +`(number)` end_pos byte offset in old_text where change ends +Return ~ +`(string)` insert_text the text to insert at start + + +============================================================================== +------------------------------------------------------------------------------ +Class ~ +{DiffEdit} +Fields ~ +{type} "`(ghost)`" | "delete" | "match" +{offset} `(number)` Position in buffer (0-indexed from cursor) +{text} `(string)` The text content + +------------------------------------------------------------------------------ +Class ~ +{DiffResult} +Fields ~ +{edits} `(DiffEdit[])` + +------------------------------------------------------------------------------ + *M.calculate_diff()* + `M.calculate_diff`({completion}, {buffer}, {is_complete}) +matching algorithm for calculating diff between completion and buffer. + +each character in buffer, finds its next occurrence in completion. +in completion become ghost text edits. Matched characters are preserved. + +Parameters ~ +{completion} `(string)` The completion text (first line only) +{buffer} `(string)` The text after cursor on current line +{is_complete} `(boolean)` If true, mark leftover buffer for deletion +Return ~ +`(DiffResult)` + +------------------------------------------------------------------------------ + *M.merge_edits()* + `M.merge_edits`({edits}) +consecutive edits of the same type at the same effective position. +simplifies the edit list for rendering. +Parameters ~ +{edits} `(DiffEdit[])` +Return ~ +`(DiffEdit[])` + +------------------------------------------------------------------------------ + *M.get_ghost_text()* + `M.get_ghost_text`({result}) +only ghost text edits, merged together. +Parameters ~ +{result} `(DiffResult)` +Return ~ +`(string)` The combined ghost text + +------------------------------------------------------------------------------ + *M.has_deletions()* + `M.has_deletions`({result}) +if the diff result has any delete markers. +Parameters ~ +{result} `(DiffResult)` +Return ~ +`(boolean)` + + ============================================================================== ------------------------------------------------------------------------------ *noop()* diff --git a/doc/tags b/doc/tags index 15fc29d..a7ef608 100644 --- a/doc/tags +++ b/doc/tags @@ -1,6 +1,13 @@ +M.calculate_diff() ninetyfive.txt /*M.calculate_diff()* +M.compute_delta() ninetyfive.txt /*M.compute_delta()* +M.get_ghost_text() ninetyfive.txt /*M.get_ghost_text()* +M.has_deletions() ninetyfive.txt /*M.has_deletions()* +M.merge_edits() ninetyfive.txt /*M.merge_edits()* M.post_json() ninetyfive.txt /*M.post_json()* Ninetyfive.disable() ninetyfive.txt /*Ninetyfive.disable()* Ninetyfive.enable() ninetyfive.txt /*Ninetyfive.enable()* +Ninetyfive.get_status() ninetyfive.txt /*Ninetyfive.get_status()* +Ninetyfive.get_status_color() ninetyfive.txt /*Ninetyfive.get_status_color()* Ninetyfive.options ninetyfive.txt /*Ninetyfive.options* Ninetyfive.setApiKey() ninetyfive.txt /*Ninetyfive.setApiKey()* Ninetyfive.setup() ninetyfive.txt /*Ninetyfive.setup()* diff --git a/lua/ninetyfive/config.lua b/lua/ninetyfive/config.lua index a88633f..5a6efd8 100644 --- a/lua/ninetyfive/config.lua +++ b/lua/ninetyfive/config.lua @@ -18,8 +18,6 @@ Ninetyfive.options = { -- When true, indicates Ninetyfive is used exclusively as a cmp source use_cmp = false, mappings = { - -- When `true`, creates all the mappings set - enabled = true, -- Sets a global mapping to accept a suggestion accept = "", -- Mapping to accept the next word @@ -58,17 +56,13 @@ function Ninetyfive.defaults(options) return Ninetyfive.options end ---- Registers the plugin mappings if the option is enabled. +--- Registers the plugin mappings. --- ---@param options table The mappins provided by the user. ---@param mappings table A key value map of the mapping name and its command. --- ---@private local function register_mappings(options, mappings) - if not options.enabled then - return - end - for name, command in pairs(mappings) do local key = options[name] if not key then