A lightweight and fast Neovim code editor built for competitive programming.
NOTE: README is not yet updated about prerequisites
Anyone who wants to delve into competitive programming needs a neat and fast code editor.
This code editor is an attempt at making precisely that.
Combined with CompetiTest and other UX enhancing plugins, CiNvim strives to deliver a single platform for all your CP problems.
Fun Fact: CiNvim (pronounced ci-nvim) comes from joining Cin and Nvim ;)
-
Neovim >= 0.6
-
CiNvimwas made for Linux operating systems. It may or may not support Windows. -
Install a Nerdfont for your terminal. I use FiraCode Nerd Font, which is the default font set in the editor (scroll down to learn to change defaults).
-
Update packages
sudo apt update
-
Install
ripgrepto Text Search:sudo apt install ripgrep
-
Install
lazygitto integrate Git in the code editor:LAZYGIT_VERSION=$(curl -s "https://api.github.com/repos/jesseduffield/lazygit/releases/latest" | grep -Po '"tag_name": "v\K[^"]*') curl -Lo lazygit.tar.gz "https://github.com/jesseduffield/lazygit/releases/latest/download/lazygit_${LAZYGIT_VERSION}_Linux_x86_64.tar.gz" tar xf lazygit.tar.gz lazygit sudo install lazygit /usr/local/bin
-
Install
xclipto allow the editor to use the system's clipboard, i.e. allowing you to copy and paste bidirectionally.sudo apt install xclip
-
Install
luarockssudo apt-get install luarocks
-
Install
build-essentialandclangsudo apt-get install build-essential clang
-
Install
cmakesudo snap install cmake --classic
-
Clone the contents of this repo to
~/.config/nvim. NOTE: If you cannot find a.configornvimfolder, create them usingmkdircommand. -
Open the editor in your terminal using
nvimcommand- You should see all the different plugins, language servers, linters and formatters downloading and installing in a few seconds.
-
The formatters,
styluaandclang-format, have different settings that make coding slightly inconvenient. For example,stylua, by default, formatsluafiles with a4 space-tabstyle, but the language-serverlua_lsprefers a2 spaceformatting style. This causes harmless but many unnecessary style warnings that distract while coding. Similarly,clang-formatformatsc++files with a2 spacestyle. We would like to change that style to the usual4 spaceformatting style unless you prefer it.-
For
luafiles:-
After installation, create a
.stylua.tomlfile at~/.config/nvim/.stylua.tomland enter the following lines:indent_width = 2 indent_type = "Spaces" -
We keep the
.stylua.tomlfile at the root of our Nvim directory so that all theluafiles are formatted with these style settings.
-
-
For
c++files:-
To change the
indent widthofclang-format, you would have to create a.clang-formatfile in the root directory of your "coding" folder. -
I kept my
.clang-formatfile in my home directory. This allows me to have a "global" formatter settings. -
Create a
.clang-formatfile in the root of your project/coding/root directory, -
Inside it, just enter:
IndentWidth: 4
-
you can look into different settings from the official clang-format documentation
-
-
-
Set the path to your template CP file in
.../nvim/lua/plugins/+utility.lua, then go toline 722ortemplate_file = { ... }.- Set the location to your template file for smooth operation.
- You can disable
evaluate_template_modifiersif you do not want to use modifiers. For more information, visit receive-modifiers/competitest.
-
That's it! You are now ready to use
CiNvimfor competitive programming.
NOTE: After installation, reopen nvim shell to get greeted by Alpha. If faced with an error, try reopening nvim. Sometimes closing and reopening nvim shell doesn't work, in that case, try removing the nvim folder from ~/.local/share/nvim and open nvim shell.
This will download and reinstall all the plugins.
To change the default font, go to ...nvim/lua/config/options.lua; you can change guifont to whatever you like.
Please look into /config/keymaps.lua and explore whichkey to learn more about the keybindings.
You can set your own snippets for LuaSnip in +utility file.
-
Scroll to
require("luasnip.loaders.from_vscode").lazy_load({ paths = "~/dsa/snippets" })
-
To setup custom snippets, follow this guide from
LuaSnip-
In short, in your
snippetsdirectory, you need to create apackage.jsonfile which looks like this:{ "name": "example-snippets", "contributes": { "snippets": [ { "language": ["all"], "path": "./snippets/all.json" }, { "language": ["lua"], "path": "./lua.json" } ] } } -
This file contains the overall info of all snippets linked to it.
-
Then
all.json, the name of the snippets areall1andall2. This is an example of a general snippet:{ "snip1": { "prefix": "all1", "body": ["expands? jumps? $1 $2 !"] }, "snip2": { "prefix": "all2", "body": ["multi $1", "line $2", "snippet$0"] } } -
Then
lua.json, the name of the snippet islua. This is an example of a language-based snippet:{ "snip1": { "prefix": "lua", "body": ["lualualua"] } } -
After this, just link the path to the directory to the command given in [1.]
-
NOTE: YOU MAY NEED to customise the path for CompetiTest. Just go to +utility and scroll down to:
received_problems_pathreceived_contests_direcoryreceived_contests_problems_path
The default settings are the ones that I use day to day. Feel free to modify as you like.
Here is the list of all the plugins (excluding dependencies) used:
-
Lazy.nvim: Plugin manager
-
+colorschemeNote: To change the colorscheme, changelazy = truetofalse, and the current one totrue.- Catppuccin
- github-nvim-theme
- Kanagawa: Wave -> Default colorscheme
- vim-nightfly-colors
- Nightfox
- Tokyonight
-
+cpp -
+filetree -
+git -
+lsp -
+ui -
+utility
Note: This code editor is heavily inspired by RuNvim and the Neovim tutorial playlist by chris@machine.