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
-
CiNvim
was 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
ripgrep
to Text Search:sudo apt install ripgrep
-
Install
lazygit
to 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
xclip
to allow the editor to use the system's clipboard, i.e. allowing you to copy and paste bidirectionally.sudo apt install xclip
-
Install
luarocks
sudo apt-get install luarocks
-
Install
build-essential
andclang
sudo apt-get install build-essential clang
-
Install
cmake
sudo snap install cmake --classic
-
Clone the contents of this repo to
~/.config/nvim
. NOTE: If you cannot find a.config
ornvim
folder, create them usingmkdir
command. -
Open the editor in your terminal using
nvim
command- You should see all the different plugins, language servers, linters and formatters downloading and installing in a few seconds.
-
The formatters,
stylua
andclang-format
, have different settings that make coding slightly inconvenient. For example,stylua
, by default, formatslua
files with a4 space-tab
style, but the language-serverlua_ls
prefers a2 space
formatting style. This causes harmless but many unnecessary style warnings that distract while coding. Similarly,clang-format
formatsc++
files with a2 space
style. We would like to change that style to the usual4 space
formatting style unless you prefer it.-
For
lua
files:-
After installation, create a
.stylua.toml
file at~/.config/nvim/.stylua.toml
and enter the following lines:indent_width = 2 indent_type = "Spaces"
-
We keep the
.stylua.toml
file at the root of our Nvim directory so that all thelua
files are formatted with these style settings.
-
-
For
c++
files:-
To change the
indent width
ofclang-format
, you would have to create a.clang-format
file in the root directory of your "coding" folder. -
I kept my
.clang-format
file in my home directory. This allows me to have a "global" formatter settings. -
Create a
.clang-format
file 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 722
ortemplate_file = { ... }
.- Set the location to your template file for smooth operation.
- You can disable
evaluate_template_modifiers
if you do not want to use modifiers. For more information, visit receive-modifiers/competitest.
-
That's it! You are now ready to use
CiNvim
for 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
snippets
directory, you need to create apackage.json
file 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 areall1
andall2
. 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_path
received_contests_direcory
received_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
-
+colorscheme
Note: To change the colorscheme, changelazy = true
tofalse
, 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
.