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

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

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

Toshikazu Ohashi

April 18, 2019
Tweet

More Decks by Toshikazu Ohashi

Other Decks in Programming

Transcript

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

    View full-size slide

  2. ΠϯτϩμΫγϣϯ

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  7. ΞδΣϯμ
    • LSP(Language Server Protocol)ͱ͸ͳʹ͔
    • LSPΫϥΠΞϯτϓϥάΠϯͷ঺հ
    • ϦϞʔτϓϥάΠϯͱ͸ͳʹ͔
    • VimϓϥάΠϯͷมԽ
    • ·ͱΊ

    View full-size slide

  8. -41ͱ͸ͳʹ͔

    View full-size slide

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

    -BOHVBHF4FSWFSͱΫϥΠΞϯτؒͰ࢖༻͢Δϓϩτίϧ
    w .JDSPTPGU͕࢓༷ࡦఆ 74$PEFͷͨΊʁ

    w +40/31$ϕʔε
    -41ͱ͸ͳʹ͔

    View full-size slide

  10. ͜Ε·Ͱ͸ΤσΟλຖʹݴޠπʔϧΛར༻͢ΔϓϥάΠϯ͕ඞཁͩͬ
    ͨ
    w 74$PEFͷ1ZUIPOϓϥάΠϯ
    w "UPNͷ1ZUIPOϓϥάΠϯ
    w 7JNͷ1ZUIPOϓϥάΠϯ
    w 4VCMJNF5FYU &NBDT 4PVSDFHSBQIFUD
    ݴޠίϛϡχςΟͷ։ൃϦιʔεΛ-BOHVBHF
    4FSWFSʹूதͯ͠ߴ඼࣭ͳݴޠ։ൃπʔϧΛ࡞
    Δ
    Ϣʔβ͸-41ΛαϙʔτΫϥΠΞϯτΛಋೖͯ͠
    ͙͢ʹߴ඼࣭ͳݴޠͷαϙʔτΛڗडͰ͖Δ
    -41͸ͳͥඞཁ͔

    View full-size slide

  11. .FUIPE ػೳ
    textDocument/completion ࣗಈิ׬
    textDocument/definition ఆٛδϟϯϓ
    textDocument/formatting ϑΥʔϚοτ
    textDocument/hover ώϯτදࣔ
    textDocument/implementation ࣮૷(ܧঝ/ΠϯλϑΣʔε)ͷϦετ
    textDocument/rename ໊લมߋ
    textDocument/references γϯϘϧࢀরݕࡧ
    textDocument/documentSymbol υΩϡϝϯτγϯϘϧݕࡧ
    workspace/symbol ϫʔΫεϖʔεγϯϘϧݕࡧ
    -41ͷఏڙ͢Δػೳ

    View full-size slide

  12. KFEJ
    HPDPEF
    BVUPQFQ
    qBLF
    JTPSU
    ZBSQ
    CMBDL
    HPEFG
    JNQM
    HVSV
    HPMJOU
    7JN
    ϦϯλʔϑΥʔϚολ
    ϓϥάΠϯ
    "-&

    ࣗಈิ׬
    EFPQMFUF

    (PݴޠπʔϧϓϥάΠϯ
    WJNHP

    1ZUIPOݴޠπʔϧϓϥάΠϯ
    KFEJWJN

    1ZUIPOิ׬
    EFPQMFUFKFEJ

    (Pิ׬
    EFPQMFUFHP

    View full-size slide

  13. KFEJ
    HPDPEF
    BVUPQFQ
    qBLF
    JTPSU
    ZBSQ
    CMBDL
    HPEFG
    JNQM
    HVSV
    HPMJOU
    ϦϯλʔϑΥʔϚολ
    ϓϥάΠϯ
    "-&

    ࣗಈิ׬
    EFPQMFUF

    (PݴޠπʔϧϓϥάΠϯ
    WJNHP

    1ZUIPOݴޠπʔϧϓϥάΠϯ
    KFEJWJN

    1ZUIPOิ׬
    EFPQMFUFKFEJ

    (Pิ׬
    EFPQMFUFHP

    7JN
    7JN

    View full-size slide

  14. KFEJ
    HPDPEF
    BVUPQFQ
    qBLF
    JTPSU
    ZBSQ
    CMBDL
    HPEFG
    JNQM
    HVSV
    HPMJOU
    7JN
    ϦϯλʔϑΥʔϚολ
    ϓϥάΠϯ
    "-&

    ࣗಈิ׬
    EFPQMFUF

    (PݴޠπʔϧϓϥάΠϯ
    WJNHP

    1ZUIPOݴޠπʔϧϓϥάΠϯ
    KFEJWJN

    1ZUIPOิ׬
    EFPQMFUFKFEJ

    (Pิ׬
    EFPQMFUFHP

    7JNϓϥάΠϯ

    View full-size slide

  15. 7JN
    ϦϯλʔϑΥʔϚολ
    ϓϥάΠϯ
    "-&

    ࣗಈิ׬
    EFPQMFUF

    (PݴޠπʔϧϓϥάΠϯ
    WJNHP

    1ZUIPOݴޠπʔϧϓϥάΠϯ
    KFEJWJN

    1ZUIPOิ׬
    EFPQMFUFKFEJ

    (Pิ׬
    EFPQMFUFHP

    KFEJ
    HPDPEF
    BVUPQFQ
    qBLF
    JTPSU
    ZBSQ
    CMBDL
    HPEFG
    JNQM
    HVSV
    HPMJOU
    ݴޠ։ൃπʔϧ

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    1ZUIPOݴޠπʔϧϓϥάΠϯ
    KFEJWJN

    Language
    Server
    Client
    (vim-lsp)
    7JNTDSJQU(P
    7JNTDSJQU1ZUIPO

    View full-size slide

  20. (PݴޠπʔϧϓϥάΠϯ
    WJNHP

    1ZUIPOݴޠπʔϧϓϥάΠϯ
    KFEJWJN

    Language
    Server
    Client
    (vim-lsp)
    7JNTDSJQU0OMZ
    Ϧιʔεͷूத

    View full-size slide

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

    (PݴޠπʔϧϓϥάΠϯ
    WTDPEFHP

    gopls
    7JN(P
    74$PEF(P

    View full-size slide

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

    (PݴޠπʔϧϓϥάΠϯ
    WTDPEFHP

    gopls
    HPQMT

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  27. -BOHVBHF$MJFOUOFPWJN
    • Rust(ϦϞʔτϓϥάΠϯ)
    • NeoVimͱ͍͍ͭͯΔ͕VimͰ΋ಈ͘
    • LSPΫϥΠΞϯτͱͯ͠͸vim-lspͱಉఔ౓ͷ࣮

    • fzfͳͲdenite.nvimͳͲͷ֎෦࿈ܞ͸एׯڧ͍
    ҹ৅

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  31. /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

    View full-size slide

  32. ͬ͘͟Γ
    • 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Ҏ֎ͷ͋ΒΏΔϓϩά
    ϥϜݴޠͰॻ͚Δ

    View full-size slide

  33. ৄղ
    • :h remote_plugin
    • NeoVim͸RPCΛ௨ͯ͡ຊମૢ࡞Λߦ͑ΔAPIΛ
    උ͑Δ
    • ϦϞʔτϓϥάΠϯ͸ຊମͱผϓϩηεͰىಈ
    ͠msgpack-RPCͰ্هAPIͱ௨৴͢Δ
    • ଟ͘ͷ৔߹௨৴͸ϥούʔ͞ΕͨϥΠϒϥϦΛ
    ༻͍Δ

    View full-size slide

  34. /FP7JNͰ͔͠ಈ͔ͳ͍ʁ
    • NeoVimͷϦϞʔτϓϥάΠϯΛVimͰ΋࢖༻Ͱ͖ΔΑ͏
    ʹ͢Δϥούʔ૚΋͋Δ
    • ͔͠͠·࣮ͩݧతͳཱͪҐஔ
    • nvim-yarp
    • https://github.com/roxma/nvim-yarp
    • vim-hug-neovim-rpc
    • https://github.com/roxma/vim-hug-neovim-rpc

    View full-size slide

  35. 7JNϓϥάΠϯͷมԽ

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  43. 7JNʹ͸
    ·ͩ·ͩՄೳੑ͕͋Δ
    • Vim͸ރΕͯΔͱࢥ͕ͬͨͦΜͳ͜ͱ͸ͳ͔ͬͨ
    • ৽͍͠ϓϥάΠϯ͸ͲΜͲΜग़ͯ͘Δ
    • deoplete-vim-lsp࡞͕ͬͨ਺Χ݄ޙ΋͏ϨΨγʔʹͳ
    ΔͷͰ͸ʁ
    • ·ͩ·֤ͩLSPΫϥΠΞϯτʹ͸଍Γͳ͍෦෼ͳͲͨ͘͞
    Μ͋Δ
    • ࢲୡ͸ߩݙ͢Δ͜ͱ͕Ͱ͖Δ

    View full-size slide

  44. -FU`TFOKPZ
    ZPVS7JNMJGF

    View full-size slide