neovim-elixir Neovim 主机插件 Elixir

程序名称:neovim-elixir

授权协议: 未知

操作系统: 跨平台

开发语言:

neovim-elixir 介绍

Neovim 主机插件 Elixir 。

示例代码;

defmodule AutoComplete do
  use NVim.Plugin

  deffunc elixir_complete("1",_,cursor,line,state), eval: "col('.')", eval: "getline('.')" do
    cursor = cursor - 1 # because we are in insert mode
    [tomatch] = Regex.run(~r"[\w\.:]*$",String.slice(line,0..cursor-1))
    cursor - String.length(tomatch)  end
  deffunc elixir_complete(_,base,_,_,state), eval: "col('.')", eval: "getline('.')" do
    case (base |> to_char_list |> Enum.reverse |> IEx.Autocomplete.expand) do
      {:no,_,_}-> [base] # no expand
      {:yes,comp,[]}->["#{base}#{comp}"] #simple expand, no choices
      {:yes,_,alts}-> # multiple choices
        Enum.map(alts,fn comp->
          {base,comp} = {String.replace(base,~r"[^.]*$",""), to_string(comp)}          case Regex.run(~r"^(.*)/([0-9]+)$",comp) do # first see if these choices are module or function
            [_,function,arity]-> # it is a function completion
              replace = base<>function
              module = if String.last(base) == ".", do: Module.concat([String.slice(base,0..-2)]), else: Kernel
              if (docs=Code.get_docs(module,:docs)) && (doc=List.keyfind(docs,{:"#{function}",elem(Integer.parse(arity),0)},0)) && (docmd=elem(doc,4)) do
                 %{"word"=>replace,"kind"=> if(elem(doc,2)==:def, do: "f", else: "m"), "abbr"=>comp,"info"=>docmd}              else
                %{"word"=>replace,"abbr"=>comp}              end
            nil-> # it is a module completion
              module = base<>comp              case Code.get_docs(Module.concat([module]),:moduledoc) do
                {_,moduledoc} -> %{"word"=>module,"info"=>moduledoc}                _ -> %{"word"=>module}              end
          end
        end)    end
  end

  defautocmd file_type(state), pattern: "elixir", async: true do
    {:ok,nil} = NVim.vim_command("filetype plugin on")
    {:ok,nil} = NVim.vim_command("set omnifunc=ElixirComplete")
    state  endend

neovim-elixir 官网

https://github.com/awetzel/neovim-elixir

相关编程语言

Pacman 是一个软件包管理器, 作为 ArchLinux 发行版...
Smb4K 是KDE下的网络共享浏览器 更多屏幕截图请看:...
Wine (“Wine Is Not an Emulator” 的首字母缩写)...
虚拟桌面软件,可管理最多9个虚拟桌面,你可以用热键...
UNetbootin (Universal Netboot Installer)为一种跨...
Cobbler 可以用来快速建立 Linux 网络安装环境,它已...