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
880
Other Decks in Programming
See All in Programming
気づいたらRubyで100作品 ー クリエイティブコーディングが生活の一部になるまで / 100 Ruby Sketches Later: How Creative Coding Became Part of My Life
chobishiba
3
550
柔軟なPDFレイアウトエディタを支える型システム設計 — Discriminated UnionとConditional Typeの実践
minako__ph
4
1.5k
AI 時代のソフトウェア設計の学び方
masuda220
PRO
29
12k
dRuby over BLE
makicamel
2
320
Javaの型とAI時代に型が大事な理由 / java types and type in AI era
kishida
2
110
Dataformのリポジトリを立ち上げるときにまずやること / dataform-day0-2026
snhryt
0
120
Composerを使ったサプライチェーン攻撃の様子を眺めてみる #phpstudy
o0h
PRO
2
230
The NotImplementedError Problem in Ruby
koic
1
650
ECSアプリログをFireLensでコスト削減しようとしたけど諦めた話 in Fargate×Node.js
akihisaikeda
2
110
Make SRE Operations Easier with Azure SRE Agent
kkamegawa
0
4.7k
Semantic Version 単位で戦略を柔軟に変えて、パッケージアップデートを自動化する
daitasu
0
170
JavaDoc 再入門
nagise
0
300
Featured
See All Featured
Product Roadmaps are Hard
iamctodd
PRO
55
12k
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
300
エンジニアに許された特別な時間の終わり
watany
107
250k
How to Talk to Developers About Accessibility
jct
2
220
brightonSEO & MeasureFest 2025 - Christian Goodrich - Winning strategies for Black Friday CRO & PPC
cargoodrich
3
720
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
230
Reflections from 52 weeks, 52 projects
jeffersonlam
356
21k
Agile Leadership in an Agile Organization
kimpetersen
PRO
0
160
Building a Modern Day E-commerce SEO Strategy
aleyda
45
9.1k
Tell your own story through comics
letsgokoyo
1
950
Facilitating Awesome Meetings
lara
57
6.9k
Speed Design
sergeychernyshev
33
1.8k
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 ͍͍ͧ