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

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

    4PVSDFHSBQIFUD ݴޠίϛϡχςΟͷ։ൃϦιʔεΛ-BOHVBHF 4FSWFSʹूதͯ͠ߴ඼࣭ͳݴޠ։ൃπʔϧΛ࡞Δ Ϣʔβ͸-41ΛαϙʔτΫϥΠΞϯτΛಋೖͯ͠ ͙͢ʹߴ඼࣭ͳݴޠͷαϙʔτΛڗडͰ͖Δ ͋ͱͰৄ͘͠࿩͠·͢ -BOHVBHF4FSWFS͸ͳͥඞཁ͔
  3. .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ݴޠ։ൃπʔϧ * αʔυύʔςΟ੡πʔϧ
  4. .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Λऔಘͨ݁͠Ռ
  5. KFEJ HPDPEF BVUPQFQ qBLF JTPSU ZBSQ CMBDL HPEFG JNQM JNQM

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

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

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

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

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

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

    Client (vim-lsp) -41 ͪ͜ΒʹूதͰ͖Δ มΘͬͨ͜ͱ -41Ͱ࢓༷͕౷Ұ͞Ε͍ͯΔ͔Β -BOHVBHF4FSWFSΛม͑ͯ΋ݸผରԠඞཁφγ
  12. 7JN ϦϯλʔϑΥʔϚολ ϓϥάΠϯ "-& ࣗಈิ׬ EFPQMFUF (PݴޠπʔϧϓϥάΠϯ WJNHP 1ZUIPOݴޠπʔϧϓϥάΠϯ KFEJWJN

    1ZUIPOิ׬ EFPQMFUFKFEJ (Pิ׬ EFPQMFUFHP KFEJ HPDPEF BVUPQFQ qBLF JTPSU ZBSQ CMBDL HPEFG JNQM JNQM HVSV HPMJOU ຊདྷ΍Γ͍ͨ͜ͱ ਖ਼֬Ͱߴ଎ͳϨεϙϯεͨΊʹ ΧϦΧϦͷνϡʔχϯά
  13. 7JN ϦϯλʔϑΥʔϚολ ϓϥάΠϯ "-& ࣗಈิ׬ EFPQMFUF (PݴޠπʔϧϓϥάΠϯ WJNHP 1ZUIPOݴޠπʔϧϓϥάΠϯ KFEJWJN

    1ZUIPOิ׬ EFPQMFUFKFEJ (Pิ׬ EFPQMFUFHP KFEJ HPDPEF BVUPQFQ qBLF JTPSU ZBSQ CMBDL HPEFG JNQM JNQM HVSV HPMJOU ࢓ํ͕ͳ͘΍Δ͜ͱ ΤσΟλຖͷݸผରԠ w ΤσΟλ͕ड͚औΓՄೳͳग़ྗ w ड͚औΓқ͍ܗࣜ΁ͷύʔε
  14. ࣗಈิ׬ (deoplete) LSPิ׬ (deoplete- vim-lsp) 7JN Language Server Client (vim-lsp)

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

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

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

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