generated from ellisonleao/nvim-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cb49af2
commit 57a4ebb
Showing
4 changed files
with
78 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
local source = {} | ||
|
||
---Return whether this source is available in the current context or not (optional). | ||
---@return boolean | ||
function source:is_available() | ||
return true | ||
end | ||
|
||
---Return the debug name of this source (optional). | ||
---@return string | ||
function source:get_debug_name() | ||
return "forester cmp" | ||
end | ||
|
||
---Return LSP's PositionEncodingKind. | ||
---@NOTE: If this method is omitted, the default value will be `utf-16`. | ||
---@return lsp.PositionEncodingKind | ||
function source:get_position_encoding_kind() | ||
return "utf-16" | ||
end | ||
|
||
---Return the keyword pattern for triggering completion (optional). | ||
---If this is omitted, nvim-cmp will use a default keyword pattern. See |cmp-config.completion.keyword_pattern|. | ||
---@return string | ||
function source:get_keyword_pattern() | ||
return [[\k\+]] | ||
end | ||
|
||
---Return trigger characters for triggering completion (optional). | ||
function source:get_trigger_characters() | ||
return { "\\" } | ||
end | ||
|
||
---Invoke completion (required). | ||
---@param params cmp.SourceCompletionApiParams | ||
---@param callback fun(response: lsp.CompletionResponse|nil) | ||
function source:complete(params, callback) | ||
callback({ | ||
{ label = "title" }, | ||
{ label = "author" }, | ||
{ label = "date" }, | ||
{ label = "taxon" }, | ||
{ label = "def" }, | ||
{ label = "import" }, | ||
{ label = "export" }, | ||
{ label = "p" }, | ||
{ label = "strong" }, | ||
{ label = "transclude" }, | ||
{ label = "let" }, | ||
{ label = "code" }, | ||
{ label = "tex" }, | ||
}) | ||
end | ||
|
||
---Resolve completion item (optional). This is called right before the completion is about to be displayed. | ||
---Useful for setting the text shown in the documentation window (`completion_item.documentation`). | ||
---@param completion_item lsp.CompletionItem | ||
---@param callback fun(completion_item: lsp.CompletionItem|nil) | ||
function source:resolve(completion_item, callback) | ||
callback(completion_item) | ||
end | ||
|
||
---Executed after the item was selected. | ||
---@param completion_item lsp.CompletionItem | ||
---@param callback fun(completion_item: lsp.CompletionItem|nil) | ||
function source:execute(completion_item, callback) | ||
callback(completion_item) | ||
end | ||
|
||
return source |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters