GithubHelp home page GithubHelp logo

marat-turaev / sublimehaskell Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sublimehaskell/sublimehaskell

0.0 2.0 0.0 9.49 MB

A Sublime Text 2/3 plugin for Haskell. Features cabal building, error and warning highlighting, smart completion and ghc-mod integration.

License: MIT License

Haskell 8.12% JavaScript 6.03% Makefile 0.04% Python 85.81%

sublimehaskell's Introduction

README

Requirements

Necessary:

  • ghc and a recent Haskell Platform (>= 2012 should do fine)
  • cabal
  • Cabal packages: base, bytestring, aeson, haskell-src-exts (== 1.14.*), haddock (cabal install aeson haskell-src-exts haddock)
  • If you are using GHC 7.6, you might have trouble with too new versions of haddock; in that case, try cabal install haddock --constraint=haddock==2.13.2.1

Optional, but useful:

  • ghc-mod (for import and LANGUAGE completions and type inference, cabal install ghc-mod)
  • stylish-haskell (for code prettification, cabal install stylish-haskell)
  • cabal-dev if you want to use it
  • haskell-docs (for documentation in 'Symbol info' command, cabal install haskell-docs)
  • hdevtools (or fork for windows) (for type inference, cabal install hdevtools)

Binaries:

  • If your cabal, ghc-mod, ghc etc. are not installed in a system PATH, you have to adjust SublimeHaskell's add_to_PATH setting.

Installation

  1. Get Sublime Text 2: http://www.sublimetext.com/
  2. Install the Sublime Package Control package: http://wbond.net/sublime_packages/package_control/installation
  3. Use Package Control to install this package (SublimeHaskell)

Usage

In short: Press Shift-Ctrl-P and type haskell to explore all commands.

When editing Haskell source files that are part of a Cabal project, automatic error highlighting and enhanced auto-completion are available.

Each time you save, any errors in your program will be listed at the bottom of the window and highlighted in the source code.

All source files in the project are scanned when the change. Any symbols that they export are provided in the auto-complete suggestions.

To use cabal-dev instead of cabal, set use_cabal_dev to true (or use command "Switch Cabal/Cabal-Dev") and specify cabal-dev absolute path. Completion list will be rescanned and build will use cabal-dev.

Stylish-haskell can be used to stylish file or selected text.

Use Ctrl-Shift-R to go to declaration and Ctrl-K-I to show symbol info with documentation. These command are also available through context menu with right-click.

Command 'SublimeHaskell: Browse module' is similar to ghci's browse command

To show inferred types use Show type (ctrl-k ctrl-h ctrl-t) command.

To insert inferred type use Insert type (ctrl-k ctrl-h ctrl-i).

You can jump between the errors and warnings with F4 and Shift-F4. To show hidden error output, use command Show error panel (ctrl-alt-e)

Build Systems

You don't have to use SublimeHaskell's built-in build functionality.

If you prefer, you can disable them in the settings, and use plain Sublime Build Systems:

cabal

Save this to your ~/.config/sublime-text-2/Packages/User/cabal-custom.sublime-build to make a custom cabal build system:

{
  "cmd": ["cabal build --ghc-options='-O0 -hidir o0 -odir o0'"],  // append lib:myPackage or myexecutable here to only build certain cabal targets
  "shell": true,
  "file_regex": "^(\\S*?):(\\d+):(\\d+):$"  // this matches the output of ghc
}

For more options, look here.

hdevtools

Save this to your ~/.config/sublime-text-2/Packages/User/hdevtools.sublime-build to make hdevtools a build system:

{
  "cmd": ["/home/USERNAME/.cabal/bin/hdevtools", "check", "-g", "-Wall", "$file"],
  "file_regex": "^(.*?):(\\d+):(\\d+):",
  "selector": "source.haskell"
}

Using build system results

You can then build with Ctrl-B and jump between the errors with (Shift-)F4.

It is also useful to add this to your key bindings to redisplay the error panel at any time:

  { "keys": ["ctrl+alt+b"], "command": "show_panel", "args": {"panel": "output.exec"} }

Using other useful projects with SublimeText

Jump-to-definition

There are two kinds of jump-to-definition: Inside your project and outside your project. In any case, install the Sublime CTags package via Package Control, and cabal install hasktags.

CTags expects the extended exuberant ctags format.

Inside your project: hasktags

  • In your project, hasktags --ctags --extendedctag .
  • You can now jump to definitions inside your project (Ctrl-T, Ctrl-T is the default keybinding)

Inside and outside your project: codex

codex allows you to use ctags to jump to definitions that are declared in your cabal dependencies.

  • cabal install codex
  • Run codex set format sublime, that updates your ~/.codex file to Sublime's Ctags plugin's format
  • Change ~/.codex to tagsFileName: .tags
  • In your project, codex cache clean && codex update
  • You can now jump to the source code of definitions outside of your project.
  • The commands CTags: Show Symbols and CTags: Rebuild Tags currently don't work with codex

If the ModuleInspector takes too much time

The ModuleInspector is a program that looks at your Haskell environment to provide auto completion.

Depending on your environment, this may take very long.

You can disable it with the "inspect_modules": false setting.

sublimehaskell's People

Contributors

aktowns avatar albertfong avatar aninhumer avatar anton-dessiatov avatar armed avatar axman6 avatar bheklilr avatar dnnx avatar ghostbarik avatar holmak avatar joneshf avatar kolmodin avatar kxbmap avatar lukexi avatar masseguillaume avatar mvoidex avatar nh2 avatar nikita-volkov avatar princemaple avatar sukhodolin avatar sweatybridge avatar wrossmck avatar

Watchers

 avatar  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.