mirror of
				https://github.com/neovim/neovim.git
				synced 2025-11-04 09:44:31 +00:00 
			
		
		
		
	LSP/completion: add textEdit support
According to lsp specification, value of insertText should be ignored if textEdit is provided.
This commit is contained in:
		@@ -161,7 +161,7 @@ end
 | 
				
			|||||||
-- So we exclude completion candidates whose prefix does not match.
 | 
					-- So we exclude completion candidates whose prefix does not match.
 | 
				
			||||||
local function remove_unmatch_completion_items(items, prefix)
 | 
					local function remove_unmatch_completion_items(items, prefix)
 | 
				
			||||||
  return vim.tbl_filter(function(item)
 | 
					  return vim.tbl_filter(function(item)
 | 
				
			||||||
    local word = item.insertText or item.label
 | 
					    local word = (item.textEdit and item.textEdit.newText) or item.insertText or item.label
 | 
				
			||||||
    return vim.startswith(word, prefix)
 | 
					    return vim.startswith(word, prefix)
 | 
				
			||||||
  end, items)
 | 
					  end, items)
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
@@ -193,7 +193,7 @@ function M.text_document_completion_list_to_complete_items(result, prefix)
 | 
				
			|||||||
      end
 | 
					      end
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    local word = completion_item.insertText or completion_item.label
 | 
					    local word = (completion_item.textEdit and completion_item.textEdit.newText) or completion_item.insertText or completion_item.label
 | 
				
			||||||
    table.insert(matches, {
 | 
					    table.insert(matches, {
 | 
				
			||||||
      word = word,
 | 
					      word = word,
 | 
				
			||||||
      abbr = completion_item.label,
 | 
					      abbr = completion_item.label,
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user