Skip to content

Update customisation options to match the vscode extension #173

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions CONTIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Contributing to lsp-haskell
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great stuff, thanks


## Updating the configuration options for lsp-haskell

1. Generate the vscode settings file

```sh
haskell-language-server-9.6.2 vscode-extension-schema > /tmp/schema.json
```
Add `{"contributes": {"configuration": { "properties":`
to the top and
`}}}` to the bottom.

2. Generate the settings snippet

Make sure you have https://github.com/emacs-lsp/lsp-mode/blob/master/scripts/lsp-generate-settings.el
on your machine somewhere. In this example it is at `/tmp/lsp-generate-settings.el`

In emacs, activate IELM, `M-x ielm`

In IELM,

```elisp
(load-library "/tmp/lsp-generate-settings.el")
;; Do direct output to buffer
(defun p (x) (move-end-of-line 0) (insert (format "\n%s" x)))
(p (lsp-generate-settings "/tmp/schema.json" 'lsp-haskell))
```

This will emit settings that do not currently exist in the running
emacs instance.

Edit them into [lsp-haskell.el](./lsp-haskell.el)
57 changes: 53 additions & 4 deletions lsp-haskell.el
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,15 @@

(defcustom-lsp lsp-haskell-formatting-provider
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could migrate these to lsp-defcustom while we're at it. Not sure if it's just a rename or what

"ormolu"
"The formatter to use when formatting a document or range. Ensure the plugin is enabled."
"The formatter to use when formatting a document or range.
Ensure the plugin is enabled."
:group 'lsp-haskell
:type '(choice (const "brittany") (const "floskell") (const "fourmolu") (const "ormolu") (const "stylish-haskell") (const "none"))
:lsp-path "haskell.formattingProvider")
(defcustom-lsp lsp-haskell-check-project
t
"Whether to typecheck the entire project on load. It could lead to bad perfomance in large projects."
"Whether to typecheck the entire project on load.
It could lead to bad perfomance in large projects."
:group 'lsp-haskell
:type 'boolean
:lsp-path "haskell.checkProject")
Expand Down Expand Up @@ -150,7 +152,9 @@
:lsp-path "haskell.plugin.tactics.globalOn")
(defcustom-lsp lsp-haskell-plugin-tactics-config-auto-gas
4
"The depth of the search tree when performing \"Attempt to fill hole\". Bigger values will be able to derive more solutions, but will take exponentially more time."
"The depth of the search tree when performing \"Attempt to fill hole\".
Bigger values will be able to derive more solutions,
but will take exponentially more time."
:group 'lsp-haskell-plugins
:type 'number
:lsp-path "haskell.plugin.tactics.config.auto_gas")
Expand Down Expand Up @@ -221,6 +225,51 @@
:type 'boolean
:lsp-path "haskell.plugin.refineImports.globalOn")

;; Updated for haskell-language-server 2.1.0.0

(lsp-defcustom lsp-haskell-plugin-cabal-code-actions-on t
"Enables cabal code actions"
:type 'boolean
:group 'lsp-haskell-plugins
:package-version '(lsp-mode . "8.0.1")
:lsp-path "haskell.plugin.cabal.codeActionsOn")

(lsp-defcustom lsp-haskell-plugin-cabal-completion-on t
"Enables cabal completions"
:type 'boolean
:group 'lsp-haskell-plugins
:package-version '(lsp-mode . "8.0.1")
:lsp-path "haskell.plugin.cabal.completionOn")


(lsp-defcustom lsp-haskell-plugin-overloaded-record-dot-global-on t
"Enables overloaded-record-dot plugin"
:type 'boolean
:group 'lsp-haskell-plugins
:package-version '(lsp-mode . "8.0.1")
:lsp-path "haskell.plugin.overloaded-record-dot.globalOn")

(lsp-defcustom lsp-haskell-plugin-pragmas-completion-global-on t
"Enables pragmas-completion plugin"
:type 'boolean
:group 'lsp-haskell-plugins
:package-version '(lsp-mode . "8.0.1")
:lsp-path "haskell.plugin.pragmas-completion.globalOn")

(lsp-defcustom lsp-haskell-plugin-pragmas-disable-global-on t
"Enables pragmas-disable plugin"
:type 'boolean
:group 'lsp-haskell-plugins
:package-version '(lsp-mode . "8.0.1")
:lsp-path "haskell.plugin.pragmas-disable.globalOn")

(lsp-defcustom lsp-haskell-plugin-pragmas-suggest-global-on t
"Enables pragmas-suggest plugin"
:type 'boolean
:group 'lsp-haskell-plugins
:package-version '(lsp-mode . "8.0.1")
:lsp-path "haskell.plugin.pragmas-suggest.globalOn")

;; ---------------------------------------------------------------------
;; Non-language server options

Expand Down Expand Up @@ -298,7 +347,7 @@ and `lsp-haskell-server-args' and `lsp-haskell-server-wrapper-function'."
:major-modes '(haskell-mode haskell-literate-mode haskell-tng-mode haskell-cabal-mode)
;; This is arbitrary.
:server-id 'lsp-haskell
;; HLS does not currently send 'workspace/configuration' on startup (https://github.com/haskell/haskell-language-server/issues/2762),
;; HLS does not currently send 'workspace/configuration' on startup (https://github.com/haskell/haskell-language-server/issues/2762),
;; so we need to push the configuration to it manually on startup. We should be able to
;; get rid of this once the issue is fixed in HLS.
:initialized-fn (lambda (workspace)
Expand Down