GithubHelp home page GithubHelp logo

apollo007fd / leetcode.vim Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ianding1/leetcode.vim

0.0 0.0 0.0 843 KB

Solve LeetCode problems in Vim!

License: MIT License

Python 35.93% Vim Script 64.07%

leetcode.vim's Introduction

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.

Supported browsers are: Chrome, Firefox. Safari is not supported yet.

The one-time setup:

  1. Install keyring and browser-cookie3:
pip3 install keyring browser-cookie3 --user
  1. Set g:leetcode_browser to 'chrome' or 'firefox'.

Thanks @zhuopro (see #25) for his brilliant idea!

Installation

  1. Vim with +python3 feature is required. Install the pynvim package for Neovim:
pip3 install pynvim --user
  1. Install keyring and browser-cookie3:
pip3 install keyring browser-cookie3 --user
  1. Install the plugin:
Plug 'ianding1/leetcode.vim'

Quick Start

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

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>
nnoremap <leader>li :LeetCodeSignIn<cr>

Customization

g:leetcode_china

When non-zero, use LeetCode China accounts instead.

Default value is 0.

g:leetcode_solution_filetype

The preferred programming language.

Values: 'cpp', 'java', 'python', 'python3', 'csharp', 'javascript', 'ruby', 'swift', 'golang', 'scala', 'kotlin', 'rust'.

Default value is 'cpp'.

g:leetcode_browser

Set to the browser that stores the LeetCode session cookie.

Values: 'disabled', 'chrome', 'firefox'

Default value is 'disabled'.

g:leetcode_hide_paid_only

Hide the paid only problems on the list.

Default value is 0.

g:leetcode_hide_topics

Hide the topics section.

Default value is 0

g:leetcode_hide_companies

Hide the companies section.

Default value is 0

g:leetcode_problemset

Set the problemset to get from leetcode.

Default value is all

Updates

  • 2019/12/20: Fix the login issue caused by reCAPTCHA.
  • 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

I use Ubuntu and get errors when signing in. How can I fix it?

Ubuntu users might see the error message below when signing in.

    raise InitError("Failed to unlock the collection!")
keyring.errors.InitError: Failed to unlock the collection!

It's caused by the misconfiguration of python-keyring. One way to fix it is to create a file ~/.local/share/python_keyring/keyringrc.cfg with the following content:

[backend]
default-keyring=keyring.backends.Gnome.Keyring

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.

I got some errors like "ModuleNotFoundError: No module named 'keyring.util.escape'"

This solution worked for me:

pip3 install --upgrade keyrings.alt

leetcode.vim's People

Contributors

axrt avatar devinjeon avatar gu18168 avatar ianding1 avatar korbinzhang avatar ptosi avatar tenfyzhong avatar thomasding avatar zhngjan avatar zhuzhengyi avatar

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.