feat(nvim): add coq-nvim

dev-docs
Moritz Böhme 2023-07-24 18:44:03 +02:00
parent 526783f07a
commit e2aff57d72
Signed by: moritz
GPG Key ID: 970C6E89EB0547A9
7 changed files with 62 additions and 113 deletions

View File

@ -222,26 +222,35 @@ in
withNodeJs = true; withNodeJs = true;
withPython3 = true; withPython3 = true;
extraLuaConfig = lib.concatLines [ (builtins.readFile ./options.lua) lazy ]; extraLuaConfig = lib.concatLines [ (builtins.readFile ./options.lua) lazy ];
extraPackages = with pkgs; [ extraPython3Packages = ps:
alejandra let
black plugins = map (getAttr "plugin") cfg.plugins;
deadnix depAttrName = "python3Dependencies";
isort filtered = filter (hasAttr depAttrName) plugins;
jq funcs = map (getAttr depAttrName) filtered;
nil in
nixpkgs-fmt foldl (list: f: list ++ (f ps)) [ ] funcs;
nodePackages.bash-language-server extraPackages = with pkgs;
rustfmt [
shellcheck alejandra
shfmt black
statix deadnix
stylua isort
sumneko-lua-language-server jq
taplo nil
typst nixpkgs-fmt
typst-lsp nodePackages.bash-language-server
yamlfmt rustfmt
]; shellcheck
shfmt
statix
stylua
sumneko-lua-language-server
taplo
typst
typst-lsp
yamlfmt
];
plugins = [ plugins = [
pkgs.vimPlugins.lazy-nvim pkgs.vimPlugins.lazy-nvim
]; ];

View File

@ -0,0 +1,2 @@
-- dont show ghost text
vim.g.codeium_render = false

View File

@ -0,0 +1,3 @@
vim.g.coq_settings = {
auto_start = "shut-up",
}

View File

@ -0,0 +1,4 @@
require("coq_3p")({
{ src = "orgmode", short_name = "ORG" },
{ src = "codeium", short_name = "COD" },
})

View File

@ -82,28 +82,6 @@ with builtins;
{ plugin = nvim-web-devicons; } { plugin = nvim-web-devicons; }
]; ];
} }
{
plugin = nvim-cmp;
conf = readFile ./nvim-cmp.lua;
event = [ "InsertEnter" ];
dependencies = [
{ plugin = cmp-async-path; }
{ plugin = cmp-nvim-lsp; }
{ plugin = cmp_luasnip; }
{
plugin = copilot-cmp;
dependencies = [
{
plugin = copilot-lua;
conf = readFile ./copilot-lua.lua;
dependencies = [{ plugin = which-key-nvim; }];
}
];
}
{ plugin = friendly-snippets; }
{ plugin = luasnip; }
];
}
{ {
plugin = todo-comments-nvim; plugin = todo-comments-nvim;
event = [ "BufReadPost" "BufNewFile" ]; event = [ "BufReadPost" "BufNewFile" ];
@ -281,5 +259,25 @@ with builtins;
plugin = markdown-preview-nvim; plugin = markdown-preview-nvim;
lazy = false; lazy = false;
} }
{
plugin = coq_nvim;
lazy = false;
init = builtins.readFile ./coq-nvim.lua;
dependencies = [
{
plugin = coq-thirdparty;
conf = builtins.readFile ./coq-thirdparty.lua;
dependencies = [
{
plugin = codeium-vim;
init = builtins.readFile ./codeium-vim.lua;
}
];
}
{
plugin = coq-artifacts;
}
];
}
]; ];
} }

View File

@ -1,63 +0,0 @@
local cmp = require("cmp")
local luasnip = require("luasnip")
require("luasnip.loaders.from_vscode").lazy_load()
require("copilot_cmp").setup()
local default_sources = {
{ name = "async_path", priority = 1 },
{ name = "copilot", priority = 2 },
{ name = "luasnip", priority = 2 },
{ name = "nvim_lsp", priority = 3 },
}
cmp.setup({
formatting = {
format = require("lspkind").cmp_format({
mode = "symbol", -- show only symbol annotations
maxwidth = 50, -- prevent the popup from showing more than provided characters
ellipsis_char = "...", -- when popup menu exceed maxwidth, the truncated part would show ellipsis_char instead
symbol_map = {
Copilot = "",
},
}),
},
snippet = {
-- REQUIRED - you must specify a snippet engine
expand = function(args)
require("luasnip").lsp_expand(args.body)
end,
},
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(),
["<CR>"] = cmp.mapping.confirm({ select = true }),
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
else
fallback()
end
end, { "i", "s" }),
["<S-Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif luasnip.jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, { "i", "s" }),
}),
sources = default_sources,
})
cmp.setup.filetype("org", {
sources = vim.tbl_deep_extend("force", default_sources, {
{ name = "buffer", priority = 1 },
{ name = "orgmode", priority = 3 },
}),
})

View File

@ -5,9 +5,6 @@ vim.diagnostic.config({
virtual_text = false, virtual_text = false,
}) })
-- The nvim-cmp almost supports LSP's capabilities so You should advertise it to LSP servers..
local capabilities = require("cmp_nvim_lsp").default_capabilities()
vim.o.foldcolumn = "1" -- '0' is not bad vim.o.foldcolumn = "1" -- '0' is not bad
vim.o.foldlevel = 99 -- Using ufo provider need a large value, feel free to decrease the value vim.o.foldlevel = 99 -- Using ufo provider need a large value, feel free to decrease the value
vim.o.foldlevelstart = 99 vim.o.foldlevelstart = 99
@ -47,6 +44,7 @@ require("which-key").register({
M = { require("ufo").closeAllFolds, "Close all folds" }, M = { require("ufo").closeAllFolds, "Close all folds" },
}, },
}) })
local capabilities = vim.lsp.protocol.make_client_capabilities()
-- Tell the server the capability of foldingRange, -- Tell the server the capability of foldingRange,
-- Neovim hasn't added foldingRange to default capabilities, users must add it manually -- Neovim hasn't added foldingRange to default capabilities, users must add it manually
capabilities.textDocument.foldingRange = { capabilities.textDocument.foldingRange = {
@ -107,9 +105,6 @@ end
local lspconfig_default_options = { local lspconfig_default_options = {
on_attach = on_attach_def, on_attach = on_attach_def,
capabilities = capabilities, capabilities = capabilities,
flags = {
debounce_text_changes = 100,
},
} }
---function to add default options to lspconfig ---function to add default options to lspconfig
@ -117,8 +112,9 @@ local lspconfig_default_options = {
---@param options table ---@param options table
---@return nil ---@return nil
local function lspconfig_setup(lsp, options) local function lspconfig_setup(lsp, options)
local final_options = vim.tbl_deep_extend("force", lspconfig_default_options, options) local coq_options = require("coq").lsp_ensure_capabilities({})
lspconfig[lsp].setup(final_options) local merged_options = vim.tbl_deep_extend("force", coq_options, lspconfig_default_options, options)
lspconfig[lsp].setup(merged_options)
end end
local servers = { local servers = {