Skip to content

A lightweight and fast Neovim code editor built for competitive programming

License

Notifications You must be signed in to change notification settings

cringeyburger/cinvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CiNvim

A lightweight and fast Neovim code editor built for competitive programming.

NOTE: README is not yet updated about prerequisites

For Whom Is This Editor For?

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 ;)

How to Install

Prerequisites

  1. Neovim >= 0.6

  2. CiNvim was made for Linux operating systems. It may or may not support Windows.

  3. 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).

  4. Update packages

    sudo apt update
  5. Install ripgrep to Text Search:

    sudo apt install ripgrep
  6. 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
  7. 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
  8. Install luarocks

    sudo apt-get install luarocks
  9. Install build-essential and clang

    sudo apt-get install build-essential clang
  10. Install cmake

    sudo snap install cmake --classic

Installation

  1. Clone the contents of this repo to ~/.config/nvim. NOTE: If you cannot find a .config or nvim folder, create them using mkdir command.

  2. Open the editor in your terminal using nvim command

    1. You should see all the different plugins, language servers, linters and formatters downloading and installing in a few seconds.
  3. The formatters, stylua and clang-format, have different settings that make coding slightly inconvenient. For example, stylua, by default, formats lua files with a 4 space-tab style, but the language-server lua_ls prefers a 2 space formatting style. This causes harmless but many unnecessary style warnings that distract while coding. Similarly, clang-format formats c++ files with a 2 space style. We would like to change that style to the usual 4 space formatting style unless you prefer it.

    1. For lua files:

      1. After installation, create a .stylua.toml file at ~/.config/nvim/.stylua.toml and enter the following lines:

        indent_width = 2
        indent_type = "Spaces"
      2. We keep the .stylua.toml file at the root of our Nvim directory so that all the lua files are formatted with these style settings.

    2. For c++ files:

      1. To change the indent width of clang-format, you would have to create a .clang-format file in the root directory of your "coding" folder.

      2. I kept my .clang-format file in my home directory. This allows me to have a "global" formatter settings.

      3. Create a .clang-format file in the root of your project/coding/root directory,

      4. Inside it, just enter:

        IndentWidth: 4
      5. you can look into different settings from the official clang-format documentation

  4. Set the path to your template CP file in .../nvim/lua/plugins/+utility.lua, then go to line 722 or template_file = { ... }.

    1. Set the location to your template file for smooth operation.
    2. You can disable evaluate_template_modifiers if you do not want to use modifiers. For more information, visit receive-modifiers/competitest.
  5. 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.

Additional Notes

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.

  1. Scroll to

    require("luasnip.loaders.from_vscode").lazy_load({ paths = "~/dsa/snippets" })
  2. To setup custom snippets, follow this guide from LuaSnip

    1. In short, in your snippets directory, you need to create a package.json file which looks like this:

      {
        "name": "example-snippets",
        "contributes": {
          "snippets": [
            {
              "language": ["all"],
              "path": "./snippets/all.json"
            },
            {
              "language": ["lua"],
              "path": "./lua.json"
            }
          ]
        }
      }
    2. This file contains the overall info of all snippets linked to it.

    3. Then all.json, the name of the snippets are all1 and all2. 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"]
        }
      }
    4. Then lua.json, the name of the snippet is lua. This is an example of a language-based snippet:

      {
        "snip1": {
          "prefix": "lua",
          "body": ["lualualua"]
        }
      }
    5. 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:

  1. received_problems_path
  2. received_contests_direcory
  3. 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:

  1. Lazy.nvim: Plugin manager

  2. +colorscheme Note: To change the colorscheme, change lazy = true to false, and the current one to true.

    1. Catppuccin
    2. github-nvim-theme
    3. Kanagawa: Wave -> Default colorscheme
    4. vim-nightfly-colors
    5. Nightfox
    6. Tokyonight
  3. +cpp

    1. clangd_extensions
  4. +filetree

    1. nvim-tree
  5. +git

    1. gitsigns
    2. lazygi
  6. +lsp

    1. nvim-lspconfig
    2. mason
    3. lsp_lines
    4. lspsaga
    5. conform
    6. nvim-lint
  7. +ui

    1. alpha
    2. project
    3. nvim-colorizer
    4. noice
    5. nvim-notify
    6. lualine
    7. barbar
    8. hlargs
    9. dressing
    10. indent-blankline
  8. +utility

    1. popup
    2. plenary
    3. autopairs
    4. nvim-cmp
    5. nvim-docs-view
    6. neodev
    7. nvim-ufo
    8. nvim-surround
    9. telescope
    10. todo-comments
    11. toggleterm
    12. nvim-treesitter
    13. trouble
    14. which-key
    15. smart-splits
    16. code_runner
    17. hop
    18. competitest

Note: This code editor is heavily inspired by RuNvim and the Neovim tutorial playlist by chris@machine.

About

A lightweight and fast Neovim code editor built for competitive programming

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published