Skip to content

Instantly share code, notes, and snippets.

@Comamoca
Last active February 16, 2023 13:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Comamoca/487ed2bf9470e55ca8e1481288a241b5 to your computer and use it in GitHub Desktop.
Save Comamoca/487ed2bf9470e55ca8e1481288a241b5 to your computer and use it in GitHub Desktop.

Nvim + Masonでelixirlsを使う

追記

Masonを使っている場合は以下のように設定すれば動きます。教えてくださったyuys13さん、ありがとうございました🙏

if server == "elixirls" then
	require("lspconfig").elixirls.setup({
		-- Unix
		cmd = { "/home/coma/.local/share/nvim/mason/bin/elixir-ls" },
	})
end

この設定をしてもハイライトは効かないので、適宜プラグインをインストールしてください。


Masonで既に別の言語の補完ができる状態(補完用のプラグインが導入・セットアップ済み)である事が前提で書いています。

こんな感じで使えます。若干応答が悪いです...

https://twitter.com/Comamoca_/status/1626175497666433029?s=20

ハイライト

まず初めにシンタックスハイライトをするためのプラグインを導入します。 今思いましたがこれTreeSitterでもいいですね...

https://github.com/elixir-editors/vim-elixir

LSP

次にLSPをインストール...させたいのですが、elixirlsはインストールにちょっと癖があります。 まず初めに任意の場所にリポジトリをクローンしときます。

そしてビルド方法を参考にビルドします。 このとき最後の-oオプションに指定したパス(絶対パスの方が良いと思われる)を覚えておきます。

次にLSPと連携をするためのプラグインを導入します。

https://github.com/mhanberg/elixir.nvim

require("elixir").setup({
  cmd = "ここにさっきのパスを書く",
})

こうすれば冒頭のツイートのように補完が効くはずです。

自分の場合

最終的に僕の設定ファイル(DeinのTomlで管理しています。)を貼っておきます。

language_server.shはghqでgetしたリポジトリのrelease配下(-oreleaseを指定)においてあります。

[[plugins]]
repo = 'https://github.com/mhanberg/elixir.nvim'
on_ft = ["elixir"]
lua_source = """
require("elixir").setup({
  cmd = "/home/coma/ghq/github.com/elixir-lsp/elixir-ls/release/language_server.sh",
})
"""

[[plugins]]
repo = 'https://github.com/elixir-editors/vim-elixir'
on_ft = ["elixir"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment