Блог пользователя gabrielsimoes

Автор gabrielsimoes, история, 8 лет назад, По-английски

I have moved from emacs to vim, so I have decided to port gnull's cfparser to vimscript. The result is here.

As gnull's plugin, cfparser.vim can:

  • Submit solutions
  • Download tests
  • Run solution with sample tests
  • Keep your login through cookies
  • Open problem statements
  • Only dependency is curl (and bash, diff and gcc for testing solution)

You can install it with your favorite vim plugin manager, and setup as explained at the project repository:

cfparser.vim

  • Проголосовать: нравится
  • +35
  • Проголосовать: не нравится

»
8 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Auto comment: topic has been updated by gabrielsimoes (previous revision, new revision, compare).

  • »
    »
    8 лет назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    What is a "diff"?

    • »
      »
      »
      8 лет назад, # ^ |
      Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

      diff is a linux utility to compare two files. It is included in most linux distros by default. In cfparser.vim, diff is used to compare the expected output and the program output.

      • »
        »
        »
        »
        8 лет назад, # ^ |
          Проголосовать: нравится 0 Проголосовать: не нравится

        Thanks.

        I installed the cfparser.vim plugin. Can you please elaborate on its usage?For eg.What commands to use? When and where should I type the commands(cfi, cfp etc) mentioned in the project repository.I'm a newbie.

        • »
          »
          »
          »
          »
          8 лет назад, # ^ |
          Rev. 3   Проголосовать: нравится 0 Проголосовать: не нравится

          First, you have to setup your leader key (http://usevim.com/2012/07/20/vim101-leader/) to use the keybindings (note they start with <leader>).

          Some commands can be used anywhere, such as login, and list submissions. Others may be used while writing your solution.

          Suppose you are writing your solution for problem 342D, name your file or fold hierarchy as mentioned in the repo README, eg: 342D.cpp. Then cfparser.vim will recognize the problem your dealing with when you run the commands to download tests, test your solution, read problem statement and submit your solution.

          To run the command that submits your solution, for example, you must be logged in and press the <leader> key, followed by c, f and s.

          • »
            »
            »
            »
            »
            »
            8 лет назад, # ^ |
            Rev. 11   Проголосовать: нравится 0 Проголосовать: не нравится

            I couldn't understand the procedure to setup "leader" key for codeforces :(.

            Does your plugin work during off-contest?

            I wrote the following lines in my .vimrc file:-

              noremap <leader>cfi :CFLogin<CR>
              noremap <leader>cfo :CFLogout<CR>
              noremap <leader>cfw :CFWhoAmI<CR>
              noremap <leader>cfp :CFProblemStatement<CR>
              noremap <leader>cfd :CFDownloadTests<CR>
              noremap <leader>cft :CFTestAll<CR>
              noremap <leader>cfs :CFSubmit<CR>
              noremap <leader>cfl :CFLastSubmissions<CR>
            

            Edit-

            I figured out the procedure of setting up the <leader> key.

            <leader>cfi
            <leader>cfo
            <leader>cfw
            <leader>cfp
            

            are working fine for me.But, <leader>cfd shows the following error:-

            downloading tests for 723/a...                                                                           
            Error detected while processing function cfparser#CFDownloadTests..cfparser#CFGetTests..cfparser#CFParseTests:
            line    7:
            E117: Unknown function: matchstrpos
            E15: Invalid expression: matchstrpos(a:data, input_regex, from)[2] 
            line    9:
            E117: Unknown function: matchstrpos
            E15: Invalid expression: matchstrpos(a:data, output_regex, from)[2] 
            line    7:
            E117: Unknown function: matchstrpos
            E15: Invalid expression: matchstrpos(a:data, input_regex, from)[2] 
            line    9:
            E117: Unknown function: matchstrpos
            E15: Invalid expression: matchstrpos(a:data, output_regex, from)[2] 
            line    7:
            E117: Unknown function: matchstrpos
            E15: Invalid expression: matchstrpos(a:data, input_regex, from)[2] 
            line    9:
            E117: Unknown function: matchstrpos
            E15: Invalid expression: matchstrpos(a:data, output_regex, from)[2] 
            line    7:
            E117: Unknown function: matchstrpos
            E15: Invalid expression: matchstrpos(a:data, input_regex, from)[2] 
            line    9:
            E117: Unknown function: matchstrpos
            E15: Invalid expression: matchstrpos(a:data, output_regex, from)[2] 
            line    7:
            E117: Unknown function: matchstrpos
            E15: Invalid expression: matchstrpos(a:data, input_regex, from)[2] 
            line    9:
            E117: Unknown function: matchstrpos
            E15: Invalid expression: matchstrpos(a:data, output_regex, from)[2] 
            line    7:
            E117: Unknown function: matchstrpos
            E15: Invalid expression: matchstrpos(a:data, input_regex, from)[2] 
            line    9:
            E117: Unknown function: matchstrpos
            E15: Invalid expression: matchstrpos(a:data, output_regex, from)[2] 
            
            

            <leader>cfs shows the following error:-

            Error detected while processing function cfparser#CFSubmit:                                              
            line   22:
            E121: Undefined variable: g:cf_language
            E116: Invalid arguments for function printf("curl --location --silent --cookie-jar %s --cookie %s -F 'csrf_token=%s' -F 'action=su
            bmitSolutionFormSubmitted' -F 'submittedProblemIndex=%s' -F 'programTypeId=%s' -F \"source=@%s\" '%s://%s/contest/%s/submit?csrf_t
            oken=%s'", g:cf_cookies_file, g:cf_cookies_file, csrf_token, problem, g:cf_language, temp_file, s:cf_proto, s:cf_host, contest, cs
            rf_token))
            E116: Invalid arguments for function system(printf("curl --location --silent --cookie-jar %s --cookie %s -F 'csrf_token=%s' -F 'ac
            tion=submitSolutionFormSubmitted' -F 'submittedProblemIndex=%s' -F 'programTypeId=%s' -F \"source=@%s\" '%s://%s/contest/%s/submit
            ?csrf_token=%s'", g:cf_cookies_file, g:cf_cookies_file, csrf_token, problem, g:cf_language, temp_file, s:cf_proto, s:cf_host, cont
            est, csrf_token))
            E15: Invalid expression: system(printf("curl --location --silent --cookie-jar %s --cookie %s -F 'csrf_token=%s' -F 'action=submitS
            olutionFormSubmitted' -F 'submittedProblemIndex=%s' -F 'programTypeId=%s' -F \"source=@%s\" '%s://%s/contest/%s/submit?csrf_token=
            %s'", g:cf_cookies_file, g:cf_cookies_file, csrf_token, problem, g:cf_language, temp_file, s:cf_proto, s:cf_host, contest, csrf_to
            ken))
            submit: ok [by aspera_ to 723/a]
            
            

            What is going wrong here?Please help.

            • »
              »
              »
              »
              »
              »
              »
              8 лет назад, # ^ |
              Rev. 4   Проголосовать: нравится 0 Проголосовать: не нравится

              I think this would be better discussed at the issues page on the github repository.

              However, which version of VIM are you using, the function matchstrpos should be native, it looks like your VIM version is lacking it.

              I just fixed the second error, sorry for this. Please update and check if it is working.

              You actually don't need to setup the keybindings, they are already configured by the plugin.

              EDIT: I tried replacing the function that was missing on the first error, please update and check if it is working.

              • »
                »
                »
                »
                »
                »
                »
                »
                7 лет назад, # ^ |
                  Проголосовать: нравится 0 Проголосовать: не нравится

                Now,I'm getting the following error on using :CFLastSubmissions<CR> command:-

                Error detected while processing function cfparser#CFLastSubmissions:                                           
                line    8:
                E706: Variable type mismatch for: cf_response
                line   10:
                E121: Undefined variable: status
                E116: Invalid arguments for function matchstr(cf_response.status, "OK"))
                E116: Invalid arguments for function empty(matchstr(cf_response.status, "OK"))
                E15: Invalid expression: empty(matchstr(cf_response.status, "OK"))
                
                

                How can it be fixed?