Add settings for Neorg and keybinds

This commit is contained in:
Archie Fox
2025-08-15 02:02:47 +03:00
parent 78a39cfbfb
commit af607b992e
8 changed files with 403 additions and 108 deletions

View File

@@ -1,3 +1,4 @@
local lspkind = require("lspkind")
return {
"hrsh7th/nvim-cmp",
version = false, -- last release is way too old
@@ -18,7 +19,7 @@ return {
vim.api.nvim_set_hl(0, "CmpGhostText", { link = "Comment", default = true })
local cmp = require("cmp")
local defaults = require("cmp.config.default")()
local lspkind = require("lspkind")
-- local lspkind = require("lspkind")
-- Проверяем наличие luasnip
local has_luasnip = pcall(require, "luasnip")
@@ -196,79 +197,79 @@ return {
}
-- Добавляем luasnip только если он доступен
if has_luasnip then
table.insert(go_sources, 2, { name = "luasnip", priority = 750 })
end
cmp.setup.filetype("go", {
sources = cmp.config.sources(go_sources, {
{ name = "buffer", priority = 500, keyword_length = 2 }, -- Меньше символов для Go
{ name = "path", priority = 400 },
}),
formatting = {
format = lspkind.cmp_format({
mode = "symbol_text",
maxwidth = 60, -- Больше места для Go типов
ellipsis_char = "...",
before = function(entry, vim_item)
if entry.source.name == "nvim_lsp" then
local completion_item = entry.completion_item
if completion_item.detail then
local detail = completion_item.detail
-- Специальная обработка Go типов
if string.match(detail, "^func") then
vim_item.menu = "[func] " .. detail:sub(1, 40)
elseif string.match(detail, "^type") then
vim_item.menu = "[type] " .. detail:sub(1, 40)
elseif string.match(detail, "^var") then
vim_item.menu = "[var] " .. detail:sub(1, 40)
elseif string.match(detail, "^const") then
vim_item.menu = "[const] " .. detail:sub(1, 40)
else
vim_item.menu = detail:sub(1, 50)
end
else
vim_item.menu = "[LSP]"
end
else
vim_item.menu = ({
luasnip = "[Snippet]",
buffer = "[Buffer]",
path = "[Path]",
nvim_lsp_signature_help = "[Signature]",
})[entry.source.name] or "[Unknown]"
end
return vim_item
end,
}),
},
matching = {
disallow_fuzzy_matching = false,
disallow_fullfuzzy_matching = false,
disallow_partial_fuzzy_matching = false, -- Разрешаем для Go
disallow_partial_matching = false,
disallow_prefix_unmatching = false,
},
})
-- if has_luasnip then
-- table.insert(go_sources, 2, { name = "luasnip", priority = 750 })
-- end
--
-- cmp.setup.filetype("go", {
-- sources = cmp.config.sources(go_sources, {
-- { name = "buffer", priority = 500, keyword_length = 2 }, -- Меньше символов для Go
-- { name = "path", priority = 400 },
-- }),
-- formatting = {
-- format = lspkind.cmp_format({
-- mode = "symbol_text",
-- maxwidth = 60, -- Больше места для Go типов
-- ellipsis_char = "...",
-- before = function(entry, vim_item)
-- if entry.source.name == "nvim_lsp" then
-- local completion_item = entry.completion_item
-- if completion_item.detail then
-- local detail = completion_item.detail
-- -- Специальная обработка Go типов
-- if string.match(detail, "^func") then
-- vim_item.menu = "[func] " .. detail:sub(1, 40)
-- elseif string.match(detail, "^type") then
-- vim_item.menu = "[type] " .. detail:sub(1, 40)
-- elseif string.match(detail, "^var") then
-- vim_item.menu = "[var] " .. detail:sub(1, 40)
-- elseif string.match(detail, "^const") then
-- vim_item.menu = "[const] " .. detail:sub(1, 40)
-- else
-- vim_item.menu = detail:sub(1, 50)
-- end
-- else
-- vim_item.menu = "[LSP]"
-- end
-- else
-- vim_item.menu = ({
-- luasnip = "[Snippet]",
-- buffer = "[Buffer]",
-- path = "[Path]",
-- nvim_lsp_signature_help = "[Signature]",
-- })[entry.source.name] or "[Unknown]"
-- end
-- return vim_item
-- end,
-- }),
-- },
-- matching = {
-- disallow_fuzzy_matching = false,
-- disallow_fullfuzzy_matching = false,
-- disallow_partial_fuzzy_matching = true, -- Разрешаем для Go
-- disallow_partial_matching = false,
-- disallow_prefix_unmatching = false,
-- },
-- })
-- 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" },
},
})
-- 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" },
}),
matching = { disallow_symbol_nonprefix_matching = false },
})
-- cmp.setup.cmdline(":", {
-- mapping = cmp.mapping.preset.cmdline(),
-- sources = cmp.config.sources({
-- { name = "path" },
-- }, {
-- { name = "cmdline" },
-- }),
-- matching = { disallow_symbol_nonprefix_matching = false },
-- })
-- Auto-pairs integration (проверяем наличие плагина)
local has_autopairs, cmp_autopairs = pcall(require, "nvim-autopairs.completion.cmp")