This repository has been archived by the owner on Aug 12, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 790
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Initial implementation for completion support
- Loading branch information
Showing
6 changed files
with
96 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
local h = require("null-ls.helpers") | ||
local methods = require("null-ls.methods") | ||
local utils = require("null-ls.utils") | ||
|
||
local COMPLETION = methods.internal.COMPLETION | ||
|
||
local M = {} | ||
|
||
M.tags = h.make_builtin({ | ||
method = COMPLETION, | ||
filetypes = {}, | ||
name = "tags", | ||
generator = { | ||
fn = function(params, done) | ||
local tags = vim.fn.taglist(params.word_to_complete) | ||
local words = {} | ||
local items = {} | ||
for _, tag in ipairs(tags) do | ||
table.insert(words, tag.name) | ||
end | ||
words = utils.tbl_uniq(words) | ||
for _, word in ipairs(words) do | ||
table.insert(items, { | ||
label = word, | ||
insertText = word, | ||
}) | ||
end | ||
|
||
done(items) | ||
end, | ||
async = true, | ||
use_cache = true, | ||
}, | ||
}) | ||
|
||
return M |
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,33 @@ | ||
local u = require("null-ls.utils") | ||
local methods = require("null-ls.methods") | ||
|
||
local M = {} | ||
|
||
M.handler = function(method, original_params, handler) | ||
local params = u.make_params(original_params, methods.map[method]) | ||
if method == methods.lsp.COMPLETION then | ||
require("null-ls.generators").run_registered({ | ||
filetype = params.ft, | ||
method = methods.map[method], | ||
params = params, | ||
callback = function(results) | ||
u.debug_log("received completion results from generators") | ||
u.debug_log(results) | ||
if #results == 0 then | ||
handler({}) | ||
else | ||
for index, item in ipairs(results) do | ||
if type(item) == "string" then | ||
results[index] = { label = item, insertText = item } | ||
end | ||
end | ||
|
||
handler({ isIncomplete = false, items = results }) | ||
end | ||
end, | ||
}) | ||
original_params._null_ls_handled = true | ||
end | ||
end | ||
|
||
return M |
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
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