From ecc9ab25f3be16cedcbe3a0ed54c0fc2f43d4137 Mon Sep 17 00:00:00 2001 From: Juergen Hoetzel Date: Thu, 17 May 2018 18:30:00 +0200 Subject: [PATCH 1/6] F# script files doesn't need to exist to be parsed Fixes #167 --- fsharp-mode-completion.el | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/fsharp-mode-completion.el b/fsharp-mode-completion.el index 5cd0efb..b6a6cce 100644 --- a/fsharp-mode-completion.el +++ b/fsharp-mode-completion.el @@ -246,9 +246,8 @@ For indirect buffers return the truename of the base buffer." (defun fsharp-ac/load-file (file) "Start the compiler binding for an individual F# script FILE." - (when (and (fsharp-ac--script-file-p file) (file-exists-p file)) - (unless (fsharp-ac--process-live-p (fsharp-ac--hostname file)) - (fsharp-ac/start-process)) + (when (and (fsharp-ac--script-file-p file) (not (fsharp-ac--process-live-p (fsharp-ac--hostname file)))) + (fsharp-ac/start-process) (add-hook 'after-save-hook 'fsharp-ac--load-after-save nil 'local))) (defun fsharp-ac--load-after-save () From 5fa66d456e98e2a3098f4d3fd318e0251878d29a Mon Sep 17 00:00:00 2001 From: Juergen Hoetzel Date: Thu, 17 May 2018 18:30:00 +0200 Subject: [PATCH 2/6] Fix invalid use of `delq' --- fsharp-mode-completion.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fsharp-mode-completion.el b/fsharp-mode-completion.el index b6a6cce..cb6b849 100644 --- a/fsharp-mode-completion.el +++ b/fsharp-mode-completion.el @@ -84,7 +84,8 @@ If set to nil, display in a help buffer instead.") (push (cons host process) fsharp-ac-completion-process-alist)) (defun fsharp-ac-completion-process-del (host) - (delq (assoc host fsharp-ac-completion-process-alist) fsharp-ac-completion-process-alist)) + (setq fsharp-ac-completion-process-alist + (delq (assoc host fsharp-ac-completion-process-alist) fsharp-ac-completion-process-alist))) (defvar fsharp-ac--project-data (make-hash-table :test 'equal) "Data returned by fsautocomplete for loaded projects.") From 4f5eca51e89b15d0cb95be2e89e089f0dd726d34 Mon Sep 17 00:00:00 2001 From: Juergen Hoetzel Date: Thu, 17 May 2018 18:30:00 +0200 Subject: [PATCH 3/6] Add flycheck verify function Refs #165. --- flycheck-fsharp.el | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/flycheck-fsharp.el b/flycheck-fsharp.el index de069d5..fa88e20 100644 --- a/flycheck-fsharp.el +++ b/flycheck-fsharp.el @@ -37,6 +37,21 @@ (defun flycheck-fsharp--can-make-request-p () (fsharp-ac-can-make-request t)) +(defun flycheck-verify-fsautocomlete (_checker) + "Verify the F# syntax checker." + (let* ((host (fsharp-ac--hostname (buffer-file-name))) + (process (fsharp-ac-completion-process host)) + (status (when process (process-status process))) + (command (when process (combine-and-quote-strings (process-command process))))) + (list + (flycheck-verification-result-new + :label "FSharp.AutoComplete process" + :message (cond + ((eq status 'run) command) + (status (format "Invalid process status: %s (%s)" command status)) + ("not running")) + :face (if (eq status 'run) 'success '(bold error)))))) + (defun flycheck-fsharp-fsautocomplete-lint-start (checker callback) "Start a F# syntax check with CHECKER. CALLBACK is the status callback passed by Flycheck." @@ -52,6 +67,7 @@ CALLBACK is the status callback passed by Flycheck." See URL `https://github.com/fsharp/FsAutoComplete'." :start #'flycheck-fsharp-fsautocomplete-lint-start :predicate #'flycheck-fsharp--can-make-request-p + :verify #'flycheck-verify-fsautocomlete :modes '(fsharp-mode)) (defvar flycheck-fsharp--error-callback-info nil) @@ -68,6 +84,7 @@ See URL `https://github.com/fsharp/FsAutoComplete'." :start #'flycheck-fsharp-fsautocomplete-start :modes '(fsharp-mode) :predicate #'flycheck-fsharp--can-make-request-p + :verify #'flycheck-verify-fsautocomlete :next-checkers '((info . fsharp-fsautocomplete-lint))) (defun flycheck-fsharp-handle-lint (data) From fe8192bf198fcfc240f99092bcd3a43be983fda7 Mon Sep 17 00:00:00 2001 From: Juergen Hoetzel Date: Fri, 18 May 2018 18:31:00 +0200 Subject: [PATCH 4/6] fsharp-ac--in-project-p: Add docstring --- fsharp-mode-completion.el | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fsharp-mode-completion.el b/fsharp-mode-completion.el index cb6b849..e8c24b2 100644 --- a/fsharp-mode-completion.el +++ b/fsharp-mode-completion.el @@ -270,6 +270,9 @@ For indirect buffers return the truename of the base buffer." (downcase (file-name-extension file))))) (defun fsharp-ac--in-project-p (file) + "Return F# project file for source FILE. + +Return nil if FILE is not part of a F# project." (gethash file fsharp-ac--project-files)) (defun fsharp-ac--reset () From b44f8a2d47dbbffec8d27034f16ca982e4cd1201 Mon Sep 17 00:00:00 2001 From: Juergen Hoetzel Date: Fri, 18 May 2018 18:31:00 +0200 Subject: [PATCH 5/6] Flycheck verify: show project information Refs #165 --- flycheck-fsharp.el | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/flycheck-fsharp.el b/flycheck-fsharp.el index fa88e20..262f39d 100644 --- a/flycheck-fsharp.el +++ b/flycheck-fsharp.el @@ -41,16 +41,22 @@ "Verify the F# syntax checker." (let* ((host (fsharp-ac--hostname (buffer-file-name))) (process (fsharp-ac-completion-process host)) + (project-file (when process (fsharp-ac--in-project-p (buffer-file-name)))) (status (when process (process-status process))) (command (when process (combine-and-quote-strings (process-command process))))) - (list + (cons (flycheck-verification-result-new :label "FSharp.AutoComplete process" :message (cond ((eq status 'run) command) (status (format "Invalid process status: %s (%s)" command status)) ("not running")) - :face (if (eq status 'run) 'success '(bold error)))))) + :face (if (eq status 'run) 'success '(bold error))) + (when (eq status 'run) + (list (flycheck-verification-result-new + :label "F# Project" + :message (or project-file "None") + :face (if project-file 'success '(bold warning)))))))) (defun flycheck-fsharp-fsautocomplete-lint-start (checker callback) "Start a F# syntax check with CHECKER. From 385c67def6d6ce39ab89d7f44161e9549e06377c Mon Sep 17 00:00:00 2001 From: Juergen Hoetzel Date: Fri, 18 May 2018 18:31:00 +0200 Subject: [PATCH 6/6] Flycheck verify: display loaded projects Fixes #165 Refs #166 --- flycheck-fsharp.el | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/flycheck-fsharp.el b/flycheck-fsharp.el index 262f39d..3e111f6 100644 --- a/flycheck-fsharp.el +++ b/flycheck-fsharp.el @@ -41,8 +41,9 @@ "Verify the F# syntax checker." (let* ((host (fsharp-ac--hostname (buffer-file-name))) (process (fsharp-ac-completion-process host)) - (project-file (when process (fsharp-ac--in-project-p (buffer-file-name)))) (status (when process (process-status process))) + (project-file (when (eq status 'run) (fsharp-ac--in-project-p (buffer-file-name)))) + (projects (when (eq status 'run) (hash-table-keys fsharp-ac--project-data))) (command (when process (combine-and-quote-strings (process-command process))))) (cons (flycheck-verification-result-new @@ -56,7 +57,13 @@ (list (flycheck-verification-result-new :label "F# Project" :message (or project-file "None") - :face (if project-file 'success '(bold warning)))))))) + :face (if project-file 'success '(bold warning))) + (flycheck-verification-result-new + :label "Loaded Projects" + :message (if projects + (mapconcat #'identity projects ", ") + "No projects loaded") + :face (if projects 'success '(bold warning)))))))) (defun flycheck-fsharp-fsautocomplete-lint-start (checker callback) "Start a F# syntax check with CHECKER.