Skip to content
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

How to add odin-mode with ols server lsp of Odin to EMACS with elpaca package manager in Linux. #13

Open
joaocarvalhoopen opened this issue Dec 9, 2023 · 2 comments

Comments

@joaocarvalhoopen
Copy link

Hello,

I would like to say here what I did in Linux (with the help of "the weak") to make this work with the elpaca package manager:

I hope that this will help others.

1º Download the OLS to the designated directory and compile it.
2º Download the odin-mode and copy to the designated directory.

3º Then in the init.el add the following:

(add-to-list 'load-path "/home/joaocarvalho/.config/emacs/elpaca/repos/odin-mode")
(add-to-list 'load-path "/home/joaocarvalho/odin/ols")

(require 'odin-mode)

; Odin
;; With odin-mode (https://github.com/mattt-b/odin-mode) and lsp-mode already added to your init.el of course!.
(setq-default lsp-auto-guess-root t) ;; if you work with Projectile/project.el this will help find the ols.json file.
(defvar lsp-language-id-configuration '((odin-mode . "odin")))


(use-package lsp-mode
  :hook ((python-mode . lsp)
         (javascript-mode . lsp)
         (odin-mode . lsp))
  :commands lsp
  :config
  (lsp-register-client
    (make-lsp-client :new-connection (lsp-stdio-connection "/home/joaocarvalho/odin/ols/ols")
                  :major-modes '(odin-mode)
                  :server-id 'ols
                  :multi-root t)) ;; This is just so lsp-mode sends the "workspaceFolders" param to the server.
  ; (setq lsp-prefer-flymake nil)) ; Or lsp-prefer-capf if you prefer LSP's completion over company-mode
) 

(use-package lsp-ui)

Best regards,

@a3ru
Copy link

a3ru commented Jun 28, 2024

image
I'm using doom emacs bdw.

;; Odin LSP

(setq-default lsp-auto-guess-root t)
(defvar lsp-language-id-configuration '((odin-mode . "odin")))


  (use-package lsp-mode
    :hook ((python-mode . lsp)
           (javascript-mode . lsp)
           (odin-mode . lsp))
    :commands lsp
    :config
    (make-lsp-client :new-connection (lsp-stdio-connection "ols")
                     :major-modes '(odin-mode)
                     :server-id 'ols
                     :multi-root t))

It didn't work for me.

@samwdp
Copy link

samwdp commented Oct 17, 2024

@a3ru if you didn't get this to work already you need to do the following

in your packages.el you need to put the following

 (package! odin-mode
   :recipe (:host github :repo "mattt-b/odin-mode"))

run a doom sync command

then in your config.el put this somewhere, probably at the bottom

;; Enable odin-mode and configure OLS as the language server
(use-package! odin-mode
  :mode ("\\.odin\\'" . odin-mode)
  :hook (odin-mode . lsp))

;; Set up OLS as the language server for Odin, ensuring lsp-mode is loaded first
(with-eval-after-load 'lsp-mode
  (setq-default lsp-auto-guess-root t) ;; Helps find the ols.json file with Projectile or project.el
  (setq lsp-language-id-configuration (cons '(odin-mode . "odin") lsp-language-id-configuration))

  (lsp-register-client
    (make-lsp-client :new-connection (lsp-stdio-connection "ols OR path_to_ols_binary")
                    :major-modes '(odin-mode)
                    :server-id 'ols
                    :multi-root t))) ;; Ensures lsp-mode sends "workspaceFolders" to the server

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants