]> Git — Sourcephile - julm/julm-nix.git/blob - home-manager/profiles/nvim/lua/plugins/blink-cmp.lua
neovim: configure, using ghostty and tmux
[julm/julm-nix.git] / home-manager / profiles / nvim / lua / plugins / blink-cmp.lua
1 -- Performant, batteries-included completion plugin for Neovim.
2 -- https://github.com/Saghen/blink.cmp
3 return {
4 "blink.cmp",
5 event = "InsertEnter",
6 after = function()
7 require("blink-cmp").setup({
8 -- Enables keymaps, completions and signature help when true (doesn't apply to cmdline or term)
9 --
10 -- If the function returns 'force', the default conditions for disabling the plugin will be ignored
11 -- Default conditions: (vim.bo.buftype ~= 'prompt' and vim.b.completion ~= false)
12 -- Note that the default conditions are ignored when `vim.b.completion` is explicitly set to `true`
13 --
14 -- Exceptions: vim.bo.filetype == 'dap-repl'
15 --enabled = function()
16 -- return not vim.tbl_contains({ "lua", "markdown" }, vim.bo.filetype)
17 --end,
18
19 -- Disable cmdline
20 -- cmdline = { enabled = false },
21
22 fuzzy = {
23 implementation = "prefer_rust_with_warning",
24 sorts = {
25 "score", -- Primary sort: by fuzzy matching score
26 "sort_text", -- Secondary sort: by sortText field if scores are equal
27 "label", -- Tertiary sort: by label if still tied
28 },
29 },
30
31 completion = {
32 -- 'prefix' will fuzzy match on the text before the cursor
33 -- 'full' will fuzzy match on the text before _and_ after the cursor
34 -- example: 'foo_|_bar' will match 'foo_' for 'prefix' and 'foo__bar' for 'full'
35 keyword = { range = "prefix" },
36
37 -- Disable auto brackets
38 -- NOTE: some LSPs may add auto brackets themselves anyway
39 accept = { auto_brackets = { enabled = false } },
40 list = {
41 selection = {
42 preselect = true,
43 auto_insert = true,
44 },
45 },
46 -- or set via a function
47 --list = {
48 -- selection = {
49 -- preselect = function(ctx)
50 -- return vim.bo.filetype ~= "markdown"
51 -- end,
52 -- },
53 --},
54
55 menu = {
56 auto_show = true,
57
58 -- nvim-cmp style menu
59 --draw = {
60 -- columns = {
61 -- { "label", "label_description", gap = 1 },
62 -- { "kind_icon", "kind" },
63 -- },
64 --},
65 },
66
67 -- Show documentation when selecting a completion item
68 documentation = { auto_show = true, auto_show_delay_ms = 2000 },
69
70 -- Whether to display a preview of the selected item on the current line
71 ghost_text = { enabled = false },
72 },
73 keymap = {
74 -- set to 'none' to disable the 'default' preset
75 preset = "none",
76
77 ["<C-space>"] = { "show", "show_documentation", "hide_documentation" },
78 ["<C-e>"] = { "hide", "fallback" },
79 ["<Tab>"] = { "accept", "fallback" },
80 --["<CR>"] = { "accept", "fallback" },
81
82 --["<Tab>"] = { "snippet_forward", "fallback" },
83 --["<S-Tab>"] = { "snippet_backward", "fallback" },
84
85 ["<Up>"] = { "select_prev", "fallback" },
86 ["<Down>"] = { "select_next", "fallback" },
87 ["<C-i>"] = { "select_prev", "fallback_to_mappings" },
88 ["<C-k>"] = { "select_next", "fallback_to_mappings" },
89
90 ["<C-j>"] = { "scroll_documentation_up", "fallback" },
91 ["<C-l>"] = { "scroll_documentation_down", "fallback" },
92
93 ["<C-n>"] = { "show_signature", "hide_signature", "fallback" },
94 },
95
96 sources = {
97 -- Remove 'buffer' if you don't want text completions,
98 -- by default it's only enabled when LSP returns no items
99 default = { "lsp", "path", "snippets", "buffer" },
100 providers = {
101
102 -- Always show the buffer source even when the LSP provides some completion
103 lsp = { fallbacks = {} },
104 },
105 },
106
107 -- Use a preset for snippets, check the snippets documentation for more information
108 snippets = { preset = "default" }, -- | "luasnip" | "mini_snippets" | "vsnip"
109
110 -- Experimental signature help support
111 signature = { enabled = true },
112 })
113 end,
114 }