Initial migrations to lazy.nvim

This commit is contained in:
2023-09-18 12:44:13 -04:00
parent 6410d07c70
commit 34da568c87
23 changed files with 706 additions and 309 deletions

118
nvim/lua/config/tmp/cmp.lua Normal file
View File

@@ -0,0 +1,118 @@
-- Setup nvim-cmp.
local cmp = require "cmp"
local lspkind = require("lspkind")
local capabilities = require('cmp_nvim_lsp').default_capabilities()
local has_words_before = function()
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 feedkey = function(key, mode)
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true),
mode, true)
end
require'lspconfig'.sourcekit.setup {
capabilities = capabilities
}
lspkind.init({
symbol_map = {
Text = "",
Method = "",
Function = "",
Constructor = "",
Field = "",
Variable = "",
Class = "",
Interface = "",
Module = "",
Property = "",
Unit = "",
Value = "",
Enum = "",
Keyword = "",
Snippet = "",
Color = "",
File = "",
Reference = "",
Folder = "",
EnumMember = "",
Constant = "",
Struct = "",
Event = "",
Operator = "",
TypeParameter = ""
}
})
cmp.setup({
formatting = {
format = lspkind.cmp_format {
with_text = false,
maxwidth = 50,
menu = {
buffer = "BUF",
nvim_lsp = "LSP",
path = "PATH",
vsnip = "SNIP",
calc = "CALC",
spell = "SPELL",
emoji = "EMOJI"
}
}
},
experimental = {native_menu = false, ghost_text = false},
snippet = {
expand = function(args)
vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users.
end
},
mapping = {
["<C-p>"] = cmp.mapping.select_prev_item(),
["<C-n>"] = cmp.mapping.select_next_item(),
["<C-d>"] = cmp.mapping.scroll_docs(-4),
["<C-f>"] = cmp.mapping.scroll_docs(4),
["<C-Space>"] = cmp.mapping.complete(),
["<C-e>"] = cmp.mapping.close(),
["<CR>"] = cmp.mapping.confirm {
behavior = cmp.ConfirmBehavior.Replace,
select = false
},
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif vim.fn["vsnip#available"](1) == 1 then
feedkey("<Plug>(vsnip-expand-or-jump)", "")
elseif has_words_before() then
cmp.complete()
else
fallback() -- The fallback function sends a already mapped key. In this case, it's probably `<Tab>`.
end
end, {"i", "s"}),
["<S-Tab>"] = cmp.mapping(function()
if cmp.visible() then
cmp.select_prev_item()
elseif vim.fn["vsnip#jumpable"](-1) == 1 then
feedkey("<Plug>(vsnip-jump-prev)", "")
end
end, {"i", "s"})
},
sources = {
{name = "nvim_lsp"}, {name = "buffer", keyword_length = 5},
{name = "vsnip"}, {name = "calc"}, {name = "emoji"}, {name = "spell"},
{name = "path"}
}
})
-- Use buffer source for `/`.
cmp.setup.cmdline("/", {sources = {{name = "buffer"}}})
-- Use cmdline & path source for ':'.
cmp.setup.cmdline(":", {
sources = cmp.config.sources({{name = "path"}}, {{name = "cmdline"}})
})