Skip to content

Commit b7bc24d

Browse files
authored
basic support for c3 language. (#4699)
* basic support for c3 language. * Update docs/lsp-clients.json * Update docs/lsp-clients.json
1 parent 58c9fca commit b7bc24d

File tree

5 files changed

+99
-1
lines changed

5 files changed

+99
-1
lines changed

CHANGELOG.org

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
* Add Roc support
3232
* Add support for environment variables in rust analyzer runnables. Allowing the new ~Update Tests (Expect)~ code lens to work as expected.
3333
* Add support for [[https://github.com/mathworks/MATLAB-language-server][MATLAB language server]] (requires [[https://github.com/MathWorks/Emacs-MATLAB-Mode][matlab-mode]]).
34+
* Add support for [[https://github.com/c3lang/c3c][c3 language]] (requires [[https://github.com/c3lang/c3-ts-mode][c3-ts-mode]] and [[https://github.com/pherrymason/c3-lsp][c3lsp]]).
3435

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

clients/lsp-c3.el

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
;;; lsp-c3.el --- C3 Client settings -*- lexical-binding: t; -*-
2+
3+
;; Copyright (C) 2025 Bruno Dias
4+
5+
;; Author: Bruno Dias
6+
;; Keywords: c3 lsp
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-c3 client
24+
25+
;;; Code:
26+
27+
(require 'lsp-mode)
28+
29+
(defgroup lsp-c3 nil
30+
"LSP support for the C3 programming language, using the server from https://github.com/pherrymason/c3-lsp."
31+
:group 'lsp-mode
32+
:link '(url-link "https://github.com/pherrymason/c3-lsp"))
33+
34+
(defcustom lsp-c3-c3-language-server-path nil
35+
"Path for c3-language-server.
36+
Prefer to build by hand for now."
37+
:group 'lsp-c3
38+
:risky t
39+
:type 'file)
40+
41+
(defcustom lsp-c3-c3-path ""
42+
"The path to your C3 executable."
43+
:type 'file
44+
:group 'lsp-c3)
45+
46+
(defcustom lsp-c3-c3-format-path ""
47+
"The path to your c3-format executable.
48+
49+
There is an effort to bring formatting/linting to c3."
50+
:type 'file
51+
:group 'lsp-c3)
52+
53+
(defcustom lsp-c3-server-args '()
54+
"Arguments to pass to the server."
55+
:type '(repeat string)
56+
:group 'lsp-c3)
57+
58+
(defun lsp-c3--c3-language-server-command ()
59+
"Generate LSP startup command for the C3 Language Server."
60+
(cons
61+
(or lsp-c3-c3-language-server-path
62+
(lsp-package-path 'c3-language-server))
63+
lsp-c3-server-args))
64+
65+
(defun lsp-clients-c3--make-init-options ()
66+
"Init options for C3-language-server."
67+
`(:c3Path ,lsp-c3-c3-path
68+
:c3FormatPath ,lsp-c3-c3-format-path))
69+
70+
(lsp-register-client
71+
(make-lsp-client
72+
:new-connection (lsp-stdio-connection #'lsp-c3--c3-language-server-command)
73+
:language-id "c3-ts"
74+
:major-modes '(c3-ts-mode)
75+
:priority 0
76+
:initialization-options #'lsp-clients-c3--make-init-options
77+
:server-id 'c3lsp
78+
:download-server-fn (lambda (_client callback _error-callback _update?)
79+
(message "To use this lsp, you need to build it
80+
and use `lsp-c3-c3-language-server-path` to define where the executable is located.
81+
82+
Hope soon, we integrate with the lsp installation system.")
83+
(funcall callback))))
84+
85+
(lsp-consistency-check lsp-c3)
86+
87+
(provide 'lsp-c3)
88+
;;; lsp-c3.el ends here

docs/lsp-clients.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,14 @@
162162
"lsp-install-server": "csharp-roslyn",
163163
"debugger": "Yes (netcoredbg)"
164164
},
165+
{
166+
"name": "c3-lsp",
167+
"full-name": "c3 language server",
168+
"server-name": "c3lsp",
169+
"server-url": "https://github.com/pherrymason/c3-lsp",
170+
"installation-url": "https://github.com/pherrymason/c3-lsp",
171+
"debugger": "Yes (gdb or lldb)"
172+
},
165173
{
166174
"name": "ccls",
167175
"full-name": "C++",

lsp-mode.el

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ As defined by the Language Server Protocol 3.16."
175175
(defcustom lsp-client-packages
176176
'( ccls lsp-actionscript lsp-ada lsp-angular lsp-ansible lsp-asm lsp-astro
177177
lsp-autotools lsp-awk lsp-bash lsp-beancount lsp-bufls lsp-clangd
178-
lsp-clojure lsp-cmake lsp-cobol lsp-credo lsp-crystal lsp-csharp lsp-css
178+
lsp-clojure lsp-cmake lsp-cobol lsp-credo lsp-crystal lsp-csharp lsp-c3 lsp-css
179179
lsp-copilot lsp-cucumber lsp-cypher lsp-d lsp-dart lsp-dhall lsp-docker
180180
lsp-dockerfile lsp-earthly lsp-elixir lsp-elm lsp-emmet lsp-erlang
181181
lsp-eslint lsp-fortran lsp-futhark lsp-fsharp lsp-gdscript lsp-gleam

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ nav:
6363
- C# (omnisharp-roslyn): page/lsp-csharp-omnisharp.md
6464
- C# (csharp-roslyn): page/lsp-csharp-roslyn.md
6565
- C# (csharp-ls): page/lsp-csharp-ls.md
66+
- C3 (c3-lsp): page/lsp-c3.md
6667
- Clojure: page/lsp-clojure.md
6768
- CMake: page/lsp-cmake.md
6869
- COBOL: page/lsp-cobol.md

0 commit comments

Comments
 (0)