Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "<Tab>",
-- Sets a global mapping to accept the next word
Expand Down Expand Up @@ -142,7 +140,6 @@ use {
require("ninetyfive").setup({
enable_on_startup = true,
mappings = {
enabled = true,
accept = "<Tab>",
accept_word = "<C-h>",
accept_line = "<C-j>",
Expand All @@ -169,7 +166,6 @@ lua << EOF
require("ninetyfive").setup({
enable_on_startup = true,
mappings = {
enabled = true,
accept = "<Tab>",
accept_word = "<C-h>",
accept_line = "<C-j>",
Expand Down Expand Up @@ -197,7 +193,6 @@ return {
debug = false,
server = "wss://api.ninetyfive.gg",
mappings = {
enabled = true,
accept = "<Tab>",
accept_word = "<C-h>",
accept_line = "<C-j>",
Expand Down
96 changes: 94 additions & 2 deletions doc/ninetyfive.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)`


==============================================================================
------------------------------------------------------------------------------
Expand All @@ -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 = "<Tab>",
-- Mapping to accept the next word
Expand Down Expand Up @@ -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()*
Expand Down
7 changes: 7 additions & 0 deletions doc/tags
Original file line number Diff line number Diff line change
@@ -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()*
Expand Down
8 changes: 1 addition & 7 deletions lua/ninetyfive/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "<Tab>",
-- Mapping to accept the next word
Expand Down Expand Up @@ -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
Expand Down
Loading