Giter Club home page Giter Club logo

loadfiletorepl's Introduction

LoadFileToRepl Sublime Text 2/3 plugin

Description

This is a companion plugin for SublimeREPL providing a command to load current source file into according REPL. It just uses a REPL command, like :load "foo.hs" for Haskell, or (load-file "foo.clj") for Clojure and etc.

At the moment it supports load command for REPLs of the following languages (in alphabetic order):

Language REPL Contributor PR
Clojure Leiningen @chrisalbright #6
Common Lisp @cfmeyers #12
Elixir/Erlang iex @yitzhakbg #23
F# fsi @garystanford #31
Groovy groovysh @rcavalcanti #15
Haskell GHCi
Idris
JavaScript Node @jkroso #9
Lua @mkottman #5
Matlab @rowanc1 #17
OCaml @himito #36
PowerShell @mvoidex #7
Prolog SICStus @pedrokost #21
Python
R
Racket XREPL @keyanzhang #30
Ruby
Scala
Scheme MIT Scheme @cyberzlex #19
Standard ML SML @ActiveObject #8

It's easy to extend this list. Pull-requests are welcome!

Content

Command SublimeREPL: Load current file

  1. reveals REPL view or opens a new one according to the type of current file;
  2. optionally places REPL in another layout group (to see results simultaneously with code);
  3. optionally clears REPL before loading file;
  4. saves current file;
  5. and finally loads it into REPL, using according command;
  6. optionally moves cursor to the REPL.

You can call it using

  • Command Palette: βŒ˜β‡§P ➀ SublimeREPL: Load current file ↩
  • Menu: Tools ➀ SublimeREPL ➀ Load current file
  • Hotkeys: see below.

Settings:

Command load_file_to_repl has several options:

  • clear β€” if true, clears REPL before loading file (false by default);

  • save_focus β€” if true, saves focus on the source file, else moves cursor to REPL (true by default).

  • split β€” if it has "horizontally" or "vertically" (default) value, it determines how window is splitted to show REPL in a new layout group. If it doesn't have one of these two values, or if window was already splitted, this option doesn't take effect β€” REPL is placed in a new tab or in the next layout group.

    Note: if you want another splitting behavior or more flexibility, take a look at the Origamy plugin.

You can find these options and their default values in the menu:

  • Sublime Text ➀ Preferences ➀ Package Settings ➀ LoadFileToRepl ➀ Open Settings

or in Command Palette: Preferences: LoadFileToRepl Settings

Key Bindings:

There are two hotkeys predefined:

  • altenter β€” runs load_file_to_repl command with default options:
{ "keys": ["super+enter"], "command": "load_file_to_repl" }
  • altshiftenter β€” same, but clears REPL before loading file and moves cursor to REPL:
{ "keys": ["super+shift+enter"],
  "command": "load_file_to_repl",
  "args": {
    "clear": true,
    "save_focus": false
  }
}

You can find these bindings at

  • Sublime Text ➀ Preferences ➀ Package Settings ➀ LoadFileToRepl ➀ Default Key Bindings

Note: if you don't like them and want to turn off or make your own just set the use_load_file_to_repl_keybindings setting to false and reload Sublime.

Installation

Using Sublime Package Control:

Note: you should install SublimeREPL plugin first

βŒ˜β‡§P ➀ Package Control: Install package ➀ LoadFileToRepl

Now restart Sublime Text to load the plugin settings. That's it!

loadfiletorepl's People

Contributors

3shv avatar chrisalbright avatar garystanford avatar jkroso avatar keyz avatar laughedelic avatar mvoidex avatar rowanc1 avatar vpryim 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

loadfiletorepl's Issues

NameError: name 'load' is not defined

I'm getting this output when trying to load a python file:

Python 2.7.6 (default, Mar 22 2014, 22:59:56)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.

Traceback (most recent call last):
File "", line 1, in
File "", line 1, in
NameError: name 'load' is not defined

Any idea?

haskell source path settings is incorrect

I've tryed it on windows, and when I do loading file to the repl - it opens Prelude> for me and says that can't find the modules needed, even if this moduls are located in the same directory as Main module. Project builds sucessfully on the each save. If I change current directory via :cd source/dir/of/my/project in the REPL and then try to load/reload - all works good. It will be good also, if plugin could take in to accaunt cabal settings (hs-source-dirs for ex.)

Modifications to add Racket support

Just did some modifications to add Racket (http://racket-lang.org) support.

  1. Make sure that Racket is configured to start with XREPL automatically (http://docs.racket-lang.org/xrepl/index.html?q=)

    (Add (require xrepl) to the initialization file .racketrc)

  2. Add a specific load command in LoadFileToRepl.sublime-settings:

    , "racket_load_command" : ",en %s"

  3. Modify LoadFileToReplCommand’s run method in LoadFileToRepl.py

if repl_id == 'racket':
    self.window.run_command('run_existing_window_command', {
        'id'   : 'repl_plt_racket', 
        'file' : 'config/' + config_title + '/Main.sublime-menu'
        })
else:
    self.window.run_command('run_existing_window_command', {
        'id'   : 'repl_' + repl_id,
        'file' : 'config/' + config_title + '/Main.sublime-menu'
        })

The modification above works. However, the working directory of the REPL session is not changed to the file location; instead it’s always under /Applications/Sublime Text.app/Contents/MacOS. I’ve worked around a little bit but haven’t found a solution: Is there a setting to start a REPL session in the same directory that the current file is located in?

clisp support

Great plugin! Clisp support would be very helpful; syntax for loading a file in clisp looks almost exactly the same as clojure:
(load "myfile.lsp").

Lua command

The command to load a Lua file to the REPL is very simple:

 "lua_load_command" : "dofile(\"%s\")"

Settings not working on Sublime3

I'm giving a try to Sublime3 and experimenting with the LoadFileToRepl.

The plugin installs correctly and it works, but it's impossible to configure it.
Nothing happens when selecting: Preferences > Package Settings > LoadFileToRepl > Open Settings.

My first impression is that plugin settings in Sublime3 works differently.

Have you guys tried it out with Sublime 3 already?

Elixir support

Thank you for the lovely plugin. You mentioned that if a language is missing, you could add it. It would be nice to have Elixir. You just have to activate iex.
Thank you again

Change directory before loading file

When I import some module in Haskell, current directory is not changing. I have to explicitly change the directory with ":cd someDirectory". So, it's a good idea to start a GHCi in the same directory that the current file is located in.

'generator' object has no attribute '_view'

I'm getting the following traceback sometimes when trying to load a js file. It always happens when trying to 'reload' a changed file by killing or restarting the REPL. Even when restarting Sublime, this error remains 'sometimes'.

Btw, is there a proper way to 'reload' a changed file?

Traceback (most recent call last):
File "C:\Sublime Text 3 - Portable\sublime_plugin.py", line 797, in run_
return self.run()
File "LoadFileToRepl in C:\Sublime Text 3 - Portable\Data\Installed Packages\Load file to REPL.sublime-package", line 146, in run
AttributeError: 'generator' object has no attribute '_view'

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.