Skip to content

simta1/cptools.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Cptools.nvim

demo.mp4

Features

  • 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

Planned Features (not implemented yet)

  • Count prime <= N
  • Combinatorics
  • Modular Arithmetic
  • Primitive root
  • CRT solver
  • Base conversion

Requirements

  • Neovim 0.7+
  • GMP (GNU Multiple Precision Arithmetic Library)

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,
}

Usage

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

About

Math utilities for Competitive Programming in Neovim

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages