Skip to content

Commit 6b406a4

Browse files
Merge pull request #170 from juergenhoetzel/flycheck-verify
Flycheck verify (WIP)
2 parents a5a8298 + 385c67d commit 6b406a4

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

flycheck-fsharp.el

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,34 @@
3737
(defun flycheck-fsharp--can-make-request-p ()
3838
(fsharp-ac-can-make-request t))
3939

40+
(defun flycheck-verify-fsautocomlete (_checker)
41+
"Verify the F# syntax checker."
42+
(let* ((host (fsharp-ac--hostname (buffer-file-name)))
43+
(process (fsharp-ac-completion-process host))
44+
(status (when process (process-status process)))
45+
(project-file (when (eq status 'run) (fsharp-ac--in-project-p (buffer-file-name))))
46+
(projects (when (eq status 'run) (hash-table-keys fsharp-ac--project-data)))
47+
(command (when process (combine-and-quote-strings (process-command process)))))
48+
(cons
49+
(flycheck-verification-result-new
50+
:label "FSharp.AutoComplete process"
51+
:message (cond
52+
((eq status 'run) command)
53+
(status (format "Invalid process status: %s (%s)" command status))
54+
("not running"))
55+
:face (if (eq status 'run) 'success '(bold error)))
56+
(when (eq status 'run)
57+
(list (flycheck-verification-result-new
58+
:label "F# Project"
59+
:message (or project-file "None")
60+
:face (if project-file 'success '(bold warning)))
61+
(flycheck-verification-result-new
62+
:label "Loaded Projects"
63+
:message (if projects
64+
(mapconcat #'identity projects ", ")
65+
"No projects loaded")
66+
:face (if projects 'success '(bold warning))))))))
67+
4068
(defun flycheck-fsharp-fsautocomplete-lint-start (checker callback)
4169
"Start a F# syntax check with CHECKER.
4270
CALLBACK is the status callback passed by Flycheck."
@@ -52,6 +80,7 @@ CALLBACK is the status callback passed by Flycheck."
5280
See URL `https://github.com/fsharp/FsAutoComplete'."
5381
:start #'flycheck-fsharp-fsautocomplete-lint-start
5482
:predicate #'flycheck-fsharp--can-make-request-p
83+
:verify #'flycheck-verify-fsautocomlete
5584
:modes '(fsharp-mode))
5685

5786
(defvar flycheck-fsharp--error-callback-info nil)
@@ -68,6 +97,7 @@ See URL `https://github.com/fsharp/FsAutoComplete'."
6897
:start #'flycheck-fsharp-fsautocomplete-start
6998
:modes '(fsharp-mode)
7099
:predicate #'flycheck-fsharp--can-make-request-p
100+
:verify #'flycheck-verify-fsautocomlete
71101
:next-checkers '((info . fsharp-fsautocomplete-lint)))
72102

73103
(defun flycheck-fsharp-handle-lint (data)

fsharp-mode-completion.el

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ If set to nil, display in a help buffer instead.")
8484
(push (cons host process) fsharp-ac-completion-process-alist))
8585

8686
(defun fsharp-ac-completion-process-del (host)
87-
(delq (assoc host fsharp-ac-completion-process-alist) fsharp-ac-completion-process-alist))
87+
(setq fsharp-ac-completion-process-alist
88+
(delq (assoc host fsharp-ac-completion-process-alist) fsharp-ac-completion-process-alist)))
8889

8990
(defvar fsharp-ac--project-data (make-hash-table :test 'equal)
9091
"Data returned by fsautocomplete for loaded projects.")
@@ -269,6 +270,9 @@ For indirect buffers return the truename of the base buffer."
269270
(downcase (file-name-extension file)))))
270271

271272
(defun fsharp-ac--in-project-p (file)
273+
"Return F# project file for source FILE.
274+
275+
Return nil if FILE is not part of a F# project."
272276
(gethash file fsharp-ac--project-files))
273277

274278
(defun fsharp-ac--reset ()

0 commit comments

Comments
 (0)