From cd882069b9ebbd20575545f44a0d006cc2e4bccd Mon Sep 17 00:00:00 2001 From: Montmorency Date: Sat, 2 Mar 2024 21:29:08 +0000 Subject: [PATCH] Emacs direnv (#1872) * emacs direnv and lsp config. * added link to emacs config for direnv/nix haskell. --- Guide/editors.markdown | 64 ++++++++++++++++++++++++++++++++++ Guide/search/package-lock.json | 58 ++++++++++++++++++++++++++++++ 2 files changed, 122 insertions(+) diff --git a/Guide/editors.markdown b/Guide/editors.markdown index 26f78b3c4..76de50f3e 100644 --- a/Guide/editors.markdown +++ b/Guide/editors.markdown @@ -149,6 +149,70 @@ and `chmod +x ~/bin/emacs-line`, then export this env var in your shell (e.g. in export IHP_EDITOR="$HOME/bin/emacs-line" ``` +Another useful package set that integrates with lsp/lsp-ui and loads the default nix environment from direnv as well as removing [common flycheck issue](https://github.com/joncol/dotfiles/blob/master/homedir/.emacs.d/init.el). +This config also adds a jump to definition for functions bound to "C-c p": + +```emacs +(use-package direnv + :defer + :custom + (direnv-always-show-summary nil) + :config + (direnv-mode)) +(use-package lsp-mode + :custom + (lsp-lens-enable nil) + (lsp-enable-symbol-highlighting nil) + + :hook + (lsp-mode . lsp-enable-which-key-integration) + + :config + ;; This is to make `lsp-mode' work with `direnv' and pick up the correct + ;; version of GHC. + (advice-add 'lsp :before #'direnv-update-environment) + (setq lsp-modeline-code-actions-enable nil)) + +(use-package lsp-ui + :hook (prog-mode . lsp-ui-mode) + :bind (("C-c p" . lsp-ui-peek-find-definitions)) + :config + (setq lsp-ui-doc-position 'bottom)) + +;; (add-hook 'haskell-mode-hook #'lsp) +(use-package flycheck-haskell + ;; Disabling this package, since it only gives error: + ;; "Reading Haskell configuration failed with exit code Segmentation fault and + ;; output:", when trying to run it in Nix/direnv setup. + :disabled + :hook (haskell-mode . flycheck-haskell-setup)) + +(add-hook 'haskell-mode-hook + (lambda () + (rainbow-mode -1) +;; we aren't evil: +;; (evil-leader/set-key "x h" 'haskell-hoogle) +;; (setq evil-shift-width 2) + (define-key haskell-mode-map (kbd "C-c C-c C-s") + 'haskell-mode-stylish-buffer) + (bind-key (kbd "C-c C-c C-a") 'haskell-sort-imports) + (setq haskell-auto-insert-module-format-string + "module %s\n () where\n\n") + (haskell-auto-insert-module-template) + (smartparens-mode) + (sp-local-pair 'haskell-mode "{" "}") + (setq haskell-hoogle-command nil) + (ligature-mode))) + +(use-package lsp-haskell + :hook ((haskell-mode . lsp-deferred) + (haskell-literate-mode . lsp-deferred)) + :custom + (lsp-haskell-server-path "haskell-language-server")) + +(use-package haskell-mode + :defer) +``` ## Using IHP with Vim / NeoVim diff --git a/Guide/search/package-lock.json b/Guide/search/package-lock.json index c41bd2464..4e84da9b5 100644 --- a/Guide/search/package-lock.json +++ b/Guide/search/package-lock.json @@ -177,6 +177,29 @@ "react-dom": ">= 16.8.0 < 18.0.0" } }, + "node_modules/@types/prop-types": { + "version": "15.7.11", + "resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.11.tgz", + "integrity": "sha512-ga8y9v9uyeiLdpKddhxYQkxNDrfvuPrlFb0N1qnZZByvcElJaXthF1UhvCh9TLWJBEHeNtdnbysW7Y6Uq8CVng==", + "peer": true + }, + "node_modules/@types/react": { + "version": "17.0.71", + "resolved": "https://registry.npmjs.org/@types/react/-/react-17.0.71.tgz", + "integrity": "sha512-lfqOu9mp16nmaGRrS8deS2Taqhd5Ih0o92Te5Ws6I1py4ytHBcXLqh0YIqVsViqwVI5f+haiFM6hju814BzcmA==", + "peer": true, + "dependencies": { + "@types/prop-types": "*", + "@types/scheduler": "*", + "csstype": "^3.0.2" + } + }, + "node_modules/@types/scheduler": { + "version": "0.16.8", + "resolved": "https://registry.npmjs.org/@types/scheduler/-/scheduler-0.16.8.tgz", + "integrity": "sha512-WZLiwShhwLRmeV6zH+GkbOFT6Z6VklCItrDioxUnv+u4Ll+8vKeFySoFyK/0ctcRpOmwAicELfmys1sDc/Rw+A==", + "peer": true + }, "node_modules/algoliasearch": { "version": "4.10.5", "resolved": "https://registry.npmjs.org/algoliasearch/-/algoliasearch-4.10.5.tgz", @@ -198,6 +221,12 @@ "@algolia/transporter": "4.10.5" } }, + "node_modules/csstype": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.2.tgz", + "integrity": "sha512-I7K1Uu0MBPzaFKg4nI5Q7Vs2t+3gWWW648spaF+Rg7pI9ds18Ugn+lvg4SHczUdKlHI5LWBXyqfS8+DufyBsgQ==", + "peer": true + }, "node_modules/esbuild": { "version": "0.13.2", "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.13.2.tgz", @@ -629,6 +658,29 @@ "algoliasearch": "^4.0.0" } }, + "@types/prop-types": { + "version": "15.7.11", + "resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.11.tgz", + "integrity": "sha512-ga8y9v9uyeiLdpKddhxYQkxNDrfvuPrlFb0N1qnZZByvcElJaXthF1UhvCh9TLWJBEHeNtdnbysW7Y6Uq8CVng==", + "peer": true + }, + "@types/react": { + "version": "17.0.71", + "resolved": "https://registry.npmjs.org/@types/react/-/react-17.0.71.tgz", + "integrity": "sha512-lfqOu9mp16nmaGRrS8deS2Taqhd5Ih0o92Te5Ws6I1py4ytHBcXLqh0YIqVsViqwVI5f+haiFM6hju814BzcmA==", + "peer": true, + "requires": { + "@types/prop-types": "*", + "@types/scheduler": "*", + "csstype": "^3.0.2" + } + }, + "@types/scheduler": { + "version": "0.16.8", + "resolved": "https://registry.npmjs.org/@types/scheduler/-/scheduler-0.16.8.tgz", + "integrity": "sha512-WZLiwShhwLRmeV6zH+GkbOFT6Z6VklCItrDioxUnv+u4Ll+8vKeFySoFyK/0ctcRpOmwAicELfmys1sDc/Rw+A==", + "peer": true + }, "algoliasearch": { "version": "4.10.5", "resolved": "https://registry.npmjs.org/algoliasearch/-/algoliasearch-4.10.5.tgz", @@ -650,6 +702,12 @@ "@algolia/transporter": "4.10.5" } }, + "csstype": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.2.tgz", + "integrity": "sha512-I7K1Uu0MBPzaFKg4nI5Q7Vs2t+3gWWW648spaF+Rg7pI9ds18Ugn+lvg4SHczUdKlHI5LWBXyqfS8+DufyBsgQ==", + "peer": true + }, "esbuild": { "version": "0.13.2", "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.13.2.tgz",