Skip to content
This repository was archived by the owner on Apr 1, 2020. It is now read-only.

Integrating with elixir alchemist #735

Open
MikaAK opened this issue Sep 29, 2017 · 20 comments · Fixed by #2325
Open

Integrating with elixir alchemist #735

MikaAK opened this issue Sep 29, 2017 · 20 comments · Fixed by #2325

Comments

@MikaAK
Copy link
Contributor

MikaAK commented Sep 29, 2017

https://github.com/msaraiva/elixir_sense provides a language server for elixir and has been used in things like https://github.com/slashmili/alchemist.vim/wiki. How would one add support for this in oni?
If not supported it would be great to allow for a fallback to deoplete in order to support this!

Another thing I'm trying to figure out is how to get completion to work in this way
2017-09-29 04 03 34
where whenever completion next is shown it cycles through the completion options

@bryphe
Copy link
Member

bryphe commented Sep 30, 2017

Hi @MikaAK ,

The language server support is on-deck for '0.3'. You can already hook-in to a language server via the Oni API - you can see an example of that here: https://github.com/bryphe/oni-language-csharp

However, for 0.3, I want to make this even easier... The idea is you could have a configuration like:

languages.elixer.languageServer: "./path/to/elixer/language-server-provider-executable"

I need to update the roadmap but this is the next item for support, after the 'daily-editor-blockers' are addressed.

Regarding the completion issue - that seems like a bug - could you help me out with the repro steps for it? I tried on my environment but don't see it (just repro'd with a vanilla text file). It'd be helpful to know the set of plugins running, your configuration, and the exact key presses you're using.

@MikaAK
Copy link
Contributor Author

MikaAK commented Oct 2, 2017

Wow that's pretty cool, maybe I'll take a quick stab at an elixir plugin, since I use it daily I'm sure it would be handy and I'm sure other can benefit! Thanks for the info 😄

The completion is probably due to having deoplete in since this is what I wanted to use for elixir. This is my oni config

const activate = (oni) => {
  oni.input.unbind("<c-p>")
  oni.input.unbind("<Tab>")
  oni.input.unbind("<c-n>")
  oni.input.unbind("<enter>")
  oni.input.unbind("<down>")
  oni.input.unbind("<up>")
  oni.input.bind("<enter>", "quickOpen.openFile")
  oni.input.bind("<up>", "menu.previous")
  oni.input.bind("<shift-tab>", "menu.previous")
  oni.input.bind("<tab>", "menu.next")
  oni.input.bind("<down>", "menu.next")
  oni.input.bind("<m-q>", () => require('electron').remote.app.quit())
  oni.input.bind('<m-w>', () => document.querySelector('.tab.selected .fa-times').click())
}

const deactivate = () => {
}

module.exports = {
   activate,
   deactivate,
  "oni.useExternalPopupMenu": true,
  "editor.completions.enabled": false,
  "oni.useDefaultConfig": false,
  "oni.loadInitVim": true,
  "tabs.enabled": true,
  "editor.fontFamily": "Hack"
}

as well as my plugins

" Completion
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }

" Movement
Plug 'easymotion/vim-easymotion'
Plug 'tpope/vim-surround'
Plug 'terryma/vim-multiple-cursors'

" Files
Plug 'kien/ctrlp.vim'
Plug 'scrooloose/nerdtree'
Plug 'Xuyuanp/nerdtree-git-plugin'

" Syntax
Plug 'vim-syntastic/syntastic'
Plug 'ternjs/tern_for_vim'
Plug 'ntpeters/vim-better-whitespace'

" Status Lines
Plug 'airblade/vim-gitgutter'
Plug 'bling/vim-airline'

" Colors
Plug 'tomasr/molokai'

" Typescript
Plug 'leafgarland/typescript-vim'
Plug 'othree/javascript-libraries-syntax.vim'
Plug 'gavocanov/vim-js-indent'
Plug 'othree/yajs'
Plug 'othree/es.next.syntax.vim'
Plug 'mhartington/nvim-typescript'

" HTML Languages
Plug 'digitaltoad/vim-pug'

" Fish
Plug 'dag/vim-fish'

" Elixir
Plug 'slashmili/alchemist.vim'
Plug 'elixir-editors/vim-elixir'

" Tracking
Plug 'wakatime/vim-wakatime'

" Utility
Plug 'jiangmiao/auto-pairs'
Plug 'scrooloose/nerdcommenter'
Plug 'godlygeek/tabular'
Plug 'tpope/tpope-vim-abolish'
Plug 'wellle/targets.vim'
Plug 'xolox/vim-misc'
Plug 'xolox/vim-session'

I have this for deoplete however

call deoplete#enable()
inoremap <expr><tab> pumvisible() ? "\<c-n>" : "\<tab>"

All I'm doing is using tab to cycle through the options visible. This is the behavior I want to keep however when using completion directly from oni I cannot find a way to replicate this. Rather I have to use next/previous then use the select completion button which does cause extra keypresses and errors when forgetting them 😭

Lemme know what else I can do to help!

@adelarsq
Copy link

adelarsq commented Oct 9, 2017

Another alternative is elixir-ls.

@bryphe any plans to support debug protocol?

@bryphe
Copy link
Member

bryphe commented Oct 10, 2017

All I'm doing is using tab to cycle through the options visible. This is the behavior I want to keep however when using completion directly from oni I cannot find a way to replicate this. Rather I have to use next/previous then use the select completion button which does cause extra keypresses and errors when forgetting them 😭

Ah ya, I'm not sure this is very well supported at the moment. Good to have this open to track. The option at the moment would be to experiment with something like input.bind("tab", "completion.next") - the downside is you still need enter to complete...

@bryphe any plans to support debug protocol?

@adelarsq Yes! I just updated the roadmap. It's really ambitious, but there is a lot I want to cram in the next few months...

@MikaAK
Copy link
Contributor Author

MikaAK commented Oct 11, 2017

I actually was using that binding before but unfortunately I found that it did slow me down. I would like to disable the autocomplete if possible and just use deoplete for now, is that possible @bryphe

@bryphe
Copy link
Member

bryphe commented Nov 11, 2017

Hi @MikaAK ,

Couple follow ups here:

  • You can use the editor.completions.enabled configuration set to false to disable completions if you'd prefer to use deoplete
  • The language server configuration is here, so you could potentially set up the elixir language server support via the instructions here: https://github.com/onivim/oni/wiki/Language-Support

@bryphe bryphe added the insider label Mar 14, 2018
@tcoopman
Copy link

Has anyone made progress with this, or integrated the language support?

@adelarsq
Copy link

adelarsq commented Mar 26, 2018

@tcoopman I have plans to work on this. Maybe that this config works but I still didn't have time to test:

// elixir - https://github.com/JakeBecker/elixir-ls
"language.elixir.languageServer.command": "elixir-ls",

@ontofractal
Copy link

ontofractal commented Mar 27, 2018

@tcoopman, @adelarsq after some tinkering got LS integration working.

On my machine LS works properly only with elixir-ls configured through oni and alchemist installed through Plug manager. ¯\(ツ)

My oni config

export const configuration = {
    //add custom config here, such as

    "ui.colorscheme": "nord",

    //"oni.useDefaultConfig": true,
    //"oni.bookmarks": ["~/Documents"],
    //"oni.loadInitVim": false,
    //"editor.fontSize": "14px",
    "editor.fontFamily": "Fira Code",

    "oni.loadInitVim": true,

    // UI customizations
    "ui.animations.enabled": true,
    "ui.fontSmoothing": "auto",
    "language.elixir.languageServer.command": "/home/rangeomorph/elixir_ls/language_server.sh",
    "language.elixir.languageServer.arguments": ["--stdio"],
    "language.elixir.languageServer.rootFiles": ["mix.exs"],
    "language.elixir.languageServer.configuration": {}

}

My nvim config

call plug#begin()
Plug 'elixir-editors/vim-elixir'
Plug 'slashmili/alchemist.vim'
call plug#end()

@adelarsq
Copy link

@ontofractal Good job! 🥇 Can you provide the content from the language_server.sh file?

@ontofractal
Copy link

@adelarsq language_server.sh is a file from the latest elixir-ls release https://github.com/JakeBecker/elixir-ls/releases

@tcoopman
Copy link

@ontofractal do you know what's the reason for the need for alchemist?

@ontofractal
Copy link

@tcoopman Using just elixir-ls with Oni LS configuration led to Oni throwing errors no grammar found for language: elixir in developer console and installing alchemist fixed that.

It seems to be brittle though, couldn't get it working today, got more no grammar found errors with alchemist installed.

@tcoopman
Copy link

@ontofractal thanks. I'll guess I'll wait a while for using oni. Would love to use it, but a bit too much work for now.

@polaris6933
Copy link

polaris6933 commented Apr 6, 2018

I tried @ontofractal's configuration bit, unfortunately, it did not work for me. When I open up an elixir file I get a little loading-like animated circle in the statusbar - screenshot - and it just spins indefinitely. I got the same effect trying to use the Haskell IDE Engine but pyls worked like a charm. I'm on Manjao Linux and here's my config.js (I also tried editing config.tsx but any option I put in there had no effect whatsoever):

'use strict';
exports.__esModule = true;
exports.activate = function(oni) {
    console.log('config activated');
    // autocompletion navigation
    oni.input.bind('<C-j>', 'contextMenu.next');
    oni.input.bind('<C-k>', 'contextMenu.previous');
};
exports.deactivate = function(oni) {
    console.log('config deactivated');
};
exports.configuration = {
    'oni.useDefaultConfig': true,
    //"oni.bookmarks": ["~/Documents"],
    'oni.loadInitVim': true,
    'oni.hideMenu': true,

    'editor.fontSize': '18px',
    'editor.fontFamily': 'mononoki Nerd Font Mono',
    'editor.formatting.formatOnSwitchToNormalMode': true,

    'ui.animations.enabled': true,
    'ui.fontSmoothing': 'auto',
    'ui.colorscheme': 'nord',
    'ui.fontSize': '16px',

    'statusbar.fontSize': '16px',

    'language.elixir.languageServer.command':
        '/home/zdravko/elixir_ls/language_server.sh',
    'language.elixir.languageServer.arguments': ['--stdio'],
    'language.elixir.languageServer.rootFiles': ['mix.exs'],
    'language.elixir.languageServer.configuration': {}

    'language.haskell.languageServer.command': 'hie',
    'language.haskell.languageServer.arguments': ['--lsp'],
    'language.haskell.languageServer.configuration': {}
};

@niklaas
Copy link

niklaas commented Jun 15, 2018

@polaris6933 Same issue here. I'm just guessing but it might have something to do with language.elixir.languageServer.rootFiles when there is no mix.exs (maybe because one is simply editing an .exs file without a mix project). Maybe Oni keeps on looking for the file but can't find it.

@ghost ghost mentioned this issue Jun 15, 2018
@MikaAK
Copy link
Contributor Author

MikaAK commented Oct 20, 2018

@Akin909 this is actually still a problem. I realized now #2325 adds syntaxes but not a language server itself.

@akinsho akinsho reopened this Oct 20, 2018
@akinsho
Copy link
Member

akinsho commented Oct 20, 2018

@MikaAK thanks for pointing this out I thought there was maybe a solution for this. I don't think we would ship oni with one for elixir but would be good to find a client that does work or probably its a question of how we integrate lsp which is currently causing the issue.

As a side note I believe there's actually an issue with the syntaxes added in #2325

@MikaAK
Copy link
Contributor Author

MikaAK commented Oct 20, 2018

Once #2640 lands I think that would open the doors to using elixir-ls

@tlvenn
Copy link

tlvenn commented Apr 28, 2019

Given #2640 has landed, curious to see if anyone has been able to successfully integrate with elixir-ls ? Thanks

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants