Consider a more imperative formatter API
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 25/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Cần làm rõ
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- vim
- Lĩnh vực
- tooling
Hướng nghiên cứu
Bắt đầu bằng việc xem xét các triển khai FormatRange hiện có và cách codefmt gọi chúng; không có tệp hoặc kiểm thử cụ thể nào được nêu tên. Đánh giá các thao tác formattable được đề xuất, bao gồm GetLines, SetLines, SetCursor và AddError, trong mối tương quan với việc xử lý phạm vi và hành vi quickfix. Hoàn thành nghĩa là đã thống nhất thiết kế API và xác định được lộ trình di chuyển cho các formatter.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Formatters right now take a range and modify the buffer as a side-effect, e.g.
function someformatter.FormatRange(startline, endline) abort
let l:lines = getline(1, line('$'))
let l:result = maktaba#syscall#Create(…).WithStdin(join(l:lines, "\n")).Call()
call maktaba#buffer#Overwrite(1, line('$'), split(l:result.stdout, "\n"))
endfunction
codefmt itself has very little insight into what the formatter is doing, and the amount of boilerplate is also a little annoying. Things can get weird if e.g. FormatRange is called multiple times to process multiple ranges, especially with formatters that try to populate errors into the quickfix list.
A different approach would be to pass a codefmt handle and implement formatter operations in terms of that handle, like
formattable.GetLines([start], [end])formattable.SetLines({lines})formattable.SetLines({start}, {end}, {lines})formattable.SetCursor({row}, {col})formattable.AddError({error}, [row], [col])
A simple formatter would look like
function someformatter.FormatRange(startline, endline, formattable) abort
let l:input = join(a:formattable.GetLines(), "\n")
let l:result = maktaba#syscall#Create(…).WithStdin(l:input).Call()
call a:formattable.SetLines(l:result.stdout)
endfunction
Some advantages are that it can make some formatting operations more convenient and anti-patterns like overwriting files on disk less natural. If we run into wonkiness as we enable fancy features like format-changed-lines-on-save (multiple ranges), it could help solve issues like that, too.
- Ngôn ngữ chính
- Vim Script
- Star
- 1.1k
- Fork
- 102
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của google/vim-codefmt
-
Write a codefmt FAQ Đang mởenhancement
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 68/100
google/vim-codefmt#53 ·
-
Add meson format Đang mởnew formatter
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 45/100
google/vim-codefmt#243 ·
-
LCF for lua formatting Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 52/100
google/vim-codefmt#240 · 1 bình luận ·
-
Add `:CodefmtInfo` command to report diagnostics to help users check config / diagnose problems Đang mởenhancement
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
google/vim-codefmt#234 · 2 bình luận ·
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 45/100
google/vim-codefmt#222 · 3 bình luận ·
Tất cả issue của google/vim-codefmt
Issue tương tự
-
sponsored
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
microsoft/navcontainerhelper#4217 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
use-agent-os/agent-os#3314 ·
-
[aw] Upgrade available Đang mởagentic-workflows
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
githubnext/rig#534 ·
-
Implement GitHub Issue templates Đang mởdocumentation low-priority templates
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
jesseray718/openroot#87 ·