mirror of
https://github.com/m-housh/dotfiles.git
synced 2026-02-15 06:32:40 +00:00
feat: Luasnip working with blink.cmp
This commit is contained in:
@@ -1,58 +1,54 @@
|
|||||||
|
-- https://cmp.saghen.dev/
|
||||||
return {
|
return {
|
||||||
{
|
{
|
||||||
"saghen/blink.cmp",
|
"saghen/blink.cmp",
|
||||||
enabled = false,
|
enabled = true,
|
||||||
dependencies = {
|
dependencies = {
|
||||||
"rafamadriz/friendly-snippets",
|
-- "rafamadriz/friendly-snippets",
|
||||||
--"L3MON4D3/LuaSnip",
|
{ "L3MON4D3/LuaSnip", version = "v2.*" },
|
||||||
},
|
},
|
||||||
version = "v0.*",
|
version = "v0.*",
|
||||||
opts = {
|
opts = {
|
||||||
appearance = {
|
|
||||||
use_nvim_cmp_as_default = true,
|
|
||||||
nerd_font_variant = "mono",
|
|
||||||
},
|
|
||||||
signature = { enabled = true },
|
signature = { enabled = true },
|
||||||
keymap = {
|
|
||||||
preset = "default",
|
|
||||||
["<CR>"] = { "accept", "fallback" },
|
|
||||||
["<C-space>"] = {
|
|
||||||
function(cmp)
|
|
||||||
cmp.show({ providers = { "snippets" } })
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
--["<C-k>"] = { "select_prev", "fallback" },
|
|
||||||
--["<C-j>"] = { "select_next", "fallback" },
|
|
||||||
["<C-n>"] = {
|
|
||||||
function(cmp)
|
|
||||||
if cmp.snippet_active() then
|
|
||||||
return cmp.accept()
|
|
||||||
else
|
|
||||||
return cmp.select_and_accept()
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
"snippet_forward",
|
|
||||||
"fallback",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
-- snippets = {
|
|
||||||
-- expand = function(snippet)
|
|
||||||
-- require("luasnip").lsp_expand(snippet)
|
|
||||||
-- end,
|
|
||||||
-- active = function(filter)
|
|
||||||
-- if filter and filter.direction then
|
|
||||||
-- return require("luasnip").jumpable(filter.direction)
|
|
||||||
-- end
|
|
||||||
-- return require("luasnip").in_snippet()
|
|
||||||
-- end,
|
|
||||||
-- jump = function(direction)
|
|
||||||
-- require("luasnip").jump(direction)
|
|
||||||
-- end,
|
|
||||||
-- },
|
|
||||||
sources = {
|
sources = {
|
||||||
default = { "lsp", "path", "snippets", "buffer" },
|
default = { "lsp", "path", "snippets", "buffer", "luasnip" },
|
||||||
|
providers = {
|
||||||
|
lsp = {
|
||||||
|
name = "lsp",
|
||||||
|
enabled = true,
|
||||||
|
module = "blink.cmp.sources.lsp",
|
||||||
|
score_offset = 1000, -- higher = higher priority
|
||||||
|
},
|
||||||
|
luasnip = {
|
||||||
|
name = "luasnip",
|
||||||
|
enabled = true,
|
||||||
|
module = "blink.cmp.sources.luasnip",
|
||||||
|
score_offset = 950,
|
||||||
|
},
|
||||||
|
snippets = {
|
||||||
|
name = "snippets",
|
||||||
|
enabled = true,
|
||||||
|
module = "blink.cmp.sources.snippets",
|
||||||
|
score_offset = 900,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
snippets = {
|
||||||
|
expand = function(snippet)
|
||||||
|
require("luasnip").lsp_expand(snippet)
|
||||||
|
end,
|
||||||
|
active = function(filter)
|
||||||
|
if filter and filter.direction then
|
||||||
|
return require("luasnip").jumpable(filter.direction)
|
||||||
|
end
|
||||||
|
return require("luasnip").in_snippet()
|
||||||
|
end,
|
||||||
|
jump = function(direction)
|
||||||
|
require("luasnip").jump(direction)
|
||||||
|
end,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
opts_extend = { "sources.default" },
|
opts_extend = { "sources.default" },
|
||||||
|
keymap = { preset = "default" },
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
return {
|
return {
|
||||||
"hrsh7th/nvim-cmp",
|
"hrsh7th/nvim-cmp",
|
||||||
enabled = true,
|
enabled = false,
|
||||||
event = "VeryLazy",
|
event = "VeryLazy",
|
||||||
dependencies = {
|
dependencies = {
|
||||||
"hrsh7th/cmp-nvim-lsp",
|
"hrsh7th/cmp-nvim-lsp",
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ return {
|
|||||||
"neovim/nvim-lspconfig",
|
"neovim/nvim-lspconfig",
|
||||||
event = { "BufReadPre", "BufNewFile" },
|
event = { "BufReadPre", "BufNewFile" },
|
||||||
dependencies = {
|
dependencies = {
|
||||||
"hrsh7th/cmp-nvim-lsp",
|
-- "hrsh7th/cmp-nvim-lsp",
|
||||||
--"saghen/blink.cmp",
|
"saghen/blink.cmp",
|
||||||
{ "antosha417/nvim-lsp-file-operations", config = true },
|
{ "antosha417/nvim-lsp-file-operations", config = true },
|
||||||
"williamboman/mason.nvim",
|
"williamboman/mason.nvim",
|
||||||
"williamboman/mason-lspconfig.nvim",
|
"williamboman/mason-lspconfig.nvim",
|
||||||
@@ -37,9 +37,9 @@ return {
|
|||||||
automatic_installation = true,
|
automatic_installation = true,
|
||||||
})
|
})
|
||||||
local lspconfig = require("lspconfig")
|
local lspconfig = require("lspconfig")
|
||||||
local cmp_nvim_lsp = require("cmp_nvim_lsp")
|
-- local cmp_nvim_lsp = require("cmp_nvim_lsp")
|
||||||
local capabilities = cmp_nvim_lsp.default_capabilities()
|
-- local capabilities = cmp_nvim_lsp.default_capabilities()
|
||||||
--local capabilities = require("blink.cmp").get_lsp_capabilities()
|
local capabilities = require("blink.cmp").get_lsp_capabilities()
|
||||||
local opts = { noremap = true, silent = true }
|
local opts = { noremap = true, silent = true }
|
||||||
local on_attach = function(_, bufnr)
|
local on_attach = function(_, bufnr)
|
||||||
opts.buffer = bufnr
|
opts.buffer = bufnr
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ return {
|
|||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
config = function(_, opts)
|
config = function()
|
||||||
local ls = require("luasnip")
|
local ls = require("luasnip")
|
||||||
ls.setup({
|
ls.setup({
|
||||||
history = true,
|
history = true,
|
||||||
|
|||||||
@@ -12,12 +12,12 @@ local rep = require("luasnip.extras").rep
|
|||||||
-- Add snippets
|
-- Add snippets
|
||||||
ls.add_snippets("swift", {
|
ls.add_snippets("swift", {
|
||||||
-- Add a dependency snippet.
|
-- Add a dependency snippet.
|
||||||
s({ trig = "@d", desc = "Add a dependency." }, fmt("@Dependency(\\.{}) var {}", { i(1), rep(1) })),
|
s({ trig = "@Dep", desc = "Add a dependency." }, fmt("@Dependency(\\.{}) var {}", { i(1), rep(1) })),
|
||||||
|
|
||||||
-- Add a dependency client.
|
-- Add a dependency client.
|
||||||
s(
|
s(
|
||||||
{
|
{
|
||||||
trig = "@dc",
|
trig = "@DC",
|
||||||
desc = "Add a dependency client.",
|
desc = "Add a dependency client.",
|
||||||
},
|
},
|
||||||
fmt(
|
fmt(
|
||||||
|
|||||||
Reference in New Issue
Block a user