feat(nvim): add cmp-async-path
This commit is contained in:
parent
d6fbbb945c
commit
f47c711d57
5 changed files with 74 additions and 39 deletions
|
|
@ -63,6 +63,7 @@ in
|
|||
yamlfmt
|
||||
];
|
||||
plugins = with pkgs.vimPlugins; [
|
||||
cmp-async-path
|
||||
cmp-nvim-lsp
|
||||
cmp_luasnip
|
||||
copilot-cmp
|
||||
|
|
|
|||
|
|
@ -1,5 +1,33 @@
|
|||
require("impatient")
|
||||
|
||||
---merge tables
|
||||
---@param ... table[]
|
||||
---@return table
|
||||
local function table_merge(...)
|
||||
local tables_to_merge = { ... }
|
||||
assert(#tables_to_merge > 1, "There should be at least two tables to merge them")
|
||||
|
||||
for k, t in ipairs(tables_to_merge) do
|
||||
assert(type(t) == "table", string.format("Expected a table as function parameter %d", k))
|
||||
end
|
||||
|
||||
local result = tables_to_merge[1]
|
||||
|
||||
for i = 2, #tables_to_merge do
|
||||
local from = tables_to_merge[i]
|
||||
for k, v in pairs(from) do
|
||||
if type(v) == "table" then
|
||||
result[k] = result[k] or {}
|
||||
result[k] = table_merge(result[k], v)
|
||||
else
|
||||
result[k] = v
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return result
|
||||
end
|
||||
|
||||
require("nvim-treesitter.configs").setup({
|
||||
sync_install = false,
|
||||
auto_install = false,
|
||||
|
|
@ -16,6 +44,13 @@ vim.api.nvim_create_autocmd("InsertEnter", {
|
|||
local luasnip = require("luasnip")
|
||||
require("copilot_cmp").setup()
|
||||
|
||||
local default_sources = {
|
||||
{ name = "async_path", priority = 4 },
|
||||
{ name = "copilot", priority = 3 },
|
||||
{ name = "luasnip", priority = 2 },
|
||||
{ name = "nvim_lsp", priority = 4 },
|
||||
}
|
||||
|
||||
cmp.setup({
|
||||
formatting = {
|
||||
format = require("lspkind").cmp_format({
|
||||
|
|
@ -58,45 +93,18 @@ vim.api.nvim_create_autocmd("InsertEnter", {
|
|||
end
|
||||
end, { "i", "s" }),
|
||||
}),
|
||||
sources = {
|
||||
{ name = "buffer", priority = 1 },
|
||||
{ name = "copilot", priority = 8 },
|
||||
{ name = "luasnip", priority = 7 },
|
||||
{ name = "nvim_lsp", priority = 9 },
|
||||
{ name = "orgmode", priority = 9 },
|
||||
},
|
||||
sources = default_sources,
|
||||
})
|
||||
|
||||
cmp.setup.filetype("org", {
|
||||
sources = table_merge(default_sources, {
|
||||
{ name = "buffer", priority = 5 },
|
||||
{ name = "orgmode", priority = 5 },
|
||||
}),
|
||||
})
|
||||
end,
|
||||
})
|
||||
|
||||
---merge tables
|
||||
---@param ... table[]
|
||||
---@return table
|
||||
local function table_merge(...)
|
||||
local tables_to_merge = { ... }
|
||||
assert(#tables_to_merge > 1, "There should be at least two tables to merge them")
|
||||
|
||||
for k, t in ipairs(tables_to_merge) do
|
||||
assert(type(t) == "table", string.format("Expected a table as function parameter %d", k))
|
||||
end
|
||||
|
||||
local result = tables_to_merge[1]
|
||||
|
||||
for i = 2, #tables_to_merge do
|
||||
local from = tables_to_merge[i]
|
||||
for k, v in pairs(from) do
|
||||
if type(v) == "table" then
|
||||
result[k] = result[k] or {}
|
||||
result[k] = table_merge(result[k], v)
|
||||
else
|
||||
result[k] = v
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return result
|
||||
end
|
||||
|
||||
local lsp_lines = require("lsp_lines")
|
||||
lsp_lines.setup()
|
||||
-- Disable virtual_text since it's redundant due to lsp_lines.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue