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

Go Language Server 使うべし

Go Language Server 使うべし

Go(Un)Conference(Goあんこ)LT大会 5kg

Toshikazu Ohashi

January 31, 2019
Tweet

More Decks by Toshikazu Ohashi

Other Decks in Programming

Transcript

  1. (P
    -BOHVBHF
    4FSWFS
    ࢖͏΂͠
    (P 6O
    $POGFSFODFʢ(P͋Μ͜ʣ-5େձLH
    !MJHIUUJHFS

    View full-size slide

  2. -BOHVBHF4FSWFS 1SPUPDPM

    ͳʹʁͳͥ

    View full-size slide

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

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

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

    View full-size slide

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

    View full-size slide

  5. (Pͷ-BOHVBHF4FSWFS

    View full-size slide

  6. ݱঢ়ɺൃల͕ظ଴͞Ε͍ͯΔ(Pͷ-BOHVBHF4FSWFS͸ҎԼͷͭ
    HPQMT
    w (Pެࣜͷ-BOVHBHF4FSWFS
    CJOHP
    w TPVSDFHSBQIHPMBOHTFSWFSΠϯεύΠϠͷ
    αʔυύʔςΟ-BOHVBHF4FSWFS

    View full-size slide

  7. .FUIPE ػೳ (P5PPMT
    textDocument/completion ࣗಈิ׬ gocode*
    textDocument/definition ఆٛδϟϯϓ godef*
    textDocument/formatting ϑΥʔϚοτ gofmt
    textDocument/hover ώϯτදࣔ gogetdoc*
    textDocument/implementation ܧঝؔ܎ impl
    textDocument/rename ໊લมߋ gorename*
    textDocument/references γϯϘϧࢀরݕࡧ guru
    textDocument/documentSymbol υΩϡϝϯτγϯϘϧݕࡧ guru
    workspace/symbol ϫʔΫεϖʔεγϯϘϧݕࡧ guru
    -41ͱ(Pݴޠ։ൃπʔϧ
    * αʔυύʔςΟ੡πʔϧ

    View full-size slide

  8. .FUIPE HPQMT CJOHP
    textDocument/completion ○ ○
    textDocument/definition ○ ○
    textDocument/formatting ○ ○
    textDocument/hover ○ ○
    textDocument/implementation - ○
    textDocument/rename - ○
    textDocument/references - ○
    textDocument/documentSymbol - ○
    workspace/symbol - ○
    HPQMTͱCJOHPͷൺֱ
    2019/01/28࣌఺Ͱ֤ServerͷCapabilitiesΛऔಘͨ݁͠Ռ

    View full-size slide

  9. ͳ͍ͥ·
    -BOHVBHF4FSWFSͳͷ͔

    View full-size slide

  10. ಡΜͰ͍ͩ͘͞
    (P"EWFOU$BMFOEBS೔໨
    ʰHPDPEF΍Ί·͢ ͦͯ͠-BOHVBHF4FSWFS΁
    ʱ
    IUUQTNBUUOLBPSJZBOFUTPGUXBSFMBOHHPIUN

    View full-size slide

  11. ࢖ͬͯΘ͔ͬͨ
    -BOHVBHF4FSWFSͷԸܙ

    View full-size slide

  12. ͔͜͜Β൒෼
    ͘Β͍7JNͷ࿩
    8BSOJOH

    View full-size slide

  13. -BOHVBHF4FSWFSಋೖ
    #FGPSF"GUFS

    View full-size slide

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

    ࣗಈิ׬
    EFPQMFUF

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

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

    1ZUIPOิ׬
    EFPQMFUFKFEJ

    (Pิ׬
    EFPQMFUFHP

    View full-size slide

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

    ࣗಈิ׬
    EFPQMFUF

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

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

    1ZUIPOิ׬
    EFPQMFUFKFEJ

    (Pิ׬
    EFPQMFUFHP

    7JN
    ΤσΟλ

    View full-size slide

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

    ࣗಈิ׬
    EFPQMFUF

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

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

    1ZUIPOิ׬
    EFPQMFUFKFEJ

    (Pิ׬
    EFPQMFUFHP

    ΤσΟλϓϥάΠϯ

    View full-size slide

  17. 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

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  21. ͲΜͳਓʹͲΜͳԸܙ͕
    ͋Δ͔ ໝ૝


    View full-size slide

  22. -41͸ίϛϡχςΟͷ։ൃϦιʔεΛΑΓޮ཰తʹ
    ӡ༻͢ΔͨΊͷϑϨʔϜϫʔΫ
    ͍ΖΜͳཱ৔ͷਓʹԸܙ͕͋Δ
    w ΤσΟλϓϥάΠϯ։ൃऀ
    w ݴޠπʔϧ։ൃऀ
    w ΤσΟλϢʔβ

    View full-size slide

  23. ΤσΟλϓϥάΠϯ։ൃऀ

    View full-size slide

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

    ࣗಈิ׬
    EFPQMFUF

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

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

    1ZUIPOิ׬
    EFPQMFUFKFEJ

    (Pิ׬
    EFPQMFUFHP

    7JN
    ຊདྷ΍Γ͍ͨ͜ͱ
    ड͚औͬͨ݁ՌΛͲ͏දࣔ͢Ε͹ΑΓ
    Ϣʔβ͕ศརʹͳΔ͔

    View full-size slide

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

    ࣗಈิ׬
    EFPQMFUF

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

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

    1ZUIPOิ׬
    EFPQMFUFKFEJ

    (Pิ׬
    EFPQMFUFHP

    ࢓ํ͕ͳ͘΍Δ͜ͱ
    ݴޠ։ൃπʔϧ͝ͱʹ࣮૷͕ඞཁ
    w ݺͼग़͠ํ๏ Φϓγϣϯͷҧ͍

    w ݁Ռͷύʔε ग़ྗϑΥʔϚοτҧ͍

    πʔϧ͕ҧ͑͹࢖͍ํ΋ҧ͏

    View full-size slide

  26. ࣗಈิ׬
    (deoplete)
    LSPิ׬
    (deoplete-
    vim-lsp)
    QZMT
    HPQMTCJOHP
    7JN
    Language
    Server
    Client
    (vim-lsp)
    -41
    ͪ͜ΒʹूதͰ͖Δ
    มΘͬͨ͜ͱ
    -41Ͱ࢓༷͕౷Ұ͞Ε͍ͯΔ͔Β
    -BOHVBHF4FSWFSΛม͑ͯ΋ݸผରԠඞཁφγ

    View full-size slide

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

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

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

    View full-size slide

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

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

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

    View full-size slide

  29. ݴޠπʔϧ։ൃऀ

    View full-size slide

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

    ࣗಈิ׬
    EFPQMFUF

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

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

    1ZUIPOิ׬
    EFPQMFUFKFEJ

    (Pิ׬
    EFPQMFUFHP

    KFEJ
    HPDPEF
    BVUPQFQ
    qBLF
    JTPSU
    ZBSQ
    CMBDL
    HPEFG
    JNQM
    JNQM
    HVSV
    HPMJOU
    ຊདྷ΍Γ͍ͨ͜ͱ
    ਖ਼֬Ͱߴ଎ͳϨεϙϯεͨΊʹ
    ΧϦΧϦͷνϡʔχϯά

    View full-size slide

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

    ࣗಈิ׬
    EFPQMFUF

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

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

    1ZUIPOิ׬
    EFPQMFUFKFEJ

    (Pิ׬
    EFPQMFUFHP

    KFEJ
    HPDPEF
    BVUPQFQ
    qBLF
    JTPSU
    ZBSQ
    CMBDL
    HPEFG
    JNQM
    JNQM
    HVSV
    HPMJOU
    ࢓ํ͕ͳ͘΍Δ͜ͱ
    ΤσΟλຖͷݸผରԠ
    w ΤσΟλ͕ड͚औΓՄೳͳग़ྗ
    w ड͚औΓқ͍ܗࣜ΁ͷύʔε

    View full-size slide

  32. ࣗಈิ׬
    (deoplete)
    LSPิ׬
    (deoplete-
    vim-lsp)
    7JN
    Language
    Server
    Client
    (vim-lsp)
    QZMT
    HPQMTCJOHP
    -41
    ΤσΟλຖͷࠩ෼Λؾʹ͢Δඞཁ͸ͳ͍
    ͦͯ͠-41ʹ͸ੑೳʹد༩͢Δ
    ϢʔςΟϦςΟతͳ.FUIPE΋ଘࡏ͠ɺ
    ੑೳ޲্ʹΑΓྗΛׂ͚Δ
    มΘͬͨ͜ͱ

    View full-size slide

  33. ΤσΟλϢʔβ

    View full-size slide

  34. 7JN
    ຊདྷ΍Γ͍ͨ͜ͱ
    ίʔυΛॻ͘͜ͱ
    WJNSD͸ؚ·ͳ͍

    $PEF

    View full-size slide

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

    ࣗಈิ׬
    EFPQMFUF

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

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

    1ZUIPOิ׬
    EFPQMFUFKFEJ

    (Pิ׬
    EFPQMFUFHP

    ࢓ํ͕ͳ͘΍Δ͜ͱ ָ͍͠

    ݴޠϓϥάΠϯຖͷઃఆ
    w දࣔಈ࡞Φϓγϣϯ
    w ίϚϯυͷΩʔόΠϯυ

    View full-size slide

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

    ࣗಈิ׬
    EFPQMFUF

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

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

    1ZUIPOิ׬
    EFPQMFUFKFEJ

    (Pิ׬
    EFPQMFUFHP

    KFEJ
    HPDPEF
    BVUPQFQ
    qBLF
    JTPSU
    ZBSQ
    CMBDL
    HPEFG
    JNQM
    JNQM
    HVSV
    HPMJOU
    ࢓ํ͕ͳ͘΍Δ͜ͱ ָ͍͠

    ݸผͷίϚϯυͷΠϯετʔϧ
    w Ϧϯλʔ
    w ϑΥʔϚολʔ
    w ࣗಈิ׬
    w ͦͷଞ੩తղੳ

    View full-size slide

  37. ࣗಈิ׬
    (deoplete)
    LSPิ׬
    (deoplete-
    vim-lsp)
    QZMT
    HPQMTCJOHP
    7JN
    Language
    Server
    Client
    (vim-lsp)
    -41
    มΘͬͨ͜ͱ
    ͲͷݴޠͰ΋-BOHVBHF4FSWFS$MJFOUͰର
    ԠͰ͖Δ
    w ΠϯετʔϧηοτΞοϓͷলྗԽ
    w ݴޠຖͷݸผઃఆͷ౷Ұ

    View full-size slide

  38. ࣗಈิ׬
    (deoplete)
    LSPิ׬
    (deoplete-
    vim-lsp)
    7JN
    Language
    Server
    Client
    (vim-lsp)
    QZMT
    HPQMTCJOHP
    -41
    มΘͬͨ͜ͱ
    ݴޠ։ൃπʔϧͷ౷߹
    w ΠϯετʔϧηοτΞοϓͷলྗԽ
    ݴޠίϛϡχςΟ։ൃϦιʔεूதʹΑΔ
    ੑೳ޲্
    w ߴ඼࣭ͳݴޠ։ൃػೳͷڗड

    View full-size slide

  39. 7JN
    ॻ͚Δʜίʔυ͕ॻ͚Δͧ
    $PEF
    มΘͬͨ͜ͱ

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  42. (P
    -BOHVBHF
    4FSWFS
    ࢖͏΂͠

    View full-size slide