feat: move to blink.cmp from cmp
This commit is contained in:
@@ -59,7 +59,7 @@ end
|
|||||||
|
|
||||||
-- used to enable autocompletion (assign to every lsp server config)
|
-- used to enable autocompletion (assign to every lsp server config)
|
||||||
-- local capabilities = cmp_nvim_lsp.default_capabilities()
|
-- local capabilities = cmp_nvim_lsp.default_capabilities()
|
||||||
M.capabilities = vim.lsp.protocol.make_client_capabilities()
|
M.capabilities = require("blink.cmp").get_lsp_capabilities(vim.lsp.protocol.make_client_capabilities())
|
||||||
M.capabilities.textDocument.completion.completionItem.snippetSupport = true
|
M.capabilities.textDocument.completion.completionItem.snippetSupport = true
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|||||||
@@ -1,130 +0,0 @@
|
|||||||
return {
|
|
||||||
-- competion
|
|
||||||
"hrsh7th/nvim-cmp",
|
|
||||||
event = { "InsertEnter", "LspAttach" },
|
|
||||||
dependencies = {
|
|
||||||
{ "hrsh7th/cmp-buffer" }, -- source for text in buffer
|
|
||||||
{ "hrsh7th/cmp-path" }, -- source for file system paths
|
|
||||||
{ "L3MON4D3/LuaSnip" }, -- snippet engine
|
|
||||||
{ "saadparwaiz1/cmp_luasnip" }, -- for autocompletion
|
|
||||||
{ "rafamadriz/friendly-snippets" }, -- useful snippets
|
|
||||||
{ "onsails/lspkind.nvim" }, -- icons for cmp
|
|
||||||
},
|
|
||||||
config = function()
|
|
||||||
local cmp = require("cmp")
|
|
||||||
local lspkind = require("lspkind")
|
|
||||||
local luasnip = require("luasnip")
|
|
||||||
|
|
||||||
-- loads vscode style snippets from installed plugins (e.g. friendly-snippets)
|
|
||||||
require("luasnip.loaders.from_vscode").lazy_load()
|
|
||||||
require("luasnip.loaders.from_vscode").load({ paths = { "~/.config/nvim/snippets" } })
|
|
||||||
luasnip.setup({})
|
|
||||||
|
|
||||||
-- luasnip.filetype_extend("htmldjango", { "html" })
|
|
||||||
|
|
||||||
cmp.setup({
|
|
||||||
completion = {
|
|
||||||
completeopt = "menu,menuone,preview,noselect",
|
|
||||||
},
|
|
||||||
|
|
||||||
window = {
|
|
||||||
documentation = cmp.config.window.bordered({
|
|
||||||
border = { "╭", "─", "╮", "│", "╯", "─", "╰", "│" },
|
|
||||||
}),
|
|
||||||
completion = cmp.config.window.bordered({
|
|
||||||
border = { "╭", "─", "╮", "│", "╯", "─", "╰", "│" },
|
|
||||||
winhighlight = "Normal:CmpPmenu,CursorLine:PmenuSel,Search:None",
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
|
|
||||||
snippet = { -- configure how nvim-cmp interacts with snippet engine
|
|
||||||
expand = function(args)
|
|
||||||
luasnip.lsp_expand(args.body)
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
|
|
||||||
mapping = cmp.mapping.preset.insert({
|
|
||||||
["<C-j>"] = cmp.mapping.select_next_item({ behavior = cmp.ConfirmBehavior.Select }), -- next suggestion
|
|
||||||
["<C-k>"] = cmp.mapping.select_prev_item({ behavior = cmp.ConfirmBehavior.Select }), -- prev suggestion
|
|
||||||
["<C-S-J>"] = cmp.mapping.scroll_docs(4, { behavior = cmp.ConfirmBehavior.Select }), -- docs forward
|
|
||||||
["<C-S-K>"] = cmp.mapping.scroll_docs(-4, { behavior = cmp.ConfirmBehavior.Select }), -- docs back
|
|
||||||
["<C-Space>"] = cmp.mapping.complete(), -- show completion suggestions
|
|
||||||
["<C-q>"] = cmp.mapping.abort(), -- close completion window
|
|
||||||
["<CR>"] = cmp.mapping.confirm({ select = false }), -- autocomplete if selected
|
|
||||||
-- Mapping for Tab key
|
|
||||||
["<Tab>"] = cmp.mapping(function(fallback)
|
|
||||||
if cmp.visible() then
|
|
||||||
cmp.confirm({ behavior = cmp.ConfirmBehavior.Insert, select = true })
|
|
||||||
else
|
|
||||||
-- Otherwise, fallback (insert a tab character)
|
|
||||||
fallback()
|
|
||||||
end
|
|
||||||
end, { "i", "s" }),
|
|
||||||
|
|
||||||
-- Mapping for jumping in snippets
|
|
||||||
["<C-p>"] = cmp.mapping(function(fallback)
|
|
||||||
if require("luasnip").jumpable() then
|
|
||||||
-- Jump backwards if inside a snippet
|
|
||||||
require("luasnip").jump()
|
|
||||||
else
|
|
||||||
-- Otherwise, fallback (insert a tab character)
|
|
||||||
fallback()
|
|
||||||
end
|
|
||||||
end, { "i", "s" }),
|
|
||||||
|
|
||||||
-- Mapping for jumping backwards in snippets
|
|
||||||
["<C-S-p>"] = cmp.mapping(function(fallback)
|
|
||||||
if require("luasnip").jumpable() then
|
|
||||||
-- Jump backwards if inside a snippet
|
|
||||||
require("luasnip").jump()
|
|
||||||
else
|
|
||||||
-- Otherwise, fallback (insert a tab character)
|
|
||||||
fallback()
|
|
||||||
end
|
|
||||||
end, { "i", "s" }),
|
|
||||||
}),
|
|
||||||
|
|
||||||
-- sources for autocompletion
|
|
||||||
sources = cmp.config.sources({
|
|
||||||
{ name = "nvim_lsp" }, -- lsp
|
|
||||||
{ name = "luasnip" }, -- snippets
|
|
||||||
{ name = "buffer" }, -- text within current buffer
|
|
||||||
{ name = "path" }, -- file system paths
|
|
||||||
}),
|
|
||||||
|
|
||||||
formatting = {
|
|
||||||
fields = { "icon", "abbr", "menu" },
|
|
||||||
format = lspkind.cmp_format({
|
|
||||||
mode = "symbol", -- show only symbol annotations
|
|
||||||
maxwidth = 50, -- prevent the popup from showing more than provided characters (e.g 50 will not show more than 50 characters)
|
|
||||||
-- can also be a function to dynamically calculate max width such as
|
|
||||||
-- maxwidth = function() return math.floor(0.45 * vim.o.columns) end,
|
|
||||||
ellipsis_char = "…", -- when popup menu exceed maxwidth, the truncated part would show ellipsis_char instead (must define maxwidth first)
|
|
||||||
show_labelDetails = true, -- show labelDetails in menu. Disabled by default
|
|
||||||
|
|
||||||
-- The function below will be called before any actual modifications from lspkind
|
|
||||||
-- so that you can provide more controls on popup customization. (See [#30](https://github.com/onsails/lspkind-nvim/pull/30))
|
|
||||||
before = function(entry, vim_item)
|
|
||||||
return vim_item
|
|
||||||
end,
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
local opts = { silent = true }
|
|
||||||
opts.desc = "next snippet placeholder"
|
|
||||||
vim.keymap.set({ "i", "s" }, "<C-,>", function()
|
|
||||||
luasnip.jump(1)
|
|
||||||
end, opts)
|
|
||||||
|
|
||||||
opts.desc = "previous snippet placeholder"
|
|
||||||
vim.keymap.set({ "i", "s" }, "<C-.>", function()
|
|
||||||
luasnip.jump(-1)
|
|
||||||
end, opts)
|
|
||||||
|
|
||||||
opts.desc = "LuaSnip unlink"
|
|
||||||
vim.keymap.set({ "i", "n" }, "<C-s>", function()
|
|
||||||
luasnip.unlink_current()
|
|
||||||
end, opts)
|
|
||||||
end,
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
return {
|
||||||
|
"saghen/blink.cmp",
|
||||||
|
-- optional: provides snippets for the snippet source
|
||||||
|
dependencies = { "rafamadriz/friendly-snippets", "L3MON4D3/LuaSnip" },
|
||||||
|
|
||||||
|
-- use a release tag to download pre-built binaries
|
||||||
|
version = "1.*",
|
||||||
|
|
||||||
|
---@module 'blink.cmp'
|
||||||
|
---@type blink.cmp.Config
|
||||||
|
opts = {
|
||||||
|
-- 'default' (recommended) for mappings similar to built-in completions (C-y to accept)
|
||||||
|
-- 'super-tab' for mappings similar to vscode (tab to accept)
|
||||||
|
-- 'enter' for enter to accept
|
||||||
|
-- 'none' for no mappings
|
||||||
|
--
|
||||||
|
-- All presets have the following mappings:
|
||||||
|
-- C-space: Open menu or open docs if already open
|
||||||
|
-- C-n/C-p or Up/Down: Select next/previous item
|
||||||
|
-- C-e: Hide menu
|
||||||
|
-- C-k: Toggle signature help (if signature.enabled = true)
|
||||||
|
--
|
||||||
|
-- See :h blink-cmp-config-keymap for defining your own keymap
|
||||||
|
keymap = {
|
||||||
|
preset = "super-tab",
|
||||||
|
["<C-k>"] = { "select_prev", "fallback" },
|
||||||
|
["<C-j>"] = { "select_next", "fallback" },
|
||||||
|
["<C-n>"] = { "show_documentation", "hide_documentation" },
|
||||||
|
["<C-S-j>"] = { "scroll_documentation_down", "scroll_signature_down" },
|
||||||
|
["<C-S-k>"] = { "scroll_documentation_up", "scroll_signature_up" },
|
||||||
|
["<C-,>"] = { "snippet_backward", "fallback" },
|
||||||
|
["<C-.>"] = { "snippet_forward", "fallback" },
|
||||||
|
["<C-s>"] = { "show_signature", "hide_signature", "fallback" },
|
||||||
|
},
|
||||||
|
|
||||||
|
appearance = {
|
||||||
|
-- 'mono' (default) for 'Nerd Font Mono' or 'normal' for 'Nerd Font'
|
||||||
|
-- Adjusts spacing to ensure icons are aligned
|
||||||
|
nerd_font_variant = "mono",
|
||||||
|
},
|
||||||
|
|
||||||
|
-- (Default) Only show the documentation popup when manually triggered
|
||||||
|
completion = {
|
||||||
|
documentation = { auto_show = false },
|
||||||
|
list = {
|
||||||
|
cycle = { from_top = true, from_bottom = true },
|
||||||
|
selection = {
|
||||||
|
auto_insert = false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
-- Default list of enabled providers defined so that you can extend it
|
||||||
|
-- elsewhere in your config, without redefining it, due to `opts_extend`
|
||||||
|
sources = {
|
||||||
|
default = { "lsp", "path", "snippets", "buffer" },
|
||||||
|
},
|
||||||
|
|
||||||
|
-- (Default) Rust fuzzy matcher for typo resistance and significantly better performance
|
||||||
|
-- You may use a lua implementation instead by using `implementation = "lua"` or fallback to the lua implementation,
|
||||||
|
-- when the Rust fuzzy matcher is not available, by using `implementation = "prefer_rust"`
|
||||||
|
--
|
||||||
|
-- See the fuzzy documentation for more information
|
||||||
|
fuzzy = { implementation = "prefer_rust_with_warning" },
|
||||||
|
},
|
||||||
|
opts_extend = { "sources.default" },
|
||||||
|
}
|
||||||
@@ -3,44 +3,50 @@
|
|||||||
-- │ LSP Configuration │
|
-- │ LSP Configuration │
|
||||||
-- ╰───────────────────────────────────────────────╯
|
-- ╰───────────────────────────────────────────────╯
|
||||||
return {
|
return {
|
||||||
-- lsp configuration
|
-- lsp configuration
|
||||||
"neovim/nvim-lspconfig",
|
"neovim/nvim-lspconfig",
|
||||||
dependencies = {
|
dependencies = {
|
||||||
"hrsh7th/cmp-nvim-lsp",
|
{ "antosha417/nvim-lsp-file-operations", config = true },
|
||||||
{ "antosha417/nvim-lsp-file-operations", config = true },
|
"mfussenegger/nvim-jdtls",
|
||||||
"mfussenegger/nvim-jdtls",
|
},
|
||||||
},
|
config = function()
|
||||||
config = function()
|
-- Change the Diagnostic symbols in the sign column (gutter)
|
||||||
-- Change the Diagnostic symbols in the sign column (gutter)
|
local signs = { Error = " ", Warn = " ", Hint = "", Info = " " }
|
||||||
local signs = { Error = " ", Warn = " ", Hint = "", Info = " " }
|
for type, icon in pairs(signs) do
|
||||||
for type, icon in pairs(signs) do
|
local hl = "DiagnosticSign" .. type
|
||||||
local hl = "DiagnosticSign" .. type
|
vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = "" })
|
||||||
vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = "" })
|
end
|
||||||
end
|
|
||||||
|
|
||||||
-- ───────────────────────────────────────────────────────────────────
|
local luasnip = require("luasnip")
|
||||||
-- ╭───────────────────────────────────────────────╮
|
|
||||||
-- │ Import configs from other files │
|
-- loads vscode style snippets from installed plugins (e.g. friendly-snippets)
|
||||||
-- ╰───────────────────────────────────────────────╯
|
require("luasnip.loaders.from_vscode").lazy_load()
|
||||||
require("plugins.lsp.ls.bashls")
|
require("luasnip.loaders.from_vscode").load({ paths = { "~/.config/nvim/snippets" } })
|
||||||
require("plugins.lsp.ls.c")
|
luasnip.setup({})
|
||||||
require("plugins.lsp.ls.dart")
|
|
||||||
require("plugins.lsp.ls.docker")
|
-- ───────────────────────────────────────────────────────────────────
|
||||||
require("plugins.lsp.ls.gh-actions")
|
-- ╭───────────────────────────────────────────────╮
|
||||||
require("plugins.lsp.ls.go")
|
-- │ Import configs from other files │
|
||||||
require("plugins.lsp.ls.haskell")
|
-- ╰───────────────────────────────────────────────╯
|
||||||
require("plugins.lsp.ls.hypr")
|
require("plugins.lsp.ls.bashls")
|
||||||
require("plugins.lsp.ls.low-level")
|
require("plugins.lsp.ls.c")
|
||||||
require("plugins.lsp.ls.luals")
|
require("plugins.lsp.ls.dart")
|
||||||
require("plugins.lsp.ls.pyright")
|
require("plugins.lsp.ls.docker")
|
||||||
require("plugins.lsp.ls.qml")
|
require("plugins.lsp.ls.gh-actions")
|
||||||
require("plugins.lsp.ls.rust-analyzer")
|
require("plugins.lsp.ls.go")
|
||||||
require("plugins.lsp.ls.ruby")
|
require("plugins.lsp.ls.haskell")
|
||||||
require("plugins.lsp.ls.sql")
|
require("plugins.lsp.ls.hypr")
|
||||||
require("plugins.lsp.ls.text")
|
require("plugins.lsp.ls.low-level")
|
||||||
require("plugins.lsp.ls.web")
|
require("plugins.lsp.ls.luals")
|
||||||
require("plugins.lsp.ls.yaml")
|
require("plugins.lsp.ls.pyright")
|
||||||
-- ───────────────────────────────────────────────────────────────────
|
require("plugins.lsp.ls.qml")
|
||||||
end,
|
require("plugins.lsp.ls.rust-analyzer")
|
||||||
|
require("plugins.lsp.ls.ruby")
|
||||||
|
require("plugins.lsp.ls.sql")
|
||||||
|
require("plugins.lsp.ls.text")
|
||||||
|
require("plugins.lsp.ls.web")
|
||||||
|
require("plugins.lsp.ls.yaml")
|
||||||
|
-- ───────────────────────────────────────────────────────────────────
|
||||||
|
end,
|
||||||
}
|
}
|
||||||
-- ───────────────────────────────────────────────────────────────────
|
-- ───────────────────────────────────────────────────────────────────
|
||||||
|
|||||||
@@ -15,11 +15,9 @@ return {
|
|||||||
})
|
})
|
||||||
require("noice").setup({
|
require("noice").setup({
|
||||||
lsp = {
|
lsp = {
|
||||||
-- override markdown rendering so that **cmp** and other plugins use **Treesitter**
|
|
||||||
override = {
|
override = {
|
||||||
["vim.lsp.util.convert_input_to_markdown_lines"] = true,
|
["vim.lsp.util.convert_input_to_markdown_lines"] = true,
|
||||||
["vim.lsp.util.stylize_markdown"] = true,
|
["vim.lsp.util.stylize_markdown"] = true,
|
||||||
["cmp.entry.get_documentation"] = true, -- requires hrsh7th/nvim-cmp
|
|
||||||
},
|
},
|
||||||
progress = {
|
progress = {
|
||||||
format = "lsp_progress",
|
format = "lsp_progress",
|
||||||
|
|||||||
Reference in New Issue
Block a user