While Neovim is a powerful and very pluggable text editor, obtaining the smooth, VS Code-like autocompletion experience has always involved traversing a regime of plugins like "Luasnip," "cmp_luasnip," and "nvim-cmp." It typically formed a significant barrier, especially to newcomers.
Enter `blink.cmp`. This plugin basically simplifies obtaining feature-rich snippets functional in Neovim, with a very rational and simple approach.
It's super simple to get started. Just copy and paste the following lines into your Neovim config (typically your `init.lua` or a standalone plugin config file):
'saghen/blink.cmp',
dependencies = { 'rafamadriz/friendly-snippets' },
version = '1.*',
opts = {
keymap = { preset = 'enter' },
appearance = {
nerd_font_variant = 'normal'
},
completion = { documentation = { auto_show = false } },
sources = {
default = { 'lsp', 'path', 'snippets', 'buffer' },
},
fuzzy = { implementation = "prefer_rust_with_warning" }
},
opts_extend = { "sources.default" }
That's it. As a long-time Neovim user, I can attest to how remarkably simple this setup is.
### Bonus: Enhancing Completions with LSP Integration
To further elevate your autocompletion experience, seamlessly integrate your Language Server Protocol (LSP) plugins and configurations with `blink.cmp`. Here's how:
return {
{
"williamboman/mason.nvim",
config = function()
require("mason").setup()
end
},
{
"williamboman/mason-lspconfig.nvim",
config = function()
require("mason-lspconfig").setup({
ensure_installed = {"lua_ls", "cssls", "vtsls", "html", "eslint", "pyright"}
})
end
},
{
"neovim/nvim-lspconfig",
config = function()
local lspconfig = require("lspconfig")
---- THESE ARE THE KEY LINES ----
local capabilities = require("blink.cmp").get_lsp_capabilities()
-- lspconfig.lua_ls.setup{} -- You can configure individual LSPs here
lspconfig.cssls.setup{capabilities = capabilities}
lspconfig.vtsls.setup{capabilities = capabilities}
lspconfig.html.setup{capabilities = capabilities}
lspconfig.eslint.setup{capabilities = capabilities}
lspconfig.pyright.setup{capabilities = capabilities}
--------------------------------
end
}
By including these configurations, `blink.cmp` has access to the rich semantic information that your LSP servers offer, resulting in more intelligent and context-aware suggestions.
`blink.cmp` is actually a game changer for Neovim users seeking an optimal and solid autocompletion setup. It eliminates the hassle and allows you to focus on what matters the most: coding.
Comments
Post a Comment