Skip to content

zhoupro/leetcode.vim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

leetcode.vim

asciicast

Solve LeetCode problems in Vim!

This Vim plugin is inspired by skygragon/leetcode-cli.

Attention: Recently LeetCode used Google reCAPTCHA to enhance security, prohibiting automatic login through LeetCode API.

The new login procedure needs you to login in your browser first so that leetcode.vim can read the LeetCode session cookie from the browser's cookie storage.

g:leetcode_china

When non-zero, use LeetCode China accounts instead. Default value is 1.

Installation

  1. Vim with +python3 feature is required. Install the pynvim package for Neovim:
pip3 install pynvim --user
  1. Install the plugin:

plug

Plug 'zhoupro/leetcode.vim', { 'do': 'pip3 install -r requirements.txt' }

packer

use({ "zhoupro/leetcode.vim", run = "pip3 install -r requirements.txt" })

Quick Start

  • :LeetCodeList: browse the problems.
  • :LeetCodeTest: run the code with the default test case.
  • :LeetCodeSubmit: submit the code.

Local Code

When test and submit, match local end to last. You can add your local code before //local end.

Key mappings

leetcode.vim doesn't bind any key mappings by default. Put the following lines to your .vimrc to set up the key mappings.

nnoremap <leader>ll :LeetCodeList<cr>
nnoremap <leader>lt :LeetCodeTest<cr>
nnoremap <leader>ls :LeetCodeSubmit<cr>

Customization

g:leetcode_solution_filetype

The preferred programming language.

Values: 'python', 'python3', 'golang' .

Default value is 'golang'.

Updates

  • 2022/11/18: update for website change and use browser cookie
  • 2020/01/17: Add Top151 list. leetcode151
  • 2020/01/16: Rewrite this plugin.
  • 2019/08/01: Support custom test input
  • 2019/07/28: Support showing frequencies and sorting by columns
  • 2019/07/27:
    • Support LeetCode China accounts
    • Support refreshing
  • 2019/07/23: Support topics and companies

FAQ

Why can't I test the problem/submit the problem/list the problems?

Once you sign in on your browser in LeetCode website, the LeetCode session in Vim get expired immediatelly. Then you need to sign in again in Vim before doing other things. (No longer having this problem)

Why can't I test and submit solutions?

According to issue #5, if the email address is not active, then you can only login and download problems, but cannot test and submit any code.

About

solve leetcode inside vim

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 8