demo.mp4
- Divisors: Generate and list all divisors of a 64-bit unsigned integer
- Highly composite number ≤ N: Find the largest highly composite number ≤ N (64-bit unsigned), with divisor count and prime factorization
- Integer square root: Exact
floor(sqrt(N))
for big integers. - Primality test: Check if a 64-bit unsigned integer is prime
- Prime factorization: Factorize a 64-bit unsigned integer into primes
- Count prime <= N
- Combinatorics
- Modular Arithmetic
- Primitive root
- CRT solver
- Base conversion
If GMP is not installed on your system, install it first:
# Arch Linux
sudo pacman -S gmp
# Ubuntu/Debian
sudo apt install libgmp-dev
Installation (lazy.nvim)
Install the plugin with your preferred plugin manager, and add require("cptools").setup()
to your Neovim configuration.
{
"simta1/cptools.nvim",
config = function()
require("cptools").setup()
vim.keymap.set("n", "<leader>cp", "<cmd>Cptools<cr>", { desc = "Open CP Tools" })
end,
}
By default, all available tools are automatically registered, and they appear in the :Cptools
menu in alphabetical order.
If you want to customize which tools appear (and in which order), you can explicitly list them.
When you define tools
in the config, the menu will show them in the same order you specify:
{
"simta1/cptools.nvim",
config = function()
require("cptools").setup({
tools = {
-- 'use' is the filename under 'lua/cptools/tools/'
-- 'as' is the display name shown in the :Cptools menu
{ use = "divisors", as = "divisors" },
{ use = "highly_composite_number", as = "highly composite number" },
{ use = "isqrt", as = "isqrt" },
{ use = "primality_test", as = "prime check" },
{ use = "prime_factorization", as = "prime factorization" },
}
})
vim.keymap.set("n", "<leader>cp", "<cmd>Cptools<cr>", { desc = "Open CP Tools" })
end,
}
This plugin does not define any default key mappings. You can create your own mappings, for example:
vim.keymap.set("n", "<leader>cp", "<cmd>Cptools<cr>", { desc = "Open CP Tools" })
Or simply run the command:
:Cptools