Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(snippets): switch to blink[^1] #107

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 1 addition & 12 deletions packages/nvim/config/lazy-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,12 @@
"LazyVim": { "branch": "main", "commit": "13a4a84e3485a36e64055365665a45dc82b6bf71" },
"LuaSnip": { "branch": "master", "commit": "e808bee352d1a6fcf902ca1a71cee76e60e24071" },
"SchemaStore.nvim": { "branch": "main", "commit": "dd374887d6e1de38e9d7041da824a8dc10cae401" },
"blink.cmp": { "branch": "main", "commit": "506ea74e53a825cc6efd40a46c4129576409e440" },
"bufferline.nvim": { "branch": "main", "commit": "0b2fd861eee7595015b6561dade52fb060be10c4" },
"catppuccin": { "branch": "main", "commit": "7be452ee067978cdc8b2c5f3411f0c71ffa612b9" },
"cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" },
"cmp-cmdline": { "branch": "main", "commit": "d250c63aa13ead745e3a40f61fdd3470efde3923" },
"cmp-emoji": { "branch": "main", "commit": "e8398e2adf512a03bb4e1728ca017ffeac670a9f" },
"cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" },
"cmp-nvim-lsp-signature-help": { "branch": "main", "commit": "031e6ba70b0ad5eee49fd2120ff7a2e325b17fa7" },
"cmp-nvim-lua": { "branch": "main", "commit": "f12408bdb54c39c23e67cab726264c10db33ada8" },
"cmp-nvim-wikilinks": { "branch": "master", "commit": "058fbd51b01db67d2fd21c6d8b54e4613a6838c6" },
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
"cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" },
"conform.nvim": { "branch": "master", "commit": "40d4e98fcc3e6f485f0e8924c63734bc7e305967" },
"copilot-cmp": { "branch": "master", "commit": "b6e5286b3d74b04256d0a7e3bd2908eabec34b44" },
"copilot.lua": { "branch": "master", "commit": "1a237cf50372830a61d92b0adf00d3b23882e0e1" },
"crates.nvim": { "branch": "main", "commit": "8bf8358ee326d5d8c11dcd7ac0bcc9ff97dbc785" },
"d2-vim": { "branch": "master", "commit": "981c87dccb63df2887cc41b96e84bf550f736c57" },
"flash.nvim": { "branch": "main", "commit": "34c7be146a91fec3555c33fe89c7d643f6ef5cf1" },
"friendly-snippets": { "branch": "main", "commit": "00ebcaa159e817150bd83bfe2d51fa3b3377d5c4" },
Expand Down Expand Up @@ -54,7 +45,6 @@
"nvim-lint": { "branch": "master", "commit": "27f44d1cc3d733a38a736acb902f94879d99c76c" },
"nvim-lspconfig": { "branch": "master", "commit": "04680101ff79e99b4e33a4386ec27cbd0d360c75" },
"nvim-nio": { "branch": "master", "commit": "a428f309119086dc78dd4b19306d2d67be884eee" },
"nvim-snippets": { "branch": "main", "commit": "56b4052f71220144689caaa2e5b66222ba5661eb" },
"nvim-spectre": { "branch": "master", "commit": "ba7fb777edff6c1fbbeffd343e113af64c04e90a" },
"nvim-surround": { "branch": "main", "commit": "ec2dc7671067e0086cdf29c2f5df2dd909d5f71f" },
"nvim-treesitter": { "branch": "master", "commit": "86c10df7ef77daf45a0e4a918934bb59083db1e1" },
Expand All @@ -67,7 +57,6 @@
"plenary.nvim": { "branch": "master", "commit": "2d9b06177a975543726ce5c73fca176cedbffe9d" },
"render-markdown.nvim": { "branch": "main", "commit": "d20d19fa54965f6eb94558c0b84fe9a942169fb4" },
"rustaceanvim": { "branch": "master", "commit": "d1f56672638508a7bc971cde31a29df4018579a9" },
"tailwindcss-colorizer-cmp.nvim": { "branch": "main", "commit": "3d3cd95e4a4135c250faf83dd5ed61b8e5502b86" },
"todo-comments.nvim": { "branch": "main", "commit": "ae0a2afb47cf7395dc400e5dc4e05274bf4fb9e0" },
"tokyonight.nvim": { "branch": "main", "commit": "2c85fad417170d4572ead7bf9fdd706057bd73d7" },
"trouble.nvim": { "branch": "main", "commit": "254145ffd528b98eb20be894338e2d5c93fa02c2" },
Expand Down
71 changes: 68 additions & 3 deletions packages/nvim/config/lua/plugins/coding.lua
Original file line number Diff line number Diff line change
@@ -1,12 +1,75 @@
local function __dirname()
local fullpath = debug.getinfo(1,"S").source:sub(2)
local dirname, filename = fullpath:match('^(.*/)([^/]-)$')
local fullpath = debug.getinfo(1, "S").source:sub(2)
local dirname, filename = fullpath:match("^(.*/)([^/]-)$")

return dirname, filename
end

---@type LazyPluginSpec[]
return {
-- TODO: doesn't support luasnip
-- lua snippets like ::today
-- or textmate style snippets
-- TODO: path completion is kinda buggy but probably easy to upstream a fix
{
"saghen/blink.cmp",
lazy = false, -- lazy loading handled internally

-- use a release tag to download pre-built binaries
version = "v0.*",
-- OR build from source, requires nightly: https://rust-lang.github.io/rustup/concepts/channels.html#working-with-nightly-rust
-- build = 'cargo build --release',

-- see <https://github.com/Saghen/blink.cmp>
opts = {
keymap = {
show = "<C-l>",
accept = "<C-k>",

select_next = { "<Up>", "<C-n>" },
select_prev = { "<Up>", "<C-p>" },

snippet_forward = { "<C-k>" },
snippet_backward = { "<C-j>" },

-- show_documentation = { "<C-k>" },
},
highlight = {
-- sets the fallback highlight groups to nvim-cmp's highlight groups
-- useful for when your theme doesn't support blink.cmp
-- will be removed in a future release, assuming themes add support
use_nvim_cmp_as_default = true,
},
-- set to 'mono' for 'Nerd Font Mono' or 'normal' for 'Nerd Font'
-- adjusts spacing to ensure icons are aligned
nerd_font_variant = "normal",

-- experimental auto-brackets support
-- accept = { auto_brackets = { enabled = true } }

-- experimental signature help support
-- trigger = { signature_help = { enabled = true } }

signature_help = {
enabled = true,
},

sources = {
providers = {
-- grouping are processed in-order; subsequent groups are fallbacks
{
{ "blink.cmp.sources.lsp" },
{ "blink.cmp.sources.path" },
{ "blink.cmp.sources.snippets", score_offset = -3 },
},
{
{ "blink.cmp.sources.buffer" },
}
},
},
},
},

-- see https://www.lazyvim.org/plugins/coding
-- completion
{
Expand All @@ -15,6 +78,7 @@ return {
-- cache (watch neotree for invalidation or maybe fswatch)
-- Fix #88
"hjdivad/cmp-nvim-wikilinks",
enabled = false,
opts = {
-- log_level = 'trace',
-- log_to_file = true,
Expand All @@ -27,6 +91,7 @@ return {
-- see $HOME/.local/share/nvim/lazy/LazyVim/lua/lazyvim/plugins/coding.lua
{
"hrsh7th/nvim-cmp",
enabled = false,
version = false, -- last release is way too old
event = "InsertEnter",
dependencies = {
Expand Down Expand Up @@ -158,7 +223,7 @@ return {

local snippets_paths = {
"~/.config/nvim/snippets",
__dirname() .. "/../../../../../local-packages/nvim/config/snippets"
__dirname() .. "/../../../../../local-packages/nvim/config/snippets",
}
require("luasnip.loaders.from_snipmate").lazy_load({
paths = snippets_paths,
Expand Down