File tree Expand file tree Collapse file tree 1 file changed +17
-3
lines changed Expand file tree Collapse file tree 1 file changed +17
-3
lines changed Original file line number Diff line number Diff line change 142
142
(setq args (append args lsp-golangci-lint-run-args)))
143
143
args))
144
144
145
+ (defun lsp-golangci-lint--get-version ()
146
+ " Get the version of golangci-lint."
147
+ (with-temp-buffer
148
+ (when (= 0 (call-process lsp-golangci-lint-path nil t nil " version" ))
149
+ (goto-char (point-min ))
150
+ (when (re-search-forward " has version \\ ([0-9]+\\ )\\ ." nil t )
151
+ (string-to-number (match-string 1 ))))))
152
+
145
153
(defun lsp-golangci-lint--get-initialization-options ()
146
154
" Return initialization options for golangci-lint-langserver."
147
- (let ((opts (make-hash-table :test 'equal ))
148
- (command (vconcat `(, lsp-golangci-lint-path )
149
- [" run" " --out-format=json" " --issues-exit-code=1" ]
155
+ (let* ((opts (make-hash-table :test 'equal ))
156
+ (version (lsp-golangci-lint--get-version))
157
+ (format-args (if (and version (>= version 2 ))
158
+ [" --output.json.path" " stdout" " --show-stats=false" ]
159
+ [" --out-format" " json" ]))
160
+ (command (vconcat `(, lsp-golangci-lint-path )
161
+ [" run" ]
162
+ format-args
163
+ [" --issues-exit-code=1" ]
150
164
(lsp-golangci-lint--run-args))))
151
165
(puthash " command" command opts)
152
166
opts))
You can’t perform that action at this time.
0 commit comments