rescript-lang / rescript-lang/vim-rescript

Omni completion for items without documentation

Đang mở Phù hợp với người mới
#57 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Ngôn ngữ chính
Vim Script
Star
164
Fork
17
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

Under the hood, rescript-editor-analysis.exe returns null instead of an object/dict when a completion item has no documentation. This results in multiple errors in rescript#Complete.

A minimal example with vim-plug and the latest versions of vim-rescript and rescript (tested in VIM 8.2 and in Neovim 0.6.1):

~/.vimrc or ~/.config/nvim/init.vim:

call plug#begin()
Plug 'rescript-lang/vim-rescript'
call plug#end()

set omnifunc=rescript#Complete
set completeopt+=preview

Example.res:

let myInteger = 1
let myString = "2"

Also needed:

  • complete/completion mismatch fix: #56

Make sure the project is built. Type let my as the last line of Example.res and hit <C-x><C-o> in insert mode. You'll get the following errors twice:

Error detected while processing function rescript#Complete:
line   36:
E121: Undefined variable: value
Press ENTER or type command to continue
Error detected while processing function rescript#Complete:
line   38:
E121: Undefined variable: entry
Press ENTER or type command to continue
Error detected while processing function rescript#Complete:
line   38:
E116: Invalid arguments for function add(l:ret, entry)
Press ENTER or type command to continue

After hitting ENTER enough times:

-- Omni completion (^O^N^P) Pattern not found

I think the problem lies here:

https://github.com/rescript-lang/vim-rescript/blob/faeeb2deef1ad0ec67fc892ceeb9949f3bf2d77c/autoload/rescript.vim#L369

item.documentation is null for undocumented matches.

I tried to replace the offending line with the following, and now omni completion works both for built-in items and for undocumented local items (but I'm no expert in vimscript, so this may be a silly way to do it):

    if type(item.documentation) == v:t_dict
      let l:info = item.documentation.value
    else
      let l:info = item.detail " or some default value
    endif

    let entry = { 'word': item.label, 'kind': l:kind, 'info': l:info }

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu trong autoload/rescript.vim, quanh dòng 369, và build project trước khi tái hiện trường hợp completion từ issue trong Vim hoặc Neovim. Kiểm tra cách xử lý item.documentation khi nó là null, với bản sửa lỗi không khớp completion trong #56 làm ngữ cảnh. Được xem là hoàn tất khi các item cục bộ tích hợp sẵn và không có tài liệu được completion mà không xuất hiện các lỗi đã báo cáo.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
vim
Lĩnh vực
tooling
Loại issue
Lỗi
Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Đặc tả rõ ràng
Mức phù hợp với người mới
68/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.