Skip to content

v3.0

Latest
Compare
Choose a tag to compare
@hkupty hkupty released this 17 May 21:33
· 302 commits to master since this release
3f6c27b
version 3.0 (#206)

* Remove tables functions

They were either not used or provided by neovim already

* Remove unnecessary strings file

* Use vim.fn instead

* Remove unused module

* Replace commands for higher-level api calls

* Replace window number for id

This way is easier to work with neovim's API

* Replace api call for cmd wrapper

* Fix typo

* Prepare simplification of repl creation

Ideally, a top-level function will require the repl creation.
In order to do so, it will have to make sure:
  a) a window exists;
  b) a repl definition exists;

Then, it will have to manually manage the window logic, for example:
  - Create the repl window
  - Move to repl window
  - Create repl
  - Move back to original window

* Prepare simplification of repl definition

It seems convoluted that the users have to:
  a) create a repl definition to an arbitrary name;
  b) refer to that arbitrary name to get the definition;

This seems to cause a lot of confusion.
The new structure should allow for a direct reference:

{
  repl_definition = {
    python = {
      command = {"ipython3", "--whatever-flags"}
    }
  }
}

So the caller code will look up in the config and, if no
value is explicitly defined, it will lookup with the metamethod
to get the first available repl definition.

Explicitly defining the preferred repl definition
would be as easy as:

{
  repl_definition = {
    python = require("iron.fts.python").ipython
  }
}

* Move deprecated functions down

So they are easier to find.
Also, adds documentation to the functions that are being kept.

* Avoid unnecessary function call

* Remove unused parameter

* Refactor core functions to use new internal api

This makes them more straightforward and starts drawing some patterns on
usage that could be simplified even further.

* Simplify view functions

There's no need to curry them. This just makes maintenance less obvious.

* Apply small fixes to internal functions

They should be self-contained and, as the unix philosophy mandates,
do one thing and do it well.

Therefore, we remove the indenting code (that apparently does nothing)
from `send_to_repl`.

Also, it seems logical to me that low level functions should not call
themselves. This lifts the work to the caller but makes them dead
simple.

As a final addition to this, users can configure to use scratch buffers
for the repl, which might make them lose the ability to toggle, but it
is configurable nonetheless.

* Pass `ft` to false clause

This allows for reusing the `false`-case function, as it is now treated
as stateless function and not a closure (as it was implied by the
no-argument arity)

* Split conditional

So a nil true-case function doesn't cause a false-case function to be
called if the repl exists.

* Replace usage of `ensure_repl_exists`

* refactor: Ensure function works on empty ft

It should never happen but since this function could call a side-effect
of creating a repl, to avoid further processing it is better to
short-circuit out of that processing as early as possible

* style: Ensure  condition is in a single line

* docs: Add docstrings to lowlevel functions

* refactor: Extract lowlevel calls to local wrapper

This should solve the issue of lowlevel calls being verbose and
repetitive. With this local layer, core functions can create the REPLs
without much duplication respecting their individual characteristics
(i.e. in the current window, restarting the current repl, etc.).

* refactor: Restructure commands and mappings

This should make it simpler to work with the mappings and commands
defined by iron

* Add function to close repl from lua

* Simplify send functions

* Add documentation to core functions

* fixup! Simplify send functions

* Simplify config

* Auto close windows

* Add docs to low level functions

* Fix marks

* Add docs to marks functions

* Remove unnecessary comments from init

* Add docs

* Break functions for visual an motion

It is easier to maintain if they're separate.

* Fix marks placement

* Fix up docs and remove unused function

Additionally ensures `core.send` will handle null data

* Default to float window

Also, make it easier to use floats from user config by adding a `.curry`
layer, allowing for `view.curry.<fn>` to return a curried version of
`<fn>` that only expects the buffer, instead of forcing the user to
wrap the function, which could lead to bugs by the user forgetting the
return value.

* Fix typo

* Allow to send the data to a hidden repl

* Rename function + Stop focusing on toggle

To keep toggle consistent, we should not focus on the repl when
returning. It can be done by `IronFocus` anyway, which is a keymap away
from the user.

* Remove inspect

* Avoid the creation of unnecessary buffers

Both `new_window` and `create_repl_on_current_window` created buffers
for their local usage, which would cause multiple unnecessary buffers to
be created unnecessarily. By moving the creation out we can avoid that
and reusue previously created buffers for window and term
initialization.

* Document state changes

* Fix codeclimate errors

* Fix command that changed name

* Install locally

* Remove unused import

* Allow for passing in options

It looks like we shouldn't figure "config" in this layer
If that's the case, then we move out the config import

Memory management will then belong to another namespace which could rely
on config, and that is ok