Skip to content

Commit 45ab3a8

Browse files
authored
feat: added odin language support through ols (#4818)
* feat: added odin language support through ols * fix: removed trace of omnisharp which i used as reference * fix: had duplicate function from testing * fix: f-join not handling nil made the cond a pcase and gave a defulat of the linux versions * fix: brace in wrong place
1 parent ff1a5b4 commit 45ab3a8

File tree

5 files changed

+128
-2
lines changed

5 files changed

+128
-2
lines changed

CHANGELOG.org

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
* Add Python(ty) support
4242
* Add support for [[https://github.com/tombi-toml/tombi][Tombi language server]] (TOML language).
4343
* Make lsp-headerline--check-breadcrumb public
44+
* Added Odin langauge server support [[https://github.com/DanielGavin/ols][ols]]
4445

4546
** 9.0.0
4647
* Add language server config for QML (Qt Modeling Language) using qmlls.

clients/lsp-odin.el

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
;;; lsp-odin.el --- Description -*- lexical-binding: t; -*-
2+
;;
3+
;; Copyright (C) 2025 Sam Precious
4+
;;
5+
;; Author: Sam Precious <samwdp@gmail.com>
6+
;; Keywords: lsp, odin
7+
;;
8+
;; This program is free software; you can redistribute it and/or modify
9+
;; it under the terms of the GNU General Public License as published by
10+
;; the Free Software Foundation, either version 3 of the License, or
11+
;; (at your option) any later version.
12+
13+
;; This program is distributed in the hope that it will be useful,
14+
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
;; GNU General Public License for more details.
17+
18+
;; You should have received a copy of the GNU General Public License
19+
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
20+
;;
21+
;;; Commentary:
22+
;;
23+
;; LSP client for Odin using the ols language server
24+
;;
25+
;;; Code:
26+
27+
(require 'lsp-mode)
28+
(require 'f)
29+
30+
(defgroup lsp-odin-ols nil
31+
"LSP support for Odin, using ols."
32+
:group 'lsp-mode
33+
:link '(url-link "https://github.com/DanielGavin/ols")
34+
:package-version '(lsp-mode . "9.0.0"))
35+
36+
(defcustom lsp-odin-ols-download-url
37+
(let ((suffix
38+
(pcase system-type
39+
('windows-nt
40+
(when (and (string-match "^x86_64-.*" system-configuration)
41+
(version<= "26.4" emacs-version))
42+
"ols-x86_64-pc-windows-msvc.zip"))
43+
('darwin
44+
(if (string-match "aarch64-.*" system-configuration)
45+
"ols-arm64-darwin.zip"
46+
"ols-x86_64-darwin.zip"))
47+
(_
48+
"ols-x86_64-unknown-linux-gnu"))))
49+
(when suffix
50+
(f-join "https://github.com/DanielGavin/ols/releases/download/nightly/"
51+
suffix)))
52+
"Automatic download url for ols language server."
53+
:group 'lsp-odin-ols
54+
:type 'string)
55+
56+
(defcustom lsp-odin-ols-server-install-dir
57+
(f-join lsp-server-install-dir "ols/")
58+
"Installation directory for ols server."
59+
:group 'lsp-odin-ols
60+
:type 'directory)
61+
62+
(defcustom lsp-odin-ols-store-path
63+
(f-join lsp-odin-ols-server-install-dir "latest" "ols.zip")
64+
"The path where ols .zip archive will be stored."
65+
:group 'lsp-odin-ols
66+
:type 'file)
67+
68+
(defcustom lsp-odin-ols-server-dir
69+
(f-join lsp-odin-ols-server-install-dir "latest" "ols")
70+
"The path where ols .zip archive will be extracted."
71+
:group 'lsp-odin-ols
72+
:type 'file)
73+
74+
(defcustom lsp-odin-ols-binary-path
75+
(f-join lsp-odin-ols-server-install-dir "latest"
76+
(pcase system-type
77+
('windows-nt
78+
"ols-x86_64-pc-windows-msvc.exe")
79+
('darwin
80+
(if (string-match "aarch64-.*" system-configuration)
81+
"ols-arm64-darwin"
82+
"ols-x86_64-darwin"))
83+
(_
84+
"ols-x86_64-unknown-linux-gnu")))
85+
"The path where ols binary after will be stored."
86+
:group 'lsp-odin-ols
87+
:type 'file)
88+
89+
90+
(lsp-dependency
91+
'ols
92+
`(:download :url lsp-odin-ols-download-url
93+
:decompress :zip
94+
:store-path lsp-odin-ols-store-path
95+
:binary-path lsp-odin-ols-binary-path
96+
:set-executable? t)
97+
'(:system "ols"))
98+
99+
(defun lsp-odin--ols-download-server (_client callback error-callback _update?)
100+
"Download zip package for ols and install it.
101+
Will invoke CALLBACK on success, ERROR-CALLBACK on error."
102+
(lsp-package-ensure 'ols callback error-callback))
103+
104+
(lsp-register-client
105+
(make-lsp-client :new-connection (lsp-stdio-connection lsp-odin-ols-binary-path)
106+
:major-modes '(odin-mode odin-ts-mode)
107+
:language-id "odin"
108+
:activation-fn (lsp-activate-on "odin")
109+
:server-id 'ols
110+
:multi-root t
111+
:download-server-fn #'lsp-odin--ols-download-server))
112+
113+
(provide 'lsp-odin)
114+
;;; lsp-odin.el ends here

docs/lsp-clients.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -798,6 +798,14 @@
798798
"installation-url": "https://github.com/ocaml-lsp/ocaml-language-server#server",
799799
"debugger": "Not available"
800800
},
801+
{
802+
"name": "ols",
803+
"full-name": "Odin Language Server",
804+
"server-name": "ols",
805+
"server-url": "https://github.com/DanielGavin/ols",
806+
"installation-url": "https://github.com/DanielGavin/ols",
807+
"debugger": "Not available"
808+
},
801809
{
802810
"name": "openscad",
803811
"full-name": "OpenSCAD",

lsp-mode.el

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ As defined by the Language Server Protocol 3.16."
184184
lsp-json lsp-kotlin lsp-kubernetes-helm lsp-latex lsp-lisp lsp-ltex
185185
lsp-ltex-plus lsp-lua lsp-fennel lsp-magik lsp-markdown lsp-marksman
186186
lsp-matlab lsp-mdx lsp-meson lsp-metals lsp-mint lsp-mojo lsp-move lsp-mssql
187-
lsp-nextflow lsp-nginx lsp-nim lsp-nix lsp-nushell lsp-ocaml lsp-openscad
187+
lsp-nextflow lsp-nginx lsp-nim lsp-nix lsp-nushell lsp-ocaml lsp-odin lsp-openscad
188188
lsp-pascal lsp-perl lsp-perlnavigator lsp-php lsp-pls lsp-postgres
189189
lsp-purescript lsp-pwsh lsp-pyls lsp-pylsp lsp-pyright lsp-python-ms lsp-python-ty
190190
lsp-qml lsp-r lsp-racket lsp-remark lsp-rf lsp-roc lsp-roslyn lsp-rubocop
@@ -1004,7 +1004,9 @@ Changes take effect only when a new session is started."
10041004
(yang-mode . "yang")
10051005
(matlab-mode . "matlab")
10061006
(message-mode . "plaintext")
1007-
(mu4e-compose-mode . "plaintext"))
1007+
(mu4e-compose-mode . "plaintext")
1008+
(odin-mode . "odin")
1009+
(odin-ts-mode . "odin"))
10081010
"Language id configuration.")
10091011

10101012
(defvar lsp--last-active-workspaces nil

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ nav:
132132
- Nix (nil): page/lsp-nix-nil.md
133133
- Nushell: page/lsp-nushell.md
134134
- OCaml (ocaml-lsp): page/lsp-ocaml-lsp-server.md
135+
- Odin (ols): page/lsp-odin-ols-server.md
135136
- OpenSCAD: page/lsp-openscad.md
136137
- Pascal/Object Pascal: page/lsp-pascal.md
137138
- Perl (PLS): page/lsp-pls.md

0 commit comments

Comments
 (0)