Giter Club home page Giter Club logo

sublime-coq-plugin's Introduction

Sublime-Coq

This package provides Coq syntax highlighting and an interactive coqtop plugin for Coq in Sublime Text 3 & 4. The plugin supports Coq versions 8.11 to 8.17.

I have been maintaining this plugin since 2014. It has some advantages and disadvantages compared to the community-supported Coq plugin that you will find in Sublime's Package Control. The main advantage is that Coq processing happens off the main thread, making the plugin much snappier. I also regularly test support for all the versions of Coq this plugin claims to support.

Install

There is a different sublime-coq plugin in Package Control. That is NOT this one. This one is different.

cd 'sublime-text-folder/Packages'
git clone https://github.com/Calvin-L/sublime-coq-plugin.git

You can find the sublime-text-folder/Packages folder from Sublime Text by going to Preferences -> Browse Packages.

NOTE: This plugin expects to be in a folder named sublime-coq-plugin in your packages folder. The plugin will still work if you rename the folder, but the menu entries to open the settings and keyboard mappings may not work properly.

You may need to tell the plugin where to find Coq on your system. Modify your plugin-specific user settings (Preferences -> Package Settings -> CoqInteractive -> Settings--User). You should copy and modify settings from the default file (Preferences -> Package Settings -> CoqInteractive -> Settings--Default).

Usage

ctrl+enter: evaluate to (or rewind to) the current cursor
shift+ctrl+k: kill coqtop

Secret commands

This plugin provides some fine-grained CoqIDE-style seek commands that are not bound to keys by default:

  • coq_seek_next: evaluate the next command
  • coq_seek_prev: rewind the previous command
  • coq_seek_end: evaluate the entire file
  • coq_seek_start: rewind to the start of the file

To use these commands, bind them to keystrokes by putting a keystroke configuration into the plugin key bindings (Preferences -> Package Settings -> CoqInteractive -> Key Bindings--User). For example:

[
    { "keys": ["ctrl+option+down"], "command": "coq_seek_next" },
    { "keys": ["ctrl+option+up"], "command": "coq_seek_prev" },
    { "keys": ["ctrl+option+right"], "command": "coq_seek_end" },
    { "keys": ["ctrl+option+left"], "command": "coq_seek_start" }
]

Compatibility with different versions of Coq

I regularly test support for Coq versions 8.11 to 8.17. In addition,

  • The Coq API has crystallized, so future releases of Coq are likely to work as well.
  • I believe that the plugin should work with Coq versions back to 8.5. I used to test support for versions going back to 8.5, but it is increasingly hard to get these very old versions to run on new hardware.
  • Coq 8.4 and earlier are not compatible. While 8.4 was the latest release when I started writing this plugin, 8.5 introduced some major breaking changes to the API.

Known Issues / TODO

  • Custom notations using the . symbol cause problems
  • Behavior is weird and undefined when the file you are interacting with is re-loaded because it changed on disk
  • Sublime Text 2 is not supported (and never will be)
  • The current goal takes a long time to display when there are many goals, even if the current goal is very small
  • The plugin listens to every text change on every buffer whether or not Coq is running. The performance impact should be negligible. See Issue 9 for a longer description.

sublime-coq-plugin's People

Contributors

calvin-l avatar ericr avatar lephe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

sublime-coq-plugin's Issues

Water mark does not always go up after editing stepped code

In some cases, mostly after getting a Coq error after trying to step a statement, editing stepped code will not move the water mark back up.

Steps to reproduce :

  1. Input the following code
About id.
Definition idT: Type -> Type := id.
  1. Step About id (which succeeds), then step the definition for idT (which fails because id only works at Type 0).
  2. Notice the water mark stays at the end of the first line (at offset 9), as expected.
  3. Add a character to the first line to change it into About id2.
  4. If the bug triggered, the water mark is now still on the first line.
  5. Additionally, stepping down again sends coqtop a dot (the new character at offset 9).

It doesn't happen all the time... I tried to debug it by changing the logger to print to the console, and it went away. I'm suspecting maybe some async/delay issues?

(I'm back at it and may have a PR or two coming, hopefully that helps!)

High water mark incorrectly moved during undo

Hi! Recently I've been noticing issues with the high water mark moving after an undo.

Steps to reproduce:

  • In a new file, type Definition X := 2. and step through the command.
  • Change X into Y: the high water mark returns to the beginning of the file.
  • Undo: the high water mark is now incorrectly back after Definition X := 2.

I suspect Sublime is undoing the region change automatically. Notice how changing X back to Y after the Steps to reproduce does not remove this incorrect highlighting, because the plugin's internal high water mark variable is correctly at the beginning of the file so the text change listener does nothing.

The following is a fairly easy, but unsatisfying fix, since you can see the high water mark jump down after then undo then up after this bit of code runs.

diff --git a/CoqPlugin.py b/CoqPlugin.py
index edfd64b..ebdcfed 100644
--- a/CoqPlugin.py
+++ b/CoqPlugin.py
@@ -843,6 +843,9 @@ def handle_view_modification(view, modification_start_index):
             text = view.substr(sublime.Region(0, worker_watermark + 1))
             worker.mark_dirty(text=text)
             worker.display.set_bad_ranges([])
+        else:
+            worker.display.set_marks(worker_watermark, worker_watermark)
+            worker.display.set_bad_ranges([])

 def check_for_terminated_views():
     for worker_key, worker in list(coq_threads.items()):

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.