1

I am writing a major mode for a new programming language that looks very similar to Haskell, and so not surprisingly I am writing a derived mode from haskell-mode

(define-derived-mode foo-mode haskell-mode "foo mode"
  "Major mode for Foo"
...
)

Separately, I have lsp-mode enabled to run when I view a Haskell file in Emacs. Thus, every time I view a *.foo file in Emacs, lsp-mode is enabled with haskell-language-server as the lsp-backend.

I would like lsp to be disabled with I view a *.foo file (i.e. using the major mode foo-mode, but enabled when I view a .*hs file (i.e. using the major mode haskell-mode.) Is this possible?

One solution I tried, which did not work: In the .dirs-local.el file of this project, I added this line:

((foo-mode . ((eval . (lsp-mode -1)))))

which I thought would disable lsp-mode whenever the major mode foo is enabled, but lsp is still enabled in this case.

Any suggestions?

Emacs version:

GNU Emacs 27.2 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.20, cairo version 1.16.0) of 2021-11-04

mark
  • 113
  • 2

1 Answers1

1

Creating a wrapper like this and using it instead of lsp function should be good enough:

(defun my/lsp ()
  (unless (eq major-mode <REPLACE-ME-WITH-MAJOR-MODE>)
    (lsp)))