Upgrade to Pro — share decks privately, control downloads, hide ads and more …

LSPがもたらしたVimプラグインの変化に思いを馳せる

 LSPがもたらしたVimプラグインの変化に思いを馳せる

A12373843afc54857a845404bdd5f5cb?s=128

Toshikazu Ohashi

April 18, 2019
Tweet

More Decks by Toshikazu Ohashi

Other Decks in Programming

Transcript

  1. -41͕΋ͨΒͨ͠ 7JNϓϥάΠϯͷมԽʹ ࢥ͍Λ஘ͤΔ VimϓϥάΠϯιϜϦΤ(ݟश͍) @lighttiger2505 gollira.vim #3

  2. ΠϯτϩμΫγϣϯ

  3. ͔ͳΓલʹ ͜ΜͳهࣄΛॻ͖·ͨ͠ • NeovimͰϞμϯͳPython؀ڥΛߏங͢Δ • https://qiita.com/lighttiger2505/items/ e0ada17634516c081ee7

  4. શવϞμϯ ͡Όͳ͘ͳͬͯΔʂʁ

  5. ͳ͔ͥ • LSP(Language Server Protocol)ͷӨڹ͕େ͖͍ • NeoVimͷϦϞʔτϓϥάΠϯͱ৽ػೳ͕ߋʹม ԽΛଅ͢

  6. ຊ೔ͷςʔϚΰʔϧ • ςʔϚ • LSP͕VimͷϓϥάΠϯʹͲͷΑ͏ͳมԽΛ΋ͨ Β͔ͨ͠ • ΰʔϧ • Vim͸ະͩʹൃల్্ʹ͋Δ

    • զʑ͸ͦͷൃలʹߩݙͰ͖Δ
  7. ΞδΣϯμ • LSP(Language Server Protocol)ͱ͸ͳʹ͔ • LSPΫϥΠΞϯτϓϥάΠϯͷ঺հ • ϦϞʔτϓϥάΠϯͱ͸ͳʹ͔ •

    VimϓϥάΠϯͷมԽ • ·ͱΊ
  8. -41ͱ͸ͳʹ͔

  9. -BOHVBHF4FSWFS ݴޠ։ൃπʔϧΛ౷߹ͨ͠αʔό w ࣗಈิ׬ w ఆٛδϟϯϓ w ࢀরݕࡧFUD -BOHVBHF4FSWFS1SPUPDPM -41

     -BOHVBHF4FSWFSͱΫϥΠΞϯτؒͰ࢖༻͢Δϓϩτίϧ w .JDSPTPGU͕࢓༷ࡦఆ 74$PEFͷͨΊʁ  w +40/31$ϕʔε -41ͱ͸ͳʹ͔
  10. ͜Ε·Ͱ͸ΤσΟλຖʹݴޠπʔϧΛར༻͢ΔϓϥάΠϯ͕ඞཁͩͬ ͨ w 74$PEFͷ1ZUIPOϓϥάΠϯ w "UPNͷ1ZUIPOϓϥάΠϯ w 7JNͷ1ZUIPOϓϥάΠϯ w 4VCMJNF5FYU

    &NBDT 4PVSDFHSBQIFUD ݴޠίϛϡχςΟͷ։ൃϦιʔεΛ-BOHVBHF 4FSWFSʹूதͯ͠ߴ඼࣭ͳݴޠ։ൃπʔϧΛ࡞ Δ Ϣʔβ͸-41ΛαϙʔτΫϥΠΞϯτΛಋೖͯ͠ ͙͢ʹߴ඼࣭ͳݴޠͷαϙʔτΛڗडͰ͖Δ -41͸ͳͥඞཁ͔
  11. .FUIPE ػೳ textDocument/completion ࣗಈิ׬ textDocument/definition ఆٛδϟϯϓ textDocument/formatting ϑΥʔϚοτ textDocument/hover ώϯτදࣔ

    textDocument/implementation ࣮૷(ܧঝ/ΠϯλϑΣʔε)ͷϦετ textDocument/rename ໊લมߋ textDocument/references γϯϘϧࢀরݕࡧ textDocument/documentSymbol υΩϡϝϯτγϯϘϧݕࡧ workspace/symbol ϫʔΫεϖʔεγϯϘϧݕࡧ -41ͷఏڙ͢Δػೳ
  12. #FGPSF"GUFS

  13. KFEJ HPDPEF BVUPQFQ qBLF JTPSU ZBSQ CMBDL HPEFG JNQM HVSV

    HPMJOU 7JN ϦϯλʔϑΥʔϚολ ϓϥάΠϯ "-& ࣗಈิ׬ EFPQMFUF (PݴޠπʔϧϓϥάΠϯ WJNHP 1ZUIPOݴޠπʔϧϓϥάΠϯ KFEJWJN 1ZUIPOิ׬ EFPQMFUFKFEJ (Pิ׬ EFPQMFUFHP
  14. KFEJ HPDPEF BVUPQFQ qBLF JTPSU ZBSQ CMBDL HPEFG JNQM HVSV

    HPMJOU ϦϯλʔϑΥʔϚολ ϓϥάΠϯ "-& ࣗಈิ׬ EFPQMFUF (PݴޠπʔϧϓϥάΠϯ WJNHP 1ZUIPOݴޠπʔϧϓϥάΠϯ KFEJWJN 1ZUIPOิ׬ EFPQMFUFKFEJ (Pิ׬ EFPQMFUFHP 7JN 7JN
  15. KFEJ HPDPEF BVUPQFQ qBLF JTPSU ZBSQ CMBDL HPEFG JNQM HVSV

    HPMJOU 7JN ϦϯλʔϑΥʔϚολ ϓϥάΠϯ "-& ࣗಈิ׬ EFPQMFUF (PݴޠπʔϧϓϥάΠϯ WJNHP 1ZUIPOݴޠπʔϧϓϥάΠϯ KFEJWJN 1ZUIPOิ׬ EFPQMFUFKFEJ (Pิ׬ EFPQMFUFHP 7JNϓϥάΠϯ
  16. 7JN ϦϯλʔϑΥʔϚολ ϓϥάΠϯ "-& ࣗಈิ׬ EFPQMFUF (PݴޠπʔϧϓϥάΠϯ WJNHP 1ZUIPOݴޠπʔϧϓϥάΠϯ KFEJWJN

    1ZUIPOิ׬ EFPQMFUFKFEJ (Pิ׬ EFPQMFUFHP KFEJ HPDPEF BVUPQFQ qBLF JTPSU ZBSQ CMBDL HPEFG JNQM HVSV HPMJOU ݴޠ։ൃπʔϧ
  17. #FGPSF"GUFS

  18. ࣗಈิ׬ (deoplete) LSPิ׬ (deoplete- vim-lsp) QZMT HPQMT Language Server Client

    (vim-lsp) 7JN -41
  19. ࣗಈิ׬ (deoplete) LSPิ׬ (deoplete- vim-lsp) QZMT HPQMT 7JN Language Server

    Client (vim-lsp) -41 -BOHVBHF4FSWFS$MJFOU
  20. ࣗಈิ׬ (deoplete) LSPิ׬ (deoplete- vim-lsp) 7JN Language Server Client (vim-lsp)

    QZMT HPQMT -41 -BOHVBHF4FSWFS
  21. Ϧιʔεͷूத (PݴޠπʔϧϓϥάΠϯ WJNHP 1ZUIPOݴޠπʔϧϓϥάΠϯ KFEJWJN Language Server Client (vim-lsp) 7JNTDSJQU

    (P 7JNTDSJQU 1ZUIPO
  22. (PݴޠπʔϧϓϥάΠϯ WJNHP 1ZUIPOݴޠπʔϧϓϥάΠϯ KFEJWJN Language Server Client (vim-lsp) 7JNTDSJQU0OMZ Ϧιʔεͷूத

  23. Ϧιʔεͷूத (PݴޠπʔϧϓϥάΠϯ WJNHP (PݴޠπʔϧϓϥάΠϯ WTDPEFHP gopls 7JN (P 74$PEF (P

  24. Ϧιʔεͷूத (PݴޠπʔϧϓϥάΠϯ WJNHP (PݴޠπʔϧϓϥάΠϯ WTDPEFHP gopls HPQMT

  25. -41ΫϥΠΞϯτ ϓϥάΠϯͷ঺հ

  26. -41ࡾॐ࢜ • vim-lsp • LanguageClient-neovim • coc.nvim

  27. WJNMTQ • Vim script • Vimͱ΋NeoVimͱ΋ߴ౓ͳޓ׵ੑ • NeoVimͷ৽ػೳ௥ै΋ੵۃత

  28. 8JUI"VUP$PNQMFUF • asyncomplete.vim • asyncomplete-lsp.vim • deoplete.nvim • deoplete-vim-lsp •

    ncm2 • ncm2-vim-lsp
  29. -BOHVBHF$MJFOUOFPWJN • Rust(ϦϞʔτϓϥάΠϯ) • NeoVimͱ͍͍ͭͯΔ͕VimͰ΋ಈ͘ • LSPΫϥΠΞϯτͱͯ͠͸vim-lspͱಉఔ౓ͷ࣮ ૷ • fzfͳͲdenite.nvimͳͲͷ֎෦࿈ܞ͸एׯڧ͍

    ҹ৅
  30. 8JUI"VUP$PNQMFUF • deoplete.nvim • LanguageClient source(ϦϙδτϦʹಉࠝ) • ncm2

  31. DPDOWJN • Type Script(ϦϞʔτϓϥάΠϯ) • nvimͱ͍͍ͭͯΔ͕VimͰ΋ಈ͘ • ࣗಈิ׬ʙͦͷଞΠϯςϦηϯε·Ͱશ෦ೖΓ • FloatingWindowରԠͷ଎͞

  32. ϦϞʔτϓϥάΠϯ ͱ͸ͳʹ͔

  33. /FP7JNʹ͍ͭͯ͸ҎԼࢀর • Differences between Nvim and Vim full version •

    https://www.slideshare.net/Shougo/ differences-between-nvim-and-vim-full-version • Neovim͕Ͳ͏͍͏ϓϩδΣΫτͳͷ͔·ͱΊ • https://qiita.com/lighttiger2505/items/ 440c32e40082dc310c1e
  34. ͬ͘͟Γ • Improve the extensibility power with a new plugin

    architecture based on coprocesses. Plugins will be written in any programming language without any explicit support from the editor. • https://github.com/Neovim/Neovim/wiki/ Introduction • VimϓϥάΠϯΛVim scriptҎ֎ͷ͋ΒΏΔϓϩά ϥϜݴޠͰॻ͚Δ
  35. ৄղ • :h remote_plugin • NeoVim͸RPCΛ௨ͯ͡ຊମૢ࡞Λߦ͑ΔAPIΛ උ͑Δ • ϦϞʔτϓϥάΠϯ͸ຊମͱผϓϩηεͰىಈ ͠msgpack-RPCͰ্هAPIͱ௨৴͢Δ

    • ଟ͘ͷ৔߹௨৴͸ϥούʔ͞ΕͨϥΠϒϥϦΛ ༻͍Δ
  36. /FP7JNͰ͔͠ಈ͔ͳ͍ʁ • NeoVimͷϦϞʔτϓϥάΠϯΛVimͰ΋࢖༻Ͱ͖ΔΑ͏ ʹ͢Δϥούʔ૚΋͋Δ • ͔͠͠·࣮ͩݧతͳཱͪҐஔ • nvim-yarp • https://github.com/roxma/nvim-yarp

    • vim-hug-neovim-rpc • https://github.com/roxma/vim-hug-neovim-rpc
  37. 7JNϓϥάΠϯͷมԽ

  38. -41ΫϥΠΞϯτ͸΍Δ͜ͱ ͕ͨ͘͞Μ • ࣗಈิ׬ • ੩తղੳ • ίʔυδϟϯϓ • γϯϘϧݕࡧ/දࣔ

    • ฤूதͷϑΝΠϧಉظ
  39. -41ΫϥΠΞϯτ͸΍Δ͜ͱ ͕ͨ͘͞Μ • Language Serverͱͷ௨৴(JSON-RPC2) • ඇಉظ • ߴ଎

  40. -41ొ৔ʹΑΓ ϓϥάΠϯͷ΍Δ͜ͱ͕ ͲΜͲΜ૿͍͑ͯ͘

  41. 7JNTDSJQUͷಛੑ • Vimʹ౥ࡌ͞Ε͍ͯΔͨΊɺผ్ϥϯλΠϜෆཁ • VimಠࣗͷείʔϓɺΠϕϯτϋϯυϦϯά • ΦϒδΣΫτࢦ޲(Ϋϥε)ͳͲݱ୅తͳϓϩάϥ ϛϯάػೳͷܽ೗

  42. ϦϞʔτϓϥάΠϯͰ ࡞ͬͨ΄͏͕ྑ͍ʁ • Vim scriptͷ΄͏͕؆୯ʹ͔͚Δ৔໘΋͋Δ • Vimͱͷೖग़ྗҎ֎ͷϩδοΫ͕૿͑ଓ͚Δͱ൚ ༻ϓϩάϥϜݴޠͷ΄͏͕༗རͳ৔໘΋͋Δ • ϞδϡʔϧԽɺߏ଄Խ

  43. ·ͱΊ • LSPͷొ৔ʹΑͬͯϓϥάΠϯʹେ͖ͳมԽ • ݴޠΠϯςϦηϯεΛಘΔୈҰͷखஈͱͯ͠LSPΫϥΠΞϯτ ͕ొ৔ • ͜Ε·ͰݸผʹඞཁͩͬͨϓϥάΠϯ͕LSPΫϥΠΞϯτ ʹ·ͱ·Δ •

    LSPΫϥΠΞϯτ͕େ͖ͳϓϥάΠϯʹ • ϦϞʔτϓϥάΠϯͰ࣮૷͞ΕΔLSPΫϥΠϯτͷొ ৔
  44. Ͳ͏ͳΔͷ͔Θ͔Βͳ͍ • coc.nvimͷΑ͏ͳLSPΫϥΠΞϯτʹଞͷϓϥά Πϯͷػೳ͕શ෦΋Γ͜·ΕΔͷ͔ • খ͞ͳಛఆػೳͷϓϥάΠϯΛ૊Έ߹Θ͍ͤͯ͘ ͷ͔ • ϕετϓϥΫςΟε͸ͳ͘·ͩΈΜͳ໛ࡧ͍ͯ͠ Δঢ়گ

  45. 7JNʹ͸ ·ͩ·ͩՄೳੑ͕͋Δ • Vim͸ރΕͯΔͱࢥ͕ͬͨͦΜͳ͜ͱ͸ͳ͔ͬͨ • ৽͍͠ϓϥάΠϯ͸ͲΜͲΜग़ͯ͘Δ • deoplete-vim-lsp࡞͕ͬͨ਺Χ݄ޙ΋͏ϨΨγʔʹͳ ΔͷͰ͸ʁ •

    ·ͩ·֤ͩLSPΫϥΠΞϯτʹ͸଍Γͳ͍෦෼ͳͲͨ͘͞ Μ͋Δ • ࢲୡ͸ߩݙ͢Δ͜ͱ͕Ͱ͖Δ
  46. -FU`TFOKPZ ZPVS7JNMJGF