oni icon indicating copy to clipboard operation
oni copied to clipboard

Integrating with elixir alchemist

Open MikaAK opened this issue 8 years ago • 20 comments

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

MikaAK avatar Sep 29 '17 07:09 MikaAK

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.

bryphe avatar Sep 30 '17 17:09 bryphe

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!

MikaAK avatar Oct 02 '17 04:10 MikaAK

Another alternative is elixir-ls.

@bryphe any plans to support debug protocol?

adelarsq avatar Oct 09 '17 22:10 adelarsq

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

bryphe avatar Oct 10 '17 00:10 bryphe

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

MikaAK avatar Oct 11 '17 22:10 MikaAK

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 avatar Nov 11 '17 01:11 bryphe

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

tcoopman avatar Mar 26 '18 12:03 tcoopman

@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",

adelarsq avatar Mar 26 '18 23:03 adelarsq

@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()

ontofractal avatar Mar 27 '18 19:03 ontofractal

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

adelarsq avatar Mar 28 '18 01:03 adelarsq

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

ontofractal avatar Mar 28 '18 09:03 ontofractal

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

tcoopman avatar Mar 28 '18 11:03 tcoopman

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

ontofractal avatar Mar 28 '18 11:03 ontofractal

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

tcoopman avatar Mar 28 '18 14:03 tcoopman

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': {}
};

polaris6933 avatar Apr 06 '18 18:04 polaris6933

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

niklaas avatar Jun 15 '18 07:06 niklaas

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

MikaAK avatar Oct 20 '18 02:10 MikaAK

@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

akinsho avatar Oct 20 '18 10:10 akinsho

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

MikaAK avatar Oct 20 '18 23:10 MikaAK

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

tlvenn avatar Apr 28 '19 14:04 tlvenn