Skip to content
This repository was archived by the owner on Oct 13, 2021. It is now read-only.

Commit 80af93c

Browse files
authored
Merge pull request #323 from runiq/snippets.nvim-should-use-opt.get_option
Use opt.get_option with snippets.nvim completion
2 parents ad23096 + 63888ce commit 80af93c

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

lua/completion.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ local function hasConfirmedCompletion()
125125
if completed_item.user_data == nil then return end
126126
if completed_item.user_data.lsp ~= nil then
127127
applyAddtionalTextEdits(completed_item)
128-
if vim.g.completion_enable_snippet == "snippets.nvim" then
128+
if opt.get_option('enable_snippet') == "snippets.nvim" then
129129
require 'snippets'.expand_at_cursor(completed_item.user_data.actual_item, completed_item.word)
130130
end
131131
end

lua/completion/source/lsp.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ local function get_completion_word(item, prefix, suffix)
2525
newText = item.textEdit.newText
2626
end
2727
if protocol.InsertTextFormat[item.insertTextFormat] == "PlainText"
28-
or vim.g.completion_enable_snippet == "snippets.nvim" then
28+
or opt.get_option('enable_snippet') == "snippets.nvim" then
2929
return newText
3030
else
3131
return vim.lsp.util.parse_snippet(newText)
3232
end
3333
elseif item.insertText ~= nil and item.insertText ~= vim.NIL then
3434
if protocol.InsertTextFormat[item.insertTextFormat] == "PlainText"
35-
or vim.g.completion_enable_snippet == "snippets.nvim" then
35+
or opt.get_option('enable_snippet') == "snippets.nvim" then
3636
return item.insertText
3737
else
3838
return vim.lsp.util.parse_snippet(item.insertText)
@@ -99,7 +99,7 @@ local function text_document_completion_list_to_complete_items(result, params)
9999
}
100100
}
101101
if protocol.InsertTextFormat[completion_item.insertTextFormat] == 'Snippet'
102-
and vim.g.completion_enable_snippet == "snippets.nvim" then
102+
and opt.get_option('enable_snippet') == "snippets.nvim" then
103103
item.user_data.actual_item = item.word
104104
item.word = completion_item.label
105105
end

lua/completion/source/snippet.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ M.getSnippetsNvimItems = function(prefix)
109109
end
110110

111111
M.getCompletionItems = function(prefix)
112-
local source = vim.g.completion_enable_snippet
112+
local source = opt.get_option('enable_snippet')
113113
local snippet_list = {}
114114
if source == 'UltiSnips' then
115115
snippet_list = M.getUltisnipItems(prefix)

0 commit comments

Comments
 (0)