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
Lemonade + Foundry Toolkit でお手軽アプリ開発
seosoft
1
320
セキュリティの専門家じゃなくてもできる。「セキュリティ意識」をアップデートして サプライチェーン攻撃への耐性を高めよう。
tk3fftk
5
720
生成AI時代にこそ効くGo | Why Go Works in the Age of Generative AI
mom0tomo
8
3.2k
AI駆動開発で崩れていくコードベースを立て直す
kyoko_nr_nr
1
450
DynamoDBには集計系のクエリがないけどなんとかしたい
musan
1
130
OSもどきOS
arkw
0
530
Semantic Version 単位で戦略を柔軟に変えて、パッケージアップデートを自動化する
daitasu
0
220
気づいたらRubyで100作品 ー クリエイティブコーディングが生活の一部になるまで / 100 Ruby Sketches Later: How Creative Coding Became Part of My Life
chobishiba
3
570
Hunting Vulnerabilities in Symfony with LLMs
vinceamstoutz
0
540
「AIで開発し、AIを届ける」をEvalでつなぐ 〜AIネイティブに始めるプロダクト開発の実践〜 / Connecting "Develop with AI, deliver AI" with Eval
rkaga
4
4.9k
タクシーアプリ『GO』の バックエンド開発のおける AI利活用と若者のすべて
pyama86
3
2k
TSKaigi Night Talks 2026_TypeScriptでサプライチェーンの整合性を型に閉じ込める
geekplus_tech
0
340
Featured
See All Featured
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
200
VelocityConf: Rendering Performance Case Studies
addyosmani
333
25k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.8k
Building a Scalable Design System with Sketch
lauravandoore
463
34k
Learning to Love Humans: Emotional Interface Design
aarron
275
41k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
830
Embracing the Ebb and Flow
colly
88
5.1k
[SF Ruby Conf 2025] Rails X
palkan
2
1.1k
Ethics towards AI in product and experience design
skipperchong
2
310
jQuery: Nuts, Bolts and Bling
dougneiner
66
8.5k
We Have a Design System, Now What?
morganepeng
55
8.2k
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 ͍͍ͧ