Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Emacs で LSP を使ってみたよ
Search
Taiju Aoki
January 23, 2019
Programming
1.5k
4
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Emacs で LSP を使ってみたよ
Slide for M3 TechTalk
Taiju Aoki
January 23, 2019
More Decks by Taiju Aoki
See All by Taiju Aoki
本番運用中 Oracle を破壊してしまった話 ~ 破壊と創世 ~ / Oracle Destruction and Creation
blue0513
0
3.2k
オンプレ to オンプレした話/on-premises2on-premises
blue0513
0
3.2k
GitもCIもテストもないプロジェクトでデプロイを自動化するまでの道 / rebuild of DevOps
blue0513
0
3.4k
Git & GitLab & コードレビューって? / about Git, GitLab, CodeReview
blue0513
0
270
ElectronでSlackをさらに便利にしちゃう / Slack with Electron
blue0513
3
920
GitHub の README をいい感じにする / Cool Readme
blue0513
3
1.7k
Emacs × Sound やってみた / Emacs with Sound
blue0513
1
1.1k
Slack を TweetDeck にしてみた件 / slackdeck-proto
blue0513
0
3.1k
知ってるとお得な iTerm2 と zsh/bash の小技
blue0513
3
890
Other Decks in Programming
See All in Programming
技術記事、 専門家としてのプログラマ、 言語化
mizchi
14
7.3k
Snowflake Summitでの新機能 CoCo / CoWork / snowflake-summit-2026-overall-what-new-coco
tatsuhiro
1
220
霧の中の代数的エフェクト
funnyycat
1
320
Language Server 使ってる? 〜VSCode と Zed の場合〜 / Are you using a Language Server? ~For VS Code and Zed~
handlename
0
840
act1-costs.pdf
sumedhbala
0
200
その問い、本当に正しいですか?AI時代のエンジニアに必要な哲学と認知科学 / ai-philosophy-cognitive-science
minodriven
14
6.8k
なぜ型を書くのか? TSKaigi2026で改めて考える #tskaigi_smarthr
kajitack
0
310
スマートグラスで並列バイブコーディング
hyshu
0
280
決定論的オーケストレーションの設計と実装 / Design and Implementation of Deterministic Orchestration
nrslib
4
1.6k
Go1.27で導入されるジェネリクスメソッドでできること
mackee
0
260
過去最大のMCPアップデート! 2026-07-28 RC版の謎に迫る
licux
6
460
キャリア迷子上等 ─ "ない道"は自分で作ればいい
16bitidol
3
2.8k
Featured
See All Featured
The Limits of Empathy - UXLibs8
cassininazir
1
410
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
390
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
3k
Reality Check: Gamification 10 Years Later
codingconduct
0
2.2k
Building AI with AI
inesmontani
PRO
1
1.1k
[RailsConf 2023] Rails as a piece of cake
palkan
59
6.7k
Bioeconomy Workshop: Dr. Julius Ecuru, Opportunities for a Bioeconomy in West Africa
akademiya2063
PRO
1
170
Fireside Chat
paigeccino
42
4k
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
2.1k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
Transcript
Emacs Ͱ LSP ΛͬͯΈͨΑ @blue_1617
Who Am I ‣ VTuber ͱ Emacs ͖ͷ ‣ ࣾձਓ
10ϲ݄ ͷεʔύʔΤϯδχΞ blue (@blue_1617) ࠷ۙͷ Emacs ͳ׆ಈ ‣ ౦ژ Emacs ձ 2018 ‣ (nth 2 shibuyaku-elisp) ‣ GitHub/flycheck-flash-mode-line ‣ GitHub/electron-desktop-character ࠷ۙͷ OSS ͳ׆ಈ ‣ GitHub/cycle-frame-transparency ࠷ۙͷ Qiita ͳ׆ಈ ‣ Emacs Ͱ LSP Λ׆༻ͯ͠ΈΔ ‣ 2018͚ͩͲσεΫτοϓϚείοτΛ ࡞Γ͔ͨͬͨΜͩ ‣ Emacs ΛϫϯίϚϯυͰಁաͤ͞Δ ‣ flycheck Ͱ Emacs ͷ Mode Line ΛޫΒͤΔ ‣ counsel-recentf ͷରΛ Project ϑΝΠϧ ʹߜΔ ‣ Emacs Ͱࣗ࡞ؔΛͬͯΈΔ ࠷ۙ࡞ͬͨϙʔτϑΥϦΦ (https://blue0513.github.io/show_room/)
ࣄͷൃ Emacs ͬͯ V̋Cőe ʹൺͯ ิͱ͔ఆٛࢀরೳྗ͕͘ͳ͍ʁ ͱͯେ͖ͳͩ…… LSP Λ͑ղܾ͢ΔΒ͍͠
ࣄͷൃ Emacs ͬͯ V̋Cőe ʹൺͯ ิͱ͔ఆٛࢀরೳྗ͕͘ͳ͍ʁ ͱͯେ͖ͳͩ…… LSP Λ͑ղܾ͢ΔΒ͍͠ LSP
Ͱ Emacs Λڧ͍ͨ͘͠ʂ
LSPͱʁ Language Server Protocol (JSON-RPC) Development Tool Notification: textDocument/didChange; Params:
{documentURI, changes} Notification: textDocument/publishDiagnostics; Params: Diagnostic[] Language Server Request: textDocument/definition; Params: {documentURI, position} Notification: textDocument/didOpen; Params: document Open document Edit document Goto definition Publish Publish Response: textDocument/definition; Result: Location https://microsoft.github.io/language-server-protocol/overview
LSPͱʁ Language Server Protocol (JSON-RPC) Notification: textDocument/didChange; Params: {documentURI, changes}
Notification: textDocument/publishDiagnostics; Params: Diagnostic[] Language Server Request: textDocument/definition; Params: {documentURI, position} Notification: textDocument/didOpen; Params: document Open document Edit document Goto definition Publish Publish Response: textDocument/definition; Result: Location https://microsoft.github.io/language-server-protocol/overview Development Tool ΤσΟλͱ͔
LSPͱʁ Language Server Protocol (JSON-RPC) Development Tool Notification: textDocument/didChange; Params:
{documentURI, changes} Notification: textDocument/publishDiagnostics; Params: Diagnostic[] Request: textDocument/definition; Params: {documentURI, position} Notification: textDocument/didOpen; Params: document Open document Edit document Goto definition Publish Publish Response: textDocument/definition; Result: Location https://microsoft.github.io/language-server-protocol/overview Language Server ιʔείʔυͷղੳΛͯ͘͠ΕΔαʔό ʢϩʔΧϧʹཱͯΒΕΔʣ
LSPͱʁ https://microsoft.github.io/language-server-protocol/implementors/servers/ ݴޠ͝ͱͷ Language Server ʢ܈༤ׂڌͳঢ়ଶʣ
LSPͱʁ Development Tool Notification: textDocument/didChange; Params: {documentURI, changes} Notification: textDocument/publishDiagnostics;
Params: Diagnostic[] Request: textDocument/definition; Params: {documentURI, position} Notification: textDocument/didOpen; Params: document Open document Edit document Goto definition Publish Publish Response: textDocument/definition; Result: Location https://microsoft.github.io/language-server-protocol/overview Language Server ͜Ε͕ LSP ΤσΟλͱαʔόؒͷ௨৴ϓϩτίϧ Language Server Protocol (JSON-RPC)
LSPͱʁ Language Server Protocol (JSON-RPC) Development Tool Notification: textDocument/didChange; Params:
{documentURI, changes} Notification: textDocument/publishDiagnostics; Params: Diagnostic[] Language Server Request: textDocument/definition; Params: {documentURI, position} Notification: textDocument/didOpen; Params: document Open document Edit document Goto definition Publish Publish Response: textDocument/definition; Result: Location https://microsoft.github.io/language-server-protocol/overview
LSPͱʁ Language Server Protocol (LSP) ͱ..... ݴޠͷղੳͳͲΛߦ͏ Language Server ͱ֤πʔϧʢClientʣ͕
௨৴ɾ࿈ܞ͢ΔࡍͷϓϩτίϧΛنఆ͢Δͷ ‣ ֤πʔϧ Language Server ͕ͲͷݴޠΛѻ͍ͬͯΔ͔Λҙࣝ͢ Δ͜ͱͳ͘ɺิఆٛࢀরΛߦ͑Δ ϝϦοτ..... https://microsoft.github.io/language-server-protocol/ ‣ Emacs ͷΤσΟλͷ ิɾఆٛࢀরೳྗ্͕ ͢Δ
LSPͱʁ Language Server Protocol (LSP) ͱ..... ݴޠͷղੳͳͲΛߦ͏ Language Server ͱ֤πʔϧʢClientʣ͕
௨৴ɾ࿈ܞ͢ΔࡍͷϓϩτίϧΛنఆ͢Δͷ ‣ ֤πʔϧ Language Server ͕ͲͷݴޠΛѻ͍ͬͯΔ͔Λҙࣝ͢ Δ͜ͱͳ͘ɺิఆٛࢀরΛߦ͑Δ ϝϦοτ..... https://microsoft.github.io/language-server-protocol/ ‣ Emacs ͷΤσΟλͷ ิɾఆٛࢀরೳྗ্͕ ͢Δ LSP Ͱ Emacs ͕ڧ͘ͳΔʂ ͬͨͥ
Emacs Ͱ LSP Λ׆༻ͯ͠ΈΔ Developer Tool Language Server Language Server
Protocol (JSON-RPC) (Host) Development Tool Ruby JavaScript Java Request: textDocument/definition Response: Location https://microsoft.github.io/language-server-protocol/overview
Demo (Emacs & LSP)
ઃఆ Language Server : solargraph Client Package : eglot EmacsͰLSPΛ׆༻ͯ͠ΈΔ
(https://qiita.com/blue0513/items/acc962738c7f4da26656) https://github.com/joaotavora/eglot https://github.com/castwide/solargraph Step1. Install Language Server Step2. Edit init.el $ gem install solargraph (add-hook 'ruby-mode-hook 'eglot-ensure)
ิ ‣ String.class ͳΒɺto_i ͕αδΣετ͞ΕΔ ‣ Array.class ͳΒɺto_h ͕αδΣετ͞ΕΔ
ิ ‣ Πϯελϯεϝιου αδΣετ͞ΕΔ ‣ `Subscription#to_param` ΛαδΣετ
ఆٛࢀর `Subscription.confirm` ʹఆٛδϟϯϓ͢Δʂ
ࢀরݕࡧ 'Subscription.confirm' ͷࢀরՕॴΛݕࡧ͢Δʂ
͓·͚ ~ Rails ͷิ ~ $ yard gems $ solargraph
config 3. `.solargraph.yml` Λฤू 2. `.solargraph.yml` Λੜ 1. Installed gem ʹ document ੜ https://github.com/castwide/solargraph/issues/87
͓·͚ ~ Rails ͷิ ~ `ActiveRecord` ͳͲ͕ީิͱͯ͠αδΣετ͞ΕΔʂ
͓·͚ ~ Rails ͷิ ~ `ActiveRecord` ͳͲ͕ީิͱͯ͠αδΣετ͞ΕΔʂ LSP Ͱ Emacs
͕ڧ͘ͳͬͨʂ ͬͨͥ
Emacs Ͱ LSP Λࢼͨ͠ײ ‣ ิɾఆٛࢀরɾࢀরݕࡧ͔ͳΓߴϨϕϧ ‣ Good Point ‣
Problematic Point ‣ ಋೖ͕ͱͯखܰ ‣ େنϓϩδΣΫτͩͱগ͠ಈ࡞͕ॏ͍ ‣ খنϓϩδΣΫτͳΒߴಈ࡞ ‣ Language Server & Client ͕܈༤ׂڌ
࠷ޙʹ ‣ LSP ੌ͍ ‣ Emacs ੌ͍ ‣ Ruby Project
ͰิఆٛࢀরΛ࣮ߦ ‣ εϐʔυײ͋;ΕΔ։ൃʢΫϥΠΞϯταΠυ܈༤ׂڌʣ ‣ LSP ͷ **ྗ** ΛआΓͯ V̋Cőe ʹෛ͚ͳ͍ิೳྗ ‣ 3rd party ͷ࿈ܞϥΠϒϥϦΛಠࣗ։ൃͰ͖Δ LSP ͱ Emacs ͍͍ͧ