fix: remove usages from vim.lsp.util.parse_snippet (#1734)

This commit is contained in:
Maria José Solano
2023-10-24 18:54:30 -07:00
committed by GitHub
parent d3a3056204
commit 51260c02a8
3 changed files with 4 additions and 11 deletions

View File

@@ -114,9 +114,6 @@ entry.get_word = function(self)
local word local word
if self:get_completion_item().textEdit and not misc.empty(self:get_completion_item().textEdit.newText) then if self:get_completion_item().textEdit and not misc.empty(self:get_completion_item().textEdit.newText) then
word = str.trim(self:get_completion_item().textEdit.newText) word = str.trim(self:get_completion_item().textEdit.newText)
if self:get_completion_item().insertTextFormat == types.lsp.InsertTextFormat.Snippet then
word = vim.lsp.util.parse_snippet(word)
end
local overwrite = self:get_overwrite() local overwrite = self:get_overwrite()
if 0 < overwrite[2] or self:get_completion_item().insertTextFormat == types.lsp.InsertTextFormat.Snippet then if 0 < overwrite[2] or self:get_completion_item().insertTextFormat == types.lsp.InsertTextFormat.Snippet then
word = str.get_word(word, string.byte(self.context.cursor_after_line, 1), overwrite[1] or 0) word = str.get_word(word, string.byte(self.context.cursor_after_line, 1), overwrite[1] or 0)
@@ -124,7 +121,7 @@ entry.get_word = function(self)
elseif not misc.empty(self:get_completion_item().insertText) then elseif not misc.empty(self:get_completion_item().insertText) then
word = str.trim(self:get_completion_item().insertText) word = str.trim(self:get_completion_item().insertText)
if self:get_completion_item().insertTextFormat == types.lsp.InsertTextFormat.Snippet then if self:get_completion_item().insertTextFormat == types.lsp.InsertTextFormat.Snippet then
word = str.get_word(vim.lsp.util.parse_snippet(word)) word = str.get_word(word)
end end
else else
word = str.trim(self:get_completion_item().label) word = str.trim(self:get_completion_item().label)
@@ -432,7 +429,7 @@ entry.get_completion_item = function(self)
end end
---Create documentation ---Create documentation
---@return string ---@return string[]
entry.get_documentation = function(self) entry.get_documentation = function(self)
local item = self:get_completion_item() local item = self:get_completion_item()

View File

@@ -99,8 +99,8 @@ end
---get_word ---get_word
---@param text string ---@param text string
---@param stop_char integer ---@param stop_char? integer
---@param min_length integer ---@param min_length? integer
---@return string ---@return string
str.get_word = function(text, stop_char, min_length) str.get_word = function(text, stop_char, min_length)
min_length = min_length or 0 min_length = min_length or 0

View File

@@ -1,7 +1,6 @@
local config = require('cmp.config') local config = require('cmp.config')
local misc = require('cmp.utils.misc') local misc = require('cmp.utils.misc')
local str = require('cmp.utils.str') local str = require('cmp.utils.str')
local types = require('cmp.types')
local api = require('cmp.utils.api') local api = require('cmp.utils.api')
---@class cmp.GhostTextView ---@class cmp.GhostTextView
@@ -71,9 +70,6 @@ end
--- of character differences instead of just byte difference. --- of character differences instead of just byte difference.
ghost_text_view.text_gen = function(self, line, cursor_col) ghost_text_view.text_gen = function(self, line, cursor_col)
local word = self.entry:get_insert_text() local word = self.entry:get_insert_text()
if self.entry.completion_item.insertTextFormat == types.lsp.InsertTextFormat.Snippet then
word = vim.lsp.util.parse_snippet(word)
end
word = str.oneline(word) word = str.oneline(word)
local word_clen = vim.str_utfindex(word) local word_clen = vim.str_utfindex(word)
local cword = string.sub(line, self.entry:get_offset(), cursor_col) local cword = string.sub(line, self.entry:get_offset(), cursor_col)