feat(nvim): replace nvim.cmp with blink.cmp
This commit is contained in:
parent
f0cdafad6a
commit
cab0610450
4 changed files with 235 additions and 122 deletions
63
modules/programs/nvim/new_plugins/blink-cmp.nix
Normal file
63
modules/programs/nvim/new_plugins/blink-cmp.nix
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
{ lib, pkgs, inputs, ... }:
|
||||
|
||||
{
|
||||
home-manager.users.moritz.programs.nixvim = {
|
||||
extraPlugins = [
|
||||
(pkgs.vimUtils.buildVimPlugin {
|
||||
pname = "blink-compat";
|
||||
src = inputs.blink-compat;
|
||||
version = lib.my.mkVersionInput inputs.blink-compat;
|
||||
})
|
||||
];
|
||||
extraConfigLuaPre = ''
|
||||
require("blink.compat").setup({
|
||||
impersonate_nvim_cmp = true
|
||||
})
|
||||
'';
|
||||
plugins.blink-cmp = {
|
||||
enable = true;
|
||||
package = inputs.blink-cmp.packages.${pkgs.system}.blink-cmp;
|
||||
settings = {
|
||||
keymap = {
|
||||
"<C-e>" = [ "hide" ];
|
||||
"<C-space>" = [ "show" "show_documentation" "hide_documentation" ];
|
||||
"<Tab>" = [ "select_next" "fallback" ];
|
||||
"<S-Tab>" = [ "select_prev" "fallback" ];
|
||||
"<C-n>" = [ "snippet_forward" "fallback" ];
|
||||
"<C-p>" = [ "snippet_backward" "fallback" ];
|
||||
"<CR>" = [ "accept" "fallback" ];
|
||||
cmdline.preset = "super-tab";
|
||||
};
|
||||
appearance.nerd_font_variant = "mono";
|
||||
sources = {
|
||||
default = [
|
||||
"lsp"
|
||||
"path"
|
||||
"luasnip"
|
||||
"buffer"
|
||||
"vimtex"
|
||||
];
|
||||
providers.vimtex = {
|
||||
name = "vimtex";
|
||||
module = "blink.compat.source";
|
||||
};
|
||||
};
|
||||
signature.enabled = true;
|
||||
completion.documentation.auto_show = true;
|
||||
completion.accept.auto_brackets.enabled = true;
|
||||
snippets = {
|
||||
expand.__raw = ''require("luasnip").lsp_expand'';
|
||||
active.__raw = ''
|
||||
function(filter)
|
||||
if filter and filter.direction then
|
||||
return require('luasnip').jumpable(filter.direction)
|
||||
end
|
||||
return require('luasnip').in_snippet()
|
||||
end
|
||||
'';
|
||||
jump.__raw = ''require("luasnip").jump'';
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
@ -1,77 +0,0 @@
|
|||
{ config, lib, pkgs, inputs, ... }:
|
||||
|
||||
let
|
||||
inherit (lib) mkEnableOption mkIf readFile;
|
||||
in
|
||||
{
|
||||
home-manager.users.moritz.programs.nixvim = {
|
||||
extraConfigLuaPre = ''
|
||||
local has_words_before = function()
|
||||
if vim.api.nvim_buf_get_option(0, "buftype") == "prompt" then
|
||||
return false
|
||||
end
|
||||
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
|
||||
return col ~= 0 and vim.api.nvim_buf_get_text(0, line-1, 0, line-1, col, {})[1]:match("^%s@*$") == nil
|
||||
end
|
||||
'';
|
||||
plugins.cmp = {
|
||||
autoEnableSources = true;
|
||||
enable = true;
|
||||
settings.sources = [
|
||||
{ priority = 1; name = "async_path"; }
|
||||
{ priority = 1; name = "buffer"; }
|
||||
{ priority = 2; name = "nvim_lsp"; }
|
||||
{ priority = 3; name = "nvim_lsp_signature_help"; }
|
||||
{ priority = 4; name = "luasnip"; }
|
||||
{ priority = 4; name = "vimtex"; }
|
||||
];
|
||||
settings.mapping = {
|
||||
__raw = ''
|
||||
cmp.mapping.preset.insert({
|
||||
['<C-b>'] = cmp.mapping.scroll_docs(-4),
|
||||
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||
['<C-Space>'] = cmp.mapping.complete(),
|
||||
['<C-e>'] = cmp.mapping.abort(),
|
||||
['<CR>'] = cmp.mapping.confirm({ select = true }),
|
||||
["<Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item({ behavior = cmp.SelectBehavior.Select })
|
||||
elseif require("luasnip").locally_jumpable(1) and has_words_before() then
|
||||
require("luasnip").jump(1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
["<S-Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item({ behavior = cmp.SelectBehavior.Select })
|
||||
elseif require("luasnip").locally_jumpable(-1) then
|
||||
require("luasnip").jump(-1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
["<C-n>"] = cmp.mapping(function(fallback)
|
||||
if require("luasnip").choice_active() then
|
||||
require("luasnip").change_choice(1)
|
||||
elseif require("luasnip").locally_jumpable(1) then
|
||||
require("luasnip").jump(1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
["<C-p>"] = cmp.mapping(function(fallback)
|
||||
if require("luasnip").choice_active() then
|
||||
require("luasnip").change_choice(-1)
|
||||
elseif require("luasnip").locally_jumpable(-1) then
|
||||
require("luasnip").jump(-1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
})
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue