tonini / alchemist.el Goto Github PK
View Code? Open in Web Editor NEWElixir Tooling Integration Into Emacs
Home Page: http://www.alchemist-elixir.org
Elixir Tooling Integration Into Emacs
Home Page: http://www.alchemist-elixir.org
Consider it helpful, if the real command-name is indicated by menu.
That way user may question C-h f NAME.
Also some docu displayed seems useful.
It my iex buffer is hidden, and I use something like C-c a i r, the region is evaluated, but we don't see it because the iex buffer remains hidden.
This is possibly the way it is supposed to be. :)
Is it just me or tab completion inside IEx buffer does not work? That is the only problem, right now I am using a normal terminal because of that.
If it is so, is there any work around?
When opening a file in Elixir-mode I get the following message:
Company back-end 'alchemist-company' could not be initialized:
Symbol's function definition is void: init
Last I checked a few days ago it was working fine (probably on 0.7.0).
Hi,
First of all thanks for alchemist. It's really nice tool. :)
I've had issue with the completions showing up a bit strange. Here's what happens...
Completions on the module level seems to work well. Also linking to documentation works for modules. When it lists functions inside a module it breaks like that. Any ideas?
Emacs version is 25.0.50.1 (installed via Homebrew), alchemist version is 0.10.0, company version is 0.8.7 and elixir-mode version is 2.0.2. All installed via melpa-stable.
Inside the Alchemist-IEx buffer:
EDIT
So I realize that you can use erase-buffer inside eshell. So maybe this issue is not that important anymore.
Enabling alchemist, enables it in all buffers. Expected behavior would be that it's only enabled in elixir-mode
It's great plugin and one of the reason why I switched to Emacs :) Thanks for that!
But one thing is annoying me – company-mode shows only alchemist backend (I think it's related to #66). So my suggestion is not activate backend automatically, but give necessary code in documentation.
At least any suggestions how to disable backend?
I tried add hook where remove that backend, but without succeed.
When I run alchemist-help-search-at-point on this line:
Riffer4.testMike
I get a documentation window.
When I run it on a line within the same module with just:
testMike
I don't get a documentation window; instead I get "error in process sentinel: Wrong type argument: stringp, nil.
If a nested mix project defines its own dependencies, mix tool keep them in deps/ in the root directory of the whole project. This is right and desired behavior. Unfortunately, this fools Alchemist which pops up:
== ALCHEMIST COMPLETION FAILED ==
== OUTPUT BEGIN:
Unchecked dependencies for environment dev:
* asn1ex (https://github.com/vicentfg/asn1ex.git)
the dependency is not available, run `mix deps.get`
** (Mix) Can't continue due to errors on dependencies
== OUTPUT END:
When I did deps.get immediately in the nested project, I get another error:
== ALCHEMIST COMPLETION FAILED ==
== OUTPUT BEGIN:
** (Mix) Could not start application lte_rrc: could not find application file: lte_rrc.app
== OUTPUT END:
I guess it can be related with the fact that in Emacs by default CWD is where a visited file resides, not where emacs process was started, a fortiori where root of a whole Elixir project is.
Obviously, whatever completions are provided by standard Elixir shell (iex -S mix
) started in the root, works as expected, e.g. :lte_rrc.<TAB>
list all exported functions.
Definitions with a do...end
or a do:
are handled perfectly, but bodyless clauses (used for documenting arguments and setting default argument values) cause some problems:
In the example above, dgettext/4
is defined as:
@spec dgettext(module, binary, binary, bindings) :: binary
def dgettext(backend, domain, msgid, bindings \\ %{})
def dgettext(backend, domain, msgid, bindings) when is_list(bindings) do
dgettext(backend, domain, msgid, Enum.into(bindings, %{}))
end
def dgettext(backend, domain, msgid, bindings) do
backend.lgettext(locale(), domain, msgid, bindings)
|> handle_backend_result
end
dngettext/6
is very similar.
[WARNING: feature-request]
It would be nice to have org-mode babel support to run pieces of elixir in .org files. That would make it very easy to create tutorials for elixir inside emacs.
My emacslisp-fu is not good at all so that is why this is not a PR \o/.
If this is not the place for this discussion, please close it and tell me where it would fit better.
Can't put in a form like:
if true do
"asdf"
end
IEx hangs, resp. echos the input, but not the expected result.
Whilst when iex is called from bash, "asdf" appears as expected.
Thanks!
Company mode is active and completion works fine, but I don't see documentation for selected functions like shown in "Complete & Documentation lookup" paragraph. I use alchemist version 20150107.2241 and Elixir 1.0.2. Am I doing something wrong?
One might use snippets instead (that's what I did back on VIM), but automatically closing do
would apply everywhere else there aren't snippets.
What gets typed
def start_link do\n|
What gets inserted
def start_link do
|
end
I'm fairly new to emacs, so apologies if this isn't terribly descriptive. I'm on 24.4.91.1 and alchemist-20150407.55 fwiw.
I'm using company mode w/ global-company-mode. My init.el looks something like this
(use-package elixir-mode :ensure)
(use-package alchemist :ensure)
(use-package company :ensure)
(add-hook 'after-init-hook 'global-company-mode)
In non-elixir files, company-mode's company-backends look like this
company-backends is a variable defined in `company.el'.
Its value is (company-bbdb company-nxml company-css company-eclim company-semantic company-clang company-xcode company-cmake company-capf
(company-dabbrev-code company-gtags company-etags company-keywords)
company-oddmuse company-files company-dabbrev)
These allow completion of keywords, words in open buffers, etc. It is very useful.
When in an elixir file, company-backends looks like this
company-backends is a variable defined in `company.el'.
Its value is (alchemist-company company-bbdb company-nxml company-css company-eclim company-semantic company-clang company-xcode company-cmake company-capf
(company-dabbrev-code company-gtags company-etags company-keywords)
company-oddmuse company-files company-dabbrev)
where alchemist-company has been inserted into the beginning. But unfortunately if a match doesn't come up in alchemist-company, it does not list options from the other backends.
I would love to use alchemist-company and still failover to the other backends.
Am I doing something wrong? Any advice, or is this just not possible?
Hello,
I am a rookie when it comes to emacs and lisp, and i have trouble getting this to work.
I have added this:
(add-hook 'after-init-hook 'global-company-mode)
(add-to-list 'auto-mode-alist '(".ex$" . alchemist-mode))
(add-to-list 'auto-mode-alist '(".exs$" . alchemist-mode))
But neither syntax highlighting or auto complete are working, any ideas or a manual for how to use this? README.md is not very clear for me...
Thanks, Ivan.
In the following example, when point is on the function(2)
call and I call alchemist-goto-definition-at-point
(M-.), I get Don't know how to find: function
defmodule X do
def use_fun do
function(2)
end
def function(x) do
x
end
end
When function doesn't have module name specified, it should be assumed that function is from current module. I've hacked a proposal but it's shity and brakes things: 7a02c70
I sometimes want to run alchemist commands against an existing erlang node rather than boot up a new node. This would potentially help with issues like #50, #46, #33, etc.
I knocked together an example of what this might look like for autocomplete using distel over here. This could be expanded to back thing like alchemist's help/whatever functionality.
I like how alchemist currently does things, and distel would be an added dependency, so I think this might work well as an optional feature.
Installed from MELPA on emacs 24.3.50.1 and Elixir 1.0.2
In my elisp run on emacs load:
(require 'elixir-mode)
(require 'alchemist)
(add-hook 'after-init-hook 'global-company-mode)
(setq alchemist-help-docs-ansi-color-enabled t)
Any attempt to complete an Elixir call simply outputs, "Cannot complete at point" to the minibuffer.
Company works otherwise. And alchemist works fine besides this.
When jumping to a function that is in current buffer nothing happens.
Removing save-excursion
from alchemist-goto-definition-at-point
solves the problem - I think it shouldn't be in a function which supposed to move the point.
When I add company-yasnippet to my company backends, alchemist completions break but I get Elixir snippets. If I then add alchemist back into the the company backends , if I add it after adding company-yasnippet, it starts working and yasnippets quit getting loaded as a backend, and vice-versa. Basically, I'd like to have both show up in my list of completions, but I can't figure out how.
Does using ctags (mmorearty/elixir-ctags, rgrinberg/mix_ctags) can enhance in any way alchemist?
Does those to features need to run the entire project? Sometimes apps do some kind of cleaning up and resetting some data (clearing logs, metric counters, etc) when are started, so developers run them in strict conditions. Or simply take a while to initiate. But alchemist starts them whenever it needs.
I've noticed '--no-compile' option when alchemist runs mix run and I think there should be also '--no-start' - what will it break?
This happens when I try to compile:
Debugger entered--Lisp error: (void-function alchemist-utils--establish-project-root-directory)
(alchemist-utils--establish-project-root-directory)
(let ((old-directory default-directory)) (alchemist-utils--establish-project-root-directory) (alchemist-buffer-run (alchemist-utils--build-runner-cmdlist cmdlist) alchemist-mix-buffer-name) (cd old-directory))
alchemist-mix-execute(("mix" "test"))
The problem is here: https://github.com/tonini/alchemist.el/blob/master/alchemist-mix.el#L143
when alchemist-project-compile-when-needed
is set, elixirc
is used to compile the current buffer regardless of if it contains an .exs
elixir script file or not. Per the docs, script files are not meant to be compiled – and in fact, running elixirc
on them will actually eval them.
Thankfully I discovered this due to excessive CPU usage in time to prevent some what would have been catastrophic data loss (long story).
I'll see about submitting a PR to fix this but I'm still kinda new to emacs.
As some keys got broken, checking for the reasons: alchemist-mode-map displayed a violation of
http://www.gnu.org/software/emacs/manual/html_node/elisp/Key-Binding-Conventions.html
Don't define C-c letter as a key in Lisp programs. Sequences consisting of C-c and a letter (either upper or lower case) are reserved for users;
Pretty straightforward: I'd love to be able to set the MIX_ENV
for the various alchemist mix commands, e.g. alchemist-mix-compile
. Having to switch constantly switch environment with getenv
/setenv
is tiring and error prone.
Maybe it could be implemented as a prefix arg to the mix commands?
btw, I've only been using alchemist for a couple of weeks, but it's already saved me a ton of time -- thanks!!
Since I updated alchemist last week there are no font face colours being applied.
I have my init.el set to auto load alchemist-mode when I open an .ex or .exs file.
The mode line shows is Elixir, alchemist and company, but there are no completions nor suggestions when I type and there are no font face colours. Other modes work fine, and alchemist was working correctly about 2 weeks ago.
When I click Elixir | Text Properties | Display faces it shows lots of font faces in the colours of my colour theme (moe-dark). They all look correct, but they aren't applied as you can see in the top half..
I'm also getting no support at all with company mode.
I suspect I've configured something wrongly but can't work out what. I haven't changed anything related to alchemist in my init.el.
Any ideas
EDIT: Sorry - I should add:
Emacs : GNU Emacs 24.5.1
Company version : 0.9.0-cvs
Elixir version: Elixir 1.0.4
aclehmist-mode : 0.16.1
elixir-mode : 1.0.0
Debugger entered--Lisp error: (void-variable alchemist-mode-map)
IIUC the reason is defining the menu before alchemist-mode-map is initialised.
Maybe a (defvar alchemist-mode-map nil) before solves it.
Resp. start with the map, here an example from python.el
(defvar python-mode-map
(let ((map (make-sparse-keymap)))
;; Movement
(define-key map [remap backward-sentence] 'python-nav-backward-block)
(define-key map [remap forward-sentence] 'python-nav-forward-block)
(define-key map [remap backward-up-list] 'python-nav-backward-up-list)
(define-key map "\C-c\C-j" 'imenu)
;; Indent specific
(define-key map "\177" 'python-indent-dedent-line-backspace)
(define-key map (kbd "") 'python-indent-dedent-line)
(define-key map "\C-c<" 'python-indent-shift-left)
(define-key map "\C-c>" 'python-indent-shift-right)
...
After using the bindings I realized that they're too long, we should think about it how we could trim them down a bit.
/cc @pragdave
Thanks a lot writing that marvellous stuff. Is it going to be backported to emacs-elixir?
Alchemist seems to take the menu of elixir-mode. Maybe not define as own (minor)-mode, just loading the stuff as extension?
I'm just starting with Elixir myself. Wondering what are the differences between the two modes.
I'm seeing different outputs of runing `mix test' on a generated project (with some modifications), and wondering why the reporting is so different?
With elixir-mix-test:
Compiled lib/postgrex/binary_utils.ex
Compiled lib/postgrex/error.ex
Compiled lib/postgrex/structs.ex
== Compilation error on file lib/postgrex/protocol.ex ==
** (CompileError) lib/postgrex/protocol.ex:247: function 'nil?'/1 undefined
(stdlib) lists.erl:1336: :lists.foreach/2
(stdlib) erl_eval.erl:657: :erl_eval.do_apply/6
could not compile dependency postgrex, mix compile failed. You can recompile this dependency with `mix deps.compile postgrex` or update it with `mix deps.update postgrex`
ElixirMix exited abnormally with code 1 at Sat Oct 25 19:24:20
While with alchemist-mix-test:
Elixir started at Sat Oct 25 19:26:32
mix test
==> postgrex
�[31m�[1mwarning: the dependency postgrex requires Elixir "0.15.0" but you are running on v1.0.1�[0m
Compiled lib/postgrex/binary_utils.ex
Compiled lib/postgrex/error.ex
Compiled lib/postgrex/structs.ex
lib/postgrex/types.ex:5: warning: unused import Postgrex.BinaryUtils
== Compilation error on file lib/postgrex/types.ex ==
** (CompileError) lib/postgrex/types.ex:97: cannot invoke local nil?/1 inside guard
(stdlib) lists.erl:1352: :lists.mapfoldl/3
(elixir) src/elixir_clauses.erl:53: :elixir_clauses.translate_guard/4
(elixir) src/elixir_clauses.erl:49: :elixir_clauses."-guards/4-lc$^0/1-0-"/4
(elixir) src/elixir_clauses.erl:39: :elixir_clauses.clause/7
(elixir) src/elixir_clauses.erl:82: anonymous fn/5 in :elixir_clauses.do_clauses/4
could not compile dependency postgrex, mix compile failed. You can recompile this dependency with `mix deps.compile postgrex` or update it with `mix deps.update postgrex`
Elixir exited abnormally with code 1 at Sat Oct 25 19:26:35
I've just installed Alchemist (it looks great!). I've also installed company (and uninstalled auto-complete). Completion generally works, but I get no completion options for e.g. List.
When I run company-complete manually, it says there are no completions.
I installed Alchemist from Melpa. alchemist-version reports "Alchemist 0.13.0snapshot".
I also have elixir-mode version 2.30snapshot.
My modeline shows Elixir alchemist company (and other stuff)
I'm running on a Mac/Yosemite.
Thanks!
It would be nice if the automatic setup of company-mode for elixir files would allow it to define a list of company-backends to be tried if the Elixir/Erlang completion does not find a hit; at the moment I do not get completion for the code in the project files. A customization-variable would be nice, as I guess two emacs users have three opinions on what fallback backends are the most appropriate...
I could tackle that on my own and provide a PR, if need be. Just thought I ask you first, since this is very freshly released and you might have plans already.
Notably for beginners a menu is helpful
I think we should definitely implement something in the line of this pr to rspec-mode
I would be fantastic if I could customize alchemist so it does not automatically start the application when running tests from the 'test-on-save' hook.
If this feature is already there, I apologize. I've been looking for a while now, but failed to find it.
Hello! Thanks for awesome mode, looks great!
I've got completion working out of the box, just after installing company-mode
, but I can't M-.
to the sources of e.g. List.flatten
For that purpose there're two variables you can set:
(setq alchemist-goto-erlang-source-dir "/path/to/erlang/source/")
(setq alchemist-goto-elixir-source-dir "/path/to/elixir/source/")
So, I git clone <github elixir repo>
to /usr/local/src/
. What value should I set
to this vars?
Same question for Erlang, I've installed erlang-src in Debian and found:
tree /usr/lib/erlang/lib -L 1
├── asn1-3.0.4
├── common_test-1.10
├── compiler-5.0.4
├── cosEvent-2.1.15
├── cosEventDomain-1.1.14
├── cosFileTransfer-1.1.16
├── cosNotification-1.1.21
├── cosProperty-1.1.17
├── cosTime-1.1.14
├── cosTransactions-1.2.14
├── crypto-3.5
├── debugger-4.0.3
├── dialyzer-2.7.4
├── diameter-1.9
├── edoc-0.7.16
├── eldap-1.1.1
├── erl_docgen-0.3.7
├── erl_interface-3.7.20
├── erts-6.4
├── et-1.5
├── eunit-2.2.9
├── gs-1.5.16
├── hipe-3.11.3
├── ic-4.3.6
├── inets-5.10.6
├── jinterface-1.5.12
├── kernel-3.2
├── megaco-3.17.3
├── mnesia-4.12.5
├── observer-2.0.4
├── odbc-2.10.22
├── orber-3.7.1
├── ose-1.0.2
├── os_mon-2.3.1
├── otp_mibs-1.0.10
├── parsetools-2.0.12
├── percept-0.8.10
├── public_key-0.23
├── reltool-0.6.6
├── runtime_tools-1.8.16
├── sasl-2.4.1
├── snmp-5.1.1
├── ssh-3.2
├── ssl-6.0
├── stdlib-2.4
├── syntax_tools-1.6.18
├── test_server-3.8
├── tools-2.7.2
├── typer-0.9.8
├── webtool-0.8.10
├── wx-1.3.3
└── xmerl-1.3.7
Looks like a little bit dump question, but i've tried different values with no result, always getting Don't know how to find: List.flatten
When I try to use the help
function (specifically, alchemist-help-search-at-point
) I get the error:
error in process sentinel: Wrong type argument: stringp, nil
I'm using evil-mode so it's possible that is where the problem is. I am not sure how long since it stopped working.
Hi, I'm an Elixir newbie, using Alchemist. I've run across something that I'm not sure if is a bug in my code, my usage, or alchemist. Since I'm not sure, I've created a minimal project. It's here: https://github.com/BrianHicks/testplug
The problem is: I get an error on the use Plug.Router
line in lib/testplug.ex
when compiling with alchemist-compile-this-buffer
:
elixirc /Users/brianhicks/code/sandbox/testplug/lib/testplug.ex
lib/testplug.ex:1: warning: redefining module TestPlug
== Compilation error on file lib/testplug.ex ==
** (CompileError) lib/testplug.ex:2: module Plug.Router is not loaded and could not be found
(elixir) expanding macro: Kernel.use/1
lib/testplug.ex:2: TestPlug (module)
However, the tests all pass and the app will run and respond when started with Cowboy. So I'm at a bit of a loss here - is there something else I have to configure? I've pulled down the deps... are they in some weird location I need to set?
When working with rspec-mode
the feature I've come to love the most is being able to jump back and forth between test and implementation.
From what I was able to find (correct me if I'm wrong!) alchemist.el
only provides me with going from implementation to test (and always splitting windows, which sometimes is not what I want).
Would you be interested in adding this feature ? I would happily implement it ;)
How can I use company mode when not in a mix project or in an exs file?
Alchemist reuses the mix buffer if it's in the same frame as the cursor, but if you have a mix buffer in another frame, it opens a new one in the current frame, and then the output is shown in both frames.
It would be better if Alchemist could notice if the buffer already exists in any frame, and just reuse that one.
If I enter Keyword.fetch
and wait a bit, one suggestion is shown Keyword.fetch!
. If I then press enter or tab Keyword.fetch
is replaced with only fetch!
not Keyword.fetch!
as expected.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.