mirror of
https://github.com/traxys/Nixfiles.git
synced 2026-03-28 15:07:22 +01:00
neovim: Switch from nvim-cmp to blink
This commit is contained in:
parent
3dfdb88915
commit
dbf3b2cad7
4 changed files with 86 additions and 60 deletions
17
flake.lock
generated
17
flake.lock
generated
|
|
@ -1,5 +1,21 @@
|
|||
{
|
||||
"nodes": {
|
||||
"blink.compat": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1731176257,
|
||||
"narHash": "sha256-/2fGykyb8gmAdchCf96udZLuBxN8feWkQ1BlCl5LsIw=",
|
||||
"owner": "saghen",
|
||||
"repo": "blink.compat",
|
||||
"rev": "a951034404c14051129b47e09cfed83f7a306898",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "saghen",
|
||||
"repo": "blink.compat",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"cargo2nix": {
|
||||
"inputs": {
|
||||
"flake-compat": "flake-compat_2",
|
||||
|
|
@ -1295,6 +1311,7 @@
|
|||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"blink.compat": "blink.compat",
|
||||
"comma": "comma",
|
||||
"diagram.nvim": "diagram.nvim",
|
||||
"fioul": "fioul",
|
||||
|
|
|
|||
|
|
@ -97,6 +97,10 @@
|
|||
url = "github:3rd/diagram.nvim/feature/toggle";
|
||||
flake = false;
|
||||
};
|
||||
"blink.compat" = {
|
||||
url = "github:saghen/blink.compat";
|
||||
flake = false;
|
||||
};
|
||||
};
|
||||
|
||||
outputs =
|
||||
|
|
|
|||
|
|
@ -1,68 +1,68 @@
|
|||
{ pkgs, ... }:
|
||||
{
|
||||
extraConfigLuaPre = ''
|
||||
local has_words_before = function()
|
||||
unpack = unpack or table.unpack
|
||||
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
|
||||
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
|
||||
end
|
||||
local luasnip = require("luasnip")
|
||||
'';
|
||||
extraPlugins = [ pkgs.vimPlugins.blink-compat ];
|
||||
|
||||
plugins.cmp = {
|
||||
enable = true;
|
||||
|
||||
settings = {
|
||||
snippet.expand = ''
|
||||
function(args)
|
||||
require('luasnip').lsp_expand(args.body)
|
||||
end
|
||||
plugins.blink-cmp = {
|
||||
luaConfig.pre = # lua
|
||||
''
|
||||
require('blink.compat').setup({debug = true})
|
||||
'';
|
||||
mapping = {
|
||||
"<CR>" = "cmp.mapping.confirm({select = true })";
|
||||
"<C-d>" = "cmp.mapping.scroll_docs(-4)";
|
||||
"<C-f>" = "cmp.mapping.scroll_docs(4)";
|
||||
"<C-Space>" = "cmp.mapping.complete()";
|
||||
"<Tab>" = # lua
|
||||
''
|
||||
cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
-- You could replace the expand_or_jumpable() calls with expand_or_locally_jumpable()
|
||||
-- they way you will only jump inside the snippet region
|
||||
elseif luasnip.expand_or_locally_jumpable() then
|
||||
luasnip.expand_or_jump()
|
||||
elseif has_words_before() then
|
||||
cmp.complete()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" })
|
||||
'';
|
||||
"<S-Tab>" = # lua
|
||||
''
|
||||
cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
elseif luasnip.jumpable(-1) then
|
||||
luasnip.jump(-1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" })
|
||||
'';
|
||||
"<Down>" = "cmp.mapping(cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Select }), {'i'})";
|
||||
"<Up>" = "cmp.mapping(cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Select }), {'i'})";
|
||||
};
|
||||
|
||||
sources = [
|
||||
{ name = "luasnip"; }
|
||||
{ name = "nvim_lsp"; }
|
||||
{ name = "path"; }
|
||||
{ name = "buffer"; }
|
||||
{ name = "calc"; }
|
||||
{ name = "git"; }
|
||||
{ name = "omni"; }
|
||||
enable = true;
|
||||
settings = {
|
||||
keymap = {
|
||||
preset = "enter";
|
||||
"<A-Tab>" = [
|
||||
"snippet_forward"
|
||||
"fallback"
|
||||
];
|
||||
"<A-S-Tab>" = [
|
||||
"snippet_backward"
|
||||
"fallback"
|
||||
];
|
||||
"<Tab>" = [
|
||||
"select_next"
|
||||
"fallback"
|
||||
];
|
||||
"<S-Tab>" = [
|
||||
"select_prev"
|
||||
"fallback"
|
||||
];
|
||||
};
|
||||
completion.enabled_providers = [
|
||||
"lsp"
|
||||
"buffer"
|
||||
"path"
|
||||
"git"
|
||||
"calc"
|
||||
"omni"
|
||||
];
|
||||
# Does not seem to work
|
||||
providers = {
|
||||
git = {
|
||||
name = "git";
|
||||
module = "blink.compat.source";
|
||||
};
|
||||
calc = {
|
||||
name = "calc";
|
||||
module = "blink.compat.source";
|
||||
};
|
||||
omni = {
|
||||
name = "omni";
|
||||
module = "blink.compat.source";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
plugins.lsp.capabilities = # lua
|
||||
''
|
||||
capabilities = require('blink.cmp').get_lsp_capabilities(capabilities)
|
||||
'';
|
||||
|
||||
plugins.cmp-omni.enable = true;
|
||||
plugins.cmp-git.enable = true;
|
||||
plugins.cmp-calc.enable = true;
|
||||
|
||||
performance.combinePlugins.standalonePlugins = [ "nvim-cmp" ];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,6 +37,11 @@
|
|||
src = inputs."diagram.nvim";
|
||||
version = inputs."diagram.nvim".shortRev;
|
||||
};
|
||||
blink-compat = prev.vimUtils.buildVimPlugin {
|
||||
pname = "blink.compat";
|
||||
src = inputs."blink.compat";
|
||||
version = inputs."blink.compat".shortRev;
|
||||
};
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue