$30 off During Our Annual Pro Sale. View Details »

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

  2. -BOHVBHF4FSWFS 1SPUPDPM  ͳʹʁͳͥ  

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

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

    4PVSDFHSBQIFUD ݴޠίϛϡχςΟͷ։ൃϦιʔεΛ-BOHVBHF 4FSWFSʹूதͯ͠ߴ඼࣭ͳݴޠ։ൃπʔϧΛ࡞Δ Ϣʔβ͸-41ΛαϙʔτΫϥΠΞϯτΛಋೖͯ͠ ͙͢ʹߴ඼࣭ͳݴޠͷαϙʔτΛڗडͰ͖Δ ͋ͱͰৄ͘͠࿩͠·͢ -BOHVBHF4FSWFS͸ͳͥඞཁ͔
  5. (Pͷ-BOHVBHF4FSWFS  

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

  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ݴޠ։ൃπʔϧ * αʔυύʔςΟ੡πʔϧ
  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Λऔಘͨ݁͠Ռ
  9. ͳ͍ͥ· -BOHVBHF4FSWFSͳͷ͔  

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

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

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

  13. -BOHVBHF4FSWFSಋೖ #FGPSF"GUFS  

  14. #FGPSF"GUFS

  15. KFEJ HPDPEF BVUPQFQ qBLF JTPSU ZBSQ CMBDL HPEFG JNQM JNQM

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

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

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

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

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

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

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

    QZMT HPQMTCJOHP -41 -BOHVBHF4FSWFS
  23. ͲΜͳਓʹͲΜͳԸܙ͕ ͋Δ͔ ໝ૝  

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

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

  26. #FGPSF"GUFS

  27. KFEJ HPDPEF BVUPQFQ qBLF JTPSU ZBSQ CMBDL HPEFG JNQM JNQM

    HVSV HPMJOU ϦϯλʔϑΥʔϚολ ϓϥάΠϯ "-& ࣗಈิ׬ EFPQMFUF (PݴޠπʔϧϓϥάΠϯ WJNHP 1ZUIPOݴޠπʔϧϓϥάΠϯ KFEJWJN 1ZUIPOิ׬ EFPQMFUFKFEJ (Pิ׬ EFPQMFUFHP 7JN ຊདྷ΍Γ͍ͨ͜ͱ ड͚औͬͨ݁ՌΛͲ͏දࣔ͢Ε͹ΑΓ Ϣʔβ͕ศརʹͳΔ͔
  28. KFEJ HPDPEF BVUPQFQ qBLF JTPSU ZBSQ CMBDL HPEFG JNQM JNQM

    HVSV HPMJOU ϦϯλʔϑΥʔϚολ ϓϥάΠϯ "-& ࣗಈิ׬ EFPQMFUF (PݴޠπʔϧϓϥάΠϯ WJNHP 1ZUIPOݴޠπʔϧϓϥάΠϯ KFEJWJN 1ZUIPOิ׬ EFPQMFUFKFEJ (Pิ׬ EFPQMFUFHP ࢓ํ͕ͳ͘΍Δ͜ͱ ݴޠ։ൃπʔϧ͝ͱʹ࣮૷͕ඞཁ w ݺͼग़͠ํ๏ Φϓγϣϯͷҧ͍  w ݁Ռͷύʔε ग़ྗϑΥʔϚοτҧ͍  πʔϧ͕ҧ͑͹࢖͍ํ΋ҧ͏
  29. #FGPSF"GUFS

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

    Client (vim-lsp) -41 ͪ͜ΒʹूதͰ͖Δ มΘͬͨ͜ͱ -41Ͱ࢓༷͕౷Ұ͞Ε͍ͯΔ͔Β -BOHVBHF4FSWFSΛม͑ͯ΋ݸผରԠඞཁφγ
  31. Ϧιʔεͷूத (PݴޠπʔϧϓϥάΠϯ WJNHP 1ZUIPOݴޠπʔϧϓϥάΠϯ KFEJWJN Language Server Client (vim-lsp) 7JNTDSJQU

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

  33. ݴޠπʔϧ։ൃऀ  

  34. #FGPSF"GUFS

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

    1ZUIPOิ׬ EFPQMFUFKFEJ (Pิ׬ EFPQMFUFHP KFEJ HPDPEF BVUPQFQ qBLF JTPSU ZBSQ CMBDL HPEFG JNQM JNQM HVSV HPMJOU ຊདྷ΍Γ͍ͨ͜ͱ ਖ਼֬Ͱߴ଎ͳϨεϙϯεͨΊʹ ΧϦΧϦͷνϡʔχϯά
  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 ड͚औΓқ͍ܗࣜ΁ͷύʔε
  37. #FGPSF"GUFS

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

    QZMT HPQMTCJOHP -41 ΤσΟλຖͷࠩ෼Λؾʹ͢Δඞཁ͸ͳ͍ ͦͯ͠-41ʹ͸ੑೳʹد༩͢Δ ϢʔςΟϦςΟతͳ.FUIPE΋ଘࡏ͠ɺ ੑೳ޲্ʹΑΓྗΛׂ͚Δ มΘͬͨ͜ͱ
  39. ΤσΟλϢʔβ  

  40. #FGPSF"GUFS

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

  42. KFEJ HPDPEF BVUPQFQ qBLF JTPSU ZBSQ CMBDL HPEFG JNQM JNQM

    HVSV HPMJOU ϦϯλʔϑΥʔϚολ ϓϥάΠϯ "-& ࣗಈิ׬ EFPQMFUF (PݴޠπʔϧϓϥάΠϯ WJNHP 1ZUIPOݴޠπʔϧϓϥάΠϯ KFEJWJN 1ZUIPOิ׬ EFPQMFUFKFEJ (Pิ׬ EFPQMFUFHP ࢓ํ͕ͳ͘΍Δ͜ͱ ָ͍͠ ݴޠϓϥάΠϯຖͷઃఆ w දࣔಈ࡞Φϓγϣϯ w ίϚϯυͷΩʔόΠϯυ
  43. 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 ͦͷଞ੩తղੳ
  44. #FGPSF"GUFS

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

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

    QZMT HPQMTCJOHP -41 มΘͬͨ͜ͱ ݴޠ։ൃπʔϧͷ౷߹ w ΠϯετʔϧηοτΞοϓͷলྗԽ ݴޠίϛϡχςΟ։ൃϦιʔεूதʹΑΔ ੑೳ޲্ w ߴ඼࣭ͳݴޠ։ൃػೳͷڗड
  47. 7JN ॻ͚Δʜίʔυ͕ॻ͚Δͧ $PEF มΘͬͨ͜ͱ

  48. એ఻  

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

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

    LSPิ׬ (deoplete- vim-lsp)
  51. None
  52. ·ͱΊ  

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