Rename locals to scopes

This commit is contained in:
hrsh7th
2022-03-30 20:49:14 +09:00
parent dc3113a79f
commit 2de24d3e1c
3 changed files with 11 additions and 11 deletions

View File

@@ -100,12 +100,12 @@ compare.order = function(entry1, entry2)
end end
end end
-- locals -- scopes
compare.locals = setmetatable({ compare.scopes = setmetatable({
locals_map = {}, scopes_map = {},
update = function(self) update = function(self)
local config = require('cmp').get_config() local config = require('cmp').get_config()
if not vim.tbl_contains(config.sorting.comparators, compare.locals) then if not vim.tbl_contains(config.sorting.comparators, compare.scopes) then
return return
end end
@@ -139,8 +139,8 @@ compare.locals = setmetatable({
for _, definition in pairs(definitions) do for _, definition in pairs(definitions) do
if scope:id() == locals.containing_scope(definition.node, buf):id() then if scope:id() == locals.containing_scope(definition.node, buf):id() then
local text = ts_utils.get_node_text(definition.node)[1] local text = ts_utils.get_node_text(definition.node)[1]
if not self.locals_map[text] then if not self.scopes_map[text] then
self.locals_map[text] = depth self.scopes_map[text] = depth
end end
end end
end end
@@ -150,8 +150,8 @@ compare.locals = setmetatable({
end, end,
}, { }, {
__call = function(self, entry1, entry2) __call = function(self, entry1, entry2)
local local1 = self.locals_map[entry1:get_completion_item().label] local local1 = self.scopes_map[entry1:get_completion_item().label]
local local2 = self.locals_map[entry2:get_completion_item().label] local local2 = self.scopes_map[entry2:get_completion_item().label]
if local1 ~= local2 then if local1 ~= local2 then
if local1 == nil then if local1 == nil then
return false return false

View File

@@ -101,7 +101,7 @@ return function()
compare.exact, compare.exact,
compare.score, compare.score,
compare.recently_used, compare.recently_used,
-- compare.locals, -- compare.scopes,
compare.kind, compare.kind,
compare.sort_text, compare.sort_text,
compare.length, compare.length,

View File

@@ -339,14 +339,14 @@ autocmd.subscribe('CursorMoved', function()
end) end)
autocmd.subscribe('InsertEnter', function() autocmd.subscribe('InsertEnter', function()
cmp.config.compare.locals:update() cmp.config.compare.scopes:update()
end) end)
cmp.event:on('complete_done', function(evt) cmp.event:on('complete_done', function(evt)
if evt.entry then if evt.entry then
cmp.config.compare.recently_used:add_entry(evt.entry) cmp.config.compare.recently_used:add_entry(evt.entry)
end end
cmp.config.compare.locals:update() cmp.config.compare.scopes:update()
end) end)
cmp.event:on('confirm_done', function(evt) cmp.event:on('confirm_done', function(evt)