Slide 1

Slide 1 text

LSP ͷྗΛ࢖ͬͯ Ruby ͢Δʂ @blue_1617

Slide 2

Slide 2 text

Who Am I ‣ ΤϜεϦʔגࣜձࣾ Ͱ Ϋϥ΢υిࢠΧϧς Λ։ൃ blue (@blue_1617) ‣ Ruby, JavaScript, Scala etc Λ׆༻ https://blue0513.github.io/show_room/ ‣ Emacs ޷͖ͷΤϯδχΞ 2 ࠷ۙͷ LT ͱ͔ ‣ Emacs Ͱ LSP Λ࢖ͬͯΈͨΑ ‣ Emacs Ͱ Web αʔϏεΛ։ൃͯ͠8ϲ݄͕ܦͪ·ͨ͠ ‣ 2018೥Ͱ΋ʢԶ͸ʣEmacs Λ࢖͍͍ͨ ‣ VTuber ͬͯ஌ͬͯ·͢ʁ ‣ VTuber Λࢧ͑Δٕज़ ۙگͱ͔ ‣ ౬ͨΜΆΛങͬͯշ຾ͯ͠Δ (´ɾωɾ`)

Slide 3

Slide 3 text

Who Am I ‣ ΤϜεϦʔגࣜձࣾ Ͱ Ϋϥ΢υిࢠΧϧς Λ։ൃ blue (@blue_1617) ‣ Ruby, JavaScript, Scala etc Λ׆༻ https://blue0513.github.io/show_room/ ‣ Emacs ޷͖ͷΤϯδχΞ 3 ࠷ۙͷ LT ͱ͔ ‣ Emacs Ͱ LSP Λ࢖ͬͯΈͨΑ ‣ Emacs Ͱ Web αʔϏεΛ։ൃͯ͠8ϲ݄͕ܦͪ·ͨ͠ ‣ 2018೥Ͱ΋ʢԶ͸ʣEmacs Λ࢖͍͍ͨ ‣ VTuber ͬͯ஌ͬͯ·͢ʁ ‣ VTuber Λࢧ͑Δٕज़ ۙگͱ͔ ‣ ౬ͨΜΆΛങͬͯշ຾ͯ͠Δ (´ɾωɾ`) We are Hiring !! M3, Inc.

Slide 4

Slide 4 text

ࣄͷൃ୺ ~ LSP ͕ੌ͍ͱฉ͍ͯ ~ Emacs Ͱ Ruby ॻ͍ͯΔͱ ิ׬ͱ͔ఆٛࢀরͭΒ͘ͳ͍....ʁ ʮRuby ͷؾ͕࣋ͪղΒͳ͍.....ʯ ʮิ׬Ͱ͖ͳ͍.....ʯ 4

Slide 5

Slide 5 text

LSP Λ࢖͏ͱิ׬͕ڧ͘ͳΔʂʁ LSP ʮRuby ͷؾ͕࣋ͪ෼͔Δʂʯ ʮิ׬͕Ͱ͖ΔɺͰ͖Δͧʂʯ ࣄͷൃ୺ ~ LSP ͕ੌ͍ͱฉ͍ͯ ~ 5

Slide 6

Slide 6 text

LSP Λ࢖͏ͱิ׬͕ڧ͘ͳΔʂʁ LSP ʮRuby ͷؾ͕࣋ͪ෼͔Δʂʯ ʮิ׬͕Ͱ͖ΔɺͰ͖Δͧʂʯ ࣄͷൃ୺ ~ LSP ͕ੌ͍ͱฉ͍ͯ ~ LSP Ͱ Ruby ͷิ׬ΛڧԽ͍ͨ͠ʂ 6

Slide 7

Slide 7 text

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 7

Slide 8

Slide 8 text

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 ΤσΟλͱ͔ 8

Slide 9

Slide 9 text

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 ιʔείʔυͷղੳΛͯ͘͠ΕΔαʔό ʢϩʔΧϧʹཱͯΒΕΔʣ 9

Slide 10

Slide 10 text

LSPͱ͸ʁ https://microsoft.github.io/language-server-protocol/implementors/servers/ ݴޠ͝ͱͷ Language Server ʢ܈༤ׂڌͳঢ়ଶʣ 10

Slide 11

Slide 11 text

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) 11

Slide 12

Slide 12 text

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 12

Slide 13

Slide 13 text

LSPͱ͸ʁ Language Server Protocol (LSP) ͱ͸..... ݴޠͷղੳͳͲΛߦ͏ Language Server ͱ֤πʔϧʢClientʣ͕ ௨৴ɾ࿈ܞ͢ΔࡍͷϓϩτίϧΛنఆ͢Δ΋ͷ ‣ ֤πʔϧ͸ Language Server ͕ͲͷݴޠΛѻ͍ͬͯΔ͔Λҙࣝ͢ Δ͜ͱͳ͘ɺิ׬΍ఆٛࢀরΛߦ͑Δ ϝϦοτ͸..... https://microsoft.github.io/language-server-protocol/ ‣ Emacs ౳ͷΤσΟλͷ ิ׬ɾఆٛࢀরೳྗ౳͕޲্ ͢Δ 13

Slide 14

Slide 14 text

LSPͱ͸ʁ Language Server Protocol (LSP) ͱ͸..... ݴޠͷղੳͳͲΛߦ͏ Language Server ͱ֤πʔϧʢClientʣ͕ ௨৴ɾ࿈ܞ͢ΔࡍͷϓϩτίϧΛنఆ͢Δ΋ͷ ‣ ֤πʔϧ͸ Language Server ͕ͲͷݴޠΛѻ͍ͬͯΔ͔Λҙࣝ͢ Δ͜ͱͳ͘ɺิ׬΍ఆٛࢀরΛߦ͑Δ ϝϦοτ͸..... https://microsoft.github.io/language-server-protocol/ ‣ Emacs ౳ͷΤσΟλͷ ิ׬ɾఆٛࢀরೳྗ౳͕޲্ ͢Δ LSP Ͱ Ruby ͷิ׬͕ڧ͘ͳΔʂ 14

Slide 15

Slide 15 text

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 15

Slide 16

Slide 16 text

Demo (Emacs & LSP) 16

Slide 17

Slide 17 text

ઃఆ 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) 17

Slide 18

Slide 18 text

ิ׬ ‣ String.class ͳΒɺto_i ͕αδΣετ͞ΕΔ ‣ Array.class ͳΒɺto_h ͕αδΣετ͞ΕΔ 18

Slide 19

Slide 19 text

ิ׬ ‣ String.class ͳΒɺto_i ͕αδΣετ͞ΕΔ ‣ Array.class ͳΒɺto_h ͕αδΣετ͞ΕΔ ಈը 19

Slide 20

Slide 20 text

ิ׬ ‣ Πϯελϯεϝιου ΋αδΣετ͞ΕΔ ‣ `Subscription#to_param` ΛαδΣετ 20

Slide 21

Slide 21 text

ิ׬ ‣ Πϯελϯεϝιου ΋αδΣετ͞ΕΔ ‣ `Subscription#to_param` ΛαδΣετ ಈը 21

Slide 22

Slide 22 text

ఆٛࢀর 22

Slide 23

Slide 23 text

ఆٛࢀর `Subscription.confirm` ʹఆٛδϟϯϓ͢Δʂ ಈը 23

Slide 24

Slide 24 text

ࢀরݕࡧ 'Subscription.confirm' ͷࢀরՕॴΛݕࡧ͢Δʂ 24

Slide 25

Slide 25 text

ࢀরݕࡧ ಈը 25

Slide 26

Slide 26 text

͓·͚ ~ Rails ͷิ׬ ~ $ yard gems $ solargraph config 3. `.solargraph.yml` Λฤू 2. `.solargraph.yml` Λੜ੒ 1. Installed gem ʹ document ੜ੒ https://github.com/castwide/solargraph/issues/87 26

Slide 27

Slide 27 text

͓·͚ ~ Rails ͷิ׬ ~ `ActiveRecord` ͳͲ͕ީิͱͯ͠αδΣετ͞ΕΔʂ 27

Slide 28

Slide 28 text

͓·͚ ~ Rails ͷิ׬ ~ `ActiveRecord` ͳͲ͕ީิͱͯ͠αδΣετ͞ΕΔʂ LSP Ͱշదͳ Ruby ίʔσΟϯά 28

Slide 29

Slide 29 text

Ruby Ͱ LSP Λࢼͨ͠ײ૝ ‣ ิ׬ɾఆٛࢀরɾࢀরݕࡧ͸͔ͳΓߴϨϕϧ ‣ Good Point ‣ Problematic Point ‣ ಋೖ͕ͱͯ΋खܰ ‣ େن໛ϓϩδΣΫτͩͱগ͠ಈ࡞͕ॏ͍ ‣ খن໛ϓϩδΣΫτͳΒߴ଎ಈ࡞ ‣ Language Server & Client ͕܈༤ׂڌ 29

Slide 30

Slide 30 text

࠷ޙʹ ‣ LSP ͸ੌ͍ ‣ Ruby Project Ͱ΋ิ׬΍ఆٛࢀরΛ࣮ߦ ‣ εϐʔυײ͋;ΕΔ։ൃʢLanguage Server & Clientʣ LSP Ͱ Ruby ָ͕ʹʂ ‣ ֎෦ gem ͷఆٛࢀর΋ OKʂ ‣ ඪ४ϝιουҎ֎ͷิ׬΋ OKʂ ‣ Rails ͷαϙʔτ΋ॆ࣮ ‣ Emacs ΍ Vim ౳ͷΤσΟλͰ΋շదʹ Ruby ͕ॻ͚Δ 30