Neovim and VS Code— AI-Assisted Code Completion
Let’s try out AI-assisted code completion plugins for Neovim and VS Code.
Want to try out AI-assisted coding? Let’s check out a few plugins that provide AI-based code completion for Neovim and VS Code.
Check out the following article for more tips and tricks to configure a modern Neovim development environment!
Tabnine
Tabnine is a mature AI assistant and supports all major IDEs, including Vim/Neovim and VS Code.
Neovim
For Neovim, you can use coc.nvim, deoplete.nvim, or nvim-cmp.
- I am going to use
nvim-cmp
. Below I usepacker.nvim
to installcmp-tabnine
together with other plugins.
use {
"hrsh7th/nvim-cmp",
requires = {
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-nvim-lsp",
"quangnguyen30192/cmp-nvim-ultisnips",
"hrsh7th/cmp-nvim-lua",
"octaltree/cmp-look",
"hrsh7th/cmp-path",
"hrsh7th/cmp-calc",
"f3fora/cmp-spell",
"hrsh7th/cmp-emoji",
"ray-x/cmp-treesitter",
},
config = function()
require("config.cmp").setup()
end,
}
use { "tzachar/cmp-tabnine", run = "./install.sh" }
- In
cmp.lua
, I configuredcmp-tabnine
as one of the completion sources.
cmp.setup {
formatting = {
format = function(entry, vim_item)
-- fancy icons and a name of kind
vim_item.kind = require("lspkind").presets.default[vim_item.kind] .. " " .. vim_item.kind-- set a name for each source
local menu = ({
buffer = "[Buffer]",
nvim_lsp = "[LSP]",
ultisnips = "[UltiSnips]",
nvim_lua = "[Lua]",
cmp_tabnine = "[TabNine]",
look = "[Look]",
path = "[Path]",
spell = "[Spell]",
calc = "[Calc]",
emoji = "[Emoji]",
treesitter = "[treesitter]",
neorg = "[Neorg]",
})[entry.source.name] if entry.source.name == "cmp_tabnine" then
if entry.completion_item.data ~= nil and entry.completion_item.data.detail ~= nil…