Giter VIP home page Giter VIP logo

ojparser.vim's Introduction

cfparser.vim

A codeforces helper plugin for vim, ported from emacs plugin gnull/cfparser.

Installation

  • Install curl.
  • Install cfparser.vim with your favorite vim plugin manager. If you use vim-plug:
Plug 'gabrielsimoes/cfparser.vim'

Optional setup

You can setup some variables at your .vimrc:

  • g:cf_cookies_file - File in which curl will store cookies (default: '~/.cf_cookies')
  • g:cf_default_language - Language to be used when it it not recognized from file extension. Languages codes are available at plugin/cfparser.vim. The default is "54" which corresponds to C++17, as defined in the variable g:cf_pl_gpp.
  • g:cf_pl_by_ext_custom - A dictionary from file extension to language code to override the defaults. cfparser.vim will first check in the custom map, and if not found it will check the default map, and finally g:cf_default_language. If you prefer C++11 over C++17, for example:
let g:cf_pl_by_ext_custom = {'.cpp': "42"}
  • g:cf_locale - Language to download problem statement. Either "ru" or "en" (default: "en")
  • You can also redefine the function cfparser#CFTestAll(), that is, the function that is called to test your solution against test files. The default definition is as follows. You can redefine the function by writing your own version of it at your .vimrc, after loading cfparser.vim.
function! cfparser#CFTestAll()
    echo system(printf("g++ %s -o /tmp/cfparser_exec;
                        \cnt=0;
                        \for i in `ls %s/*.in | sed 's/\\.in$//'`; do
                        \   let cnt++;
                        \   echo \"\nTEST $cnt\";
                        \   /tmp/cfparser_exec < $i.in | diff -y - $i.out;
                        \done;
                        \rm /tmp/cfparser_exec",
        \ expand('%:p'), expand('%:p:h')))
endfunction

This will compile the file with g++ and test it against 0.in and 0.out, 1.in and 1.out, etc...

  • You also redefine the function cfparser#CFRun(), the function that is called to test your solution in an interactive shell. You can redefine it by writing your own version of it at your .vimrc, after loading cfparser.vim. The default definition is below:
function! cfparser#CFRun()
    echo system(printf("g++ %s -o /tmp/cfparser_exec", expand('%s:p')))
    RunInInteractiveShell /tmp/cfparser_exec
    call system("rm /tmp/cfparser_exec")
endfunction

This will compile the file with g++ and run it with the command RunInteractiveShell, which is provided by the following plugin: christoomey/vim-run-interactive.

Usage

  • <leader>cfi - Login (calls CFLogin())
  • <leader>cfo - Logout (calls CFLogout())
  • <leader>cfw - Who am I (calls CFWhoAmI())
  • <leader>cfp - Display problem statement (calls CFProblemStatement())
  • <leader>cfd - Download sample tests to current code folder (0.in, 0.out, 1.in ...) (calls CFDownloadTests())
  • <leader>cfc - Clear previously downloaded sample tests from current folder (0.in, 0.out, 1.in ...) (calls CFClearTests())
  • <leader>cft - Runs code with sample tests (calls CFTestAll())
  • <leader>cfr - Runs code in an interactive shell (calls CFRun())
  • <leader>cfs - Submit current open file (calls CFSubmit())
  • <leader>cfl - List most recent submissions (calls CFLastSubmissions() without arguments - can be called with username as argument, default to logged in user)

When using the submit, download sample tests and problem statement functions, cfparser will "guess" the contest number, problem index and the programming language by the current file name. It should be in one of the following forms: (it could be any extension besides .cpp)

  • directory/123/A/myfile.cpp
  • directory/123/A.cpp
  • directory/123A.cpp

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.