.config/nvim/lua/kamu/plugins/completions.lua aktualisiert

This commit is contained in:
2024-12-22 22:30:12 +01:00
parent 4795515213
commit cd1e024847

View File

@@ -1,16 +1,3 @@
-- local function check_backspace()
-- local col = vim.fn.col(".") - 1
-- if col == 0 or vim.fn.getline("."):sub(col, col):match("%s") then
-- return true
-- else
-- return false
-- end
-- end
--
-- local function T(str)
-- return vim.api.nvim_replace_termcodes(str, true, true, true)
-- end
return { return {
{ {
'saghen/blink.cmp', 'saghen/blink.cmp',
@@ -31,7 +18,7 @@ return {
opts = { opts = {
keymap = { preset = 'super-tab' }, keymap = { preset = 'super-tab' },
appearance = { appearance = {
use_nvim_cmp_as_default = false, use_nvim_cmp_as_default = true,
nerd_font_variant = 'mono', nerd_font_variant = 'mono',
}, },
completion = { completion = {
@@ -41,6 +28,7 @@ return {
}, },
}, },
menu = { menu = {
border = "single",
draw = { draw = {
treesitter = { "lsp" }, treesitter = { "lsp" },
}, },
@@ -48,11 +36,18 @@ return {
documentation = { documentation = {
auto_show = true, auto_show = true,
auto_show_delay_ms = 200, auto_show_delay_ms = 200,
window = {
border = "single",
},
}, },
ghost_text = {
enabled = true
}
}, },
signature = { enabled = true }, signature = { enabled = true },
sources = { sources = {
default = { 'lsp', 'path', 'luasnip', 'buffer' }, default = { 'lsp', 'path', 'luasnip', 'buffer' },
-- TODO: add cmp-emoji as another cmp source -- needs https://github.com/Saghen/blink.compat
per_filetype = { per_filetype = {
tex = { 'lsp', 'path', 'luasnip', 'buffer' }, tex = { 'lsp', 'path', 'luasnip', 'buffer' },
lua = { 'lsp', 'path', 'luasnip', 'buffer', 'lazydev' }, lua = { 'lsp', 'path', 'luasnip', 'buffer', 'lazydev' },
@@ -108,145 +103,3 @@ return {
end, end,
}, },
} }
-- return {
-- {
-- 'hrsh7th/nvim-cmp',
-- dependencies = {
-- 'hrsh7th/cmp-nvim-lsp',
-- 'hrsh7th/cmp-buffer',
-- 'hrsh7th/cmp-path',
-- 'hrsh7th/cmp-cmdline',
-- 'onsails/lspkind.nvim',
-- { 'L3MON4D3/LuaSnip', build = "make install_jsregexp" },
-- 'saadparwaiz1/cmp_luasnip',
-- 'rafamadriz/friendly-snippets',
-- },
-- lazy = false,
-- priority = 100,
-- config = function()
-- vim.opt.completeopt = { "menu", "menuone" }
--
--
-- local lspkind = require('lspkind')
-- local cmp = require('cmp')
-- local ls = require("luasnip")
-- ls.setup({
-- history = true,
-- })
--
-- ls.filetype_extend("latex", { "tex" })
--
-- -- require("luasnip.loaders.from_vscode").lazy_load()
-- require("luasnip.loaders.from_lua").load({
-- -- paths = vim.api.nvim_get_runtime_file("lua/kamu/snippets/", true)[1]
-- paths = "~/.config/nvim/lua/kamu/snippets/",
-- })
-- -- require("luasnip.loaders").edit_snippet_files()
--
-- -- vim.keymap.set({ "i", "s" }, "<Tab>", function()
-- -- if ls.expand_or_jumpable() then
-- -- ls.expand_or_jump()
-- -- else
-- -- return "<Tab>"
-- -- end
-- -- end, { expr = true, silent = true })
-- --
-- -- vim.keymap.set({ "i", "s" }, "<S-Tab>", function()
-- -- if ls.jumpable(-1) then
-- -- ls.jump(-1)
-- -- else
-- -- print("can't go further back")
-- -- end
-- -- end, { silent = true })
--
-- cmp.setup({
-- formatting = {
-- format = lspkind.cmp_format({
-- mode = 'symbol_text',
-- }),
-- },
-- ellipsis_char = '...',
-- show_labelDetails = true,
-- snippet = {
-- expand = function(args)
-- -- vim.snippet.expand(args.body)
-- require('luasnip').lsp_expand(args.body)
-- end,
-- },
-- maxwidth = {
-- menu = 50,
-- abbr = 50,
-- },
-- window = {
-- -- completion = cmp.config.window.bordered(),
-- -- documentation = cmp.config.window.bordered(),
-- },
-- mapping = 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(),
-- -- ['<Tab>'] = cmp.mapping.confirm({ select = false }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
-- ['<CR>'] = cmp.mapping.confirm({ select = false }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
-- ['<Tab>'] = cmp.mapping(function(fallback)
-- if vim.fn.pumvisible() == 1 then
-- vim.fn.feedkeys(T('<C-n>'), 'n')
-- elseif ls.expand_or_jumpable() then
-- ls.expand_or_jump()
-- elseif not check_backspace() then
-- cmp.mapping.complete()(core, fallback)
-- else
-- vim.cmd(':>')
-- vim.cmd(':startinsert')
-- end
-- end, { "i", "s" }),
-- ['<S-Tab>'] = cmp.mapping(function(fallback)
-- if vim.fn.pumvisible() == 1 then
-- vim.fn.feedkeys(T('<C-p>'), 'n')
-- elseif ls.jumpable(-1) then
-- ls.jump(-1)
-- else
-- vim.cmd(':<')
-- vim.cmd(':startinsert')
-- end
-- end, { "i", "s" }),
-- }),
-- sources = cmp.config.sources({
-- { name = 'nvim_lsp' },
-- { name = 'luasnip' },
-- { name = 'path' },
-- { name = 'buffer' },
-- }),
-- })
--
-- -- Set configuration for specific filetype.
-- -- cmp.setup.filetype('gitcommit', {
-- -- sources = cmp.config.sources({
-- -- { name = 'git' }, -- You can specify the `git` source if [you were installed it](https://github.com/petertriho/cmp-git).
-- -- }, {
-- -- { name = 'buffer' },
-- -- })
-- -- })
--
-- -- -- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore).
-- -- cmp.setup.cmdline({ '/', '?' }, {
-- -- mapping = cmp.mapping.preset.cmdline(),
-- -- sources = {
-- -- { name = 'buffer' }
-- -- }
-- -- })
-- --
--
-- -- -- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
-- -- cmp.setup.cmdline(':', {
-- -- mapping = cmp.mapping.preset.cmdline(),
-- -- sources = cmp.config.sources({
-- -- { name = 'path' }
-- -- }, {
-- -- { name = 'cmdline' }
-- -- })
-- -- })
-- end
-- },
-- }