use blink.cmp in neovim_unstable

This commit is contained in:
Alexander Navarro 2025-04-17 16:18:37 -04:00
parent 2bd9b3d518
commit 9de6da65bd
9 changed files with 92 additions and 35 deletions

View file

@ -16,6 +16,7 @@ end
vim.opt.rtp:prepend(lazypath) vim.opt.rtp:prepend(lazypath)
require("aleidk.options") require("aleidk.options")
require("aleidk.autocmds")
require("aleidk.keymaps") require("aleidk.keymaps")
-- Setup lazy.nvim -- Setup lazy.nvim

View file

@ -1,4 +1,6 @@
{ {
"blink.cmp": { "branch": "main", "commit": "cb5e346d9e0efa7a3eee7fd4da0b690c48d2a98e" },
"blink.compat": { "branch": "main", "commit": "2ed6d9a28b07fa6f3bface818470605f8896408c" },
"catppuccin": { "branch": "main", "commit": "5b5e3aef9ad7af84f463d17b5479f06b87d5c429" }, "catppuccin": { "branch": "main", "commit": "5b5e3aef9ad7af84f463d17b5479f06b87d5c429" },
"comment-box.nvim": { "branch": "main", "commit": "06bb771690bc9df0763d14769b779062d8f12bc5" }, "comment-box.nvim": { "branch": "main", "commit": "06bb771690bc9df0763d14769b779062d8f12bc5" },
"conform.nvim": { "branch": "master", "commit": "6632e7d788a85bf8405ea0c812d343fc308b7b8c" }, "conform.nvim": { "branch": "master", "commit": "6632e7d788a85bf8405ea0c812d343fc308b7b8c" },
@ -11,7 +13,7 @@
"mini.nvim": { "branch": "main", "commit": "0420076298c4457f200c2de468f65d080597a347" }, "mini.nvim": { "branch": "main", "commit": "0420076298c4457f200c2de468f65d080597a347" },
"neogen": { "branch": "main", "commit": "b2e78708876f4da507839726816010a68e33fec8" }, "neogen": { "branch": "main", "commit": "b2e78708876f4da507839726816010a68e33fec8" },
"nvim-lint": { "branch": "master", "commit": "93b8040115c9114dac1047311763bef275e752dc" }, "nvim-lint": { "branch": "master", "commit": "93b8040115c9114dac1047311763bef275e752dc" },
"nvim-lspconfig": { "branch": "master", "commit": "ff6471d4f837354d8257dfa326b031dd8858b16e" }, "nvim-lspconfig": { "branch": "master", "commit": "a56f4b9dde5daf3d4c7bb50cf78ab609537f2259" },
"nvim-treesitter": { "branch": "master", "commit": "9be6836ebeb88a536055bf1ce0961eef68da4bc6" }, "nvim-treesitter": { "branch": "master", "commit": "9be6836ebeb88a536055bf1ce0961eef68da4bc6" },
"nvim-treesitter-context": { "branch": "master", "commit": "93b29a32d5f4be10e39226c6b796f28d68a8b483" }, "nvim-treesitter-context": { "branch": "master", "commit": "93b29a32d5f4be10e39226c6b796f28d68a8b483" },
"nvim-ts-context-commentstring": { "branch": "main", "commit": "1b212c2eee76d787bbea6aa5e92a2b534e7b4f8f" }, "nvim-ts-context-commentstring": { "branch": "main", "commit": "1b212c2eee76d787bbea6aa5e92a2b534e7b4f8f" },

View file

@ -1,5 +0,0 @@
return {
cmd = { "rust-analyzer" },
filetypes = { 'rust' },
root_markers = { "cargo.toml" },
}

View file

@ -6,14 +6,29 @@ vim.api.nvim_create_autocmd('LspAttach', {
return return
end end
vim.bo[args.buf].omnifunc = 'v:lua.MiniCompletion.completefunc_lsp'
-- Prefer LSP folding if client supports it -- Prefer LSP folding if client supports it
if client:supports_method('textDocument/foldingRange') then if client:supports_method('textDocument/foldingRange') then
local win = vim.api.nvim_get_current_win() local win = vim.api.nvim_get_current_win()
vim.wo[win][0].foldexpr = 'v:lua.vim.lsp.foldexpr()' vim.wo[win][0].foldexpr = 'v:lua.vim.lsp.foldexpr()'
end end
if client:supports_method 'textDocument/completion' then vim.keymap.set({ "n", "x", "v" }, "<leader>la", vim.lsp.buf.code_action, { buffer = args.buf, desc = "Code Action" })
vim.lsp.completion.enable(true, client.id, args.buf, { autotrigger = true }) vim.keymap.set({ "n", "x", "v" }, "<leader>ld", vim.diagnostic.open_float, { desc = "Show diagnostic under cursor" })
vim.keymap.set({ "n", "x", "v" }, "<leader>lc", function()
local curpos = vim.fn.getcurpos()
local diagnostics = vim.diagnostic.get(0, { lnum = curpos[2] - 1 })
if #diagnostics == 0 then
vim.notify("No diagnostic under cursor")
return
end end
local diagnostic = diagnostics[1]
local msg = string.format("%s [%s]: %s", diagnostic.source, diagnostic.code, diagnostic.message)
vim.fn.setreg("+", msg)
vim.notify("Diagnostic saved to clipboard:\n\n" .. msg)
end, { buffer = args.buf, desc = "Copy diagnostic to clipboard" })
end, end,
}) })

View file

@ -157,22 +157,4 @@ vim.lsp.enable({
vim.diagnostic.config({ vim.diagnostic.config({
virtual_lines = { current_line = true }, virtual_lines = { current_line = true },
on_attach = function(_, bufnr)
vim.keymap.set({ "n", "x", "v" }, "<leader>la", vim.lsp.buf.code_action, { buffer = bufnr, desc = "Code Action" })
vim.keymap.set({ "n", "x", "v" }, "<leader>ld", vim.diagnostic.open_float, { desc = "Show diagnostic under cursor" })
vim.keymap.set({ "n", "x", "v" }, "<leader>lc", function()
local curpos = vim.fn.getcurpos()
local diagnostics = vim.diagnostic.get(0, { lnum = curpos[2] - 1 })
if #diagnostics == 0 then
vim.notify("No diagnostic under cursor")
return
end
local diagnostic = diagnostics[1]
local msg = string.format("%s [%s]: %s", diagnostic.source, diagnostic.code, diagnostic.message)
vim.fn.setreg("+", msg)
vim.notify("Diagnostic saved to clipboard:\n\n" .. msg)
end, { buffer = bufnr, desc = "Copy diagnostic to clipboard" })
end,
}) })

View file

@ -0,0 +1,63 @@
return {
"saghen/blink.cmp",
lazy = false,
version = "*",
dependencies = {
"neovim/nvim-lspconfig",
"echasnovski/mini.nvim",
"folke/lazydev.nvim",
{ "saghen/blink.compat", version = "*", },
},
opts = function()
local window_options = {
border = "rounded",
winblend = vim.o.pumblend,
}
---@module 'blink.cmp'
---@type blink.cmp.Config
return {
appearance = {
nerd_font_variant = 'mono'
},
completion = {
accept = { auto_brackets = { enabled = true }, },
-- Show documentation when selecting a completion item
documentation = { auto_show = true, auto_show_delay_ms = 500 },
-- Display a preview of the selected item on the current line
ghost_text = { enabled = true },
},
keymap = {
preset = "enter",
["<C-j>"] = { 'select_next', 'fallback' },
["<C-k>"] = { 'select_prev', 'fallback' },
["<C-u>"] = { 'scroll_documentation_up', 'fallback' },
["<C-d>"] = { 'scroll_documentation_down', 'fallback' },
},
sources = {
providers = {
dadbod = { name = "Dadbod", module = "vim_dadbod_completion.blink" },
lazydev = { name = "LazyDev", module = "lazydev.integrations.blink" },
luasnip = {
name = 'luasnip',
module = 'blink.compat.source',
score_offset = -3,
opts = {
use_show_condition = false,
show_autosnippets = true,
},
},
},
default = {
"lsp",
"path",
"snippets",
"buffer",
"dadbod",
"lazydev",
},
},
}
end
}

View file

@ -1,4 +1,5 @@
return { return {
'neovim/nvim-lspconfig',
'tpope/vim-sleuth', -- Detect tabstop and shiftwidth automatically 'tpope/vim-sleuth', -- Detect tabstop and shiftwidth automatically
{ "nvim-tree/nvim-web-devicons", lazy = true }, { "nvim-tree/nvim-web-devicons", lazy = true },
{ {

View file

@ -14,6 +14,10 @@ return {
NeogitCommitMessage = { "gitlint" }, NeogitCommitMessage = { "gitlint" },
gitcommit = { "gitlint" }, gitcommit = { "gitlint" },
markdown = { "markdownlint" }, markdown = { "markdownlint" },
javascript = { "biome" },
typescript = { "biome" },
javascriptreact = { "biome" },
typescriptreact = { "biome" },
} }
vim.api.nvim_create_autocmd({ "BufWritePost" }, { vim.api.nvim_create_autocmd({ "BufWritePost" }, {

View file

@ -17,14 +17,9 @@ return {
require('mini.splitjoin').setup() require('mini.splitjoin').setup()
require("mini.align").setup({}) require("mini.align").setup({})
require('mini.animate').setup() require('mini.animate').setup()
require('mini.notify').setup({ require('mini.notify').setup()
-- Notifications about LSP progress
lsp_progress = {
-- Whether to enable showing
enable = false,
}
})
vim.notify = require('mini.notify').make_notify() vim.notify = require('mini.notify').make_notify()
vim.keymap.set('n', '<Leader>un', require('mini.notify').show_history, { desc = 'Show notifications', silent = true })
require('mini.statusline').setup({}) require('mini.statusline').setup({})
require('mini.diff').setup({ view = { style = 'sign' } }) require('mini.diff').setup({ view = { style = 'sign' } })
@ -160,7 +155,6 @@ return {
{ mode = "n", keys = "<Leader>l", desc = "+LSP" }, { mode = "n", keys = "<Leader>l", desc = "+LSP" },
{ mode = "n", keys = "<Leader>r", desc = "+Replace" }, { mode = "n", keys = "<Leader>r", desc = "+Replace" },
{ mode = "n", keys = "<Leader>u", desc = "+UI & Config" }, { mode = "n", keys = "<Leader>u", desc = "+UI & Config" },
{ mode = "n", keys = "<Leader>un", desc = "+Noice" },
{ mode = "n", keys = "<Leader>w", desc = "+Workspace" }, { mode = "n", keys = "<Leader>w", desc = "+Workspace" },
{ mode = "n", keys = "<Leader>p", desc = "+Run stuff" }, { mode = "n", keys = "<Leader>p", desc = "+Run stuff" },
{ mode = "n", keys = "<Leader>z", desc = "+ZK" }, { mode = "n", keys = "<Leader>z", desc = "+ZK" },