Git Product home page Git Product logo

idris2-vim's Introduction

Idris 2 mode for vim

This is an Idris2 mode for vim which features interactive editing, syntax highlighting, indentation and optional syntax checking via Syntastic. If you need a REPL I recommend using Vimshell. It is mostly cloned from the original idris-mode. Unlike the Idris 1 mode, there is no need to have an Idris REPL running - it invokes Idris 2 directly.

If there is a .ipkg file in any of the parent directories, the mode will use that as the root of the source tree, and process any options declared in it (for example, to load packages).

Not all of the commands work yet. Note that the keyboard shortcuts have been updated since Idris 1 to be consistent with the Atom mode (e.g. <LocalLeader>a to add definition, rather than <LocalLeader>d) although the old shortcuts still work.

Screenshot

Installation

I recommend using Pathogen for installation. Simply clone this repo into your ~/.vim/bundle directory and you are ready to go.

cd ~/.vim/bundle
git clone https://github.com/edwinb/idris2-vim.git

Manual Installation

Copy content into your ~/.vim directory.

Be sure that the following lines are in your .vimrc

syntax on
filetype on
filetype plugin indent on

Features

Apart from syntax highlighting, indentation, and unicode character concealing, idris-vim offers some neat interactive editing features. For more information on how to use it, read this blog article by Edwin Brady on Interactive Idris editing with vim.

Interactive Editing Commands

Idris2 mode for vim offers interactive editing capabilities, the following commands are supported.

<LocalLeader>r reload file

<LocalLeader>t show type

<LocalLeader>a Create an initial clause for a type declaration.

<LocalLeader>c case split

<LocalLeader>mc make case

<LocalLeader>w add with clause

<LocalLeader>e evaluate expression

<LocalLeader>l make lemma

<LocalLeader>m add missing clause

<LocalLeader>f refine item

<LocalLeader>o obvious proof search

<LocalLeader>s proof search

<LocalLeader>i open idris response window

<LocalLeader>d show documentation

Configuration

Indentation

To configure indentation in idris-vim you can use the following variables:

  • let g:idris_indent_if = 3

      if bool
      >>>then ...
      >>>else ...
    
  • let g:idris_indent_case = 5

      case xs of
      >>>>>[]      => ...
      >>>>>(y::ys) => ...
    
  • let g:idris_indent_let = 4

      let x = 0 in
      >>>>x
    
  • let g:idris_indent_where = 6

      where f : Int -> Int
      >>>>>>f x = x
    
  • let g:idris_indent_do = 3

      do x <- a
      >>>y <- b
    
  • let g:idris_indent_rewrite = 8

      rewrite prf in expr
      >>>>>>>>x
    

Concealing

Concealing with unicode characters is off by default, but let g:idris_conceal = 1 turns it on.

Tab Characters

If you simply must use tab characters, and would prefer that the ftplugin not set expandtab add let g:idris_allow_tabchar = 1.

idris2-vim's People

Contributors

buzden avatar edwinb avatar mrkgnao avatar neriglissar avatar shinkage avatar ziman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

idris2-vim's Issues

MakeWith is broken

When I'm on a hole and I use <LocalLeader>w, it prints the with syntax, but it doesn't actually modify the buffer at all.

Not working at all

When ever I to do anything it throws a parse error about symbols that are not even it the file. Here is my file, called test.idr.

module test

test : a -> ()

If i put my cursor any where on the line with the test function and do '\a' I get this output on the '\i' screen and my cursor is set to the colon.

Parse error: Unrecognised command (next tokens: [identifier ac, symbol !, end of input])

MakeLemma doesn't transport erasable implicit arguments that must be explicitly bound for type checking

data BNat = BZ | O BNat | E BNat

bnat_ind : {0 p : BNat -> Type}
        -> p BZ
        -> ((bn : BNat) -> p bn -> p (O bn))
        -> ((bn : BNat) -> p bn -> p (E bn))
        -> (bn : BNat) -> p bn
bnat_ind pbz po pe = go
 where
  go : (bn : BNat) -> p bn
  go BZ = ?pbz_hole
  go (O x) = po x (go x)
  go (E x) = pe x (go x)

Using MakeLemma <LocalLeader>l on the ?pbz_hole in the above results in:

pbz_hole : ((bn : BNat) -> p bn -> p (E bn)) -> ((bn : BNat) -> p bn -> p (O bn)) -> p BZ -> p BZ

being created, but that doesn't type check:

file:loc:While processing type of pbz_hole at talia.idr:16:1--18:1:                                                                              
Undefined name p

(and then further failures since pbz_hole ends up not bound in the global context.)

Case splitting inserts invalid code that uses "$resolvedXXX" as an identifer.

There's almost certainly a smaller example, but this is the one I have and it's fairly small.

data BNat = BZ | O BNat | E BNat

data BLT : BNat -> BNat -> Type where
  BLT_ZO : BLT BZ (O bn)
  BLT_ZE : BLT BZ (E bn)
  BLT_OO : BLT bn bm -> BLT (O bn) (O bm)
  BLT_OE : BLT bn bm -> BLT (O bn) (E bm)
  BLT_OE_Eq : BLT (O bn) (E bn)
  BLT_EO : BLT bn bm -> BLT (E bn) (O bm)
  BLT_EE : BLT bn bm -> BLT (E bn) (E bm)

notLtz : BLT bn BZ -> Void
notLtz x = ?notLtz_rhs

Then do a case-split on x in the last line and you get:

notLtz : BLT bn BZ -> Void
notLtz $resolved123 impossible
notLtz $resolved124 impossible
notLtz ($resolved125 x) impossible
notLtz ($resolved127 x) impossible
notLtz $resolved126 impossible
notLtz ($resolved128 x) impossible
notLtz ($resolved129 x) impossible

(the numbers at the end of "resolved" may vary.)

Plugin does not load correctly on neovim / vim-plug

This might be specific to my setup, I've installed the plugin using Vim-Plug and I'm running the nightly build of NeoVim.

The plugin would not load and no Idris2-Vim commands / functions were available.

Without loading any plugins ( commenting out the plugins ) except for the Idris2-Vim plugin, the plugin still would not work.

When calling set runtimepath? within an Idris2 buffer the idris2-vim/after folder is listed within the runtime variable.

After installing the plugin using Vim-Plug and without exiting NeoVim the plugin would work as expected on Idris2 buffers.

[ Solution ]

Moving the following line to above the plug#begin function within my init.vim configuration file allows the plugin to work as expected:

filetype plugin indent off

Hopefully this description can help others in a similar predicament.

Syntastic does not work out of the box

managed to make it work

installed idris2 and syntastic with pathogen

inside ~/.vim/bundle/idris2/syntax_checkers/idris2/idris2.vim

function! SyntaxCheckers_idris_idris_GetLocList() dict
changed to

function! SyntaxCheckers_idris2_idris2_GetLocList() dict

in vimrc

let g:syntastic_idris_checkers = ['idris']
let g:syntastic_idris2_checkers = ['idris2']

I do not even get syntax highlighting

I have done exactly the steps

cd ~/.vim/bundle
git clone https://github.com/edwinb/idris2-vim.git

But after opening some idris file, I do not even get syntax highlighting.

Note: I do not understand what you meant by recommend use of pathogen.

Maybe additional steps have to be done.

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.